atcommand.c 273 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514
  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 "clif.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "intif.h"
  22. #include "itemdb.h"
  23. #include "log.h"
  24. #include "map.h"
  25. #include "pc.h"
  26. #include "pc_groups.h" // groupid2name
  27. #include "status.h"
  28. #include "skill.h"
  29. #include "mob.h"
  30. #include "npc.h"
  31. #include "pet.h"
  32. #include "homunculus.h"
  33. #include "mail.h"
  34. #include "mercenary.h"
  35. #include "elemental.h"
  36. #include "party.h"
  37. #include "guild.h"
  38. #include "script.h"
  39. #include "storage.h"
  40. #include "trade.h"
  41. #include "unit.h"
  42. #include "mapreg.h"
  43. #include "quest.h"
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <string.h>
  47. #include <math.h>
  48. #define ATCOMMAND_LENGTH 50
  49. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  50. #define MAX_MSG 1500
  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 char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  67. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  68. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  69. static config_t atcommand_config;
  70. static char atcmd_output[CHAT_SIZE_MAX];
  71. static char atcmd_player_name[NAME_LENGTH];
  72. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  73. static const char* atcommand_checkalias(const char *aliasname); // @help
  74. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  75. // @commands (script-based)
  76. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  77. int i = 0;
  78. if( *name == atcommand_symbol || *name == charcommand_symbol )
  79. name++; // for backwards compatibility
  80. ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
  81. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  82. }
  83. //-----------------------------------------------------------
  84. // Return the message string of the specified number by [Yor]
  85. //-----------------------------------------------------------
  86. const char* msg_txt(int msg_number)
  87. {
  88. if (msg_number >= 0 && msg_number < MAX_MSG &&
  89. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  90. return msg_table[msg_number];
  91. return "??";
  92. }
  93. /*==========================================
  94. * Read Message Data
  95. *------------------------------------------*/
  96. int msg_config_read(const char* cfgName)
  97. {
  98. int msg_number;
  99. char line[1024], w1[1024], w2[1024];
  100. FILE *fp;
  101. static int called = 1;
  102. if ((fp = fopen(cfgName, "r")) == NULL) {
  103. ShowError("Messages file not found: %s\n", cfgName);
  104. return 1;
  105. }
  106. if ((--called) == 0)
  107. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  108. while(fgets(line, sizeof(line), fp))
  109. {
  110. if (line[0] == '/' && line[1] == '/')
  111. continue;
  112. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  113. continue;
  114. if (strcmpi(w1, "import") == 0)
  115. msg_config_read(w2);
  116. else
  117. {
  118. msg_number = atoi(w1);
  119. if (msg_number >= 0 && msg_number < MAX_MSG)
  120. {
  121. if (msg_table[msg_number] != NULL)
  122. aFree(msg_table[msg_number]);
  123. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  124. strcpy(msg_table[msg_number],w2);
  125. }
  126. }
  127. }
  128. fclose(fp);
  129. return 0;
  130. }
  131. /*==========================================
  132. * Cleanup Message Data
  133. *------------------------------------------*/
  134. void do_final_msg(void)
  135. {
  136. int i;
  137. for (i = 0; i < MAX_MSG; i++)
  138. aFree(msg_table[i]);
  139. }
  140. /**
  141. * retrieves the help string associated with a given command.
  142. *
  143. * @param name the name of the command to retrieve help information for
  144. * @return the string associated with the command, or NULL
  145. */
  146. static const char* atcommand_help_string(const char* command)
  147. {
  148. const char* str = NULL;
  149. config_setting_t* info;
  150. if( *command == atcommand_symbol || *command == charcommand_symbol )
  151. {// remove the prefix symbol for the raw name of the command
  152. command ++;
  153. }
  154. // convert alias to the real command name
  155. command = atcommand_checkalias(command);
  156. // attept to find the first default help command
  157. info = config_lookup(&atcommand_config, "help");
  158. if( info == NULL )
  159. {// failed to find the help property in the configuration file
  160. return NULL;
  161. }
  162. if( !config_setting_lookup_string( info, command, &str ) )
  163. {// failed to find the matching help string
  164. return NULL;
  165. }
  166. // push the result from the method
  167. return str;
  168. }
  169. /*==========================================
  170. * @send (used for testing packet sends from the client)
  171. *------------------------------------------*/
  172. ACMD_FUNC(send)
  173. {
  174. int len=0,off,end,type;
  175. long num;
  176. // read message type as hex number (without the 0x)
  177. if(!message || !*message ||
  178. !((sscanf(message, "len %x", &type)==1 && (len=1))
  179. || sscanf(message, "%x", &type)==1) )
  180. {
  181. int i;
  182. for (i = 900; i <= 903; ++i)
  183. clif_displaymessage(fd, msg_txt(i));
  184. return -1;
  185. }
  186. #define PARSE_ERROR(error,p) \
  187. {\
  188. clif_displaymessage(fd, (error));\
  189. sprintf(atcmd_output, ">%s", (p));\
  190. clif_displaymessage(fd, atcmd_output);\
  191. }
  192. //define PARSE_ERROR
  193. #define CHECK_EOS(p) \
  194. if(*(p) == 0){\
  195. clif_displaymessage(fd, "Unexpected end of string");\
  196. return -1;\
  197. }
  198. //define CHECK_EOS
  199. #define SKIP_VALUE(p) \
  200. {\
  201. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  202. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  203. }
  204. //define SKIP_VALUE
  205. #define GET_VALUE(p,num) \
  206. {\
  207. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  208. PARSE_ERROR("Invalid number in:",(p));\
  209. return -1;\
  210. }\
  211. }
  212. //define GET_VALUE
  213. if (type > 0 && type < MAX_PACKET_DB) {
  214. if(len)
  215. {// show packet length
  216. sprintf(atcmd_output, msg_txt(904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  217. clif_displaymessage(fd, atcmd_output);
  218. return 0;
  219. }
  220. len=packet_db[sd->packet_ver][type].len;
  221. off=2;
  222. if(len == 0)
  223. {// unknown packet - ERROR
  224. sprintf(atcmd_output, msg_txt(905), type); // Unknown packet: 0x%x
  225. clif_displaymessage(fd, atcmd_output);
  226. return -1;
  227. } else if(len == -1)
  228. {// dynamic packet
  229. len=SHRT_MAX-4; // maximum length
  230. off=4;
  231. }
  232. WFIFOHEAD(fd, len);
  233. WFIFOW(fd,0)=TOW(type);
  234. // parse packet contents
  235. SKIP_VALUE(message);
  236. while(*message != 0 && off < len){
  237. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  238. {// default (byte)
  239. GET_VALUE(message,num);
  240. WFIFOB(fd,off)=TOB(num);
  241. ++off;
  242. } else if(TOUPPER(*message) == 'B')
  243. {// byte
  244. ++message;
  245. GET_VALUE(message,num);
  246. WFIFOB(fd,off)=TOB(num);
  247. ++off;
  248. } else if(TOUPPER(*message) == 'W')
  249. {// word (2 bytes)
  250. ++message;
  251. GET_VALUE(message,num);
  252. WFIFOW(fd,off)=TOW(num);
  253. off+=2;
  254. } else if(TOUPPER(*message) == 'L')
  255. {// long word (4 bytes)
  256. ++message;
  257. GET_VALUE(message,num);
  258. WFIFOL(fd,off)=TOL(num);
  259. off+=4;
  260. } else if(TOUPPER(*message) == 'S')
  261. {// string - escapes are valid
  262. // get string length - num <= 0 means not fixed length (default)
  263. ++message;
  264. if(*message == '"'){
  265. num=0;
  266. } else {
  267. GET_VALUE(message,num);
  268. while(*message != '"')
  269. {// find start of string
  270. if(*message == 0 || ISSPACE(*message)){
  271. PARSE_ERROR(msg_txt(906),message); // Not a string:
  272. return -1;
  273. }
  274. ++message;
  275. }
  276. }
  277. // parse string
  278. ++message;
  279. CHECK_EOS(message);
  280. end=(num<=0? 0: min(off+((int)num),len));
  281. for(; *message != '"' && (off < end || end == 0); ++off){
  282. if(*message == '\\'){
  283. ++message;
  284. CHECK_EOS(message);
  285. switch(*message){
  286. case 'a': num=0x07; break; // Bell
  287. case 'b': num=0x08; break; // Backspace
  288. case 't': num=0x09; break; // Horizontal tab
  289. case 'n': num=0x0A; break; // Line feed
  290. case 'v': num=0x0B; break; // Vertical tab
  291. case 'f': num=0x0C; break; // Form feed
  292. case 'r': num=0x0D; break; // Carriage return
  293. case 'e': num=0x1B; break; // Escape
  294. default: num=*message; break;
  295. case 'x': // Hexadecimal
  296. {
  297. ++message;
  298. CHECK_EOS(message);
  299. if(!ISXDIGIT(*message)){
  300. PARSE_ERROR(msg_txt(907),message); // Not a hexadecimal digit:
  301. return -1;
  302. }
  303. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  304. if(ISXDIGIT(*message)){
  305. ++message;
  306. CHECK_EOS(message);
  307. num<<=8;
  308. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  309. }
  310. WFIFOB(fd,off)=TOB(num);
  311. ++message;
  312. CHECK_EOS(message);
  313. continue;
  314. }
  315. case '0':
  316. case '1':
  317. case '2':
  318. case '3':
  319. case '4':
  320. case '5':
  321. case '6':
  322. case '7': // Octal
  323. {
  324. num=*message-'0'; // 1st octal digit
  325. ++message;
  326. CHECK_EOS(message);
  327. if(ISDIGIT(*message) && *message < '8'){
  328. num<<=3;
  329. num+=*message-'0'; // 2nd octal digit
  330. ++message;
  331. CHECK_EOS(message);
  332. if(ISDIGIT(*message) && *message < '8'){
  333. num<<=3;
  334. num+=*message-'0'; // 3rd octal digit
  335. ++message;
  336. CHECK_EOS(message);
  337. }
  338. }
  339. WFIFOB(fd,off)=TOB(num);
  340. continue;
  341. }
  342. }
  343. } else
  344. num=*message;
  345. WFIFOB(fd,off)=TOB(num);
  346. ++message;
  347. CHECK_EOS(message);
  348. }//for
  349. while(*message != '"')
  350. {// ignore extra characters
  351. ++message;
  352. CHECK_EOS(message);
  353. }
  354. // terminate the string
  355. if(off < end)
  356. {// fill the rest with 0's
  357. memset(WFIFOP(fd,off),0,end-off);
  358. off=end;
  359. }
  360. } else
  361. {// unknown
  362. PARSE_ERROR(msg_txt(908),message); // Unknown type of value in:
  363. return -1;
  364. }
  365. SKIP_VALUE(message);
  366. }
  367. if(packet_db[sd->packet_ver][type].len == -1)
  368. {// send dynamic packet
  369. WFIFOW(fd,2)=TOW(off);
  370. WFIFOSET(fd,off);
  371. } else
  372. {// send static packet
  373. if(off < len)
  374. memset(WFIFOP(fd,off),0,len-off);
  375. WFIFOSET(fd,len);
  376. }
  377. } else {
  378. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  379. return -1;
  380. }
  381. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  382. clif_displaymessage(fd, atcmd_output);
  383. return 0;
  384. #undef PARSE_ERROR
  385. #undef CHECK_EOS
  386. #undef SKIP_VALUE
  387. #undef GET_VALUE
  388. }
  389. /*==========================================
  390. * @rura, @warp, @mapmove
  391. *------------------------------------------*/
  392. ACMD_FUNC(mapmove)
  393. {
  394. char map_name[MAP_NAME_LENGTH_EXT];
  395. unsigned short mapindex;
  396. short x = 0, y = 0;
  397. int16 m = -1;
  398. nullpo_retr(-1, sd);
  399. memset(map_name, '\0', sizeof(map_name));
  400. if (!message || !*message ||
  401. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  402. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  403. clif_displaymessage(fd, msg_txt(909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  404. return -1;
  405. }
  406. mapindex = mapindex_name2id(map_name);
  407. if (mapindex)
  408. m = map_mapindex2mapid(mapindex);
  409. if (!mapindex) { // m < 0 means on different server! [Kevin]
  410. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  411. return -1;
  412. }
  413. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  414. { //This is to prevent the pc_setpos call from printing an error.
  415. clif_displaymessage(fd, msg_txt(2));
  416. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  417. x = y = 0; //Invalid cell, use random spot.
  418. }
  419. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  420. clif_displaymessage(fd, msg_txt(247));
  421. return -1;
  422. }
  423. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  424. clif_displaymessage(fd, msg_txt(248));
  425. return -1;
  426. }
  427. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  428. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  429. return -1;
  430. }
  431. clif_displaymessage(fd, msg_txt(0)); // Warped.
  432. return 0;
  433. }
  434. /*==========================================
  435. * Displays where a character is. Corrected version by Silent. [Skotlex]
  436. *------------------------------------------*/
  437. ACMD_FUNC(where)
  438. {
  439. struct map_session_data* pl_sd;
  440. nullpo_retr(-1, sd);
  441. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  442. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  443. clif_displaymessage(fd, msg_txt(910)); // Please enter a player name (usage: @where <char name>).
  444. return -1;
  445. }
  446. pl_sd = map_nick2sd(atcmd_player_name);
  447. if (pl_sd == NULL ||
  448. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  449. (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))
  450. ) {
  451. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  452. return -1;
  453. }
  454. 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);
  455. clif_displaymessage(fd, atcmd_output);
  456. return 0;
  457. }
  458. /*==========================================
  459. *
  460. *------------------------------------------*/
  461. ACMD_FUNC(jumpto)
  462. {
  463. struct map_session_data *pl_sd = NULL;
  464. nullpo_retr(-1, sd);
  465. if (!message || !*message) {
  466. clif_displaymessage(fd, msg_txt(911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  467. return -1;
  468. }
  469. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  470. {
  471. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  472. return -1;
  473. }
  474. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  475. {
  476. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  477. return -1;
  478. }
  479. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  480. {
  481. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  482. return -1;
  483. }
  484. if( pc_isdead(sd) )
  485. {
  486. clif_displaymessage(fd, msg_txt(664));
  487. return -1;
  488. }
  489. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  490. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  491. clif_displaymessage(fd, atcmd_output);
  492. return 0;
  493. }
  494. /*==========================================
  495. *
  496. *------------------------------------------*/
  497. ACMD_FUNC(jump)
  498. {
  499. short x = 0, y = 0;
  500. nullpo_retr(-1, sd);
  501. memset(atcmd_output, '\0', sizeof(atcmd_output));
  502. sscanf(message, "%hd %hd", &x, &y);
  503. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  504. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  505. return -1;
  506. }
  507. if( pc_isdead(sd) )
  508. {
  509. clif_displaymessage(fd, msg_txt(664));
  510. return -1;
  511. }
  512. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  513. { //This is to prevent the pc_setpos call from printing an error.
  514. clif_displaymessage(fd, msg_txt(2));
  515. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  516. x = y = 0; //Invalid cell, use random spot.
  517. }
  518. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  519. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  520. clif_displaymessage(fd, atcmd_output);
  521. return 0;
  522. }
  523. /*==========================================
  524. * Display list of online characters with
  525. * various info.
  526. *------------------------------------------*/
  527. ACMD_FUNC(who)
  528. {
  529. struct map_session_data *pl_sd = NULL;
  530. struct s_mapiterator *iter = NULL;
  531. char map_name[MAP_NAME_LENGTH_EXT] = "";
  532. char player_name[NAME_LENGTH] = "";
  533. int count = 0;
  534. int level = 0;
  535. StringBuf buf;
  536. /**
  537. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  538. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  539. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  540. */
  541. int display_type = 1;
  542. int map_id = -1;
  543. nullpo_retr(-1, sd);
  544. if (strstr(command, "map") != NULL) {
  545. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  546. map_id = sd->bl.m;
  547. } else {
  548. sscanf(message, "%23s", player_name);
  549. }
  550. if (strstr(command, "2") != NULL)
  551. display_type = 2;
  552. else if (strstr(command, "3") != NULL)
  553. display_type = 3;
  554. level = pc_get_group_level(sd);
  555. StringBuf_Init(&buf);
  556. iter = mapit_getallusers();
  557. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  558. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  559. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  560. || (map_id >= 0 && pl_sd->bl.m != map_id))
  561. continue;
  562. switch (display_type) {
  563. case 2: {
  564. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  565. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  566. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  567. StringBuf_Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level,
  568. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  569. break;
  570. }
  571. case 3: {
  572. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  573. StringBuf_Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  574. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  575. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  576. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  577. StringBuf_Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  578. break;
  579. }
  580. default: {
  581. struct party_data *p = party_search(pl_sd->status.party_id);
  582. struct guild *g = guild_search(pl_sd->status.guild_id);
  583. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  584. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  585. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  586. if (p != NULL)
  587. StringBuf_Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'"
  588. if (g != NULL)
  589. StringBuf_Printf(&buf, msg_txt(346), g->name); // " | Guild: '%s'"
  590. break;
  591. }
  592. }
  593. clif_displaymessage(fd, StringBuf_Value(&buf));
  594. StringBuf_Clear(&buf);
  595. count++;
  596. }
  597. }
  598. mapit_free(iter);
  599. if (map_id < 0) {
  600. if (count == 0)
  601. StringBuf_Printf(&buf, msg_txt(28)); // No player found.
  602. else if (count == 1)
  603. StringBuf_Printf(&buf, msg_txt(29)); // 1 player found.
  604. else
  605. StringBuf_Printf(&buf, msg_txt(30), count); // %d players found.
  606. } else {
  607. if (count == 0)
  608. StringBuf_Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  609. else if (count == 1)
  610. StringBuf_Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  611. else
  612. StringBuf_Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  613. }
  614. clif_displaymessage(fd, StringBuf_Value(&buf));
  615. StringBuf_Destroy(&buf);
  616. return 0;
  617. }
  618. /*==========================================
  619. *
  620. *------------------------------------------*/
  621. ACMD_FUNC(whogm)
  622. {
  623. struct map_session_data* pl_sd;
  624. struct s_mapiterator* iter;
  625. int j, count;
  626. int pl_level, level;
  627. char match_text[CHAT_SIZE_MAX];
  628. char player_name[NAME_LENGTH];
  629. struct guild *g;
  630. struct party_data *p;
  631. nullpo_retr(-1, sd);
  632. memset(atcmd_output, '\0', sizeof(atcmd_output));
  633. memset(match_text, '\0', sizeof(match_text));
  634. memset(player_name, '\0', sizeof(player_name));
  635. if (sscanf(message, "%199[^\n]", match_text) < 1)
  636. strcpy(match_text, "");
  637. for (j = 0; match_text[j]; j++)
  638. match_text[j] = TOLOWER(match_text[j]);
  639. count = 0;
  640. level = pc_get_group_level(sd);
  641. iter = mapit_getallusers();
  642. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  643. {
  644. pl_level = pc_get_group_level(pl_sd);
  645. if (!pl_level)
  646. continue;
  647. if (match_text[0])
  648. {
  649. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  650. for (j = 0; player_name[j]; j++)
  651. player_name[j] = TOLOWER(player_name[j]);
  652. // search with no case sensitive
  653. if (strstr(player_name, match_text) == NULL)
  654. continue;
  655. }
  656. if (pl_level > level) {
  657. if (pl_sd->sc.option & OPTION_INVISIBLE)
  658. continue;
  659. sprintf(atcmd_output, msg_txt(913), pl_sd->status.name); // Name: %s (GM)
  660. clif_displaymessage(fd, atcmd_output);
  661. count++;
  662. continue;
  663. }
  664. sprintf(atcmd_output, msg_txt(914), // Name: %s (GM:%d) | Location: %s %d %d
  665. pl_sd->status.name, pl_level,
  666. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  667. clif_displaymessage(fd, atcmd_output);
  668. sprintf(atcmd_output, msg_txt(915), // BLvl: %d | Job: %s (Lvl: %d)
  669. pl_sd->status.base_level,
  670. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  671. clif_displaymessage(fd, atcmd_output);
  672. p = party_search(pl_sd->status.party_id);
  673. g = guild_search(pl_sd->status.guild_id);
  674. sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s'
  675. p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None.
  676. clif_displaymessage(fd, atcmd_output);
  677. count++;
  678. }
  679. mapit_free(iter);
  680. if (count == 0)
  681. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  682. else if (count == 1)
  683. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  684. else {
  685. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  686. clif_displaymessage(fd, atcmd_output);
  687. }
  688. return 0;
  689. }
  690. /*==========================================
  691. *
  692. *------------------------------------------*/
  693. ACMD_FUNC(save)
  694. {
  695. nullpo_retr(-1, sd);
  696. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  697. if (sd->status.pet_id > 0 && sd->pd)
  698. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  699. chrif_save(sd,0);
  700. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  701. return 0;
  702. }
  703. /*==========================================
  704. *
  705. *------------------------------------------*/
  706. ACMD_FUNC(load)
  707. {
  708. int16 m;
  709. nullpo_retr(-1, sd);
  710. m = map_mapindex2mapid(sd->status.save_point.map);
  711. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  712. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  713. return -1;
  714. }
  715. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  716. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  717. return -1;
  718. }
  719. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  720. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  721. return 0;
  722. }
  723. /*==========================================
  724. *
  725. *------------------------------------------*/
  726. ACMD_FUNC(speed)
  727. {
  728. int speed;
  729. nullpo_retr(-1, sd);
  730. memset(atcmd_output, '\0', sizeof(atcmd_output));
  731. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  732. sprintf(atcmd_output, msg_txt(918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  733. clif_displaymessage(fd, atcmd_output);
  734. return -1;
  735. }
  736. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  737. status_calc_bl(&sd->bl, SCB_SPEED);
  738. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  739. return 0;
  740. }
  741. /*==========================================
  742. *
  743. *------------------------------------------*/
  744. ACMD_FUNC(storage)
  745. {
  746. nullpo_retr(-1, sd);
  747. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  748. return -1;
  749. if (storage_storageopen(sd) == 1)
  750. { //Already open.
  751. clif_displaymessage(fd, msg_txt(250));
  752. return -1;
  753. }
  754. clif_displaymessage(fd, msg_txt(919)); // Storage opened.
  755. return 0;
  756. }
  757. /*==========================================
  758. *
  759. *------------------------------------------*/
  760. ACMD_FUNC(guildstorage)
  761. {
  762. nullpo_retr(-1, sd);
  763. if (!sd->status.guild_id) {
  764. clif_displaymessage(fd, msg_txt(252));
  765. return -1;
  766. }
  767. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  768. return -1;
  769. if (sd->state.storage_flag == 1) {
  770. clif_displaymessage(fd, msg_txt(250));
  771. return -1;
  772. }
  773. if (sd->state.storage_flag == 2) {
  774. clif_displaymessage(fd, msg_txt(251));
  775. return -1;
  776. }
  777. storage_guild_storageopen(sd);
  778. clif_displaymessage(fd, msg_txt(920)); // Guild storage opened.
  779. return 0;
  780. }
  781. /*==========================================
  782. *
  783. *------------------------------------------*/
  784. ACMD_FUNC(option)
  785. {
  786. int param1 = 0, param2 = 0, param3 = 0;
  787. nullpo_retr(-1, sd);
  788. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  789. {// failed to match the parameters so inform the user of the options
  790. const char* text = NULL;
  791. // attempt to find the setting information for this command
  792. text = atcommand_help_string( command );
  793. // notify the user of the requirement to enter an option
  794. clif_displaymessage(fd, msg_txt(921)); // Please enter at least one option.
  795. if( text )
  796. {// send the help text associated with this command
  797. clif_displaymessage( fd, text );
  798. }
  799. return -1;
  800. }
  801. sd->sc.opt1 = param1;
  802. sd->sc.opt2 = param2;
  803. pc_setoption(sd, param3);
  804. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  805. return 0;
  806. }
  807. /*==========================================
  808. *
  809. *------------------------------------------*/
  810. ACMD_FUNC(hide)
  811. {
  812. nullpo_retr(-1, sd);
  813. if (sd->sc.option & OPTION_INVISIBLE) {
  814. sd->sc.option &= ~OPTION_INVISIBLE;
  815. if (sd->disguise)
  816. status_set_viewdata(&sd->bl, sd->disguise);
  817. else
  818. status_set_viewdata(&sd->bl, sd->status.class_);
  819. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  820. // increment the number of pvp players on the map
  821. map[sd->bl.m].users_pvp++;
  822. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  823. {// register the player for ranking calculations
  824. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  825. }
  826. //bugreport:2266
  827. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  828. } else {
  829. sd->sc.option |= OPTION_INVISIBLE;
  830. sd->vd.class_ = INVISIBLE_CLASS;
  831. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  832. // decrement the number of pvp players on the map
  833. map[sd->bl.m].users_pvp--;
  834. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  835. {// unregister the player for ranking
  836. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  837. sd->pvp_timer = INVALID_TIMER;
  838. }
  839. }
  840. clif_changeoption(&sd->bl);
  841. return 0;
  842. }
  843. /*==========================================
  844. * Changes a character's class
  845. *------------------------------------------*/
  846. ACMD_FUNC(jobchange)
  847. {
  848. int job = 0, upper = 0;
  849. const char* text;
  850. nullpo_retr(-1, sd);
  851. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  852. int i, found = 0;
  853. for (i = JOB_NOVICE; i < JOB_MAX; ++i) {
  854. if (strncmpi(message, job_name(i), 16) == 0) {
  855. job = i;
  856. upper = 0;
  857. found = 1;
  858. break;
  859. }
  860. }
  861. if (!found) {
  862. text = atcommand_help_string(command);
  863. if (text)
  864. clif_displaymessage(fd, text);
  865. return -1;
  866. }
  867. }
  868. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER
  869. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  870. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  871. ) // Deny direct transformation into dummy jobs
  872. {clif_displaymessage(fd, msg_txt(923)); //"You can not change to this job by command."
  873. return 0;}
  874. if (pcdb_checkid(job))
  875. {
  876. if (pc_jobchange(sd, job, upper) == 0)
  877. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  878. else {
  879. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  880. return -1;
  881. }
  882. } else {
  883. text = atcommand_help_string(command);
  884. if (text)
  885. clif_displaymessage(fd, text);
  886. return -1;
  887. }
  888. return 0;
  889. }
  890. /*==========================================
  891. *
  892. *------------------------------------------*/
  893. ACMD_FUNC(kill)
  894. {
  895. nullpo_retr(-1, sd);
  896. status_kill(&sd->bl);
  897. clif_displaymessage(sd->fd, msg_txt(13)); // A pity! You've died.
  898. if (fd != sd->fd)
  899. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  900. return 0;
  901. }
  902. /*==========================================
  903. *
  904. *------------------------------------------*/
  905. ACMD_FUNC(alive)
  906. {
  907. nullpo_retr(-1, sd);
  908. if (!status_revive(&sd->bl, 100, 100))
  909. {
  910. clif_displaymessage(fd, msg_txt(667));
  911. return -1;
  912. }
  913. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  914. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  915. return 0;
  916. }
  917. /*==========================================
  918. * +kamic [LuzZza]
  919. *------------------------------------------*/
  920. ACMD_FUNC(kami)
  921. {
  922. unsigned long color=0;
  923. nullpo_retr(-1, sd);
  924. memset(atcmd_output, '\0', sizeof(atcmd_output));
  925. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  926. if (!message || !*message) {
  927. clif_displaymessage(fd, msg_txt(980)); // Please enter a message (usage: @kami <message>).
  928. return -1;
  929. }
  930. sscanf(message, "%199[^\n]", atcmd_output);
  931. if (strstr(command, "l") != NULL)
  932. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  933. else
  934. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  935. } else {
  936. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  937. clif_displaymessage(fd, msg_txt(981)); // Please enter color and message (usage: @kamic <color> <message>).
  938. return -1;
  939. }
  940. if(color > 0xFFFFFF) {
  941. clif_displaymessage(fd, msg_txt(982)); // Invalid color.
  942. return -1;
  943. }
  944. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  945. }
  946. return 0;
  947. }
  948. /*==========================================
  949. *
  950. *------------------------------------------*/
  951. ACMD_FUNC(heal)
  952. {
  953. int hp = 0, sp = 0; // [Valaris] thanks to fov
  954. nullpo_retr(-1, sd);
  955. sscanf(message, "%d %d", &hp, &sp);
  956. // some overflow checks
  957. if( hp == INT_MIN ) hp++;
  958. if( sp == INT_MIN ) sp++;
  959. if ( hp == 0 && sp == 0 ) {
  960. if (!status_percent_heal(&sd->bl, 100, 100))
  961. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  962. else
  963. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  964. return 0;
  965. }
  966. if ( hp > 0 && sp >= 0 ) {
  967. if(!status_heal(&sd->bl, hp, sp, 0))
  968. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  969. else
  970. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  971. return 0;
  972. }
  973. if ( hp < 0 && sp <= 0 ) {
  974. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  975. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  976. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  977. return 0;
  978. }
  979. //Opposing signs.
  980. if ( hp ) {
  981. if (hp > 0)
  982. status_heal(&sd->bl, hp, 0, 0);
  983. else {
  984. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  985. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  986. }
  987. }
  988. if ( sp ) {
  989. if (sp > 0)
  990. status_heal(&sd->bl, 0, sp, 0);
  991. else
  992. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  993. }
  994. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  995. return 0;
  996. }
  997. /*==========================================
  998. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  999. *------------------------------------------*/
  1000. ACMD_FUNC(item)
  1001. {
  1002. char item_name[100];
  1003. int number = 0, item_id, flag = 0;
  1004. struct item item_tmp;
  1005. struct item_data *item_data;
  1006. int get_count, i;
  1007. nullpo_retr(-1, sd);
  1008. memset(item_name, '\0', sizeof(item_name));
  1009. if (!message || !*message || (
  1010. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1011. sscanf(message, "%99s %d", item_name, &number) < 1
  1012. )) {
  1013. clif_displaymessage(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1014. return -1;
  1015. }
  1016. if (number <= 0)
  1017. number = 1;
  1018. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1019. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1020. {
  1021. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1022. return -1;
  1023. }
  1024. item_id = item_data->nameid;
  1025. get_count = number;
  1026. //Check if it's stackable.
  1027. if (!itemdb_isstackable2(item_data))
  1028. get_count = 1;
  1029. for (i = 0; i < number; i += get_count) {
  1030. // if not pet egg
  1031. if (!pet_create_egg(sd, item_id)) {
  1032. memset(&item_tmp, 0, sizeof(item_tmp));
  1033. item_tmp.nameid = item_id;
  1034. item_tmp.identify = 1;
  1035. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1036. clif_additem(sd, 0, 0, flag);
  1037. }
  1038. }
  1039. if (flag == 0)
  1040. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1041. return 0;
  1042. }
  1043. /*==========================================
  1044. *
  1045. *------------------------------------------*/
  1046. ACMD_FUNC(item2)
  1047. {
  1048. struct item item_tmp;
  1049. struct item_data *item_data;
  1050. char item_name[100];
  1051. int item_id, number = 0;
  1052. int identify = 0, refine = 0, attr = 0;
  1053. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1054. int flag = 0;
  1055. int loop, get_count, i;
  1056. nullpo_retr(-1, sd);
  1057. memset(item_name, '\0', sizeof(item_name));
  1058. if (!message || !*message || (
  1059. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1060. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1061. )) {
  1062. clif_displaymessage(fd, msg_txt(984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1063. clif_displaymessage(fd, msg_txt(985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1064. return -1;
  1065. }
  1066. if (number <= 0)
  1067. number = 1;
  1068. item_id = 0;
  1069. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1070. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1071. item_id = item_data->nameid;
  1072. if (item_id > 500) {
  1073. loop = 1;
  1074. get_count = number;
  1075. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1076. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1077. loop = number;
  1078. get_count = 1;
  1079. if (item_data->type == IT_PETEGG) {
  1080. identify = 1;
  1081. refine = 0;
  1082. }
  1083. if (item_data->type == IT_PETARMOR)
  1084. refine = 0;
  1085. if (refine > MAX_REFINE)
  1086. refine = MAX_REFINE;
  1087. } else {
  1088. identify = 1;
  1089. refine = attr = 0;
  1090. }
  1091. for (i = 0; i < loop; i++) {
  1092. memset(&item_tmp, 0, sizeof(item_tmp));
  1093. item_tmp.nameid = item_id;
  1094. item_tmp.identify = identify;
  1095. item_tmp.refine = refine;
  1096. item_tmp.attribute = attr;
  1097. item_tmp.card[0] = c1;
  1098. item_tmp.card[1] = c2;
  1099. item_tmp.card[2] = c3;
  1100. item_tmp.card[3] = c4;
  1101. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1102. clif_additem(sd, 0, 0, flag);
  1103. }
  1104. if (flag == 0)
  1105. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1106. } else {
  1107. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1108. return -1;
  1109. }
  1110. return 0;
  1111. }
  1112. /*==========================================
  1113. *
  1114. *------------------------------------------*/
  1115. ACMD_FUNC(itemreset)
  1116. {
  1117. int i;
  1118. nullpo_retr(-1, sd);
  1119. for (i = 0; i < MAX_INVENTORY; i++) {
  1120. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1121. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1122. }
  1123. }
  1124. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1125. return 0;
  1126. }
  1127. /*==========================================
  1128. * Atcommand @lvlup
  1129. *------------------------------------------*/
  1130. ACMD_FUNC(baselevelup)
  1131. {
  1132. int level=0, i=0, status_point=0;
  1133. nullpo_retr(-1, sd);
  1134. level = atoi(message);
  1135. if (!message || !*message || !level) {
  1136. clif_displaymessage(fd, msg_txt(986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1137. return -1;
  1138. }
  1139. if (level > 0) {
  1140. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1141. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1142. return -1;
  1143. } // End Addition
  1144. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1145. level = pc_maxbaselv(sd) - sd->status.base_level;
  1146. for (i = 0; i < level; i++)
  1147. status_point += pc_gets_status_point(sd->status.base_level + i);
  1148. sd->status.status_point += status_point;
  1149. sd->status.base_level += (unsigned int)level;
  1150. status_percent_heal(&sd->bl, 100, 100);
  1151. clif_misceffect(&sd->bl, 0);
  1152. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1153. } else {
  1154. if (sd->status.base_level == 1) {
  1155. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1156. return -1;
  1157. }
  1158. level*=-1;
  1159. if ((unsigned int)level >= sd->status.base_level)
  1160. level = sd->status.base_level-1;
  1161. for (i = 0; i > -level; i--)
  1162. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1163. if (sd->status.status_point < status_point)
  1164. pc_resetstate(sd);
  1165. if (sd->status.status_point < status_point)
  1166. sd->status.status_point = 0;
  1167. else
  1168. sd->status.status_point -= status_point;
  1169. sd->status.base_level -= (unsigned int)level;
  1170. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1171. }
  1172. sd->status.base_exp = 0;
  1173. clif_updatestatus(sd, SP_STATUSPOINT);
  1174. clif_updatestatus(sd, SP_BASELEVEL);
  1175. clif_updatestatus(sd, SP_BASEEXP);
  1176. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1177. status_calc_pc(sd, 0);
  1178. pc_baselevelchanged(sd);
  1179. if(sd->status.party_id)
  1180. party_send_levelup(sd);
  1181. return 0;
  1182. }
  1183. /*==========================================
  1184. *
  1185. *------------------------------------------*/
  1186. ACMD_FUNC(joblevelup)
  1187. {
  1188. int level=0;
  1189. nullpo_retr(-1, sd);
  1190. level = atoi(message);
  1191. if (!message || !*message || !level) {
  1192. clif_displaymessage(fd, msg_txt(987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1193. return -1;
  1194. }
  1195. if (level > 0) {
  1196. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1197. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1198. return -1;
  1199. }
  1200. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1201. level = pc_maxjoblv(sd) - sd->status.job_level;
  1202. sd->status.job_level += (unsigned int)level;
  1203. sd->status.skill_point += level;
  1204. clif_misceffect(&sd->bl, 1);
  1205. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1206. } else {
  1207. if (sd->status.job_level == 1) {
  1208. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1209. return -1;
  1210. }
  1211. level *=-1;
  1212. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1213. level = sd->status.job_level-1;
  1214. sd->status.job_level -= (unsigned int)level;
  1215. if (sd->status.skill_point < level)
  1216. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1217. if (sd->status.skill_point < level)
  1218. sd->status.skill_point = 0;
  1219. else
  1220. sd->status.skill_point -= level;
  1221. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1222. }
  1223. sd->status.job_exp = 0;
  1224. clif_updatestatus(sd, SP_JOBLEVEL);
  1225. clif_updatestatus(sd, SP_JOBEXP);
  1226. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1227. clif_updatestatus(sd, SP_SKILLPOINT);
  1228. status_calc_pc(sd, 0);
  1229. return 0;
  1230. }
  1231. /*==========================================
  1232. * @help
  1233. *------------------------------------------*/
  1234. ACMD_FUNC(help)
  1235. {
  1236. config_setting_t *help;
  1237. const char *text = NULL;
  1238. const char *command_name = NULL;
  1239. char *default_command = "help";
  1240. nullpo_retr(-1, sd);
  1241. help = config_lookup(&atcommand_config, "help");
  1242. if (help == NULL) {
  1243. clif_displaymessage(fd, msg_txt(27)); // "Commands help is not available."
  1244. return -1;
  1245. }
  1246. if (!message || !*message) {
  1247. command_name = default_command; // If no command_name specified, display help for @help.
  1248. } else {
  1249. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1250. ++message;
  1251. command_name = atcommand_checkalias(message);
  1252. }
  1253. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1254. sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command"
  1255. clif_displaymessage(fd, atcmd_output);
  1256. atcommand_get_suggestions(sd, command_name, true);
  1257. return -1;
  1258. }
  1259. if (!config_setting_lookup_string(help, command_name, &text)) {
  1260. sprintf(atcmd_output, msg_txt(988), atcommand_symbol, command_name); // There is no help for %c%s.
  1261. clif_displaymessage(fd, atcmd_output);
  1262. atcommand_get_suggestions(sd, command_name, true);
  1263. return -1;
  1264. }
  1265. sprintf(atcmd_output, msg_txt(989), atcommand_symbol, command_name); // Help for command %c%s:
  1266. clif_displaymessage(fd, atcmd_output);
  1267. { // Display aliases
  1268. DBIterator* iter;
  1269. AtCommandInfo *command_info;
  1270. AliasInfo *alias_info = NULL;
  1271. StringBuf buf;
  1272. bool has_aliases = false;
  1273. StringBuf_Init(&buf);
  1274. StringBuf_AppendStr(&buf, msg_txt(990)); // Available aliases:
  1275. command_info = get_atcommandinfo_byname(command_name);
  1276. iter = db_iterator(atcommand_alias_db);
  1277. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1278. if (alias_info->command == command_info) {
  1279. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1280. has_aliases = true;
  1281. }
  1282. }
  1283. dbi_destroy(iter);
  1284. if (has_aliases)
  1285. clif_displaymessage(fd, StringBuf_Value(&buf));
  1286. StringBuf_Destroy(&buf);
  1287. }
  1288. // Display help contents
  1289. clif_displaymessage(fd, text);
  1290. return 0;
  1291. }
  1292. // helper function, used in foreach calls to stop auto-attack timers
  1293. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1294. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1295. {
  1296. struct unit_data *ud = unit_bl2ud(bl);
  1297. int id = va_arg(ap, int);
  1298. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1299. {
  1300. unit_stop_attack(bl);
  1301. return 1;
  1302. }
  1303. return 0;
  1304. }
  1305. /*==========================================
  1306. *
  1307. *------------------------------------------*/
  1308. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1309. {
  1310. TBL_PC* sd = (TBL_PC*)bl;
  1311. clif_pvpset(sd, 0, 0, 2);
  1312. if (sd->pvp_timer != INVALID_TIMER) {
  1313. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1314. sd->pvp_timer = INVALID_TIMER;
  1315. }
  1316. return 0;
  1317. }
  1318. ACMD_FUNC(pvpoff)
  1319. {
  1320. nullpo_retr(-1, sd);
  1321. if (!map[sd->bl.m].flag.pvp) {
  1322. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1323. return -1;
  1324. }
  1325. map[sd->bl.m].flag.pvp = 0;
  1326. if (!battle_config.pk_mode)
  1327. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1328. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1329. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1330. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1331. return 0;
  1332. }
  1333. /*==========================================
  1334. *
  1335. *------------------------------------------*/
  1336. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1337. {
  1338. TBL_PC* sd = (TBL_PC*)bl;
  1339. if (sd->pvp_timer == INVALID_TIMER) {
  1340. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1341. sd->pvp_rank = 0;
  1342. sd->pvp_lastusers = 0;
  1343. sd->pvp_point = 5;
  1344. sd->pvp_won = 0;
  1345. sd->pvp_lost = 0;
  1346. }
  1347. return 0;
  1348. }
  1349. ACMD_FUNC(pvpon)
  1350. {
  1351. nullpo_retr(-1, sd);
  1352. if (map[sd->bl.m].flag.pvp) {
  1353. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1354. return -1;
  1355. }
  1356. map[sd->bl.m].flag.pvp = 1;
  1357. if (!battle_config.pk_mode)
  1358. {// display pvp circle and rank
  1359. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1360. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1361. }
  1362. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1363. return 0;
  1364. }
  1365. /*==========================================
  1366. *
  1367. *------------------------------------------*/
  1368. ACMD_FUNC(gvgoff)
  1369. {
  1370. nullpo_retr(-1, sd);
  1371. if (!map[sd->bl.m].flag.gvg) {
  1372. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1373. return -1;
  1374. }
  1375. map[sd->bl.m].flag.gvg = 0;
  1376. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1377. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1378. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1379. return 0;
  1380. }
  1381. /*==========================================
  1382. *
  1383. *------------------------------------------*/
  1384. ACMD_FUNC(gvgon)
  1385. {
  1386. nullpo_retr(-1, sd);
  1387. if (map[sd->bl.m].flag.gvg) {
  1388. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1389. return -1;
  1390. }
  1391. map[sd->bl.m].flag.gvg = 1;
  1392. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1393. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1394. return 0;
  1395. }
  1396. /*==========================================
  1397. *
  1398. *------------------------------------------*/
  1399. ACMD_FUNC(model)
  1400. {
  1401. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1402. nullpo_retr(-1, sd);
  1403. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1404. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1405. sprintf(atcmd_output, msg_txt(991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1406. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1407. clif_displaymessage(fd, atcmd_output);
  1408. return -1;
  1409. }
  1410. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1411. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1412. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1413. pc_changelook(sd, LOOK_HAIR, hair_style);
  1414. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1415. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1416. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1417. } else {
  1418. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1419. return -1;
  1420. }
  1421. return 0;
  1422. }
  1423. /*==========================================
  1424. * @dye && @ccolor
  1425. *------------------------------------------*/
  1426. ACMD_FUNC(dye)
  1427. {
  1428. int cloth_color = 0;
  1429. nullpo_retr(-1, sd);
  1430. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1431. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1432. sprintf(atcmd_output, msg_txt(992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1433. clif_displaymessage(fd, atcmd_output);
  1434. return -1;
  1435. }
  1436. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1437. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1438. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1439. } else {
  1440. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1441. return -1;
  1442. }
  1443. return 0;
  1444. }
  1445. /*==========================================
  1446. * @hairstyle && @hstyle
  1447. *------------------------------------------*/
  1448. ACMD_FUNC(hair_style)
  1449. {
  1450. int hair_style = 0;
  1451. nullpo_retr(-1, sd);
  1452. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1453. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1454. sprintf(atcmd_output, msg_txt(993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1455. clif_displaymessage(fd, atcmd_output);
  1456. return -1;
  1457. }
  1458. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1459. pc_changelook(sd, LOOK_HAIR, hair_style);
  1460. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1461. } else {
  1462. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1463. return -1;
  1464. }
  1465. return 0;
  1466. }
  1467. /*==========================================
  1468. * @haircolor && @hcolor
  1469. *------------------------------------------*/
  1470. ACMD_FUNC(hair_color)
  1471. {
  1472. int hair_color = 0;
  1473. nullpo_retr(-1, sd);
  1474. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1475. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1476. sprintf(atcmd_output, msg_txt(994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1477. clif_displaymessage(fd, atcmd_output);
  1478. return -1;
  1479. }
  1480. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1481. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1482. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1483. } else {
  1484. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1485. return -1;
  1486. }
  1487. return 0;
  1488. }
  1489. /*==========================================
  1490. * @go [city_number or city_name] - Updated by Harbin
  1491. *------------------------------------------*/
  1492. ACMD_FUNC(go)
  1493. {
  1494. int i;
  1495. int town;
  1496. char map_name[MAP_NAME_LENGTH];
  1497. int16 m;
  1498. const struct {
  1499. char map[MAP_NAME_LENGTH];
  1500. int x, y;
  1501. } data[] = {
  1502. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1503. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1504. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1505. { MAP_PAYON, 162, 233 }, // 3=Payon
  1506. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1507. #ifdef RENEWAL
  1508. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1509. #else
  1510. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1511. #endif
  1512. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1513. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1514. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1515. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1516. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1517. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1518. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1519. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1520. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1521. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1522. { MAP_JAIL, 23, 61 }, // 16=Prison
  1523. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1524. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1525. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1526. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1527. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1528. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1529. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1530. { MAP_VEINS, 216, 123 }, // 24=Veins
  1531. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1532. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1533. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1534. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  1535. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1536. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1537. { MAP_MORA, 44, 151 }, // 31=Mora
  1538. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1539. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1540. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1541. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1542. };
  1543. nullpo_retr(-1, sd);
  1544. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1545. clif_displaymessage(sd->fd,msg_txt(995)); // You cannot use @go on this map.
  1546. return 0;
  1547. }
  1548. memset(map_name, '\0', sizeof(map_name));
  1549. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1550. // get the number
  1551. town = atoi(message);
  1552. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1553. {// no value matched so send the list of locations
  1554. const char* text;
  1555. // attempt to find the text help string
  1556. text = atcommand_help_string( command );
  1557. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  1558. if( text )
  1559. {// send the text to the client
  1560. clif_displaymessage( fd, text );
  1561. }
  1562. return -1;
  1563. }
  1564. // get possible name of the city
  1565. map_name[MAP_NAME_LENGTH-1] = '\0';
  1566. for (i = 0; map_name[i]; i++)
  1567. map_name[i] = TOLOWER(map_name[i]);
  1568. // try to identify the map name
  1569. if (strncmp(map_name, "prontera", 3) == 0) {
  1570. town = 0;
  1571. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1572. strncmp(map_name, "morroc", 4) == 0) {
  1573. town = 1;
  1574. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1575. town = 2;
  1576. } else if (strncmp(map_name, "payon", 3) == 0) {
  1577. town = 3;
  1578. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1579. town = 4;
  1580. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1581. town = 5;
  1582. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1583. town = 6;
  1584. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1585. strcmp(map_name, "christmas") == 0 ||
  1586. strncmp(map_name, "xmas", 3) == 0 ||
  1587. strncmp(map_name, "x-mas", 3) == 0) {
  1588. town = 7;
  1589. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1590. town = 8;
  1591. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1592. strncmp(map_name, "yuno", 3) == 0) {
  1593. town = 9;
  1594. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1595. town = 10;
  1596. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1597. strncmp(map_name, "gonryun", 3) == 0) {
  1598. town = 11;
  1599. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1600. town = 12;
  1601. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1602. town = 13;
  1603. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1604. town = 14;
  1605. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1606. strncmp(map_name, "startpoint", 3) == 0 ||
  1607. strncmp(map_name, "beginning", 3) == 0) {
  1608. town = 15;
  1609. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1610. strncmp(map_name, "prison", 3) == 0 ||
  1611. strncmp(map_name, "jail", 3) == 0) {
  1612. town = 16;
  1613. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1614. town = 17;
  1615. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1616. town = 18;
  1617. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1618. town = 19;
  1619. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1620. town = 20;
  1621. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1622. town = 21;
  1623. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1624. town = 22;
  1625. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1626. town = 23;
  1627. } else if (strncmp(map_name, "veins", 3) == 0) {
  1628. town = 24;
  1629. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1630. town = 25;
  1631. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1632. town = 26;
  1633. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1634. town = 27;
  1635. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1636. town = 28;
  1637. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1638. town = 29;
  1639. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1640. town = 30;
  1641. } else if (strcmp(map_name, "mora") == 0) {
  1642. town = 31;
  1643. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1644. town = 32;
  1645. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1646. town = 33;
  1647. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1648. town = 34;
  1649. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1650. town = 35;
  1651. }
  1652. if (town >= 0 && town < ARRAYLENGTH(data))
  1653. {
  1654. m = map_mapname2mapid(data[town].map);
  1655. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1656. clif_displaymessage(fd, msg_txt(247));
  1657. return -1;
  1658. }
  1659. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1660. clif_displaymessage(fd, msg_txt(248));
  1661. return -1;
  1662. }
  1663. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1664. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1665. } else {
  1666. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1667. return -1;
  1668. }
  1669. } else { // if you arrive here, you have an error in town variable when reading of names
  1670. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1671. return -1;
  1672. }
  1673. return 0;
  1674. }
  1675. /*==========================================
  1676. *
  1677. *------------------------------------------*/
  1678. ACMD_FUNC(monster)
  1679. {
  1680. char name[NAME_LENGTH];
  1681. char monster[NAME_LENGTH];
  1682. char eventname[EVENT_NAME_LENGTH] = "";
  1683. int mob_id;
  1684. int number = 0;
  1685. int count;
  1686. int i, k, range;
  1687. short mx, my;
  1688. unsigned int size;
  1689. nullpo_retr(-1, sd);
  1690. memset(name, '\0', sizeof(name));
  1691. memset(monster, '\0', sizeof(monster));
  1692. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1693. if (!message || !*message) {
  1694. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  1695. return -1;
  1696. }
  1697. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1698. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1699. //All data can be left as it is.
  1700. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1701. //Here, it is possible name was not given and we are using monster for it.
  1702. if (count < 3) //Blank mob's name.
  1703. name[0] = '\0';
  1704. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1705. //All data can be left as it is.
  1706. } else if (sscanf(message, "%23s", monster) > 0) {
  1707. //As before, name may be already filled.
  1708. name[0] = '\0';
  1709. } else {
  1710. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  1711. return -1;
  1712. }
  1713. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1714. mob_id = mobdb_checkid(atoi(monster));
  1715. if (mob_id == 0) {
  1716. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1717. return -1;
  1718. }
  1719. if (mob_id == MOBID_EMPERIUM) {
  1720. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  1721. return -1;
  1722. }
  1723. if (number <= 0)
  1724. number = 1;
  1725. if( !name[0] )
  1726. strcpy(name, "--ja--");
  1727. // 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
  1728. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1729. number = battle_config.atc_spawn_quantity_limit;
  1730. if (strcmp(command+1, "monstersmall") == 0)
  1731. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1732. else if (strcmp(command+1, "monsterbig") == 0)
  1733. size = SZ_BIG;
  1734. else
  1735. size = SZ_SMALL;
  1736. if (battle_config.etc_log)
  1737. 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);
  1738. count = 0;
  1739. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1740. for (i = 0; i < number; i++) {
  1741. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1742. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1743. count += (k != 0) ? 1 : 0;
  1744. }
  1745. if (count != 0)
  1746. if (number == count)
  1747. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  1748. else {
  1749. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  1750. clif_displaymessage(fd, atcmd_output);
  1751. }
  1752. else {
  1753. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1754. return -1;
  1755. }
  1756. return 0;
  1757. }
  1758. /*==========================================
  1759. *
  1760. *------------------------------------------*/
  1761. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1762. {
  1763. struct mob_data *md;
  1764. int flag;
  1765. nullpo_ret(md=(struct mob_data *)bl);
  1766. flag = va_arg(ap, int);
  1767. if (md->guardian_data)
  1768. return 0; //Do not touch WoE mobs!
  1769. if (flag)
  1770. status_zap(bl,md->status.hp, 0);
  1771. else
  1772. status_kill(bl);
  1773. return 1;
  1774. }
  1775. ACMD_FUNC(killmonster)
  1776. {
  1777. int map_id, drop_flag;
  1778. char map_name[MAP_NAME_LENGTH_EXT];
  1779. nullpo_retr(-1, sd);
  1780. memset(map_name, '\0', sizeof(map_name));
  1781. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1782. map_id = sd->bl.m;
  1783. else {
  1784. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1785. map_id = sd->bl.m;
  1786. }
  1787. drop_flag = strcmp(command+1, "killmonster2");
  1788. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1789. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  1790. return 0;
  1791. }
  1792. /*==========================================
  1793. *
  1794. *------------------------------------------*/
  1795. ACMD_FUNC(refine)
  1796. {
  1797. int i,j, position = 0, refine = 0, current_position, final_refine;
  1798. int count;
  1799. nullpo_retr(-1, sd);
  1800. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1801. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1802. clif_displaymessage(fd, msg_txt(996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1803. sprintf(atcmd_output, msg_txt(997), EQP_HEAD_LOW); // %d: Lower Headgear
  1804. clif_displaymessage(fd, atcmd_output);
  1805. sprintf(atcmd_output, msg_txt(998), EQP_HAND_R); // %d: Right Hand
  1806. clif_displaymessage(fd, atcmd_output);
  1807. sprintf(atcmd_output, msg_txt(999), EQP_GARMENT); // %d: Garment
  1808. clif_displaymessage(fd, atcmd_output);
  1809. sprintf(atcmd_output, msg_txt(1000), EQP_ACC_L); // %d: Left Accessory
  1810. clif_displaymessage(fd, atcmd_output);
  1811. sprintf(atcmd_output, msg_txt(1001), EQP_ARMOR); // %d: Body Armor
  1812. clif_displaymessage(fd, atcmd_output);
  1813. sprintf(atcmd_output, msg_txt(1002), EQP_HAND_L); // %d: Left Hand
  1814. clif_displaymessage(fd, atcmd_output);
  1815. sprintf(atcmd_output, msg_txt(1003), EQP_SHOES); // %d: Shoes
  1816. clif_displaymessage(fd, atcmd_output);
  1817. sprintf(atcmd_output, msg_txt(1004), EQP_ACC_R); // %d: Right Accessory
  1818. clif_displaymessage(fd, atcmd_output);
  1819. sprintf(atcmd_output, msg_txt(1005), EQP_HEAD_TOP); // %d: Top Headgear
  1820. clif_displaymessage(fd, atcmd_output);
  1821. sprintf(atcmd_output, msg_txt(1006), EQP_HEAD_MID); // %d: Mid Headgear
  1822. clif_displaymessage(fd, atcmd_output);
  1823. return -1;
  1824. }
  1825. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1826. count = 0;
  1827. for (j = 0; j < EQI_MAX-1; j++) {
  1828. if ((i = sd->equip_index[j]) < 0)
  1829. continue;
  1830. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1831. continue;
  1832. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1833. continue;
  1834. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1835. continue;
  1836. if(position && !(sd->status.inventory[i].equip & position))
  1837. continue;
  1838. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1839. if (sd->status.inventory[i].refine != final_refine) {
  1840. sd->status.inventory[i].refine = final_refine;
  1841. current_position = sd->status.inventory[i].equip;
  1842. pc_unequipitem(sd, i, 3);
  1843. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1844. clif_delitem(sd, i, 1, 3);
  1845. clif_additem(sd, i, 1, 0);
  1846. pc_equipitem(sd, i, current_position);
  1847. clif_misceffect(&sd->bl, 3);
  1848. count++;
  1849. }
  1850. }
  1851. if (count == 0)
  1852. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  1853. else if (count == 1)
  1854. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  1855. else {
  1856. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  1857. clif_displaymessage(fd, atcmd_output);
  1858. }
  1859. return 0;
  1860. }
  1861. /*==========================================
  1862. *
  1863. *------------------------------------------*/
  1864. ACMD_FUNC(produce)
  1865. {
  1866. char item_name[100];
  1867. int item_id, attribute = 0, star = 0;
  1868. int flag = 0;
  1869. struct item_data *item_data;
  1870. struct item tmp_item;
  1871. nullpo_retr(-1, sd);
  1872. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1873. memset(item_name, '\0', sizeof(item_name));
  1874. if (!message || !*message || (
  1875. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  1876. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  1877. )) {
  1878. clif_displaymessage(fd, msg_txt(1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1879. return -1;
  1880. }
  1881. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1882. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1883. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  1884. return -1;
  1885. }
  1886. item_id = item_data->nameid;
  1887. if (itemdb_isequip2(item_data)) {
  1888. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1889. attribute = ATTRIBUTE_NORMAL;
  1890. if (star < MIN_STAR || star > MAX_STAR)
  1891. star = 0;
  1892. memset(&tmp_item, 0, sizeof tmp_item);
  1893. tmp_item.nameid = item_id;
  1894. tmp_item.amount = 1;
  1895. tmp_item.identify = 1;
  1896. tmp_item.card[0] = CARD0_FORGE;
  1897. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1898. ((star*5) << 8) + attribute:0;
  1899. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1900. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1901. clif_produceeffect(sd, 0, item_id);
  1902. clif_misceffect(&sd->bl, 3);
  1903. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1904. clif_additem(sd, 0, 0, flag);
  1905. } else {
  1906. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  1907. clif_displaymessage(fd, atcmd_output);
  1908. return -1;
  1909. }
  1910. return 0;
  1911. }
  1912. /*==========================================
  1913. *
  1914. *------------------------------------------*/
  1915. ACMD_FUNC(memo)
  1916. {
  1917. int position = 0;
  1918. nullpo_retr(-1, sd);
  1919. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1920. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  1921. {
  1922. int i;
  1923. clif_displaymessage(sd->fd, msg_txt(668));
  1924. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1925. {
  1926. if( sd->status.memo_point[i].map )
  1927. 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);
  1928. else
  1929. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  1930. clif_displaymessage(sd->fd, atcmd_output);
  1931. }
  1932. return 0;
  1933. }
  1934. if( position < 0 || position >= MAX_MEMOPOINTS )
  1935. {
  1936. sprintf(atcmd_output, msg_txt(1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  1937. clif_displaymessage(fd, atcmd_output);
  1938. return -1;
  1939. }
  1940. pc_memo(sd, position);
  1941. return 0;
  1942. }
  1943. /*==========================================
  1944. *
  1945. *------------------------------------------*/
  1946. ACMD_FUNC(gat)
  1947. {
  1948. int y;
  1949. nullpo_retr(-1, sd);
  1950. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1951. for (y = 2; y >= -2; y--) {
  1952. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  1953. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  1954. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  1955. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  1956. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  1957. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  1958. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  1959. clif_displaymessage(fd, atcmd_output);
  1960. }
  1961. return 0;
  1962. }
  1963. /*==========================================
  1964. *
  1965. *------------------------------------------*/
  1966. ACMD_FUNC(displaystatus)
  1967. {
  1968. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  1969. nullpo_retr(-1, sd);
  1970. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  1971. clif_displaymessage(fd, msg_txt(1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  1972. return -1;
  1973. }
  1974. if (i < 2) flag = 1;
  1975. if (i < 3) tick = 0;
  1976. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  1977. return 0;
  1978. }
  1979. /*==========================================
  1980. * @stpoint (Rewritten by [Yor])
  1981. *------------------------------------------*/
  1982. ACMD_FUNC(statuspoint)
  1983. {
  1984. int point;
  1985. unsigned int new_status_point;
  1986. if (!message || !*message || (point = atoi(message)) == 0) {
  1987. clif_displaymessage(fd, msg_txt(1010)); // Please enter a number (usage: @stpoint <number of points>).
  1988. return -1;
  1989. }
  1990. if(point < 0)
  1991. {
  1992. if(sd->status.status_point < (unsigned int)(-point))
  1993. {
  1994. new_status_point = 0;
  1995. }
  1996. else
  1997. {
  1998. new_status_point = sd->status.status_point + point;
  1999. }
  2000. }
  2001. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2002. {
  2003. new_status_point = UINT_MAX;
  2004. }
  2005. else
  2006. {
  2007. new_status_point = sd->status.status_point + point;
  2008. }
  2009. if (new_status_point != sd->status.status_point) {
  2010. sd->status.status_point = new_status_point;
  2011. clif_updatestatus(sd, SP_STATUSPOINT);
  2012. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2013. } else {
  2014. if (point < 0)
  2015. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2016. else
  2017. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2018. return -1;
  2019. }
  2020. return 0;
  2021. }
  2022. /*==========================================
  2023. * @skpoint (Rewritten by [Yor])
  2024. *------------------------------------------*/
  2025. ACMD_FUNC(skillpoint)
  2026. {
  2027. int point;
  2028. unsigned int new_skill_point;
  2029. nullpo_retr(-1, sd);
  2030. if (!message || !*message || (point = atoi(message)) == 0) {
  2031. clif_displaymessage(fd, msg_txt(1011)); // Please enter a number (usage: @skpoint <number of points>).
  2032. return -1;
  2033. }
  2034. if(point < 0)
  2035. {
  2036. if(sd->status.skill_point < (unsigned int)(-point))
  2037. {
  2038. new_skill_point = 0;
  2039. }
  2040. else
  2041. {
  2042. new_skill_point = sd->status.skill_point + point;
  2043. }
  2044. }
  2045. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2046. {
  2047. new_skill_point = UINT_MAX;
  2048. }
  2049. else
  2050. {
  2051. new_skill_point = sd->status.skill_point + point;
  2052. }
  2053. if (new_skill_point != sd->status.skill_point) {
  2054. sd->status.skill_point = new_skill_point;
  2055. clif_updatestatus(sd, SP_SKILLPOINT);
  2056. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2057. } else {
  2058. if (point < 0)
  2059. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2060. else
  2061. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2062. return -1;
  2063. }
  2064. return 0;
  2065. }
  2066. /*==========================================
  2067. * @zeny
  2068. *------------------------------------------*/
  2069. ACMD_FUNC(zeny)
  2070. {
  2071. int zeny=0, ret=-1;
  2072. nullpo_retr(-1, sd);
  2073. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2074. clif_displaymessage(fd, msg_txt(1012)); // Please enter an amount (usage: @zeny <amount>).
  2075. return -1;
  2076. }
  2077. if(zeny > 0){
  2078. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2079. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2080. }
  2081. else {
  2082. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2083. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2084. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2085. }
  2086. if(!ret) clif_displaymessage(fd, msg_txt(176)); //ret=0 mean cmd success
  2087. return 0;
  2088. }
  2089. /*==========================================
  2090. *
  2091. *------------------------------------------*/
  2092. ACMD_FUNC(param)
  2093. {
  2094. int i, value = 0, new_value, max;
  2095. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2096. short* status[6];
  2097. //we don't use direct initialization because it isn't part of the c standard.
  2098. nullpo_retr(-1, sd);
  2099. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2100. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2101. clif_displaymessage(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2102. return -1;
  2103. }
  2104. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2105. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2106. clif_displaymessage(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2107. return -1;
  2108. }
  2109. status[0] = &sd->status.str;
  2110. status[1] = &sd->status.agi;
  2111. status[2] = &sd->status.vit;
  2112. status[3] = &sd->status.int_;
  2113. status[4] = &sd->status.dex;
  2114. status[5] = &sd->status.luk;
  2115. if( battle_config.atcommand_max_stat_bypass )
  2116. max = SHRT_MAX;
  2117. else
  2118. max = pc_maxparameter(sd);
  2119. if(value < 0 && *status[i] <= -value) {
  2120. new_value = 1;
  2121. } else if(max - *status[i] < value) {
  2122. new_value = max;
  2123. } else {
  2124. new_value = *status[i] + value;
  2125. }
  2126. if (new_value != *status[i]) {
  2127. *status[i] = new_value;
  2128. clif_updatestatus(sd, SP_STR + i);
  2129. clif_updatestatus(sd, SP_USTR + i);
  2130. status_calc_pc(sd, 0);
  2131. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2132. } else {
  2133. if (value < 0)
  2134. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2135. else
  2136. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2137. return -1;
  2138. }
  2139. return 0;
  2140. }
  2141. /*==========================================
  2142. * Stat all by fritz (rewritten by [Yor])
  2143. *------------------------------------------*/
  2144. ACMD_FUNC(stat_all)
  2145. {
  2146. int index, count, value, max, new_value;
  2147. short* status[6];
  2148. //we don't use direct initialization because it isn't part of the c standard.
  2149. nullpo_retr(-1, sd);
  2150. status[0] = &sd->status.str;
  2151. status[1] = &sd->status.agi;
  2152. status[2] = &sd->status.vit;
  2153. status[3] = &sd->status.int_;
  2154. status[4] = &sd->status.dex;
  2155. status[5] = &sd->status.luk;
  2156. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2157. value = pc_maxparameter(sd);
  2158. max = pc_maxparameter(sd);
  2159. } else {
  2160. if( battle_config.atcommand_max_stat_bypass )
  2161. max = SHRT_MAX;
  2162. else
  2163. max = pc_maxparameter(sd);
  2164. }
  2165. count = 0;
  2166. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2167. if (value > 0 && *status[index] > max - value)
  2168. new_value = max;
  2169. else if (value < 0 && *status[index] <= -value)
  2170. new_value = 1;
  2171. else
  2172. new_value = *status[index] +value;
  2173. if (new_value != (int)*status[index]) {
  2174. *status[index] = new_value;
  2175. clif_updatestatus(sd, SP_STR + index);
  2176. clif_updatestatus(sd, SP_USTR + index);
  2177. count++;
  2178. }
  2179. }
  2180. if (count > 0) { // if at least 1 stat modified
  2181. status_calc_pc(sd, 0);
  2182. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2183. } else {
  2184. if (value < 0)
  2185. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2186. else
  2187. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2188. return -1;
  2189. }
  2190. return 0;
  2191. }
  2192. /*==========================================
  2193. *
  2194. *------------------------------------------*/
  2195. ACMD_FUNC(guildlevelup)
  2196. {
  2197. int level = 0;
  2198. short added_level;
  2199. struct guild *guild_info;
  2200. nullpo_retr(-1, sd);
  2201. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2202. clif_displaymessage(fd, msg_txt(1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2203. return -1;
  2204. }
  2205. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2206. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2207. return -1;
  2208. }
  2209. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2210. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2211. // return -1;
  2212. //}
  2213. added_level = (short)level;
  2214. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2215. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2216. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2217. added_level = 1 - guild_info->guild_lv;
  2218. if (added_level != 0) {
  2219. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2220. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2221. } else {
  2222. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2223. return -1;
  2224. }
  2225. return 0;
  2226. }
  2227. /*==========================================
  2228. *
  2229. *------------------------------------------*/
  2230. ACMD_FUNC(makeegg)
  2231. {
  2232. struct item_data *item_data;
  2233. int id, pet_id;
  2234. nullpo_retr(-1, sd);
  2235. if (!message || !*message) {
  2236. clif_displaymessage(fd, msg_txt(1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2237. return -1;
  2238. }
  2239. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2240. id = item_data->nameid;
  2241. else
  2242. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2243. ;
  2244. else
  2245. id = atoi(message);
  2246. pet_id = search_petDB_index(id, PET_CLASS);
  2247. if (pet_id < 0)
  2248. pet_id = search_petDB_index(id, PET_EGG);
  2249. if (pet_id >= 0) {
  2250. sd->catch_target_class = pet_db[pet_id].class_;
  2251. intif_create_pet(
  2252. sd->status.account_id, sd->status.char_id,
  2253. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2254. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2255. 100, 0, 1, pet_db[pet_id].jname);
  2256. } else {
  2257. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2258. return -1;
  2259. }
  2260. return 0;
  2261. }
  2262. /*==========================================
  2263. *
  2264. *------------------------------------------*/
  2265. ACMD_FUNC(hatch)
  2266. {
  2267. nullpo_retr(-1, sd);
  2268. if (sd->status.pet_id <= 0)
  2269. clif_sendegg(sd);
  2270. else {
  2271. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2272. return -1;
  2273. }
  2274. return 0;
  2275. }
  2276. /*==========================================
  2277. *
  2278. *------------------------------------------*/
  2279. ACMD_FUNC(petfriendly)
  2280. {
  2281. int friendly;
  2282. struct pet_data *pd;
  2283. nullpo_retr(-1, sd);
  2284. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2285. clif_displaymessage(fd, msg_txt(1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2286. return -1;
  2287. }
  2288. pd = sd->pd;
  2289. if (!pd) {
  2290. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2291. return -1;
  2292. }
  2293. if (friendly < 0 || friendly > 1000)
  2294. {
  2295. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2296. return -1;
  2297. }
  2298. if (friendly == pd->pet.intimate) {
  2299. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2300. return -1;
  2301. }
  2302. pet_set_intimate(pd, friendly);
  2303. clif_send_petstatus(sd);
  2304. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2305. return 0;
  2306. }
  2307. /*==========================================
  2308. *
  2309. *------------------------------------------*/
  2310. ACMD_FUNC(pethungry)
  2311. {
  2312. int hungry;
  2313. struct pet_data *pd;
  2314. nullpo_retr(-1, sd);
  2315. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2316. clif_displaymessage(fd, msg_txt(1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2317. return -1;
  2318. }
  2319. pd = sd->pd;
  2320. if (!sd->status.pet_id || !pd) {
  2321. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2322. return -1;
  2323. }
  2324. if (hungry < 0 || hungry > 100) {
  2325. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2326. return -1;
  2327. }
  2328. if (hungry == pd->pet.hungry) {
  2329. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2330. return -1;
  2331. }
  2332. pd->pet.hungry = hungry;
  2333. clif_send_petstatus(sd);
  2334. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2335. return 0;
  2336. }
  2337. /*==========================================
  2338. *
  2339. *------------------------------------------*/
  2340. ACMD_FUNC(petrename)
  2341. {
  2342. struct pet_data *pd;
  2343. nullpo_retr(-1, sd);
  2344. if (!sd->status.pet_id || !sd->pd) {
  2345. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2346. return -1;
  2347. }
  2348. pd = sd->pd;
  2349. if (!pd->pet.rename_flag) {
  2350. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2351. return -1;
  2352. }
  2353. pd->pet.rename_flag = 0;
  2354. intif_save_petdata(sd->status.account_id, &pd->pet);
  2355. clif_send_petstatus(sd);
  2356. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2357. return 0;
  2358. }
  2359. /*==========================================
  2360. *
  2361. *------------------------------------------*/
  2362. ACMD_FUNC(recall) {
  2363. struct map_session_data *pl_sd = NULL;
  2364. nullpo_retr(-1, sd);
  2365. if (!message || !*message) {
  2366. clif_displaymessage(fd, msg_txt(1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2367. return -1;
  2368. }
  2369. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2370. {
  2371. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2372. return -1;
  2373. }
  2374. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2375. {
  2376. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2377. return -1;
  2378. }
  2379. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2380. clif_displaymessage(fd, msg_txt(1019)); // You are not authorized to warp someone to this map.
  2381. return -1;
  2382. }
  2383. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2384. clif_displaymessage(fd, msg_txt(1020)); // You are not authorized to warp this player from their map.
  2385. return -1;
  2386. }
  2387. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2388. return -1;
  2389. }
  2390. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2391. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2392. clif_displaymessage(fd, atcmd_output);
  2393. return 0;
  2394. }
  2395. /*==========================================
  2396. * charblock command (usage: charblock <player_name>)
  2397. * This command do a definitiv ban on a player
  2398. *------------------------------------------*/
  2399. ACMD_FUNC(char_block)
  2400. {
  2401. nullpo_retr(-1, sd);
  2402. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2403. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2404. clif_displaymessage(fd, msg_txt(1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2405. return -1;
  2406. }
  2407. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2408. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2409. return 0;
  2410. }
  2411. /*==========================================
  2412. * charban command (usage: charban <time> <player_name>)
  2413. * This command do a limited ban on a player
  2414. * Time is done as follows:
  2415. * Adjustment value (-1, 1, +1, etc...)
  2416. * Modified element:
  2417. * a or y: year
  2418. * m: month
  2419. * j or d: day
  2420. * h: hour
  2421. * mn: minute
  2422. * s: second
  2423. * <example> @ban +1m-2mn1s-6y test_player
  2424. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2425. *------------------------------------------*/
  2426. ACMD_FUNC(char_ban)
  2427. {
  2428. char * modif_p;
  2429. int year, month, day, hour, minute, second, value;
  2430. time_t timestamp;
  2431. struct tm *tmtime;
  2432. nullpo_retr(-1, sd);
  2433. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2434. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2435. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2436. clif_displaymessage(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2437. return -1;
  2438. }
  2439. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2440. modif_p = atcmd_output;
  2441. year = month = day = hour = minute = second = 0;
  2442. while (modif_p[0] != '\0') {
  2443. value = atoi(modif_p);
  2444. if (value == 0)
  2445. modif_p++;
  2446. else {
  2447. if (modif_p[0] == '-' || modif_p[0] == '+')
  2448. modif_p++;
  2449. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2450. modif_p++;
  2451. if (modif_p[0] == 's') {
  2452. second = value;
  2453. modif_p++;
  2454. } else if (modif_p[0] == 'n') {
  2455. minute = value;
  2456. modif_p++;
  2457. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2458. minute = value;
  2459. modif_p = modif_p + 2;
  2460. } else if (modif_p[0] == 'h') {
  2461. hour = value;
  2462. modif_p++;
  2463. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2464. day = value;
  2465. modif_p++;
  2466. } else if (modif_p[0] == 'm') {
  2467. month = value;
  2468. modif_p++;
  2469. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2470. year = value;
  2471. modif_p++;
  2472. } else if (modif_p[0] != '\0') {
  2473. modif_p++;
  2474. }
  2475. }
  2476. }
  2477. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2478. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2479. return -1;
  2480. }
  2481. /**
  2482. * We now check if you can adjust the ban to negative (and if this is the case)
  2483. **/
  2484. timestamp = time(NULL);
  2485. tmtime = localtime(&timestamp);
  2486. tmtime->tm_year = tmtime->tm_year + year;
  2487. tmtime->tm_mon = tmtime->tm_mon + month;
  2488. tmtime->tm_mday = tmtime->tm_mday + day;
  2489. tmtime->tm_hour = tmtime->tm_hour + hour;
  2490. tmtime->tm_min = tmtime->tm_min + minute;
  2491. tmtime->tm_sec = tmtime->tm_sec + second;
  2492. timestamp = mktime(tmtime);
  2493. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2494. clif_displaymessage(fd,msg_txt(1023)); // You are not allowed to reduce the length of a ban.
  2495. return -1;
  2496. }
  2497. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2498. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2499. return 0;
  2500. }
  2501. /*==========================================
  2502. * charunblock command (usage: charunblock <player_name>)
  2503. *------------------------------------------*/
  2504. ACMD_FUNC(char_unblock)
  2505. {
  2506. nullpo_retr(-1, sd);
  2507. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2508. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2509. clif_displaymessage(fd, msg_txt(1024)); // Please enter a player name (usage: @charunblock <char name>).
  2510. return -1;
  2511. }
  2512. // send answer to login server via char-server
  2513. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2514. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2515. return 0;
  2516. }
  2517. /*==========================================
  2518. * charunban command (usage: charunban <player_name>)
  2519. *------------------------------------------*/
  2520. ACMD_FUNC(char_unban)
  2521. {
  2522. nullpo_retr(-1, sd);
  2523. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2524. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2525. clif_displaymessage(fd, msg_txt(1025)); // Please enter a player name (usage: @charunban <char name>).
  2526. return -1;
  2527. }
  2528. // send answer to login server via char-server
  2529. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2530. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2531. return 0;
  2532. }
  2533. /*==========================================
  2534. *
  2535. *------------------------------------------*/
  2536. ACMD_FUNC(night)
  2537. {
  2538. nullpo_retr(-1, sd);
  2539. if (night_flag != 1) {
  2540. map_night_timer(night_timer_tid, 0, 0, 1);
  2541. } else {
  2542. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  2543. return -1;
  2544. }
  2545. return 0;
  2546. }
  2547. /*==========================================
  2548. *
  2549. *------------------------------------------*/
  2550. ACMD_FUNC(day)
  2551. {
  2552. nullpo_retr(-1, sd);
  2553. if (night_flag != 0) {
  2554. map_day_timer(day_timer_tid, 0, 0, 1);
  2555. } else {
  2556. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  2557. return -1;
  2558. }
  2559. return 0;
  2560. }
  2561. /*==========================================
  2562. *
  2563. *------------------------------------------*/
  2564. ACMD_FUNC(doom)
  2565. {
  2566. struct map_session_data* pl_sd;
  2567. struct s_mapiterator* iter;
  2568. nullpo_retr(-1, sd);
  2569. iter = mapit_getallusers();
  2570. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2571. {
  2572. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2573. {
  2574. status_kill(&pl_sd->bl);
  2575. clif_specialeffect(&pl_sd->bl,450,AREA);
  2576. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2577. }
  2578. }
  2579. mapit_free(iter);
  2580. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2581. return 0;
  2582. }
  2583. /*==========================================
  2584. *
  2585. *------------------------------------------*/
  2586. ACMD_FUNC(doommap)
  2587. {
  2588. struct map_session_data* pl_sd;
  2589. struct s_mapiterator* iter;
  2590. nullpo_retr(-1, sd);
  2591. iter = mapit_getallusers();
  2592. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2593. {
  2594. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2595. {
  2596. status_kill(&pl_sd->bl);
  2597. clif_specialeffect(&pl_sd->bl,450,AREA);
  2598. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2599. }
  2600. }
  2601. mapit_free(iter);
  2602. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2603. return 0;
  2604. }
  2605. /*==========================================
  2606. *
  2607. *------------------------------------------*/
  2608. static void atcommand_raise_sub(struct map_session_data* sd) {
  2609. status_revive(&sd->bl, 100, 100);
  2610. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2611. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  2612. }
  2613. /*==========================================
  2614. *
  2615. *------------------------------------------*/
  2616. ACMD_FUNC(raise)
  2617. {
  2618. struct map_session_data* pl_sd;
  2619. struct s_mapiterator* iter;
  2620. nullpo_retr(-1, sd);
  2621. iter = mapit_getallusers();
  2622. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2623. if( pc_isdead(pl_sd) )
  2624. atcommand_raise_sub(pl_sd);
  2625. mapit_free(iter);
  2626. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2627. return 0;
  2628. }
  2629. /*==========================================
  2630. *
  2631. *------------------------------------------*/
  2632. ACMD_FUNC(raisemap)
  2633. {
  2634. struct map_session_data* pl_sd;
  2635. struct s_mapiterator* iter;
  2636. nullpo_retr(-1, sd);
  2637. iter = mapit_getallusers();
  2638. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2639. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2640. atcommand_raise_sub(pl_sd);
  2641. mapit_free(iter);
  2642. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2643. return 0;
  2644. }
  2645. /*==========================================
  2646. *
  2647. *------------------------------------------*/
  2648. ACMD_FUNC(kick)
  2649. {
  2650. struct map_session_data *pl_sd;
  2651. nullpo_retr(-1, sd);
  2652. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2653. if (!message || !*message) {
  2654. clif_displaymessage(fd, msg_txt(1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2655. return -1;
  2656. }
  2657. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2658. {
  2659. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2660. return -1;
  2661. }
  2662. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2663. {
  2664. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2665. return -1;
  2666. }
  2667. clif_GM_kick(sd, pl_sd);
  2668. return 0;
  2669. }
  2670. /*==========================================
  2671. *
  2672. *------------------------------------------*/
  2673. ACMD_FUNC(kickall)
  2674. {
  2675. struct map_session_data* pl_sd;
  2676. struct s_mapiterator* iter;
  2677. nullpo_retr(-1, sd);
  2678. iter = mapit_getallusers();
  2679. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2680. {
  2681. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2682. if (sd->status.account_id != pl_sd->status.account_id)
  2683. clif_GM_kick(NULL, pl_sd);
  2684. }
  2685. }
  2686. mapit_free(iter);
  2687. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  2688. return 0;
  2689. }
  2690. /*==========================================
  2691. *
  2692. *------------------------------------------*/
  2693. ACMD_FUNC(allskill)
  2694. {
  2695. nullpo_retr(-1, sd);
  2696. pc_allskillup(sd); // all skills
  2697. sd->status.skill_point = 0; // 0 skill points
  2698. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2699. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  2700. return 0;
  2701. }
  2702. /*==========================================
  2703. *
  2704. *------------------------------------------*/
  2705. ACMD_FUNC(questskill)
  2706. {
  2707. uint16 skill_id;
  2708. nullpo_retr(-1, sd);
  2709. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2710. {// also send a list of skills applicable to this command
  2711. const char* text;
  2712. // attempt to find the text corresponding to this command
  2713. text = atcommand_help_string( command );
  2714. // send the error message as always
  2715. clif_displaymessage(fd, msg_txt(1027)); // Please enter a quest skill number.
  2716. if( text )
  2717. {// send the skill ID list associated with this command
  2718. clif_displaymessage( fd, text );
  2719. }
  2720. return -1;
  2721. }
  2722. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  2723. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2724. return -1;
  2725. }
  2726. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2727. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2728. return -1;
  2729. }
  2730. if (pc_checkskill(sd, skill_id) > 0) {
  2731. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  2732. return -1;
  2733. }
  2734. pc_skill(sd, skill_id, 1, 0);
  2735. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  2736. return 0;
  2737. }
  2738. /*==========================================
  2739. *
  2740. *------------------------------------------*/
  2741. ACMD_FUNC(lostskill)
  2742. {
  2743. uint16 skill_id;
  2744. nullpo_retr(-1, sd);
  2745. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2746. {// also send a list of skills applicable to this command
  2747. const char* text;
  2748. // attempt to find the text corresponding to this command
  2749. text = atcommand_help_string( command );
  2750. // send the error message as always
  2751. clif_displaymessage(fd, msg_txt(1027)); // Please enter a quest skill number.
  2752. if( text )
  2753. {// send the skill ID list associated with this command
  2754. clif_displaymessage( fd, text );
  2755. }
  2756. return -1;
  2757. }
  2758. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  2759. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2760. return -1;
  2761. }
  2762. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2763. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2764. return -1;
  2765. }
  2766. if (pc_checkskill(sd, skill_id) == 0) {
  2767. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  2768. return -1;
  2769. }
  2770. sd->status.skill[skill_id].lv = 0;
  2771. sd->status.skill[skill_id].flag = 0;
  2772. clif_deleteskill(sd,skill_id);
  2773. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  2774. return 0;
  2775. }
  2776. /*==========================================
  2777. *
  2778. *------------------------------------------*/
  2779. ACMD_FUNC(spiritball)
  2780. {
  2781. int max_spiritballs;
  2782. int number;
  2783. nullpo_retr(-1, sd);
  2784. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2785. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2786. {
  2787. char msg[CHAT_SIZE_MAX];
  2788. safesnprintf(msg, sizeof(msg), msg_txt(1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2789. clif_displaymessage(fd, msg);
  2790. return -1;
  2791. }
  2792. if( sd->spiritball > 0 )
  2793. pc_delspiritball(sd, sd->spiritball, 1);
  2794. sd->spiritball = number;
  2795. clif_spiritball(&sd->bl);
  2796. // no message, player can look the difference
  2797. return 0;
  2798. }
  2799. /*==========================================
  2800. *
  2801. *------------------------------------------*/
  2802. ACMD_FUNC(party)
  2803. {
  2804. char party[NAME_LENGTH];
  2805. nullpo_retr(-1, sd);
  2806. memset(party, '\0', sizeof(party));
  2807. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2808. clif_displaymessage(fd, msg_txt(1029)); // Please enter a party name (usage: @party <party_name>).
  2809. return -1;
  2810. }
  2811. party_create(sd, party, 0, 0);
  2812. return 0;
  2813. }
  2814. /*==========================================
  2815. *
  2816. *------------------------------------------*/
  2817. ACMD_FUNC(guild)
  2818. {
  2819. char guild[NAME_LENGTH];
  2820. int prev;
  2821. nullpo_retr(-1, sd);
  2822. memset(guild, '\0', sizeof(guild));
  2823. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2824. clif_displaymessage(fd, msg_txt(1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2825. return -1;
  2826. }
  2827. prev = battle_config.guild_emperium_check;
  2828. battle_config.guild_emperium_check = 0;
  2829. guild_create(sd, guild);
  2830. battle_config.guild_emperium_check = prev;
  2831. return 0;
  2832. }
  2833. ACMD_FUNC(breakguild)
  2834. {
  2835. int ret = 0;
  2836. struct guild *g;
  2837. nullpo_retr(-1, sd);
  2838. if (sd->status.guild_id) { // Check if the player has a guild
  2839. g = guild_search(sd->status.guild_id); // Search the guild
  2840. if (g) { // Check if guild was found
  2841. if (sd->state.gmaster_flag) { // Check if player is guild master
  2842. ret = guild_break(sd, g->name); // Break guild
  2843. if (ret) { // Check if anything went wrong
  2844. return 0; // Guild was broken
  2845. } else {
  2846. return -1; // Something went wrong
  2847. }
  2848. } else { // Not guild master
  2849. clif_displaymessage(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
  2850. return -1;
  2851. }
  2852. } else { // Guild was not found. HOW?
  2853. clif_displaymessage(fd, msg_txt(252)); // You are not in a guild.
  2854. return -1;
  2855. }
  2856. } else { // Player does not have a guild
  2857. clif_displaymessage(fd, msg_txt(252)); // You are not in a guild.
  2858. return -1;
  2859. }
  2860. return 0;
  2861. }
  2862. /*==========================================
  2863. *
  2864. *------------------------------------------*/
  2865. ACMD_FUNC(agitstart)
  2866. {
  2867. nullpo_retr(-1, sd);
  2868. if (agit_flag == 1) {
  2869. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  2870. return -1;
  2871. }
  2872. agit_flag = 1;
  2873. guild_agit_start();
  2874. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  2875. return 0;
  2876. }
  2877. /*==========================================
  2878. *
  2879. *------------------------------------------*/
  2880. ACMD_FUNC(agitstart2)
  2881. {
  2882. nullpo_retr(-1, sd);
  2883. if (agit2_flag == 1) {
  2884. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  2885. return -1;
  2886. }
  2887. agit2_flag = 1;
  2888. guild_agit2_start();
  2889. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  2890. return 0;
  2891. }
  2892. /*==========================================
  2893. *
  2894. *------------------------------------------*/
  2895. ACMD_FUNC(agitend)
  2896. {
  2897. nullpo_retr(-1, sd);
  2898. if (agit_flag == 0) {
  2899. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  2900. return -1;
  2901. }
  2902. agit_flag = 0;
  2903. guild_agit_end();
  2904. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  2905. return 0;
  2906. }
  2907. /*==========================================
  2908. *
  2909. *------------------------------------------*/
  2910. ACMD_FUNC(agitend2)
  2911. {
  2912. nullpo_retr(-1, sd);
  2913. if (agit2_flag == 0) {
  2914. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  2915. return -1;
  2916. }
  2917. agit2_flag = 0;
  2918. guild_agit2_end();
  2919. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  2920. return 0;
  2921. }
  2922. /*==========================================
  2923. * @mapexit - shuts down the map server
  2924. *------------------------------------------*/
  2925. ACMD_FUNC(mapexit)
  2926. {
  2927. nullpo_retr(-1, sd);
  2928. do_shutdown();
  2929. return 0;
  2930. }
  2931. /*==========================================
  2932. * idsearch <part_of_name>: revrited by [Yor]
  2933. *------------------------------------------*/
  2934. ACMD_FUNC(idsearch)
  2935. {
  2936. char item_name[100];
  2937. unsigned int i, match;
  2938. struct item_data *item_array[MAX_SEARCH];
  2939. nullpo_retr(-1, sd);
  2940. memset(item_name, '\0', sizeof(item_name));
  2941. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2942. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  2943. clif_displaymessage(fd, msg_txt(1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  2944. return -1;
  2945. }
  2946. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  2947. clif_displaymessage(fd, atcmd_output);
  2948. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  2949. if (match > MAX_SEARCH) {
  2950. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  2951. clif_displaymessage(fd, atcmd_output);
  2952. match = MAX_SEARCH;
  2953. }
  2954. for(i = 0; i < match; i++) {
  2955. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  2956. clif_displaymessage(fd, atcmd_output);
  2957. }
  2958. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  2959. clif_displaymessage(fd, atcmd_output);
  2960. return 0;
  2961. }
  2962. /*==========================================
  2963. * Recall All Characters Online To Your Location
  2964. *------------------------------------------*/
  2965. ACMD_FUNC(recallall)
  2966. {
  2967. struct map_session_data* pl_sd;
  2968. struct s_mapiterator* iter;
  2969. int count;
  2970. nullpo_retr(-1, sd);
  2971. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2972. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2973. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  2974. return -1;
  2975. }
  2976. count = 0;
  2977. iter = mapit_getallusers();
  2978. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2979. {
  2980. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2981. {
  2982. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  2983. continue; // Don't waste time warping the character to the same place.
  2984. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  2985. count++;
  2986. else {
  2987. if (pc_isdead(pl_sd)) { //Wake them up
  2988. pc_setstand(pl_sd);
  2989. pc_setrestartvalue(pl_sd,1);
  2990. }
  2991. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2992. }
  2993. }
  2994. }
  2995. mapit_free(iter);
  2996. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  2997. if (count) {
  2998. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  2999. clif_displaymessage(fd, atcmd_output);
  3000. }
  3001. return 0;
  3002. }
  3003. /*==========================================
  3004. * Recall online characters of a guild to your location
  3005. *------------------------------------------*/
  3006. ACMD_FUNC(guildrecall)
  3007. {
  3008. struct map_session_data* pl_sd;
  3009. struct s_mapiterator* iter;
  3010. int count;
  3011. char guild_name[NAME_LENGTH];
  3012. struct guild *g;
  3013. nullpo_retr(-1, sd);
  3014. memset(guild_name, '\0', sizeof(guild_name));
  3015. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3016. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3017. clif_displaymessage(fd, msg_txt(1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3018. return -1;
  3019. }
  3020. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3021. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3022. return -1;
  3023. }
  3024. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3025. (g = guild_search(atoi(message))) == NULL)
  3026. {
  3027. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3028. return -1;
  3029. }
  3030. count = 0;
  3031. iter = mapit_getallusers();
  3032. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3033. {
  3034. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3035. {
  3036. 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))
  3037. continue; // Skip GMs greater than you... or chars already on the cell
  3038. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3039. count++;
  3040. else
  3041. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3042. }
  3043. }
  3044. mapit_free(iter);
  3045. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3046. clif_displaymessage(fd, atcmd_output);
  3047. if (count) {
  3048. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3049. clif_displaymessage(fd, atcmd_output);
  3050. }
  3051. return 0;
  3052. }
  3053. /*==========================================
  3054. * Recall online characters of a party to your location
  3055. *------------------------------------------*/
  3056. ACMD_FUNC(partyrecall)
  3057. {
  3058. struct map_session_data* pl_sd;
  3059. struct s_mapiterator* iter;
  3060. char party_name[NAME_LENGTH];
  3061. struct party_data *p;
  3062. int count;
  3063. nullpo_retr(-1, sd);
  3064. memset(party_name, '\0', sizeof(party_name));
  3065. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3066. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3067. clif_displaymessage(fd, msg_txt(1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3068. return -1;
  3069. }
  3070. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3071. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3072. return -1;
  3073. }
  3074. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3075. (p = party_search(atoi(message))) == NULL)
  3076. {
  3077. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3078. return -1;
  3079. }
  3080. count = 0;
  3081. iter = mapit_getallusers();
  3082. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3083. {
  3084. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3085. {
  3086. 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))
  3087. continue; // Skip GMs greater than you... or chars already on the cell
  3088. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3089. count++;
  3090. else
  3091. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3092. }
  3093. }
  3094. mapit_free(iter);
  3095. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3096. clif_displaymessage(fd, atcmd_output);
  3097. if (count) {
  3098. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3099. clif_displaymessage(fd, atcmd_output);
  3100. }
  3101. return 0;
  3102. }
  3103. /*==========================================
  3104. *
  3105. *------------------------------------------*/
  3106. ACMD_FUNC(reloaditemdb)
  3107. {
  3108. nullpo_retr(-1, sd);
  3109. itemdb_reload();
  3110. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3111. return 0;
  3112. }
  3113. /*==========================================
  3114. *
  3115. *------------------------------------------*/
  3116. ACMD_FUNC(reloadmobdb)
  3117. {
  3118. nullpo_retr(-1, sd);
  3119. mob_reload();
  3120. read_petdb();
  3121. merc_reload();
  3122. read_mercenarydb();
  3123. read_mercenary_skilldb();
  3124. reload_elementaldb();
  3125. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3126. return 0;
  3127. }
  3128. /*==========================================
  3129. *
  3130. *------------------------------------------*/
  3131. ACMD_FUNC(reloadskilldb)
  3132. {
  3133. nullpo_retr(-1, sd);
  3134. skill_reload();
  3135. merc_skill_reload();
  3136. reload_elemental_skilldb();
  3137. read_mercenary_skilldb();
  3138. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3139. return 0;
  3140. }
  3141. /*==========================================
  3142. * @reloadatcommand - reloads atcommand_athena.conf groups.conf
  3143. *------------------------------------------*/
  3144. void atcommand_doload();
  3145. ACMD_FUNC(reloadatcommand) {
  3146. config_t run_test;
  3147. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3148. clif_displaymessage(fd, msg_txt(1036)); // Error reading groups.conf, reload failed.
  3149. return -1;
  3150. }
  3151. config_destroy(&run_test);
  3152. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3153. clif_displaymessage(fd, msg_txt(1037)); // Error reading atcommand_athena.conf, reload failed.
  3154. return -1;
  3155. }
  3156. config_destroy(&run_test);
  3157. atcommand_doload();
  3158. pc_groups_reload();
  3159. clif_displaymessage(fd, msg_txt(254));
  3160. return 0;
  3161. }
  3162. /*==========================================
  3163. * @reloadbattleconf - reloads battle_athena.conf
  3164. *------------------------------------------*/
  3165. ACMD_FUNC(reloadbattleconf)
  3166. {
  3167. struct Battle_Config prev_config;
  3168. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3169. battle_config_read(BATTLE_CONF_FILENAME);
  3170. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3171. || prev_config.item_rate_common != battle_config.item_rate_common
  3172. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3173. || prev_config.item_rate_card != battle_config.item_rate_card
  3174. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3175. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3176. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3177. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3178. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3179. || prev_config.item_rate_use != battle_config.item_rate_use
  3180. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3181. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3182. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3183. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3184. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3185. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3186. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3187. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3188. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3189. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3190. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3191. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3192. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3193. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3194. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3195. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3196. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3197. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3198. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3199. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3200. )
  3201. { // Exp or Drop rates changed.
  3202. mob_reload(); //Needed as well so rate changes take effect.
  3203. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3204. }
  3205. clif_displaymessage(fd, msg_txt(255));
  3206. return 0;
  3207. }
  3208. /*==========================================
  3209. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3210. *------------------------------------------*/
  3211. ACMD_FUNC(reloadstatusdb)
  3212. {
  3213. status_readdb();
  3214. clif_displaymessage(fd, msg_txt(256));
  3215. return 0;
  3216. }
  3217. /*==========================================
  3218. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3219. *------------------------------------------*/
  3220. ACMD_FUNC(reloadpcdb)
  3221. {
  3222. pc_readdb();
  3223. clif_displaymessage(fd, msg_txt(257));
  3224. return 0;
  3225. }
  3226. /*==========================================
  3227. * @reloadmotd - reloads motd.txt
  3228. *------------------------------------------*/
  3229. ACMD_FUNC(reloadmotd)
  3230. {
  3231. pc_read_motd();
  3232. clif_displaymessage(fd, msg_txt(268));
  3233. return 0;
  3234. }
  3235. /*==========================================
  3236. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3237. *------------------------------------------*/
  3238. ACMD_FUNC(reloadscript)
  3239. {
  3240. nullpo_retr(-1, sd);
  3241. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3242. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3243. flush_fifos();
  3244. map_reloadnpc(true); // reload config files seeking for npcs
  3245. script_reload();
  3246. npc_reload();
  3247. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3248. return 0;
  3249. }
  3250. /*==========================================
  3251. * @mapinfo [0-3] <map name> by MC_Cameri
  3252. * => Shows information about the map [map name]
  3253. * 0 = no additional information
  3254. * 1 = Show users in that map and their location
  3255. * 2 = Shows NPCs in that map
  3256. * 3 = Shows the shops/chats in that map (not implemented)
  3257. *------------------------------------------*/
  3258. ACMD_FUNC(mapinfo)
  3259. {
  3260. struct map_session_data* pl_sd;
  3261. struct s_mapiterator* iter;
  3262. struct npc_data *nd = NULL;
  3263. struct chat_data *cd = NULL;
  3264. char direction[12];
  3265. int i, m_id, chat_num, list = 0;
  3266. unsigned short m_index;
  3267. char mapname[24];
  3268. nullpo_retr(-1, sd);
  3269. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3270. memset(mapname, '\0', sizeof(mapname));
  3271. memset(direction, '\0', sizeof(direction));
  3272. sscanf(message, "%d %23[^\n]", &list, mapname);
  3273. if (list < 0 || list > 3) {
  3274. clif_displaymessage(fd, msg_txt(1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3275. return -1;
  3276. }
  3277. if (mapname[0] == '\0') {
  3278. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3279. m_id = map_mapindex2mapid(sd->mapindex);
  3280. } else {
  3281. m_id = map_mapname2mapid(mapname);
  3282. }
  3283. if (m_id < 0) {
  3284. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3285. return -1;
  3286. }
  3287. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3288. clif_displaymessage(fd, msg_txt(1039)); // ------ Map Info ------
  3289. // count chats (for initial message)
  3290. chat_num = 0;
  3291. iter = mapit_getallusers();
  3292. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3293. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3294. chat_num++;
  3295. mapit_free(iter);
  3296. sprintf(atcmd_output, msg_txt(1040), mapname, map[m_id].users, map[m_id].npc_num, chat_num); // Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d
  3297. clif_displaymessage(fd, atcmd_output);
  3298. clif_displaymessage(fd, msg_txt(1041)); // ------ Map Flags ------
  3299. if (map[m_id].flag.town)
  3300. clif_displaymessage(fd, msg_txt(1042)); // Town Map
  3301. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3302. clif_displaymessage(fd, msg_txt(1043)); // Autotrade Enabled
  3303. else
  3304. clif_displaymessage(fd, msg_txt(1044)); // Autotrade Disabled
  3305. if (map[m_id].flag.battleground)
  3306. clif_displaymessage(fd, msg_txt(1045)); // Battlegrounds ON
  3307. strcpy(atcmd_output,msg_txt(1046)); // PvP Flags:
  3308. if (map[m_id].flag.pvp)
  3309. strcat(atcmd_output, msg_txt(1047)); // Pvp ON |
  3310. if (map[m_id].flag.pvp_noguild)
  3311. strcat(atcmd_output, msg_txt(1048)); // NoGuild |
  3312. if (map[m_id].flag.pvp_noparty)
  3313. strcat(atcmd_output, msg_txt(1049)); // NoParty |
  3314. if (map[m_id].flag.pvp_nightmaredrop)
  3315. strcat(atcmd_output, msg_txt(1050)); // NightmareDrop |
  3316. if (map[m_id].flag.pvp_nocalcrank)
  3317. strcat(atcmd_output, msg_txt(1051)); // NoCalcRank |
  3318. clif_displaymessage(fd, atcmd_output);
  3319. strcpy(atcmd_output,msg_txt(1052)); // GvG Flags:
  3320. if (map[m_id].flag.gvg)
  3321. strcat(atcmd_output, msg_txt(1053)); // GvG ON |
  3322. if (map[m_id].flag.gvg_dungeon)
  3323. strcat(atcmd_output, msg_txt(1054)); // GvG Dungeon |
  3324. if (map[m_id].flag.gvg_castle)
  3325. strcat(atcmd_output, msg_txt(1055)); // GvG Castle |
  3326. if (map[m_id].flag.gvg_noparty)
  3327. strcat(atcmd_output, msg_txt(1056)); // NoParty |
  3328. clif_displaymessage(fd, atcmd_output);
  3329. strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags:
  3330. if (map[m_id].flag.noteleport)
  3331. strcat(atcmd_output, msg_txt(1058)); // NoTeleport |
  3332. if (map[m_id].flag.monster_noteleport)
  3333. strcat(atcmd_output, msg_txt(1059)); // Monster NoTeleport |
  3334. if (map[m_id].flag.nowarp)
  3335. strcat(atcmd_output, msg_txt(1060)); // NoWarp |
  3336. if (map[m_id].flag.nowarpto)
  3337. strcat(atcmd_output, msg_txt(1061)); // NoWarpTo |
  3338. if (map[m_id].flag.noreturn)
  3339. strcat(atcmd_output, msg_txt(1062)); // NoReturn |
  3340. if (map[m_id].flag.nogo)
  3341. strcat(atcmd_output, msg_txt(1063)); // NoGo |
  3342. if (map[m_id].flag.nomemo)
  3343. strcat(atcmd_output, msg_txt(1064)); // NoMemo |
  3344. clif_displaymessage(fd, atcmd_output);
  3345. sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3346. (map[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off
  3347. clif_displaymessage(fd, atcmd_output);
  3348. if (map[m_id].flag.nosave) {
  3349. if (!map[m_id].save.map)
  3350. clif_displaymessage(fd, msg_txt(1068)); // No Save (Return to last Save Point)
  3351. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3352. sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3353. clif_displaymessage(fd, atcmd_output);
  3354. }
  3355. else {
  3356. sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d
  3357. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3358. clif_displaymessage(fd, atcmd_output);
  3359. }
  3360. }
  3361. strcpy(atcmd_output,msg_txt(1071)); // Weather Flags:
  3362. if (map[m_id].flag.snow)
  3363. strcat(atcmd_output, msg_txt(1072)); // Snow |
  3364. if (map[m_id].flag.fog)
  3365. strcat(atcmd_output, msg_txt(1073)); // Fog |
  3366. if (map[m_id].flag.sakura)
  3367. strcat(atcmd_output, msg_txt(1074)); // Sakura |
  3368. if (map[m_id].flag.clouds)
  3369. strcat(atcmd_output, msg_txt(1075)); // Clouds |
  3370. if (map[m_id].flag.clouds2)
  3371. strcat(atcmd_output, msg_txt(1076)); // Clouds2 |
  3372. if (map[m_id].flag.fireworks)
  3373. strcat(atcmd_output, msg_txt(1077)); // Fireworks |
  3374. if (map[m_id].flag.leaves)
  3375. strcat(atcmd_output, msg_txt(1078)); // Leaves |
  3376. /**
  3377. * No longer available, keeping here just in case it's back someday. [Ind]
  3378. **/
  3379. //if (map[m_id].flag.rain)
  3380. // strcat(atcmd_output, msg_txt(1079)); // Rain |
  3381. if (map[m_id].flag.nightenabled)
  3382. strcat(atcmd_output, msg_txt(1080)); // Displays Night |
  3383. clif_displaymessage(fd, atcmd_output);
  3384. strcpy(atcmd_output,msg_txt(1081)); // Other Flags:
  3385. if (map[m_id].flag.nobranch)
  3386. strcat(atcmd_output, msg_txt(1082)); // NoBranch |
  3387. if (map[m_id].flag.notrade)
  3388. strcat(atcmd_output, msg_txt(1083)); // NoTrade |
  3389. if (map[m_id].flag.novending)
  3390. strcat(atcmd_output, msg_txt(1084)); // NoVending |
  3391. if (map[m_id].flag.nodrop)
  3392. strcat(atcmd_output, msg_txt(1085)); // NoDrop |
  3393. if (map[m_id].flag.noskill)
  3394. strcat(atcmd_output, msg_txt(1086)); // NoSkill |
  3395. if (map[m_id].flag.noicewall)
  3396. strcat(atcmd_output, msg_txt(1087)); // NoIcewall |
  3397. if (map[m_id].flag.allowks)
  3398. strcat(atcmd_output, msg_txt(1088)); // AllowKS |
  3399. if (map[m_id].flag.reset)
  3400. strcat(atcmd_output, msg_txt(1089)); // Reset |
  3401. clif_displaymessage(fd, atcmd_output);
  3402. strcpy(atcmd_output,msg_txt(1090)); // Other Flags:
  3403. if (map[m_id].nocommand)
  3404. strcat(atcmd_output, msg_txt(1091)); // NoCommand |
  3405. if (map[m_id].flag.nobaseexp)
  3406. strcat(atcmd_output, msg_txt(1092)); // NoBaseEXP |
  3407. if (map[m_id].flag.nojobexp)
  3408. strcat(atcmd_output, msg_txt(1093)); // NoJobEXP |
  3409. if (map[m_id].flag.nomobloot)
  3410. strcat(atcmd_output, msg_txt(1094)); // NoMobLoot |
  3411. if (map[m_id].flag.nomvploot)
  3412. strcat(atcmd_output, msg_txt(1095)); // NoMVPLoot |
  3413. if (map[m_id].flag.partylock)
  3414. strcat(atcmd_output, msg_txt(1096)); // PartyLock |
  3415. if (map[m_id].flag.guildlock)
  3416. strcat(atcmd_output, msg_txt(1097)); // GuildLock |
  3417. clif_displaymessage(fd, atcmd_output);
  3418. switch (list) {
  3419. case 0:
  3420. // Do nothing. It's list 0, no additional display.
  3421. break;
  3422. case 1:
  3423. clif_displaymessage(fd, msg_txt(1098)); // ----- Players in Map -----
  3424. iter = mapit_getallusers();
  3425. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3426. {
  3427. if (pl_sd->mapindex == m_index) {
  3428. sprintf(atcmd_output, msg_txt(1099), // Player '%s' (session #%d) | Location: %d,%d
  3429. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3430. clif_displaymessage(fd, atcmd_output);
  3431. }
  3432. }
  3433. mapit_free(iter);
  3434. break;
  3435. case 2:
  3436. clif_displaymessage(fd, msg_txt(1100)); // ----- NPCs in Map -----
  3437. for (i = 0; i < map[m_id].npc_num;)
  3438. {
  3439. nd = map[m_id].npc[i];
  3440. switch(nd->ud.dir) {
  3441. case 0: strcpy(direction, msg_txt(1101)); break; // North
  3442. case 1: strcpy(direction, msg_txt(1102)); break; // North West
  3443. case 2: strcpy(direction, msg_txt(1103)); break; // West
  3444. case 3: strcpy(direction, msg_txt(1104)); break; // South West
  3445. case 4: strcpy(direction, msg_txt(1105)); break; // South
  3446. case 5: strcpy(direction, msg_txt(1106)); break; // South East
  3447. case 6: strcpy(direction, msg_txt(1107)); break; // East
  3448. case 7: strcpy(direction, msg_txt(1108)); break; // North East
  3449. case 9: strcpy(direction, msg_txt(1109)); break; // North
  3450. default: strcpy(direction, msg_txt(1110)); break; // Unknown
  3451. }
  3452. if(strcmp(nd->name,nd->exname) == 0)
  3453. sprintf(atcmd_output, msg_txt(1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3454. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3455. else
  3456. sprintf(atcmd_output, msg_txt(1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3457. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3458. clif_displaymessage(fd, atcmd_output);
  3459. }
  3460. break;
  3461. case 3:
  3462. clif_displaymessage(fd, msg_txt(1113)); // ----- Chats in Map -----
  3463. iter = mapit_getallusers();
  3464. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3465. {
  3466. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3467. pl_sd->mapindex == m_index &&
  3468. cd->usersd[0] == pl_sd)
  3469. {
  3470. sprintf(atcmd_output, msg_txt(1114), // Chat: %s | Player: %s | Location: %d %d
  3471. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3472. clif_displaymessage(fd, atcmd_output);
  3473. sprintf(atcmd_output, msg_txt(1115), // Users: %d/%d | Password: %s | Public: %s
  3474. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(1116) : msg_txt(1117)); // Yes / No
  3475. clif_displaymessage(fd, atcmd_output);
  3476. }
  3477. }
  3478. mapit_free(iter);
  3479. break;
  3480. default: // normally impossible to arrive here
  3481. clif_displaymessage(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3482. return -1;
  3483. break;
  3484. }
  3485. return 0;
  3486. }
  3487. /*==========================================
  3488. *
  3489. *------------------------------------------*/
  3490. ACMD_FUNC(mount_peco)
  3491. {
  3492. nullpo_retr(-1, sd);
  3493. if (sd->disguise) {
  3494. clif_displaymessage(fd, msg_txt(212)); // Cannot mount while in disguise.
  3495. return -1;
  3496. }
  3497. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3498. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3499. clif_displaymessage(sd->fd,msg_txt(1119)); // You have mounted your Dragon.
  3500. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3501. } else {
  3502. clif_displaymessage(sd->fd,msg_txt(1120)); // You have released your Dragon.
  3503. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3504. }
  3505. return 0;
  3506. }
  3507. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  3508. if( !pc_isridingwug(sd) ) {
  3509. clif_displaymessage(sd->fd,msg_txt(1121)); // You have mounted your Warg.
  3510. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3511. } else {
  3512. clif_displaymessage(sd->fd,msg_txt(1122)); // You have released your Warg.
  3513. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3514. }
  3515. return 0;
  3516. }
  3517. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3518. if( !pc_ismadogear(sd) ) {
  3519. clif_displaymessage(sd->fd,msg_txt(1123)); // You have mounted your Mado Gear.
  3520. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3521. } else {
  3522. clif_displaymessage(sd->fd,msg_txt(1124)); // You have released your Mado Gear.
  3523. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3524. }
  3525. return 0;
  3526. }
  3527. if (!pc_isriding(sd)) { // if actually no peco
  3528. if (!pc_checkskill(sd, KN_RIDING)) {
  3529. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  3530. return -1;
  3531. }
  3532. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3533. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  3534. } else {//Dismount
  3535. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3536. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  3537. }
  3538. return 0;
  3539. }
  3540. /*==========================================
  3541. *Spy Commands by Syrus22
  3542. *------------------------------------------*/
  3543. ACMD_FUNC(guildspy)
  3544. {
  3545. char guild_name[NAME_LENGTH];
  3546. struct guild *g;
  3547. nullpo_retr(-1, sd);
  3548. memset(guild_name, '\0', sizeof(guild_name));
  3549. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3550. if (!enable_spy)
  3551. {
  3552. clif_displaymessage(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
  3553. return -1;
  3554. }
  3555. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3556. clif_displaymessage(fd, msg_txt(1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3557. return -1;
  3558. }
  3559. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3560. (g = guild_search(atoi(message))) != NULL) {
  3561. if (sd->guildspy == g->guild_id) {
  3562. sd->guildspy = 0;
  3563. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3564. clif_displaymessage(fd, atcmd_output);
  3565. } else {
  3566. sd->guildspy = g->guild_id;
  3567. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3568. clif_displaymessage(fd, atcmd_output);
  3569. }
  3570. } else {
  3571. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  3572. return -1;
  3573. }
  3574. return 0;
  3575. }
  3576. /*==========================================
  3577. *
  3578. *------------------------------------------*/
  3579. ACMD_FUNC(partyspy)
  3580. {
  3581. char party_name[NAME_LENGTH];
  3582. struct party_data *p;
  3583. nullpo_retr(-1, sd);
  3584. memset(party_name, '\0', sizeof(party_name));
  3585. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3586. if (!enable_spy)
  3587. {
  3588. clif_displaymessage(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
  3589. return -1;
  3590. }
  3591. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3592. clif_displaymessage(fd, msg_txt(1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3593. return -1;
  3594. }
  3595. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3596. (p = party_search(atoi(message))) != NULL) {
  3597. if (sd->partyspy == p->party.party_id) {
  3598. sd->partyspy = 0;
  3599. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3600. clif_displaymessage(fd, atcmd_output);
  3601. } else {
  3602. sd->partyspy = p->party.party_id;
  3603. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3604. clif_displaymessage(fd, atcmd_output);
  3605. }
  3606. } else {
  3607. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  3608. return -1;
  3609. }
  3610. return 0;
  3611. }
  3612. /*==========================================
  3613. * @repairall [Valaris]
  3614. *------------------------------------------*/
  3615. ACMD_FUNC(repairall)
  3616. {
  3617. int count, i;
  3618. nullpo_retr(-1, sd);
  3619. count = 0;
  3620. for (i = 0; i < MAX_INVENTORY; i++) {
  3621. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3622. sd->status.inventory[i].attribute = 0;
  3623. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3624. count++;
  3625. }
  3626. }
  3627. if (count > 0) {
  3628. clif_misceffect(&sd->bl, 3);
  3629. clif_equiplist(sd);
  3630. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3631. } else {
  3632. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3633. return -1;
  3634. }
  3635. return 0;
  3636. }
  3637. /*==========================================
  3638. * @nuke [Valaris]
  3639. *------------------------------------------*/
  3640. ACMD_FUNC(nuke)
  3641. {
  3642. struct map_session_data *pl_sd;
  3643. nullpo_retr(-1, sd);
  3644. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3645. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3646. clif_displaymessage(fd, msg_txt(1128)); // Please enter a player name (usage: @nuke <char name>).
  3647. return -1;
  3648. }
  3649. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3650. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3651. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3652. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3653. } else {
  3654. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3655. return -1;
  3656. }
  3657. } else {
  3658. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3659. return -1;
  3660. }
  3661. return 0;
  3662. }
  3663. /*==========================================
  3664. * @tonpc
  3665. *------------------------------------------*/
  3666. ACMD_FUNC(tonpc)
  3667. {
  3668. char npcname[NAME_LENGTH+1];
  3669. struct npc_data *nd;
  3670. nullpo_retr(-1, sd);
  3671. memset(npcname, 0, sizeof(npcname));
  3672. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3673. clif_displaymessage(fd, msg_txt(1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3674. return -1;
  3675. }
  3676. if ((nd = npc_name2id(npcname)) != NULL) {
  3677. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3678. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3679. else
  3680. return -1;
  3681. } else {
  3682. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3683. return -1;
  3684. }
  3685. return 0;
  3686. }
  3687. /*==========================================
  3688. *
  3689. *------------------------------------------*/
  3690. ACMD_FUNC(shownpc)
  3691. {
  3692. char NPCname[NAME_LENGTH+1];
  3693. nullpo_retr(-1, sd);
  3694. memset(NPCname, '\0', sizeof(NPCname));
  3695. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3696. clif_displaymessage(fd, msg_txt(1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3697. return -1;
  3698. }
  3699. if (npc_name2id(NPCname) != NULL) {
  3700. npc_enable(NPCname, 1);
  3701. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  3702. } else {
  3703. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3704. return -1;
  3705. }
  3706. return 0;
  3707. }
  3708. /*==========================================
  3709. *
  3710. *------------------------------------------*/
  3711. ACMD_FUNC(hidenpc)
  3712. {
  3713. char NPCname[NAME_LENGTH+1];
  3714. nullpo_retr(-1, sd);
  3715. memset(NPCname, '\0', sizeof(NPCname));
  3716. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3717. clif_displaymessage(fd, msg_txt(1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3718. return -1;
  3719. }
  3720. if (npc_name2id(NPCname) == NULL) {
  3721. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3722. return -1;
  3723. }
  3724. npc_enable(NPCname, 0);
  3725. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3726. return 0;
  3727. }
  3728. ACMD_FUNC(loadnpc)
  3729. {
  3730. FILE *fp;
  3731. if (!message || !*message) {
  3732. clif_displaymessage(fd, msg_txt(1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3733. return -1;
  3734. }
  3735. // check if script file exists
  3736. if ((fp = fopen(message, "r")) == NULL) {
  3737. clif_displaymessage(fd, msg_txt(261));
  3738. return -1;
  3739. }
  3740. fclose(fp);
  3741. // add to list of script sources and run it
  3742. npc_addsrcfile(message);
  3743. npc_parsesrcfile(message,true);
  3744. npc_read_event_script();
  3745. clif_displaymessage(fd, msg_txt(262));
  3746. return 0;
  3747. }
  3748. ACMD_FUNC(unloadnpc)
  3749. {
  3750. struct npc_data *nd;
  3751. char NPCname[NAME_LENGTH+1];
  3752. nullpo_retr(-1, sd);
  3753. memset(NPCname, '\0', sizeof(NPCname));
  3754. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3755. clif_displaymessage(fd, msg_txt(1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
  3756. return -1;
  3757. }
  3758. if ((nd = npc_name2id(NPCname)) == NULL) {
  3759. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3760. return -1;
  3761. }
  3762. npc_unload_duplicates(nd);
  3763. npc_unload(nd,true);
  3764. npc_read_event_script();
  3765. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3766. return 0;
  3767. }
  3768. /*==========================================
  3769. * time in txt for time command (by [Yor])
  3770. *------------------------------------------*/
  3771. char* txt_time(unsigned int duration)
  3772. {
  3773. int days, hours, minutes, seconds;
  3774. char temp[CHAT_SIZE_MAX];
  3775. static char temp1[CHAT_SIZE_MAX];
  3776. memset(temp, '\0', sizeof(temp));
  3777. memset(temp1, '\0', sizeof(temp1));
  3778. days = duration / (60 * 60 * 24);
  3779. duration = duration - (60 * 60 * 24 * days);
  3780. hours = duration / (60 * 60);
  3781. duration = duration - (60 * 60 * hours);
  3782. minutes = duration / 60;
  3783. seconds = duration - (60 * minutes);
  3784. if (days == 1)
  3785. sprintf(temp, msg_txt(219), days); // %d day
  3786. else if (days > 1)
  3787. sprintf(temp, msg_txt(220), days); // %d days
  3788. if (hours == 1)
  3789. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  3790. else if (hours > 1)
  3791. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  3792. if (minutes < 2)
  3793. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  3794. else
  3795. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  3796. if (seconds == 1)
  3797. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  3798. else if (seconds > 1)
  3799. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  3800. return temp1;
  3801. }
  3802. /*==========================================
  3803. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3804. * Calculation management of GM modification (@day/@night GM commands) is done
  3805. *------------------------------------------*/
  3806. ACMD_FUNC(servertime)
  3807. {
  3808. const struct TimerData * timer_data;
  3809. const struct TimerData * timer_data2;
  3810. time_t time_server; // variable for number of seconds (used with time() function)
  3811. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3812. char temp[CHAT_SIZE_MAX];
  3813. nullpo_retr(-1, sd);
  3814. memset(temp, '\0', sizeof(temp));
  3815. time(&time_server); // get time in seconds since 1/1/1970
  3816. datetime = localtime(&time_server); // convert seconds in structure
  3817. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3818. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3819. clif_displaymessage(fd, temp);
  3820. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3821. if (night_flag == 0)
  3822. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3823. else
  3824. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3825. } else if (battle_config.night_duration == 0)
  3826. if (night_flag == 1) { // we start with night
  3827. timer_data = get_timer(day_timer_tid);
  3828. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  3829. clif_displaymessage(fd, temp);
  3830. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  3831. } else
  3832. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3833. else if (battle_config.day_duration == 0)
  3834. if (night_flag == 0) { // we start with day
  3835. timer_data = get_timer(night_timer_tid);
  3836. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3837. clif_displaymessage(fd, temp);
  3838. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  3839. } else
  3840. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3841. else {
  3842. if (night_flag == 0) {
  3843. timer_data = get_timer(night_timer_tid);
  3844. timer_data2 = get_timer(day_timer_tid);
  3845. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3846. clif_displaymessage(fd, temp);
  3847. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3848. sprintf(temp, msg_txt(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.
  3849. else
  3850. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  3851. clif_displaymessage(fd, temp);
  3852. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3853. clif_displaymessage(fd, temp);
  3854. } else {
  3855. timer_data = get_timer(day_timer_tid);
  3856. timer_data2 = get_timer(night_timer_tid);
  3857. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  3858. clif_displaymessage(fd, temp);
  3859. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3860. sprintf(temp, msg_txt(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.
  3861. else
  3862. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  3863. clif_displaymessage(fd, temp);
  3864. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3865. clif_displaymessage(fd, temp);
  3866. }
  3867. }
  3868. return 0;
  3869. }
  3870. //Added by Coltaro
  3871. //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...).
  3872. //Well, using time_t could still work but for some reason that looks like more coding x_x
  3873. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  3874. {
  3875. const int factor_year = 518400; //12*30*24*60 = 518400
  3876. const int factor_month = 43200; //30*24*60 = 43200
  3877. const int factor_day = 1440; //24*60 = 1440
  3878. const int factor_hour = 60;
  3879. *year = jailtime/factor_year;
  3880. jailtime -= *year*factor_year;
  3881. *month = jailtime/factor_month;
  3882. jailtime -= *month*factor_month;
  3883. *day = jailtime/factor_day;
  3884. jailtime -= *day*factor_day;
  3885. *hour = jailtime/factor_hour;
  3886. jailtime -= *hour*factor_hour;
  3887. *minute = jailtime;
  3888. *year = *year > 0? *year : 0;
  3889. *month = *month > 0? *month : 0;
  3890. *day = *day > 0? *day : 0;
  3891. *hour = *hour > 0? *hour : 0;
  3892. *minute = *minute > 0? *minute : 0;
  3893. return;
  3894. }
  3895. /*==========================================
  3896. * @jail <char_name> by [Yor]
  3897. * Special warp! No check with nowarp and nowarpto flag
  3898. *------------------------------------------*/
  3899. ACMD_FUNC(jail)
  3900. {
  3901. struct map_session_data *pl_sd;
  3902. int x, y;
  3903. unsigned short m_index;
  3904. nullpo_retr(-1, sd);
  3905. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3906. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3907. clif_displaymessage(fd, msg_txt(1134)); // Please enter a player name (usage: @jail <char_name>).
  3908. return -1;
  3909. }
  3910. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3911. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3912. return -1;
  3913. }
  3914. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  3915. { // you can jail only lower or same GM
  3916. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3917. return -1;
  3918. }
  3919. if (pl_sd->sc.data[SC_JAILED])
  3920. {
  3921. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  3922. return -1;
  3923. }
  3924. switch(rnd() % 2) { //Jail Locations
  3925. case 0:
  3926. m_index = mapindex_name2id(MAP_JAIL);
  3927. x = 24;
  3928. y = 75;
  3929. break;
  3930. default:
  3931. m_index = mapindex_name2id(MAP_JAIL);
  3932. x = 49;
  3933. y = 75;
  3934. break;
  3935. }
  3936. //Duration of INT_MAX to specify infinity.
  3937. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  3938. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  3939. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  3940. return 0;
  3941. }
  3942. /*==========================================
  3943. * @unjail/@discharge <char_name> by [Yor]
  3944. * Special warp! No check with nowarp and nowarpto flag
  3945. *------------------------------------------*/
  3946. ACMD_FUNC(unjail)
  3947. {
  3948. struct map_session_data *pl_sd;
  3949. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3950. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3951. clif_displaymessage(fd, msg_txt(1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  3952. return -1;
  3953. }
  3954. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3955. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3956. return -1;
  3957. }
  3958. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3959. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3960. return -1;
  3961. }
  3962. if (!pl_sd->sc.data[SC_JAILED])
  3963. {
  3964. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  3965. return -1;
  3966. }
  3967. //Reset jail time to 1 sec.
  3968. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  3969. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  3970. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  3971. return 0;
  3972. }
  3973. ACMD_FUNC(jailfor)
  3974. {
  3975. struct map_session_data *pl_sd = NULL;
  3976. int year, month, day, hour, minute, value;
  3977. char * modif_p;
  3978. int jailtime = 0,x,y;
  3979. short m_index = 0;
  3980. nullpo_retr(-1, sd);
  3981. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  3982. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  3983. return -1;
  3984. }
  3985. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3986. modif_p = atcmd_output;
  3987. year = month = day = hour = minute = 0;
  3988. while (modif_p[0] != '\0') {
  3989. value = atoi(modif_p);
  3990. if (value == 0)
  3991. modif_p++;
  3992. else {
  3993. if (modif_p[0] == '-' || modif_p[0] == '+')
  3994. modif_p++;
  3995. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3996. modif_p++;
  3997. if (modif_p[0] == 'n') {
  3998. minute = value;
  3999. modif_p++;
  4000. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4001. minute = value;
  4002. modif_p = modif_p + 2;
  4003. } else if (modif_p[0] == 'h') {
  4004. hour = value;
  4005. modif_p++;
  4006. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4007. day = value;
  4008. modif_p++;
  4009. } else if (modif_p[0] == 'm') {
  4010. month = value;
  4011. modif_p++;
  4012. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4013. year = value;
  4014. modif_p++;
  4015. } else if (modif_p[0] != '\0') {
  4016. modif_p++;
  4017. }
  4018. }
  4019. }
  4020. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4021. clif_displaymessage(fd, msg_txt(1136)); // Invalid time for jail command.
  4022. return -1;
  4023. }
  4024. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4025. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4026. return -1;
  4027. }
  4028. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4029. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4030. return -1;
  4031. }
  4032. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4033. if(jailtime==0) {
  4034. clif_displaymessage(fd, msg_txt(1136)); // Invalid time for jail command.
  4035. return -1;
  4036. }
  4037. //Added by Coltaro
  4038. if(pl_sd->sc.data[SC_JAILED] &&
  4039. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4040. { //Update the player's jail time
  4041. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4042. if (jailtime <= 0) {
  4043. jailtime = 0;
  4044. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4045. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4046. } else {
  4047. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4048. sprintf(atcmd_output,msg_txt(402),msg_txt(1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4049. clif_displaymessage(pl_sd->fd, atcmd_output);
  4050. sprintf(atcmd_output,msg_txt(402),msg_txt(1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4051. clif_displaymessage(fd, atcmd_output);
  4052. }
  4053. } else if (jailtime < 0) {
  4054. clif_displaymessage(fd, msg_txt(1136));
  4055. return -1;
  4056. }
  4057. //Jail locations, add more as you wish.
  4058. switch(rnd()%2)
  4059. {
  4060. case 1: //Jail #1
  4061. m_index = mapindex_name2id(MAP_JAIL);
  4062. x = 49; y = 75;
  4063. break;
  4064. default: //Default Jail
  4065. m_index = mapindex_name2id(MAP_JAIL);
  4066. x = 24; y = 75;
  4067. break;
  4068. }
  4069. sc_start4(&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).
  4070. return 0;
  4071. }
  4072. //By Coltaro
  4073. ACMD_FUNC(jailtime)
  4074. {
  4075. int year, month, day, hour, minute;
  4076. nullpo_retr(-1, sd);
  4077. if (!sd->sc.data[SC_JAILED]) {
  4078. clif_displaymessage(fd, msg_txt(1139)); // You are not in jail.
  4079. return -1;
  4080. }
  4081. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4082. clif_displaymessage(fd, msg_txt(1140)); // You have been jailed indefinitely.
  4083. return 0;
  4084. }
  4085. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4086. clif_displaymessage(fd, msg_txt(1141)); // You have been jailed for an unknown amount of time.
  4087. return -1;
  4088. }
  4089. //Get remaining jail time
  4090. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4091. sprintf(atcmd_output,msg_txt(402),msg_txt(1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4092. clif_displaymessage(fd, atcmd_output);
  4093. return 0;
  4094. }
  4095. /*==========================================
  4096. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4097. *------------------------------------------*/
  4098. ACMD_FUNC(disguise)
  4099. {
  4100. int id = 0;
  4101. nullpo_retr(-1, sd);
  4102. if (!message || !*message) {
  4103. clif_displaymessage(fd, msg_txt(1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4104. return -1;
  4105. }
  4106. if ((id = atoi(message)) > 0)
  4107. { //Acquired an ID
  4108. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4109. id = 0; //Invalid id for either mobs or npcs.
  4110. } else { //Acquired a Name
  4111. if ((id = mobdb_searchname(message)) == 0)
  4112. {
  4113. struct npc_data* nd = npc_name2id(message);
  4114. if (nd != NULL)
  4115. id = nd->class_;
  4116. }
  4117. }
  4118. if (id == 0)
  4119. {
  4120. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4121. return -1;
  4122. }
  4123. if(pc_isriding(sd))
  4124. {
  4125. clif_displaymessage(fd, msg_txt(1144)); // Character cannot be disguised while mounted.
  4126. return -1;
  4127. }
  4128. pc_disguise(sd, id);
  4129. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4130. return 0;
  4131. }
  4132. /*==========================================
  4133. * DisguiseAll
  4134. *------------------------------------------*/
  4135. ACMD_FUNC(disguiseall)
  4136. {
  4137. int mob_id=0;
  4138. struct map_session_data *pl_sd;
  4139. struct s_mapiterator* iter;
  4140. nullpo_retr(-1, sd);
  4141. if (!message || !*message) {
  4142. clif_displaymessage(fd, msg_txt(1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4143. return -1;
  4144. }
  4145. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4146. mob_id = atoi(message);
  4147. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4148. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4149. return -1;
  4150. }
  4151. iter = mapit_getallusers();
  4152. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4153. pc_disguise(pl_sd, mob_id);
  4154. mapit_free(iter);
  4155. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4156. return 0;
  4157. }
  4158. /*==========================================
  4159. * DisguiseGuild
  4160. *------------------------------------------*/
  4161. ACMD_FUNC(disguiseguild)
  4162. {
  4163. int id = 0, i;
  4164. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4165. struct map_session_data *pl_sd;
  4166. struct guild *g;
  4167. memset(monster, '\0', sizeof(monster));
  4168. memset(guild, '\0', sizeof(guild));
  4169. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4170. clif_displaymessage(fd, msg_txt(1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4171. return -1;
  4172. }
  4173. if( (id = atoi(monster)) > 0 ) {
  4174. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4175. id = 0;
  4176. } else {
  4177. if( (id = mobdb_searchname(monster)) == 0 ) {
  4178. struct npc_data* nd = npc_name2id(monster);
  4179. if( nd != NULL )
  4180. id = nd->class_;
  4181. }
  4182. }
  4183. if( id == 0 ) {
  4184. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4185. return -1;
  4186. }
  4187. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4188. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4189. return -1;
  4190. }
  4191. for( i = 0; i < g->max_member; i++ )
  4192. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4193. pc_disguise(pl_sd, id);
  4194. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4195. return 0;
  4196. }
  4197. /*==========================================
  4198. * @undisguise by [Yor]
  4199. *------------------------------------------*/
  4200. ACMD_FUNC(undisguise)
  4201. {
  4202. nullpo_retr(-1, sd);
  4203. if (sd->disguise) {
  4204. pc_disguise(sd, 0);
  4205. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4206. } else {
  4207. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4208. return -1;
  4209. }
  4210. return 0;
  4211. }
  4212. /*==========================================
  4213. * UndisguiseAll
  4214. *------------------------------------------*/
  4215. ACMD_FUNC(undisguiseall)
  4216. {
  4217. struct map_session_data *pl_sd;
  4218. struct s_mapiterator* iter;
  4219. nullpo_retr(-1, sd);
  4220. iter = mapit_getallusers();
  4221. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4222. if( pl_sd->disguise )
  4223. pc_disguise(pl_sd, 0);
  4224. mapit_free(iter);
  4225. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4226. return 0;
  4227. }
  4228. /*==========================================
  4229. * UndisguiseGuild
  4230. *------------------------------------------*/
  4231. ACMD_FUNC(undisguiseguild)
  4232. {
  4233. char guild_name[NAME_LENGTH];
  4234. struct map_session_data *pl_sd;
  4235. struct guild *g;
  4236. int i;
  4237. nullpo_retr(-1, sd);
  4238. memset(guild_name, '\0', sizeof(guild_name));
  4239. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4240. clif_displaymessage(fd, msg_txt(1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4241. return -1;
  4242. }
  4243. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4244. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4245. return -1;
  4246. }
  4247. for(i = 0; i < g->max_member; i++)
  4248. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4249. pc_disguise(pl_sd, 0);
  4250. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4251. return 0;
  4252. }
  4253. /*==========================================
  4254. * @exp by [Skotlex]
  4255. *------------------------------------------*/
  4256. ACMD_FUNC(exp)
  4257. {
  4258. char output[CHAT_SIZE_MAX];
  4259. double nextb, nextj;
  4260. nullpo_retr(-1, sd);
  4261. memset(output, '\0', sizeof(output));
  4262. nextb = pc_nextbaseexp(sd);
  4263. if (nextb)
  4264. nextb = sd->status.base_exp*100.0/nextb;
  4265. nextj = pc_nextjobexp(sd);
  4266. if (nextj)
  4267. nextj = sd->status.job_exp*100.0/nextj;
  4268. sprintf(output, msg_txt(1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4269. clif_displaymessage(fd, output);
  4270. return 0;
  4271. }
  4272. /*==========================================
  4273. * @broadcast by [Valaris]
  4274. *------------------------------------------*/
  4275. ACMD_FUNC(broadcast)
  4276. {
  4277. nullpo_retr(-1, sd);
  4278. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4279. if (!message || !*message) {
  4280. clif_displaymessage(fd, msg_txt(1149)); // Please enter a message (usage: @broadcast <message>).
  4281. return -1;
  4282. }
  4283. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4284. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4285. return 0;
  4286. }
  4287. /*==========================================
  4288. * @localbroadcast by [Valaris]
  4289. *------------------------------------------*/
  4290. ACMD_FUNC(localbroadcast)
  4291. {
  4292. nullpo_retr(-1, sd);
  4293. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4294. if (!message || !*message) {
  4295. clif_displaymessage(fd, msg_txt(1150)); // Please enter a message (usage: @localbroadcast <message>).
  4296. return -1;
  4297. }
  4298. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4299. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4300. return 0;
  4301. }
  4302. /*==========================================
  4303. * @email <actual@email> <new@email> by [Yor]
  4304. *------------------------------------------*/
  4305. ACMD_FUNC(email)
  4306. {
  4307. char actual_email[100];
  4308. char new_email[100];
  4309. nullpo_retr(-1, sd);
  4310. memset(actual_email, '\0', sizeof(actual_email));
  4311. memset(new_email, '\0', sizeof(new_email));
  4312. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4313. clif_displaymessage(fd, msg_txt(1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4314. return -1;
  4315. }
  4316. if (e_mail_check(actual_email) == 0) {
  4317. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4318. return -1;
  4319. } else if (e_mail_check(new_email) == 0) {
  4320. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4321. return -1;
  4322. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4323. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4324. return -1;
  4325. } else if (strcmpi(actual_email, new_email) == 0) {
  4326. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4327. return -1;
  4328. }
  4329. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4330. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4331. return 0;
  4332. }
  4333. /*==========================================
  4334. *@effect
  4335. *------------------------------------------*/
  4336. ACMD_FUNC(effect)
  4337. {
  4338. int type = 0, flag = 0;
  4339. nullpo_retr(-1, sd);
  4340. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4341. clif_displaymessage(fd, msg_txt(1152)); // Please enter an effect number (usage: @effect <effect number>).
  4342. return -1;
  4343. }
  4344. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4345. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4346. return 0;
  4347. }
  4348. /*==========================================
  4349. * @killer by MouseJstr
  4350. * enable killing players even when not in pvp
  4351. *------------------------------------------*/
  4352. ACMD_FUNC(killer)
  4353. {
  4354. nullpo_retr(-1, sd);
  4355. sd->state.killer = !sd->state.killer;
  4356. if(sd->state.killer)
  4357. clif_displaymessage(fd, msg_txt(241));
  4358. else {
  4359. clif_displaymessage(fd, msg_txt(292));
  4360. pc_stop_attack(sd);
  4361. }
  4362. return 0;
  4363. }
  4364. /*==========================================
  4365. * @killable by MouseJstr
  4366. * enable other people killing you
  4367. *------------------------------------------*/
  4368. ACMD_FUNC(killable)
  4369. {
  4370. nullpo_retr(-1, sd);
  4371. sd->state.killable = !sd->state.killable;
  4372. if(sd->state.killable)
  4373. clif_displaymessage(fd, msg_txt(242));
  4374. else {
  4375. clif_displaymessage(fd, msg_txt(288));
  4376. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4377. }
  4378. return 0;
  4379. }
  4380. /*==========================================
  4381. * @skillon by MouseJstr
  4382. * turn skills on for the map
  4383. *------------------------------------------*/
  4384. ACMD_FUNC(skillon)
  4385. {
  4386. nullpo_retr(-1, sd);
  4387. map[sd->bl.m].flag.noskill = 0;
  4388. clif_displaymessage(fd, msg_txt(244));
  4389. return 0;
  4390. }
  4391. /*==========================================
  4392. * @skilloff by MouseJstr
  4393. * Turn skills off on the map
  4394. *------------------------------------------*/
  4395. ACMD_FUNC(skilloff)
  4396. {
  4397. nullpo_retr(-1, sd);
  4398. map[sd->bl.m].flag.noskill = 1;
  4399. clif_displaymessage(fd, msg_txt(243));
  4400. return 0;
  4401. }
  4402. /*==========================================
  4403. * @npcmove by MouseJstr
  4404. * move a npc
  4405. *------------------------------------------*/
  4406. ACMD_FUNC(npcmove)
  4407. {
  4408. int x = 0, y = 0, m;
  4409. struct npc_data *nd = 0;
  4410. nullpo_retr(-1, sd);
  4411. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4412. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4413. clif_displaymessage(fd, msg_txt(1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4414. return -1;
  4415. }
  4416. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4417. {
  4418. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4419. return -1;
  4420. }
  4421. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4422. {
  4423. clif_displaymessage(fd, msg_txt(1154)); // NPC is not on this map.
  4424. return -1; //Not on a map.
  4425. }
  4426. x = cap_value(x, 0, map[m].xs-1);
  4427. y = cap_value(y, 0, map[m].ys-1);
  4428. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4429. map_moveblock(&nd->bl, x, y, gettick());
  4430. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4431. clif_displaymessage(fd, msg_txt(1155)); // NPC moved.
  4432. return 0;
  4433. }
  4434. /*==========================================
  4435. * @addwarp by MouseJstr
  4436. * Create a new static warp point.
  4437. *------------------------------------------*/
  4438. ACMD_FUNC(addwarp)
  4439. {
  4440. char mapname[32], warpname[NAME_LENGTH+1];
  4441. int x,y;
  4442. unsigned short m;
  4443. struct npc_data* nd;
  4444. nullpo_retr(-1, sd);
  4445. memset(warpname, '\0', sizeof(warpname));
  4446. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4447. clif_displaymessage(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4448. return -1;
  4449. }
  4450. m = mapindex_name2id(mapname);
  4451. if( m == 0 )
  4452. {
  4453. sprintf(atcmd_output, msg_txt(1157), mapname); // Unknown map '%s'.
  4454. clif_displaymessage(fd, atcmd_output);
  4455. return -1;
  4456. }
  4457. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4458. if( nd == NULL )
  4459. return -1;
  4460. sprintf(atcmd_output, msg_txt(1158), nd->exname); // New warp NPC '%s' created.
  4461. clif_displaymessage(fd, atcmd_output);
  4462. return 0;
  4463. }
  4464. /*==========================================
  4465. * @follow by [MouseJstr]
  4466. * Follow a player .. staying no more then 5 spaces away
  4467. *------------------------------------------*/
  4468. ACMD_FUNC(follow)
  4469. {
  4470. struct map_session_data *pl_sd = NULL;
  4471. nullpo_retr(-1, sd);
  4472. if (!message || !*message) {
  4473. if (sd->followtarget == -1)
  4474. return -1;
  4475. pc_stop_following (sd);
  4476. clif_displaymessage(fd, msg_txt(1159)); // Follow mode OFF.
  4477. return 0;
  4478. }
  4479. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4480. {
  4481. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4482. return -1;
  4483. }
  4484. if (sd->followtarget == pl_sd->bl.id) {
  4485. pc_stop_following (sd);
  4486. clif_displaymessage(fd, msg_txt(1159)); // Follow mode OFF.
  4487. } else {
  4488. pc_follow(sd, pl_sd->bl.id);
  4489. clif_displaymessage(fd, msg_txt(1160)); // Follow mode ON.
  4490. }
  4491. return 0;
  4492. }
  4493. /*==========================================
  4494. * @dropall by [MouseJstr]
  4495. * Drop all your possession on the ground
  4496. *------------------------------------------*/
  4497. ACMD_FUNC(dropall)
  4498. {
  4499. int i;
  4500. nullpo_retr(-1, sd);
  4501. for (i = 0; i < MAX_INVENTORY; i++) {
  4502. if (sd->status.inventory[i].amount) {
  4503. if(sd->status.inventory[i].equip != 0)
  4504. pc_unequipitem(sd, i, 3);
  4505. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4506. }
  4507. }
  4508. return 0;
  4509. }
  4510. /*==========================================
  4511. * @storeall by [MouseJstr]
  4512. * Put everything into storage
  4513. *------------------------------------------*/
  4514. ACMD_FUNC(storeall)
  4515. {
  4516. int i;
  4517. nullpo_retr(-1, sd);
  4518. if (sd->state.storage_flag != 1)
  4519. { //Open storage.
  4520. if( storage_storageopen(sd) == 1 ) {
  4521. clif_displaymessage(fd, msg_txt(1161)); // You currently cannot open your storage.
  4522. return -1;
  4523. }
  4524. }
  4525. for (i = 0; i < MAX_INVENTORY; i++) {
  4526. if (sd->status.inventory[i].amount) {
  4527. if(sd->status.inventory[i].equip != 0)
  4528. pc_unequipitem(sd, i, 3);
  4529. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4530. }
  4531. }
  4532. storage_storageclose(sd);
  4533. clif_displaymessage(fd, msg_txt(1162)); // All items stored.
  4534. return 0;
  4535. }
  4536. ACMD_FUNC(clearstorage)
  4537. {
  4538. int i, j;
  4539. nullpo_retr(-1, sd);
  4540. if (sd->state.storage_flag == 1) {
  4541. clif_displaymessage(fd, msg_txt(250));
  4542. return -1;
  4543. }
  4544. j = sd->status.storage.storage_amount;
  4545. for (i = 0; i < j; ++i) {
  4546. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4547. }
  4548. storage_storageclose(sd);
  4549. clif_displaymessage(fd, msg_txt(1394)); // Your storage was cleaned.
  4550. return 0;
  4551. }
  4552. ACMD_FUNC(cleargstorage)
  4553. {
  4554. int i, j;
  4555. struct guild *g;
  4556. struct guild_storage *gstorage;
  4557. nullpo_retr(-1, sd);
  4558. g = guild_search(sd->status.guild_id);
  4559. if (g == NULL) {
  4560. clif_displaymessage(fd, msg_txt(43));
  4561. return -1;
  4562. }
  4563. if (sd->state.storage_flag == 1) {
  4564. clif_displaymessage(fd, msg_txt(250));
  4565. return -1;
  4566. }
  4567. if (sd->state.storage_flag == 2) {
  4568. clif_displaymessage(fd, msg_txt(251));
  4569. return -1;
  4570. }
  4571. gstorage = guild2storage2(sd->status.guild_id);
  4572. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4573. return -1;
  4574. }
  4575. j = gstorage->storage_amount;
  4576. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4577. for (i = 0; i < j; ++i) {
  4578. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4579. }
  4580. storage_guild_storageclose(sd);
  4581. gstorage->lock = 0; // Cleaning done, release lock
  4582. clif_displaymessage(fd, msg_txt(1395)); // Your guild storage was cleaned.
  4583. return 0;
  4584. }
  4585. ACMD_FUNC(clearcart)
  4586. {
  4587. int i;
  4588. nullpo_retr(-1, sd);
  4589. if (pc_iscarton(sd) == 0) {
  4590. clif_displaymessage(fd, msg_txt(1396)); // You do not have a cart to be cleaned.
  4591. return -1;
  4592. }
  4593. if (sd->state.vending == 1) { //Somehow...
  4594. return -1;
  4595. }
  4596. for( i = 0; i < MAX_CART; i++ )
  4597. if(sd->status.cart[i].nameid > 0)
  4598. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4599. clif_clearcart(fd);
  4600. clif_updatestatus(sd,SP_CARTINFO);
  4601. clif_displaymessage(fd, msg_txt(1397)); // Your cart was cleaned.
  4602. return 0;
  4603. }
  4604. /*==========================================
  4605. * @skillid by [MouseJstr]
  4606. * lookup a skill by name
  4607. *------------------------------------------*/
  4608. ACMD_FUNC(skillid)
  4609. {
  4610. int skillen, idx;
  4611. nullpo_retr(-1, sd);
  4612. if (!message || !*message)
  4613. {
  4614. clif_displaymessage(fd, msg_txt(1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4615. return -1;
  4616. }
  4617. skillen = strlen(message);
  4618. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4619. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4620. {
  4621. sprintf(atcmd_output, msg_txt(1164), idx, skill_db[idx].desc); // skill %d: %s
  4622. clif_displaymessage(fd, atcmd_output);
  4623. }
  4624. }
  4625. return 0;
  4626. }
  4627. /*==========================================
  4628. * @useskill by [MouseJstr]
  4629. * A way of using skills without having to find them in the skills menu
  4630. *------------------------------------------*/
  4631. ACMD_FUNC(useskill)
  4632. {
  4633. struct map_session_data *pl_sd = NULL;
  4634. struct block_list *bl;
  4635. uint16 skill_id;
  4636. uint16 skill_lv;
  4637. char target[100];
  4638. nullpo_retr(-1, sd);
  4639. if(!message || !*message || sscanf(message, "%hui %hui %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4640. clif_displaymessage(fd, msg_txt(1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4641. return -1;
  4642. }
  4643. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4644. {
  4645. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4646. return -1;
  4647. }
  4648. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4649. {
  4650. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4651. return -1;
  4652. }
  4653. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4654. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4655. bl = &sd->hd->bl;
  4656. else
  4657. bl = &sd->bl;
  4658. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4659. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4660. else
  4661. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4662. return 0;
  4663. }
  4664. /*==========================================
  4665. * @displayskill by [Skotlex]
  4666. * Debug command to locate new skill IDs. It sends the
  4667. * three possible skill-effect packets to the area.
  4668. *------------------------------------------*/
  4669. ACMD_FUNC(displayskill)
  4670. {
  4671. struct status_data * status;
  4672. unsigned int tick;
  4673. uint16 skill_id;
  4674. uint16 skill_lv = 1;
  4675. nullpo_retr(-1, sd);
  4676. if (!message || !*message || sscanf(message, "%hui %hui", &skill_id, &skill_lv) < 1)
  4677. {
  4678. clif_displaymessage(fd, msg_txt(1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4679. return -1;
  4680. }
  4681. status = status_get_status_data(&sd->bl);
  4682. tick = gettick();
  4683. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4684. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4685. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4686. return 0;
  4687. }
  4688. /*==========================================
  4689. * @skilltree by [MouseJstr]
  4690. * prints the skill tree for a player required to get to a skill
  4691. *------------------------------------------*/
  4692. ACMD_FUNC(skilltree)
  4693. {
  4694. struct map_session_data *pl_sd = NULL;
  4695. uint16 skill_id;
  4696. int meets, j, c=0;
  4697. char target[NAME_LENGTH];
  4698. struct skill_tree_entry *ent;
  4699. nullpo_retr(-1, sd);
  4700. if(!message || !*message || sscanf(message, "%hui %23[^\r\n]", &skill_id, target) != 2) {
  4701. clif_displaymessage(fd, msg_txt(1167)); // Usage: @skilltree <skill ID> <target>
  4702. return -1;
  4703. }
  4704. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4705. {
  4706. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4707. return -1;
  4708. }
  4709. c = pc_calc_skilltree_normalize_job(pl_sd);
  4710. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4711. sprintf(atcmd_output, msg_txt(1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  4712. clif_displaymessage(fd, atcmd_output);
  4713. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4714. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4715. {
  4716. clif_displaymessage(fd, msg_txt(1169)); // The player cannot use that skill.
  4717. return 0;
  4718. }
  4719. ent = &skill_tree[c][j];
  4720. meets = 1;
  4721. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4722. {
  4723. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4724. {
  4725. sprintf(atcmd_output, msg_txt(1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  4726. clif_displaymessage(fd, atcmd_output);
  4727. meets = 0;
  4728. }
  4729. }
  4730. if (meets == 1) {
  4731. clif_displaymessage(fd, msg_txt(1171)); // The player meets all the requirements for that skill.
  4732. }
  4733. return 0;
  4734. }
  4735. // Hand a ring with partners name on it to this char
  4736. void getring (struct map_session_data* sd)
  4737. {
  4738. int flag, item_id;
  4739. struct item item_tmp;
  4740. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4741. memset(&item_tmp, 0, sizeof(item_tmp));
  4742. item_tmp.nameid = item_id;
  4743. item_tmp.identify = 1;
  4744. item_tmp.card[0] = 255;
  4745. item_tmp.card[2] = sd->status.partner_id;
  4746. item_tmp.card[3] = sd->status.partner_id >> 16;
  4747. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4748. clif_additem(sd,0,0,flag);
  4749. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4750. }
  4751. }
  4752. /*==========================================
  4753. * @marry by [MouseJstr], fixed by Lupus
  4754. * Marry two players
  4755. *------------------------------------------*/
  4756. ACMD_FUNC(marry)
  4757. {
  4758. struct map_session_data *pl_sd = NULL;
  4759. char player_name[NAME_LENGTH] = "";
  4760. nullpo_retr(-1, sd);
  4761. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4762. clif_displaymessage(fd, msg_txt(1172)); // Usage: @marry <char name>
  4763. return -1;
  4764. }
  4765. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4766. clif_displaymessage(fd, msg_txt(3));
  4767. return -1;
  4768. }
  4769. if (pc_marriage(sd, pl_sd) == 0) {
  4770. clif_displaymessage(fd, msg_txt(1173)); // They are married... wish them well.
  4771. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4772. getring(sd); // Auto-give named rings (Aru)
  4773. getring(pl_sd);
  4774. return 0;
  4775. }
  4776. clif_displaymessage(fd, msg_txt(1174)); // The two cannot wed because one is either a baby or already married.
  4777. return -1;
  4778. }
  4779. /*==========================================
  4780. * @divorce by [MouseJstr], fixed by [Lupus]
  4781. * divorce two players
  4782. *------------------------------------------*/
  4783. ACMD_FUNC(divorce)
  4784. {
  4785. nullpo_retr(-1, sd);
  4786. if (pc_divorce(sd) != 0) {
  4787. sprintf(atcmd_output, msg_txt(1175), sd->status.name); // '%s' is not married.
  4788. clif_displaymessage(fd, atcmd_output);
  4789. return -1;
  4790. }
  4791. sprintf(atcmd_output, msg_txt(1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4792. clif_displaymessage(fd, atcmd_output);
  4793. return 0;
  4794. }
  4795. /*==========================================
  4796. * @changelook by [Celest]
  4797. *------------------------------------------*/
  4798. ACMD_FUNC(changelook)
  4799. {
  4800. int i, j = 0, k = 0;
  4801. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4802. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4803. clif_displaymessage(fd, msg_txt(1177)); // Usage: @changelook {<position>} <view id>
  4804. clif_displaymessage(fd, msg_txt(1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4805. return -1;
  4806. } else if ( i == 2 ) {
  4807. if (j < 1 || j > 7)
  4808. j = 1;
  4809. j = pos[j - 1];
  4810. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4811. k = j; // swap
  4812. j = LOOK_HEAD_TOP;
  4813. }
  4814. clif_changelook(&sd->bl,j,k);
  4815. return 0;
  4816. }
  4817. /*==========================================
  4818. * @autotrade by durf [Lupus] [Paradox924X]
  4819. * Turns on/off Autotrade for a specific player
  4820. *------------------------------------------*/
  4821. ACMD_FUNC(autotrade)
  4822. {
  4823. nullpo_retr(-1, sd);
  4824. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4825. clif_displaymessage(fd, msg_txt(1179)); // Autotrade is not allowed on this map.
  4826. return -1;
  4827. }
  4828. if( pc_isdead(sd) ) {
  4829. clif_displaymessage(fd, msg_txt(1180)); // You cannot autotrade when dead.
  4830. return -1;
  4831. }
  4832. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4833. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  4834. return -1;
  4835. }
  4836. sd->state.autotrade = 1;
  4837. if( battle_config.at_timeout )
  4838. {
  4839. int timeout = atoi(message);
  4840. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  4841. }
  4842. clif_authfail_fd(fd, 15);
  4843. return 0;
  4844. }
  4845. /*==========================================
  4846. * @changegm by durf (changed by Lupus)
  4847. * Changes Master of your Guild to a specified guild member
  4848. *------------------------------------------*/
  4849. ACMD_FUNC(changegm)
  4850. {
  4851. struct guild *g;
  4852. struct map_session_data *pl_sd;
  4853. nullpo_retr(-1, sd);
  4854. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name)) {
  4855. clif_displaymessage(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
  4856. return -1;
  4857. }
  4858. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4859. clif_displaymessage(fd, msg_txt(1182)); // You cannot change guild leaders on this map.
  4860. return -1;
  4861. }
  4862. if( !message[0] ) {
  4863. clif_displaymessage(fd, msg_txt(1183)); // Usage: @changegm <guild_member_name>
  4864. return -1;
  4865. }
  4866. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4867. clif_displaymessage(fd, msg_txt(1184)); // Target character must be online and be a guild member.
  4868. return -1;
  4869. }
  4870. guild_gm_change(sd->status.guild_id, pl_sd);
  4871. return 0;
  4872. }
  4873. /*==========================================
  4874. * @changeleader by Skotlex
  4875. * Changes the leader of a party.
  4876. *------------------------------------------*/
  4877. ACMD_FUNC(changeleader)
  4878. {
  4879. nullpo_retr(-1, sd);
  4880. if( !message[0] )
  4881. {
  4882. clif_displaymessage(fd, msg_txt(1185)); // Usage: @changeleader <party_member_name>
  4883. return -1;
  4884. }
  4885. if (party_changeleader(sd, map_nick2sd((char *) message)))
  4886. return 0;
  4887. return -1;
  4888. }
  4889. /*==========================================
  4890. * @partyoption by Skotlex
  4891. * Used to change the item share setting of a party.
  4892. *------------------------------------------*/
  4893. ACMD_FUNC(partyoption)
  4894. {
  4895. struct party_data *p;
  4896. int mi, option;
  4897. char w1[16], w2[16];
  4898. nullpo_retr(-1, sd);
  4899. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4900. {
  4901. clif_displaymessage(fd, msg_txt(282));
  4902. return -1;
  4903. }
  4904. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4905. if (mi == MAX_PARTY)
  4906. return -1; //Shouldn't happen
  4907. if (!p->party.member[mi].leader)
  4908. {
  4909. clif_displaymessage(fd, msg_txt(282));
  4910. return -1;
  4911. }
  4912. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4913. {
  4914. clif_displaymessage(fd, msg_txt(1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  4915. return -1;
  4916. }
  4917. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4918. //Change item share type.
  4919. if (option != p->party.item)
  4920. party_changeoption(sd, p->party.exp, option);
  4921. else
  4922. clif_displaymessage(fd, msg_txt(286));
  4923. return 0;
  4924. }
  4925. /*==========================================
  4926. * @autoloot by Upa-Kun
  4927. * Turns on/off AutoLoot for a specific player
  4928. *------------------------------------------*/
  4929. ACMD_FUNC(autoloot)
  4930. {
  4931. int rate;
  4932. double drate;
  4933. nullpo_retr(-1, sd);
  4934. // autoloot command without value
  4935. if(!message || !*message)
  4936. {
  4937. if (sd->state.autoloot)
  4938. rate = 0;
  4939. else
  4940. rate = 10000;
  4941. } else {
  4942. drate = atof(message);
  4943. rate = (int)(drate*100);
  4944. }
  4945. if (rate < 0) rate = 0;
  4946. if (rate > 10000) rate = 10000;
  4947. sd->state.autoloot = rate;
  4948. if (sd->state.autoloot) {
  4949. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  4950. clif_displaymessage(fd, atcmd_output);
  4951. }else
  4952. clif_displaymessage(fd, msg_txt(1188)); // Autoloot is now off.
  4953. return 0;
  4954. }
  4955. /*==========================================
  4956. * @alootid
  4957. *------------------------------------------*/
  4958. ACMD_FUNC(autolootitem)
  4959. {
  4960. struct item_data *item_data = NULL;
  4961. int i;
  4962. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4963. if (message && *message) {
  4964. if (message[0] == '+') {
  4965. message++;
  4966. action = 1;
  4967. }
  4968. else if (message[0] == '-') {
  4969. message++;
  4970. action = 2;
  4971. }
  4972. else if (!strcmp(message,"reset"))
  4973. action = 4;
  4974. }
  4975. if (action < 3) // add or remove
  4976. {
  4977. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  4978. item_data = itemdb_searchname(message);
  4979. if (!item_data) {
  4980. // No items founds in the DB with Id or Name
  4981. clif_displaymessage(fd, msg_txt(1189)); // Item not found.
  4982. return -1;
  4983. }
  4984. }
  4985. switch(action) {
  4986. case 1:
  4987. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4988. if (i != AUTOLOOTITEM_SIZE) {
  4989. clif_displaymessage(fd, msg_txt(1190)); // You're already autolooting this item.
  4990. return -1;
  4991. }
  4992. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  4993. if (i == AUTOLOOTITEM_SIZE) {
  4994. clif_displaymessage(fd, msg_txt(1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  4995. return -1;
  4996. }
  4997. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  4998. sprintf(atcmd_output, msg_txt(1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  4999. clif_displaymessage(fd, atcmd_output);
  5000. sd->state.autolooting = 1;
  5001. break;
  5002. case 2:
  5003. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5004. if (i == AUTOLOOTITEM_SIZE) {
  5005. clif_displaymessage(fd, msg_txt(1193)); // You're currently not autolooting this item.
  5006. return -1;
  5007. }
  5008. sd->state.autolootid[i] = 0;
  5009. sprintf(atcmd_output, msg_txt(1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5010. clif_displaymessage(fd, atcmd_output);
  5011. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5012. if (i == AUTOLOOTITEM_SIZE) {
  5013. sd->state.autolooting = 0;
  5014. }
  5015. break;
  5016. case 3:
  5017. sprintf(atcmd_output, msg_txt(1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5018. clif_displaymessage(fd, atcmd_output);
  5019. clif_displaymessage(fd, msg_txt(1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  5020. clif_displaymessage(fd, msg_txt(1197)); // "@alootid reset" will clear your autolootitem list.
  5021. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5022. if (i == AUTOLOOTITEM_SIZE) {
  5023. clif_displaymessage(fd, msg_txt(1198)); // Your autolootitem list is empty.
  5024. } else {
  5025. clif_displaymessage(fd, msg_txt(1199)); // Items on your autolootitem list:
  5026. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5027. {
  5028. if (sd->state.autolootid[i] == 0)
  5029. continue;
  5030. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5031. 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);
  5032. continue;
  5033. }
  5034. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5035. clif_displaymessage(fd, atcmd_output);
  5036. }
  5037. }
  5038. break;
  5039. case 4:
  5040. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5041. clif_displaymessage(fd, msg_txt(1200)); // Your autolootitem list has been reset.
  5042. sd->state.autolooting = 0;
  5043. break;
  5044. }
  5045. return 0;
  5046. }
  5047. /**
  5048. * No longer available, keeping here just in case it's back someday. [Ind]
  5049. **/
  5050. /*==========================================
  5051. * It is made to rain.
  5052. *------------------------------------------*/
  5053. //ACMD_FUNC(rain)
  5054. //{
  5055. // nullpo_retr(-1, sd);
  5056. // if (map[sd->bl.m].flag.rain) {
  5057. // map[sd->bl.m].flag.rain=0;
  5058. // clif_weather(sd->bl.m);
  5059. // clif_displaymessage(fd, msg_txt(1201)); // The rain has stopped.
  5060. // } else {
  5061. // map[sd->bl.m].flag.rain=1;
  5062. // clif_weather(sd->bl.m);
  5063. // clif_displaymessage(fd, msg_txt(1202)); // It has started to rain.
  5064. // }
  5065. // return 0;
  5066. //}
  5067. /*==========================================
  5068. * It is made to snow.
  5069. *------------------------------------------*/
  5070. ACMD_FUNC(snow)
  5071. {
  5072. nullpo_retr(-1, sd);
  5073. if (map[sd->bl.m].flag.snow) {
  5074. map[sd->bl.m].flag.snow=0;
  5075. clif_weather(sd->bl.m);
  5076. clif_displaymessage(fd, msg_txt(1203)); // Snow has stopped falling.
  5077. } else {
  5078. map[sd->bl.m].flag.snow=1;
  5079. clif_weather(sd->bl.m);
  5080. clif_displaymessage(fd, msg_txt(1204)); // It has started to snow.
  5081. }
  5082. return 0;
  5083. }
  5084. /*==========================================
  5085. * Cherry tree snowstorm is made to fall. (Sakura)
  5086. *------------------------------------------*/
  5087. ACMD_FUNC(sakura)
  5088. {
  5089. nullpo_retr(-1, sd);
  5090. if (map[sd->bl.m].flag.sakura) {
  5091. map[sd->bl.m].flag.sakura=0;
  5092. clif_weather(sd->bl.m);
  5093. clif_displaymessage(fd, msg_txt(1205)); // Cherry tree leaves no longer fall.
  5094. } else {
  5095. map[sd->bl.m].flag.sakura=1;
  5096. clif_weather(sd->bl.m);
  5097. clif_displaymessage(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall.
  5098. }
  5099. return 0;
  5100. }
  5101. /*==========================================
  5102. * Clouds appear.
  5103. *------------------------------------------*/
  5104. ACMD_FUNC(clouds)
  5105. {
  5106. nullpo_retr(-1, sd);
  5107. if (map[sd->bl.m].flag.clouds) {
  5108. map[sd->bl.m].flag.clouds=0;
  5109. clif_weather(sd->bl.m);
  5110. clif_displaymessage(fd, msg_txt(1207)); // The clouds has disappear.
  5111. } else {
  5112. map[sd->bl.m].flag.clouds=1;
  5113. clif_weather(sd->bl.m);
  5114. clif_displaymessage(fd, msg_txt(1208)); // Clouds appear.
  5115. }
  5116. return 0;
  5117. }
  5118. /*==========================================
  5119. * Different type of clouds using effect 516
  5120. *------------------------------------------*/
  5121. ACMD_FUNC(clouds2)
  5122. {
  5123. nullpo_retr(-1, sd);
  5124. if (map[sd->bl.m].flag.clouds2) {
  5125. map[sd->bl.m].flag.clouds2=0;
  5126. clif_weather(sd->bl.m);
  5127. clif_displaymessage(fd, msg_txt(1209)); // The alternative clouds disappear.
  5128. } else {
  5129. map[sd->bl.m].flag.clouds2=1;
  5130. clif_weather(sd->bl.m);
  5131. clif_displaymessage(fd, msg_txt(1210)); // Alternative clouds appear.
  5132. }
  5133. return 0;
  5134. }
  5135. /*==========================================
  5136. * Fog hangs over.
  5137. *------------------------------------------*/
  5138. ACMD_FUNC(fog)
  5139. {
  5140. nullpo_retr(-1, sd);
  5141. if (map[sd->bl.m].flag.fog) {
  5142. map[sd->bl.m].flag.fog=0;
  5143. clif_weather(sd->bl.m);
  5144. clif_displaymessage(fd, msg_txt(1211)); // The fog has gone.
  5145. } else {
  5146. map[sd->bl.m].flag.fog=1;
  5147. clif_weather(sd->bl.m);
  5148. clif_displaymessage(fd, msg_txt(1212)); // Fog hangs over.
  5149. }
  5150. return 0;
  5151. }
  5152. /*==========================================
  5153. * Fallen leaves fall.
  5154. *------------------------------------------*/
  5155. ACMD_FUNC(leaves)
  5156. {
  5157. nullpo_retr(-1, sd);
  5158. if (map[sd->bl.m].flag.leaves) {
  5159. map[sd->bl.m].flag.leaves=0;
  5160. clif_weather(sd->bl.m);
  5161. clif_displaymessage(fd, msg_txt(1213)); // Leaves no longer fall.
  5162. } else {
  5163. map[sd->bl.m].flag.leaves=1;
  5164. clif_weather(sd->bl.m);
  5165. clif_displaymessage(fd, msg_txt(1214)); // Fallen leaves fall.
  5166. }
  5167. return 0;
  5168. }
  5169. /*==========================================
  5170. * Fireworks appear.
  5171. *------------------------------------------*/
  5172. ACMD_FUNC(fireworks)
  5173. {
  5174. nullpo_retr(-1, sd);
  5175. if (map[sd->bl.m].flag.fireworks) {
  5176. map[sd->bl.m].flag.fireworks=0;
  5177. clif_weather(sd->bl.m);
  5178. clif_displaymessage(fd, msg_txt(1215)); // Fireworks have ended.
  5179. } else {
  5180. map[sd->bl.m].flag.fireworks=1;
  5181. clif_weather(sd->bl.m);
  5182. clif_displaymessage(fd, msg_txt(1216)); // Fireworks have launched.
  5183. }
  5184. return 0;
  5185. }
  5186. /*==========================================
  5187. * Clearing Weather Effects by Dexity
  5188. *------------------------------------------*/
  5189. ACMD_FUNC(clearweather)
  5190. {
  5191. nullpo_retr(-1, sd);
  5192. /**
  5193. * No longer available, keeping here just in case it's back someday. [Ind]
  5194. **/
  5195. //map[sd->bl.m].flag.rain=0;
  5196. map[sd->bl.m].flag.snow=0;
  5197. map[sd->bl.m].flag.sakura=0;
  5198. map[sd->bl.m].flag.clouds=0;
  5199. map[sd->bl.m].flag.clouds2=0;
  5200. map[sd->bl.m].flag.fog=0;
  5201. map[sd->bl.m].flag.fireworks=0;
  5202. map[sd->bl.m].flag.leaves=0;
  5203. clif_weather(sd->bl.m);
  5204. clif_displaymessage(fd, msg_txt(291));
  5205. return 0;
  5206. }
  5207. /*===============================================================
  5208. * Sound Command - plays a sound for everyone around! [Codemaster]
  5209. *---------------------------------------------------------------*/
  5210. ACMD_FUNC(sound)
  5211. {
  5212. char sound_file[100];
  5213. memset(sound_file, '\0', sizeof(sound_file));
  5214. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5215. clif_displaymessage(fd, msg_txt(1217)); // Please enter a sound filename (usage: @sound <filename>).
  5216. return -1;
  5217. }
  5218. if(strstr(sound_file, ".wav") == NULL)
  5219. strcat(sound_file, ".wav");
  5220. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5221. return 0;
  5222. }
  5223. /*==========================================
  5224. * MOB Search
  5225. *------------------------------------------*/
  5226. ACMD_FUNC(mobsearch)
  5227. {
  5228. char mob_name[100];
  5229. int mob_id;
  5230. int number = 0;
  5231. struct s_mapiterator* it;
  5232. nullpo_retr(-1, sd);
  5233. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5234. clif_displaymessage(fd, msg_txt(1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5235. return -1;
  5236. }
  5237. if ((mob_id = atoi(mob_name)) == 0)
  5238. mob_id = mobdb_searchname(mob_name);
  5239. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5240. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1219),mob_name); // Invalid mob ID %s!
  5241. clif_displaymessage(fd, atcmd_output);
  5242. return -1;
  5243. }
  5244. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5245. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5246. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5247. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5248. clif_displaymessage(fd, atcmd_output);
  5249. it = mapit_geteachmob();
  5250. for(;;)
  5251. {
  5252. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5253. if( md == NULL )
  5254. break;// no more mobs
  5255. if( md->bl.m != sd->bl.m )
  5256. continue;
  5257. if( mob_id != -1 && md->class_ != mob_id )
  5258. continue;
  5259. ++number;
  5260. if( md->spawn_timer == INVALID_TIMER )
  5261. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5262. else
  5263. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5264. clif_displaymessage(fd, atcmd_output);
  5265. }
  5266. mapit_free(it);
  5267. return 0;
  5268. }
  5269. /*==========================================
  5270. * @cleanmap - cleans items on the ground
  5271. * @cleanarea - cleans items on the ground within an specified area
  5272. *------------------------------------------*/
  5273. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5274. {
  5275. nullpo_ret(bl);
  5276. map_clearflooritem(bl);
  5277. return 0;
  5278. }
  5279. ACMD_FUNC(cleanmap)
  5280. {
  5281. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5282. clif_displaymessage(fd, msg_txt(1221)); // All dropped items have been cleaned up.
  5283. return 0;
  5284. }
  5285. ACMD_FUNC(cleanarea)
  5286. {
  5287. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5288. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  5289. 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);
  5290. }
  5291. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  5292. 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);
  5293. }
  5294. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  5295. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5296. }
  5297. clif_displaymessage(fd, msg_txt(1221)); // All dropped items have been cleaned up.
  5298. return 0;
  5299. }
  5300. /*==========================================
  5301. * make a NPC/PET talk
  5302. * @npctalkc [SnakeDrak]
  5303. *------------------------------------------*/
  5304. ACMD_FUNC(npctalk)
  5305. {
  5306. char name[NAME_LENGTH],mes[100],temp[100];
  5307. struct npc_data *nd;
  5308. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5309. unsigned long color=0;
  5310. if (sd->sc.count && //no "chatting" while muted.
  5311. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5312. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5313. return -1;
  5314. if(!ifcolor) {
  5315. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5316. clif_displaymessage(fd, msg_txt(1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5317. return -1;
  5318. }
  5319. }
  5320. else {
  5321. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5322. clif_displaymessage(fd, msg_txt(1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5323. return -1;
  5324. }
  5325. }
  5326. if (!(nd = npc_name2id(name))) {
  5327. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5328. return -1;
  5329. }
  5330. strtok(name, "#"); // discard extra name identifier if present
  5331. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5332. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5333. else clif_message(&nd->bl, temp);
  5334. return 0;
  5335. }
  5336. ACMD_FUNC(pettalk)
  5337. {
  5338. char mes[100],temp[100];
  5339. struct pet_data *pd;
  5340. nullpo_retr(-1, sd);
  5341. if ( battle_config.min_chat_delay ) {
  5342. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5343. return 0;
  5344. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5345. }
  5346. if(!sd->status.pet_id || !(pd=sd->pd))
  5347. {
  5348. clif_displaymessage(fd, msg_txt(184));
  5349. return -1;
  5350. }
  5351. if (sd->sc.count && //no "chatting" while muted.
  5352. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5353. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5354. return -1;
  5355. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5356. clif_displaymessage(fd, msg_txt(1224)); // Please enter a message (usage: @pettalk <message>).
  5357. return -1;
  5358. }
  5359. if (message[0] == '/')
  5360. {// pet emotion processing
  5361. const char* emo[] = {
  5362. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5363. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5364. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5365. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5366. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5367. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5368. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5369. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5370. "/whisp"
  5371. };
  5372. int i;
  5373. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5374. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5375. if( i < ARRAYLENGTH(emo) )
  5376. {
  5377. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5378. sd->emotionlasttime = time(NULL);
  5379. return 0;
  5380. }
  5381. sd->emotionlasttime = time(NULL);
  5382. clif_emotion(&pd->bl, i);
  5383. return 0;
  5384. }
  5385. }
  5386. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5387. clif_message(&pd->bl, temp);
  5388. return 0;
  5389. }
  5390. /// @users - displays the number of players present on each map (and percentage)
  5391. /// #users displays on the target user instead of self
  5392. ACMD_FUNC(users)
  5393. {
  5394. char buf[CHAT_SIZE_MAX];
  5395. int i;
  5396. int users[MAX_MAPINDEX];
  5397. int users_all;
  5398. struct s_mapiterator* iter;
  5399. memset(users, 0, sizeof(users));
  5400. users_all = 0;
  5401. // count users on each map
  5402. iter = mapit_getallusers();
  5403. for(;;)
  5404. {
  5405. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5406. if( sd2 == NULL )
  5407. break;// no more users
  5408. if( sd2->mapindex >= MAX_MAPINDEX )
  5409. continue;// invalid mapindex
  5410. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5411. if( users_all < INT_MAX ) ++users_all;
  5412. }
  5413. mapit_free(iter);
  5414. // display results for each map
  5415. for( i = 0; i < MAX_MAPINDEX; ++i )
  5416. {
  5417. if( users[i] == 0 )
  5418. continue;// empty
  5419. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5420. clif_displaymessage(sd->fd, buf);
  5421. }
  5422. // display overall count
  5423. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5424. clif_displaymessage(sd->fd, buf);
  5425. return 0;
  5426. }
  5427. /*==========================================
  5428. *
  5429. *------------------------------------------*/
  5430. ACMD_FUNC(reset)
  5431. {
  5432. pc_resetstate(sd);
  5433. pc_resetskill(sd,1);
  5434. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5435. clif_displaymessage(fd, atcmd_output);
  5436. return 0;
  5437. }
  5438. /*==========================================
  5439. *
  5440. *------------------------------------------*/
  5441. ACMD_FUNC(summon)
  5442. {
  5443. char name[NAME_LENGTH];
  5444. int mob_id = 0;
  5445. int duration = 0;
  5446. struct mob_data *md;
  5447. unsigned int tick=gettick();
  5448. nullpo_retr(-1, sd);
  5449. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5450. {
  5451. clif_displaymessage(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5452. return -1;
  5453. }
  5454. if (duration < 1)
  5455. duration =1;
  5456. else if (duration > 60)
  5457. duration =60;
  5458. if ((mob_id = atoi(name)) == 0)
  5459. mob_id = mobdb_searchname(name);
  5460. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5461. {
  5462. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5463. return -1;
  5464. }
  5465. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5466. if(!md)
  5467. return -1;
  5468. md->master_id=sd->bl.id;
  5469. md->special_state.ai=1;
  5470. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5471. clif_specialeffect(&md->bl,344,AREA);
  5472. mob_spawn(md);
  5473. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5474. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5475. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5476. return 0;
  5477. }
  5478. /*==========================================
  5479. * @adjgroup
  5480. * Temporarily move player to another group
  5481. * Useful during beta testing to allow players to use GM commands for short periods of time
  5482. *------------------------------------------*/
  5483. ACMD_FUNC(adjgroup)
  5484. {
  5485. int new_group = 0;
  5486. nullpo_retr(-1, sd);
  5487. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5488. clif_displaymessage(fd, msg_txt(1226)); // Usage: @adjgroup <group_id>
  5489. return -1;
  5490. }
  5491. if (!pc_group_exists(new_group)) {
  5492. clif_displaymessage(fd, msg_txt(1227)); // Specified group does not exist.
  5493. return -1;
  5494. }
  5495. sd->group_id = new_group;
  5496. pc_group_pc_load(sd);/* update cache */
  5497. clif_displaymessage(fd, msg_txt(1228)); // Group changed successfully.
  5498. clif_displaymessage(sd->fd, msg_txt(1229)); // Your group has changed.
  5499. return 0;
  5500. }
  5501. /*==========================================
  5502. * @trade by [MouseJstr]
  5503. * Open a trade window with a remote player
  5504. *------------------------------------------*/
  5505. ACMD_FUNC(trade)
  5506. {
  5507. struct map_session_data *pl_sd = NULL;
  5508. nullpo_retr(-1, sd);
  5509. if (!message || !*message) {
  5510. clif_displaymessage(fd, msg_txt(1230)); // Please enter a player name (usage: @trade <char name>).
  5511. return -1;
  5512. }
  5513. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5514. {
  5515. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5516. return -1;
  5517. }
  5518. trade_traderequest(sd, pl_sd);
  5519. return 0;
  5520. }
  5521. /*==========================================
  5522. * @setbattleflag by [MouseJstr]
  5523. * set a battle_config flag without having to reboot
  5524. *------------------------------------------*/
  5525. ACMD_FUNC(setbattleflag)
  5526. {
  5527. char flag[128], value[128];
  5528. nullpo_retr(-1, sd);
  5529. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5530. clif_displaymessage(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value>
  5531. return -1;
  5532. }
  5533. if (battle_set_value(flag, value) == 0)
  5534. {
  5535. clif_displaymessage(fd, msg_txt(1232)); // Unknown battle_config flag.
  5536. return -1;
  5537. }
  5538. clif_displaymessage(fd, msg_txt(1233)); // Set battle_config as requested.
  5539. return 0;
  5540. }
  5541. /*==========================================
  5542. * @unmute [Valaris]
  5543. *------------------------------------------*/
  5544. ACMD_FUNC(unmute)
  5545. {
  5546. struct map_session_data *pl_sd = NULL;
  5547. nullpo_retr(-1, sd);
  5548. if (!message || !*message) {
  5549. clif_displaymessage(fd, msg_txt(1234)); // Please enter a player name (usage: @unmute <char name>).
  5550. return -1;
  5551. }
  5552. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5553. {
  5554. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5555. return -1;
  5556. }
  5557. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5558. clif_displaymessage(sd->fd,msg_txt(1235)); // Player is not muted.
  5559. return -1;
  5560. }
  5561. pl_sd->status.manner = 0;
  5562. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5563. clif_displaymessage(sd->fd,msg_txt(1236)); // Player unmuted.
  5564. return 0;
  5565. }
  5566. /*==========================================
  5567. * @uptime by MC Cameri
  5568. *------------------------------------------*/
  5569. ACMD_FUNC(uptime)
  5570. {
  5571. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5572. minute = 60, days = 0, hours = 0, minutes = 0;
  5573. nullpo_retr(-1, sd);
  5574. seconds = get_uptime();
  5575. days = seconds/day;
  5576. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5577. hours = seconds/hour;
  5578. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5579. minutes = seconds/minute;
  5580. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5581. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5582. clif_displaymessage(fd, atcmd_output);
  5583. return 0;
  5584. }
  5585. /*==========================================
  5586. * @changesex <sex>
  5587. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5588. *------------------------------------------*/
  5589. ACMD_FUNC(changesex)
  5590. {
  5591. int i;
  5592. nullpo_retr(-1, sd);
  5593. pc_resetskill(sd,4);
  5594. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5595. for( i=0; i<EQI_MAX; i++ )
  5596. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5597. chrif_changesex(sd);
  5598. return 0;
  5599. }
  5600. /*================================================
  5601. * @mute - Mutes a player for a set amount of time
  5602. *------------------------------------------------*/
  5603. ACMD_FUNC(mute)
  5604. {
  5605. struct map_session_data *pl_sd = NULL;
  5606. int manner;
  5607. nullpo_retr(-1, sd);
  5608. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5609. clif_displaymessage(fd, msg_txt(1237)); // Usage: @mute <time> <char name>
  5610. return -1;
  5611. }
  5612. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5613. {
  5614. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5615. return -1;
  5616. }
  5617. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5618. {
  5619. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5620. return -1;
  5621. }
  5622. clif_manner_message(sd, 0);
  5623. clif_manner_message(pl_sd, 5);
  5624. if( pl_sd->status.manner < manner ) {
  5625. pl_sd->status.manner -= manner;
  5626. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5627. } else {
  5628. pl_sd->status.manner = 0;
  5629. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5630. }
  5631. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5632. return 0;
  5633. }
  5634. /*==========================================
  5635. * @refresh (like @jumpto <<yourself>>)
  5636. *------------------------------------------*/
  5637. ACMD_FUNC(refresh)
  5638. {
  5639. nullpo_retr(-1, sd);
  5640. clif_refresh(sd);
  5641. return 0;
  5642. }
  5643. ACMD_FUNC(refreshall)
  5644. {
  5645. struct map_session_data* iter_sd;
  5646. struct s_mapiterator* iter;
  5647. nullpo_retr(-1, sd);
  5648. iter = mapit_getallusers();
  5649. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5650. clif_refresh(iter_sd);
  5651. mapit_free(iter);
  5652. return 0;
  5653. }
  5654. /*==========================================
  5655. * @identify
  5656. * => GM's magnifier.
  5657. *------------------------------------------*/
  5658. ACMD_FUNC(identify)
  5659. {
  5660. int i,num;
  5661. nullpo_retr(-1, sd);
  5662. for(i=num=0;i<MAX_INVENTORY;i++){
  5663. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5664. num++;
  5665. }
  5666. }
  5667. if (num > 0) {
  5668. clif_item_identify_list(sd);
  5669. } else {
  5670. clif_displaymessage(fd,msg_txt(1238)); // There are no items to appraise.
  5671. }
  5672. return 0;
  5673. }
  5674. /*==========================================
  5675. * @gmotd (Global MOTD)
  5676. * by davidsiaw :P
  5677. *------------------------------------------*/
  5678. ACMD_FUNC(gmotd)
  5679. {
  5680. char buf[CHAT_SIZE_MAX];
  5681. size_t len;
  5682. FILE* fp;
  5683. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5684. {
  5685. while( fgets(buf, sizeof(buf), fp) )
  5686. {
  5687. if( buf[0] == '/' && buf[1] == '/' )
  5688. {
  5689. continue;
  5690. }
  5691. len = strlen(buf);
  5692. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5693. {// strip trailing EOL characters
  5694. len--;
  5695. }
  5696. if( len )
  5697. {
  5698. buf[len] = 0;
  5699. intif_broadcast(buf, len+1, 0);
  5700. }
  5701. }
  5702. fclose(fp);
  5703. }
  5704. return 0;
  5705. }
  5706. ACMD_FUNC(misceffect)
  5707. {
  5708. int effect = 0;
  5709. nullpo_retr(-1, sd);
  5710. if (!message || !*message)
  5711. return -1;
  5712. if (sscanf(message, "%d", &effect) < 1)
  5713. return -1;
  5714. clif_misceffect(&sd->bl,effect);
  5715. return 0;
  5716. }
  5717. /*==========================================
  5718. * MAIL SYSTEM
  5719. *------------------------------------------*/
  5720. ACMD_FUNC(mail)
  5721. {
  5722. nullpo_ret(sd);
  5723. mail_openmail(sd);
  5724. return 0;
  5725. }
  5726. /*==========================================
  5727. * Show Monster DB Info v 1.0
  5728. * originally by [Lupus]
  5729. *------------------------------------------*/
  5730. ACMD_FUNC(mobinfo)
  5731. {
  5732. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5733. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5734. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5735. char atcmd_output2[CHAT_SIZE_MAX];
  5736. struct item_data *item_data;
  5737. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5738. int count;
  5739. int i, j, k;
  5740. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5741. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5742. if (!message || !*message) {
  5743. clif_displaymessage(fd, msg_txt(1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5744. return -1;
  5745. }
  5746. // If monster identifier/name argument is a name
  5747. if ((i = mobdb_checkid(atoi(message))))
  5748. {
  5749. mob_array[0] = mob_db(i);
  5750. count = 1;
  5751. } else
  5752. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5753. if (!count) {
  5754. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5755. return -1;
  5756. }
  5757. if (count > MAX_SEARCH) {
  5758. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5759. clif_displaymessage(fd, atcmd_output);
  5760. count = MAX_SEARCH;
  5761. }
  5762. for (k = 0; k < count; k++) {
  5763. mob = mob_array[k];
  5764. // stats
  5765. if (mob->mexp)
  5766. sprintf(atcmd_output, msg_txt(1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5767. else
  5768. sprintf(atcmd_output, msg_txt(1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5769. clif_displaymessage(fd, atcmd_output);
  5770. sprintf(atcmd_output, msg_txt(1242), mob->lv, mob->status.max_hp, mob->base_exp, mob->job_exp,MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
  5771. clif_displaymessage(fd, atcmd_output);
  5772. sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5773. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  5774. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5775. clif_displaymessage(fd, atcmd_output);
  5776. sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5777. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5778. mob->range2 , mob->range3, msize[mob->status.size],
  5779. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5780. clif_displaymessage(fd, atcmd_output);
  5781. // drops
  5782. clif_displaymessage(fd, msg_txt(1245)); // Drops:
  5783. strcpy(atcmd_output, " ");
  5784. j = 0;
  5785. for (i = 0; i < MAX_MOB_DROP; i++) {
  5786. int droprate;
  5787. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5788. continue;
  5789. droprate = mob->dropitem[i].p;
  5790. if (item_data->slot)
  5791. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  5792. else
  5793. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  5794. strcat(atcmd_output, atcmd_output2);
  5795. if (++j % 3 == 0) {
  5796. clif_displaymessage(fd, atcmd_output);
  5797. strcpy(atcmd_output, " ");
  5798. }
  5799. }
  5800. if (j == 0)
  5801. clif_displaymessage(fd, msg_txt(1246)); // This monster has no drops.
  5802. else if (j % 3 != 0)
  5803. clif_displaymessage(fd, atcmd_output);
  5804. // mvp
  5805. if (mob->mexp) {
  5806. sprintf(atcmd_output, msg_txt(1247), mob->mexp); // MVP Bonus EXP:%u
  5807. clif_displaymessage(fd, atcmd_output);
  5808. strcpy(atcmd_output, msg_txt(1248)); // MVP Items:
  5809. j = 0;
  5810. for (i = 0; i < MAX_MVP_DROP; i++) {
  5811. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5812. continue;
  5813. if (mob->mvpitem[i].p > 0) {
  5814. j++;
  5815. if (j == 1)
  5816. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5817. else
  5818. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5819. strcat(atcmd_output, atcmd_output2);
  5820. }
  5821. }
  5822. if (j == 0)
  5823. clif_displaymessage(fd, msg_txt(1249)); // This monster has no MVP prizes.
  5824. else
  5825. clif_displaymessage(fd, atcmd_output);
  5826. }
  5827. }
  5828. return 0;
  5829. }
  5830. /*=========================================
  5831. * @showmobs by KarLaeda
  5832. * => For 15 sec displays the mobs on minimap
  5833. *------------------------------------------*/
  5834. ACMD_FUNC(showmobs)
  5835. {
  5836. char mob_name[100];
  5837. int mob_id;
  5838. int number = 0;
  5839. struct s_mapiterator* it;
  5840. nullpo_retr(-1, sd);
  5841. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5842. return -1;
  5843. if((mob_id = atoi(mob_name)) == 0)
  5844. mob_id = mobdb_searchname(mob_name);
  5845. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5846. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1250),mob_name); // Invalid mob id %s!
  5847. clif_displaymessage(fd, atcmd_output);
  5848. return 0;
  5849. }
  5850. 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.
  5851. clif_displaymessage(fd, msg_txt(1251)); // Can't show boss mobs!
  5852. return 0;
  5853. }
  5854. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5855. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5856. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5857. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s
  5858. mob_name, mapindex_id2name(sd->mapindex));
  5859. clif_displaymessage(fd, atcmd_output);
  5860. it = mapit_geteachmob();
  5861. for(;;)
  5862. {
  5863. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5864. if( md == NULL )
  5865. break;// no more mobs
  5866. if( md->bl.m != sd->bl.m )
  5867. continue;
  5868. if( mob_id != -1 && md->class_ != mob_id )
  5869. continue;
  5870. if( md->special_state.ai || md->master_id )
  5871. continue; // hide slaves and player summoned mobs
  5872. if( md->spawn_timer != INVALID_TIMER )
  5873. continue; // hide mobs waiting for respawn
  5874. ++number;
  5875. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5876. }
  5877. mapit_free(it);
  5878. return 0;
  5879. }
  5880. /*==========================================
  5881. * homunculus level up [orn]
  5882. *------------------------------------------*/
  5883. ACMD_FUNC(homlevel)
  5884. {
  5885. TBL_HOM * hd;
  5886. int level = 0, i = 0;
  5887. nullpo_retr(-1, sd);
  5888. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  5889. clif_displaymessage(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  5890. return -1;
  5891. }
  5892. if ( !merc_is_hom_active(sd->hd) ) {
  5893. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5894. return -1;
  5895. }
  5896. hd = sd->hd;
  5897. for (i = 1; i <= level && hd->exp_next; i++){
  5898. hd->homunculus.exp += hd->exp_next;
  5899. merc_hom_levelup(hd);
  5900. }
  5901. status_calc_homunculus(hd,0);
  5902. status_percent_heal(&hd->bl, 100, 100);
  5903. clif_specialeffect(&hd->bl,568,AREA);
  5904. return 0;
  5905. }
  5906. /*==========================================
  5907. * homunculus evolution H [orn]
  5908. *------------------------------------------*/
  5909. ACMD_FUNC(homevolution)
  5910. {
  5911. nullpo_retr(-1, sd);
  5912. if ( !merc_is_hom_active(sd->hd) ) {
  5913. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5914. return -1;
  5915. }
  5916. if ( !merc_hom_evolution(sd->hd) ) {
  5917. clif_displaymessage(fd, msg_txt(1255)); // Your homunculus doesn't evolve.
  5918. return -1;
  5919. }
  5920. clif_homskillinfoblock(sd);
  5921. return 0;
  5922. }
  5923. ACMD_FUNC(hommutate)
  5924. {
  5925. int homun_id, m_class = 0, m_id;
  5926. nullpo_retr(-1, sd);
  5927. if (!merc_is_hom_active(sd->hd)) {
  5928. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5929. return -1;
  5930. }
  5931. if (!message || !*message) {
  5932. homun_id = 6048 + (rnd() % 4);
  5933. } else {
  5934. homun_id = atoi(message);
  5935. }
  5936. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  5937. m_id = hom_class2mapid(homun_id);
  5938. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  5939. hom_mutate(sd->hd, homun_id);
  5940. } else {
  5941. clif_emotion(&sd->hd->bl, E_SWT);
  5942. }
  5943. return 0;
  5944. }
  5945. /*==========================================
  5946. * call choosen homunculus [orn]
  5947. *------------------------------------------*/
  5948. ACMD_FUNC(makehomun)
  5949. {
  5950. int homunid;
  5951. nullpo_retr(-1, sd);
  5952. if ( sd->status.hom_id ) {
  5953. clif_displaymessage(fd, msg_txt(450));
  5954. return -1;
  5955. }
  5956. if (!message || !*message) {
  5957. clif_displaymessage(fd, msg_txt(1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  5958. return -1;
  5959. }
  5960. homunid = atoi(message);
  5961. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  5962. {
  5963. clif_displaymessage(fd, msg_txt(1257)); // Invalid Homunculus ID.
  5964. return -1;
  5965. }
  5966. merc_create_homunculus_request(sd,homunid);
  5967. return 0;
  5968. }
  5969. /*==========================================
  5970. * modify homunculus intimacy [orn]
  5971. *------------------------------------------*/
  5972. ACMD_FUNC(homfriendly)
  5973. {
  5974. int friendly = 0;
  5975. nullpo_retr(-1, sd);
  5976. if ( !merc_is_hom_active(sd->hd) ) {
  5977. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5978. return -1;
  5979. }
  5980. if (!message || !*message) {
  5981. clif_displaymessage(fd, msg_txt(1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  5982. return -1;
  5983. }
  5984. friendly = atoi(message);
  5985. friendly = cap_value(friendly, 0, 1000);
  5986. sd->hd->homunculus.intimacy = friendly * 100 ;
  5987. clif_send_homdata(sd,SP_INTIMATE,friendly);
  5988. return 0;
  5989. }
  5990. /*==========================================
  5991. * modify homunculus hunger [orn]
  5992. *------------------------------------------*/
  5993. ACMD_FUNC(homhungry)
  5994. {
  5995. int hungry = 0;
  5996. nullpo_retr(-1, sd);
  5997. if ( !merc_is_hom_active(sd->hd) ) {
  5998. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5999. return -1;
  6000. }
  6001. if (!message || !*message) {
  6002. clif_displaymessage(fd, msg_txt(1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6003. return -1;
  6004. }
  6005. hungry = atoi(message);
  6006. hungry = cap_value(hungry, 0, 100);
  6007. sd->hd->homunculus.hunger = hungry;
  6008. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6009. return 0;
  6010. }
  6011. /*==========================================
  6012. * make the homunculus speak [orn]
  6013. *------------------------------------------*/
  6014. ACMD_FUNC(homtalk)
  6015. {
  6016. char mes[100],temp[100];
  6017. nullpo_retr(-1, sd);
  6018. if ( battle_config.min_chat_delay ) {
  6019. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6020. return 0;
  6021. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6022. }
  6023. if (sd->sc.count && //no "chatting" while muted.
  6024. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6025. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6026. return -1;
  6027. if ( !merc_is_hom_active(sd->hd) ) {
  6028. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6029. return -1;
  6030. }
  6031. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6032. clif_displaymessage(fd, msg_txt(1260)); // Please enter a message (usage: @homtalk <message>).
  6033. return -1;
  6034. }
  6035. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6036. clif_message(&sd->hd->bl, temp);
  6037. return 0;
  6038. }
  6039. /*==========================================
  6040. * Show homunculus stats
  6041. *------------------------------------------*/
  6042. ACMD_FUNC(hominfo)
  6043. {
  6044. struct homun_data *hd;
  6045. struct status_data *status;
  6046. nullpo_retr(-1, sd);
  6047. if ( !merc_is_hom_active(sd->hd) ) {
  6048. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6049. return -1;
  6050. }
  6051. hd = sd->hd;
  6052. status = status_get_status_data(&hd->bl);
  6053. clif_displaymessage(fd, msg_txt(1261)); // Homunculus stats:
  6054. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1262), // HP: %d/%d - SP: %d/%d
  6055. status->hp, status->max_hp, status->sp, status->max_sp);
  6056. clif_displaymessage(fd, atcmd_output);
  6057. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1263), // ATK: %d - MATK: %d~%d
  6058. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6059. clif_displaymessage(fd, atcmd_output);
  6060. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1264), // Hungry: %d - Intimacy: %u
  6061. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6062. clif_displaymessage(fd, atcmd_output);
  6063. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6064. msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6065. status->str, status->agi, status->vit,
  6066. status->int_, status->dex, status->luk);
  6067. clif_displaymessage(fd, atcmd_output);
  6068. return 0;
  6069. }
  6070. ACMD_FUNC(homstats)
  6071. {
  6072. struct homun_data *hd;
  6073. struct s_homunculus_db *db;
  6074. struct s_homunculus *hom;
  6075. int lv, min, max, evo;
  6076. nullpo_retr(-1, sd);
  6077. if ( !merc_is_hom_active(sd->hd) ) {
  6078. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6079. return -1;
  6080. }
  6081. hd = sd->hd;
  6082. hom = &hd->homunculus;
  6083. db = hd->homunculusDB;
  6084. lv = hom->level;
  6085. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6086. msg_txt(1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6087. clif_displaymessage(fd, atcmd_output);
  6088. lv--; //Since the first increase is at level 2.
  6089. evo = (hom->class_ == db->evo_class);
  6090. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6091. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6092. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6093. clif_displaymessage(fd, atcmd_output);
  6094. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6095. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6096. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6097. clif_displaymessage(fd, atcmd_output);
  6098. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6099. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6100. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6101. clif_displaymessage(fd, atcmd_output);
  6102. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6103. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6104. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6105. clif_displaymessage(fd, atcmd_output);
  6106. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6107. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6108. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6109. clif_displaymessage(fd, atcmd_output);
  6110. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6111. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6112. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6113. clif_displaymessage(fd, atcmd_output);
  6114. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6115. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6116. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6117. clif_displaymessage(fd, atcmd_output);
  6118. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6119. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6120. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6121. clif_displaymessage(fd, atcmd_output);
  6122. return 0;
  6123. }
  6124. ACMD_FUNC(homshuffle)
  6125. {
  6126. nullpo_retr(-1, sd);
  6127. if(!sd->hd)
  6128. return -1; // nothing to do
  6129. if(!merc_hom_shuffle(sd->hd))
  6130. return -1;
  6131. clif_displaymessage(sd->fd, msg_txt(1275)); // Homunculus stats altered.
  6132. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6133. return 0;
  6134. }
  6135. /*==========================================
  6136. * Show Items DB Info v 1.0
  6137. * originally by [Lupus]
  6138. *------------------------------------------*/
  6139. ACMD_FUNC(iteminfo)
  6140. {
  6141. struct item_data *item_data, *item_array[MAX_SEARCH];
  6142. int i, count = 1;
  6143. if (!message || !*message) {
  6144. clif_displaymessage(fd, msg_txt(1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6145. return -1;
  6146. }
  6147. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6148. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6149. if (!count) {
  6150. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6151. return -1;
  6152. }
  6153. if (count > MAX_SEARCH) {
  6154. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6155. clif_displaymessage(fd, atcmd_output);
  6156. count = MAX_SEARCH;
  6157. }
  6158. for (i = 0; i < count; i++) {
  6159. item_data = item_array[i];
  6160. sprintf(atcmd_output, msg_txt(1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6161. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6162. itemdb_typename(item_data->type),
  6163. (item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script
  6164. );
  6165. clif_displaymessage(fd, atcmd_output);
  6166. sprintf(atcmd_output, msg_txt(1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  6167. clif_displaymessage(fd, atcmd_output);
  6168. if (item_data->maxchance == -1)
  6169. strcpy(atcmd_output, msg_txt(1281)); // - Available in the shops only.
  6170. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6171. sprintf(atcmd_output, msg_txt(1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6172. else
  6173. strcpy(atcmd_output, msg_txt(1283)); // - Monsters don't drop this item.
  6174. clif_displaymessage(fd, atcmd_output);
  6175. }
  6176. return 0;
  6177. }
  6178. /*==========================================
  6179. * Show who drops the item.
  6180. *------------------------------------------*/
  6181. ACMD_FUNC(whodrops)
  6182. {
  6183. struct item_data *item_data, *item_array[MAX_SEARCH];
  6184. int i,j, count = 1;
  6185. if (!message || !*message) {
  6186. clif_displaymessage(fd, msg_txt(1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6187. return -1;
  6188. }
  6189. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6190. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6191. if (!count) {
  6192. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6193. return -1;
  6194. }
  6195. if (count > MAX_SEARCH) {
  6196. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6197. clif_displaymessage(fd, atcmd_output);
  6198. count = MAX_SEARCH;
  6199. }
  6200. for (i = 0; i < count; i++) {
  6201. item_data = item_array[i];
  6202. sprintf(atcmd_output, msg_txt(1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
  6203. clif_displaymessage(fd, atcmd_output);
  6204. if (item_data->mob[0].chance == 0) {
  6205. strcpy(atcmd_output, msg_txt(1286)); // - Item is not dropped by mobs.
  6206. clif_displaymessage(fd, atcmd_output);
  6207. } else {
  6208. sprintf(atcmd_output, msg_txt(1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6209. clif_displaymessage(fd, atcmd_output);
  6210. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6211. {
  6212. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6213. clif_displaymessage(fd, atcmd_output);
  6214. }
  6215. }
  6216. }
  6217. return 0;
  6218. }
  6219. ACMD_FUNC(whereis)
  6220. {
  6221. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6222. int count;
  6223. int i, j, k;
  6224. if (!message || !*message) {
  6225. clif_displaymessage(fd, msg_txt(1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6226. return -1;
  6227. }
  6228. // If monster identifier/name argument is a name
  6229. if ((i = mobdb_checkid(atoi(message))))
  6230. {
  6231. mob_array[0] = mob_db(i);
  6232. count = 1;
  6233. } else
  6234. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6235. if (!count) {
  6236. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6237. return -1;
  6238. }
  6239. if (count > MAX_SEARCH) {
  6240. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6241. clif_displaymessage(fd, atcmd_output);
  6242. count = MAX_SEARCH;
  6243. }
  6244. for (k = 0; k < count; k++) {
  6245. mob = mob_array[k];
  6246. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), mob->jname); // %s spawns in:
  6247. clif_displaymessage(fd, atcmd_output);
  6248. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6249. {
  6250. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6251. if (j < 0) continue;
  6252. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6253. clif_displaymessage(fd, atcmd_output);
  6254. }
  6255. if (i == 0)
  6256. clif_displaymessage(fd, msg_txt(1290)); // This monster does not spawn normally.
  6257. }
  6258. return 0;
  6259. }
  6260. ACMD_FUNC(version)
  6261. {
  6262. const char * revision;
  6263. if ((revision = get_svn_revision()) != 0) {
  6264. sprintf(atcmd_output,msg_txt(1295),revision); // rAthena Version SVN r%s
  6265. clif_displaymessage(fd,atcmd_output);
  6266. } else
  6267. clif_displaymessage(fd,msg_txt(1296)); // Cannot determine SVN revision.
  6268. return 0;
  6269. }
  6270. /*==========================================
  6271. * @mutearea by MouseJstr
  6272. *------------------------------------------*/
  6273. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6274. {
  6275. int time, id;
  6276. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6277. if (pl_sd == NULL)
  6278. return 0;
  6279. id = va_arg(ap, int);
  6280. time = va_arg(ap, int);
  6281. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6282. pl_sd->status.manner -= time;
  6283. if (pl_sd->status.manner < 0)
  6284. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6285. else
  6286. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6287. }
  6288. return 0;
  6289. }
  6290. ACMD_FUNC(mutearea)
  6291. {
  6292. int time;
  6293. nullpo_ret(sd);
  6294. if (!message || !*message) {
  6295. clif_displaymessage(fd, msg_txt(1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6296. return -1;
  6297. }
  6298. time = atoi(message);
  6299. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6300. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6301. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6302. return 0;
  6303. }
  6304. ACMD_FUNC(rates)
  6305. {
  6306. char buf[CHAT_SIZE_MAX];
  6307. nullpo_ret(sd);
  6308. memset(buf, '\0', sizeof(buf));
  6309. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1298), // Experience rates: Base %.2fx / Job %.2fx
  6310. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6311. clif_displaymessage(fd, buf);
  6312. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6313. 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.);
  6314. clif_displaymessage(fd, buf);
  6315. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6316. 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.);
  6317. clif_displaymessage(fd, buf);
  6318. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6319. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6320. clif_displaymessage(fd, buf);
  6321. return 0;
  6322. }
  6323. /*==========================================
  6324. * @me by lordalfa
  6325. * => Displays the OUTPUT string on top of the Visible players Heads.
  6326. *------------------------------------------*/
  6327. ACMD_FUNC(me)
  6328. {
  6329. char tempmes[CHAT_SIZE_MAX];
  6330. nullpo_retr(-1, sd);
  6331. memset(tempmes, '\0', sizeof(tempmes));
  6332. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6333. if (sd->sc.count && //no "chatting" while muted.
  6334. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6335. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6336. return -1;
  6337. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6338. clif_displaymessage(fd, msg_txt(1302)); // Please enter a message (usage: @me <message>).
  6339. return -1;
  6340. }
  6341. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6342. clif_disp_overhead(sd, atcmd_output);
  6343. return 0;
  6344. }
  6345. /*==========================================
  6346. * @size
  6347. * => Resize your character sprite. [Valaris]
  6348. *------------------------------------------*/
  6349. ACMD_FUNC(size)
  6350. {
  6351. int size = 0;
  6352. nullpo_retr(-1, sd);
  6353. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6354. if(sd->state.size) {
  6355. sd->state.size = SZ_SMALL;
  6356. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6357. }
  6358. sd->state.size = size;
  6359. if( size == SZ_MEDIUM )
  6360. clif_specialeffect(&sd->bl,420,AREA);
  6361. else if( size == SZ_BIG )
  6362. clif_specialeffect(&sd->bl,422,AREA);
  6363. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6364. return 0;
  6365. }
  6366. ACMD_FUNC(sizeall)
  6367. {
  6368. int size;
  6369. struct map_session_data *pl_sd;
  6370. struct s_mapiterator* iter;
  6371. size = atoi(message);
  6372. size = cap_value(size,0,2);
  6373. iter = mapit_getallusers();
  6374. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6375. if( pl_sd->state.size != size ) {
  6376. if( pl_sd->state.size ) {
  6377. pl_sd->state.size = SZ_SMALL;
  6378. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6379. }
  6380. pl_sd->state.size = size;
  6381. if( size == SZ_MEDIUM )
  6382. clif_specialeffect(&pl_sd->bl,420,AREA);
  6383. else if( size == SZ_BIG )
  6384. clif_specialeffect(&pl_sd->bl,422,AREA);
  6385. }
  6386. }
  6387. mapit_free(iter);
  6388. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6389. return 0;
  6390. }
  6391. ACMD_FUNC(sizeguild)
  6392. {
  6393. int size = 0, i;
  6394. char guild[NAME_LENGTH];
  6395. struct map_session_data *pl_sd;
  6396. struct guild *g;
  6397. nullpo_retr(-1, sd);
  6398. memset(guild, '\0', sizeof(guild));
  6399. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6400. clif_displaymessage(fd, msg_txt(1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6401. return -1;
  6402. }
  6403. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6404. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  6405. return -1;
  6406. }
  6407. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6408. for( i = 0; i < g->max_member; i++ ) {
  6409. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6410. if( pl_sd->state.size ) {
  6411. pl_sd->state.size = SZ_SMALL;
  6412. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6413. }
  6414. pl_sd->state.size = size;
  6415. if( size == SZ_MEDIUM )
  6416. clif_specialeffect(&pl_sd->bl,420,AREA);
  6417. else if( size == SZ_BIG )
  6418. clif_specialeffect(&pl_sd->bl,422,AREA);
  6419. }
  6420. }
  6421. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6422. return 0;
  6423. }
  6424. /*==========================================
  6425. * @monsterignore
  6426. * => Makes monsters ignore you. [Valaris]
  6427. *------------------------------------------*/
  6428. ACMD_FUNC(monsterignore)
  6429. {
  6430. nullpo_retr(-1, sd);
  6431. if (!sd->state.monster_ignore) {
  6432. sd->state.monster_ignore = 1;
  6433. clif_displaymessage(sd->fd, msg_txt(1305)); // You are now immune to attacks.
  6434. } else {
  6435. sd->state.monster_ignore = 0;
  6436. clif_displaymessage(sd->fd, msg_txt(1306)); // Returned to normal state.
  6437. }
  6438. return 0;
  6439. }
  6440. /*==========================================
  6441. * @fakename
  6442. * => Gives your character a fake name. [Valaris]
  6443. *------------------------------------------*/
  6444. ACMD_FUNC(fakename)
  6445. {
  6446. nullpo_retr(-1, sd);
  6447. if( !message || !*message )
  6448. {
  6449. if( sd->fakename[0] )
  6450. {
  6451. sd->fakename[0] = '\0';
  6452. clif_charnameack(0, &sd->bl);
  6453. clif_displaymessage(sd->fd, msg_txt(1307)); // Returned to real name.
  6454. return 0;
  6455. }
  6456. clif_displaymessage(sd->fd, msg_txt(1308)); // You must enter a name.
  6457. return -1;
  6458. }
  6459. if( strlen(message) < 2 )
  6460. {
  6461. clif_displaymessage(sd->fd, msg_txt(1309)); // Fake name must be at least two characters.
  6462. return -1;
  6463. }
  6464. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6465. clif_charnameack(0, &sd->bl);
  6466. clif_displaymessage(sd->fd, msg_txt(1310)); // Fake name enabled.
  6467. return 0;
  6468. }
  6469. /*==========================================
  6470. * Ragnarok Resources
  6471. *------------------------------------------*/
  6472. ACMD_FUNC(mapflag) {
  6473. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6474. #define setflag( cmd ) \
  6475. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6476. map[ sd->bl.m ].flag.cmd = flag;\
  6477. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6478. clif_displaymessage(sd->fd,atcmd_output);\
  6479. return 0;\
  6480. }
  6481. char flag_name[100];
  6482. short flag=0,i;
  6483. nullpo_retr(-1, sd);
  6484. memset(flag_name, '\0', sizeof(flag_name));
  6485. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  6486. clif_displaymessage(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map:
  6487. clif_displaymessage(sd->fd,"----------------------------------");
  6488. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6489. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6490. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6491. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6492. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6493. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6494. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6495. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6496. checkflag(nogo); checkflag(nobaseexp);
  6497. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6498. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6499. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6500. clif_displaymessage(sd->fd," ");
  6501. clif_displaymessage(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6502. clif_displaymessage(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags.
  6503. return 1;
  6504. }
  6505. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6506. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6507. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6508. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6509. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6510. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6511. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6512. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6513. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6514. setflag(nogo); setflag(nobaseexp);
  6515. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6516. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6517. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6518. clif_displaymessage(sd->fd,msg_txt(1314)); // Invalid flag name or flag.
  6519. clif_displaymessage(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6520. clif_displaymessage(sd->fd,msg_txt(1315)); // Available Flags:
  6521. clif_displaymessage(sd->fd,"----------------------------------");
  6522. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6523. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6524. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6525. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6526. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6527. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6528. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6529. #undef checkflag
  6530. #undef setflag
  6531. return 0;
  6532. }
  6533. /*===================================
  6534. * Remove some messages
  6535. *-----------------------------------*/
  6536. ACMD_FUNC(showexp)
  6537. {
  6538. if (sd->state.showexp) {
  6539. sd->state.showexp = 0;
  6540. clif_displaymessage(fd, msg_txt(1316)); // Gained exp will not be shown.
  6541. return 0;
  6542. }
  6543. sd->state.showexp = 1;
  6544. clif_displaymessage(fd, msg_txt(1317)); // Gained exp is now shown.
  6545. return 0;
  6546. }
  6547. ACMD_FUNC(showzeny)
  6548. {
  6549. if (sd->state.showzeny) {
  6550. sd->state.showzeny = 0;
  6551. clif_displaymessage(fd, msg_txt(1318)); // Gained zeny will not be shown.
  6552. return 0;
  6553. }
  6554. sd->state.showzeny = 1;
  6555. clif_displaymessage(fd, msg_txt(1319)); // Gained zeny is now shown.
  6556. return 0;
  6557. }
  6558. ACMD_FUNC(showdelay)
  6559. {
  6560. if (sd->state.showdelay) {
  6561. sd->state.showdelay = 0;
  6562. clif_displaymessage(fd, msg_txt(1320)); // Skill delay failures will not be shown.
  6563. return 0;
  6564. }
  6565. sd->state.showdelay = 1;
  6566. clif_displaymessage(fd, msg_txt(1321)); // Skill delay failures are now shown.
  6567. return 0;
  6568. }
  6569. /*==========================================
  6570. * Duel organizing functions [LuzZza]
  6571. *
  6572. * @duel [limit|nick] - create a duel
  6573. * @invite <nick> - invite player
  6574. * @accept - accept invitation
  6575. * @reject - reject invitation
  6576. * @leave - leave duel
  6577. *------------------------------------------*/
  6578. ACMD_FUNC(invite)
  6579. {
  6580. unsigned int did = sd->duel_group;
  6581. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6582. if(did <= 0) {
  6583. // "Duel: @invite without @duel."
  6584. clif_displaymessage(fd, msg_txt(350));
  6585. return 0;
  6586. }
  6587. if(duel_list[did].max_players_limit > 0 &&
  6588. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6589. // "Duel: Limit of players is reached."
  6590. clif_displaymessage(fd, msg_txt(351));
  6591. return 0;
  6592. }
  6593. if(target_sd == NULL) {
  6594. // "Duel: Player not found."
  6595. clif_displaymessage(fd, msg_txt(352));
  6596. return 0;
  6597. }
  6598. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6599. // "Duel: Player already in duel."
  6600. clif_displaymessage(fd, msg_txt(353));
  6601. return 0;
  6602. }
  6603. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6604. {
  6605. sprintf(atcmd_output, msg_txt(364), message);
  6606. clif_displaymessage(fd, atcmd_output);
  6607. return 0;
  6608. }
  6609. duel_invite(did, sd, target_sd);
  6610. // "Duel: Invitation has been sent."
  6611. clif_displaymessage(fd, msg_txt(354));
  6612. return 0;
  6613. }
  6614. ACMD_FUNC(duel)
  6615. {
  6616. char output[CHAT_SIZE_MAX];
  6617. unsigned int maxpl=0, newduel;
  6618. struct map_session_data *target_sd;
  6619. if(sd->duel_group > 0) {
  6620. duel_showinfo(sd->duel_group, sd);
  6621. return 0;
  6622. }
  6623. if(sd->duel_invite > 0) {
  6624. // "Duel: @duel without @reject."
  6625. clif_displaymessage(fd, msg_txt(355));
  6626. return 0;
  6627. }
  6628. if(!duel_checktime(sd)) {
  6629. // "Duel: You can take part in duel only one time per %d minutes."
  6630. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6631. clif_displaymessage(fd, output);
  6632. return 0;
  6633. }
  6634. if( message[0] ) {
  6635. if(sscanf(message, "%d", &maxpl) >= 1) {
  6636. if(maxpl < 2 || maxpl > 65535) {
  6637. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6638. return 0;
  6639. }
  6640. duel_create(sd, maxpl);
  6641. } else {
  6642. target_sd = map_nick2sd((char *)message);
  6643. if(target_sd != NULL) {
  6644. if((newduel = duel_create(sd, 2)) != -1) {
  6645. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6646. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6647. return 0;
  6648. }
  6649. duel_invite(newduel, sd, target_sd);
  6650. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6651. }
  6652. } else {
  6653. // "Duel: Player not found."
  6654. clif_displaymessage(fd, msg_txt(352));
  6655. return 0;
  6656. }
  6657. }
  6658. } else
  6659. duel_create(sd, 0);
  6660. return 0;
  6661. }
  6662. ACMD_FUNC(leave)
  6663. {
  6664. if(sd->duel_group <= 0) {
  6665. // "Duel: @leave without @duel."
  6666. clif_displaymessage(fd, msg_txt(358));
  6667. return 0;
  6668. }
  6669. duel_leave(sd->duel_group, sd);
  6670. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6671. return 0;
  6672. }
  6673. ACMD_FUNC(accept)
  6674. {
  6675. char output[CHAT_SIZE_MAX];
  6676. if(!duel_checktime(sd)) {
  6677. // "Duel: You can take part in duel only one time per %d minutes."
  6678. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6679. clif_displaymessage(fd, output);
  6680. return 0;
  6681. }
  6682. if(sd->duel_invite <= 0) {
  6683. // "Duel: @accept without invititation."
  6684. clif_displaymessage(fd, msg_txt(360));
  6685. return 0;
  6686. }
  6687. 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 )
  6688. {
  6689. // "Duel: Limit of players is reached."
  6690. clif_displaymessage(fd, msg_txt(351));
  6691. return 0;
  6692. }
  6693. duel_accept(sd->duel_invite, sd);
  6694. // "Duel: Invitation has been accepted."
  6695. clif_displaymessage(fd, msg_txt(361));
  6696. return 0;
  6697. }
  6698. ACMD_FUNC(reject)
  6699. {
  6700. if(sd->duel_invite <= 0) {
  6701. // "Duel: @reject without invititation."
  6702. clif_displaymessage(fd, msg_txt(362));
  6703. return 0;
  6704. }
  6705. duel_reject(sd->duel_invite, sd);
  6706. // "Duel: Invitation has been rejected."
  6707. clif_displaymessage(fd, msg_txt(363));
  6708. return 0;
  6709. }
  6710. /*===================================
  6711. * Cash Points
  6712. *-----------------------------------*/
  6713. ACMD_FUNC(cash)
  6714. {
  6715. char output[128];
  6716. int value;
  6717. int ret=0;
  6718. nullpo_retr(-1, sd);
  6719. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6720. clif_displaymessage(fd, msg_txt(1322)); // Please enter an amount.
  6721. return -1;
  6722. }
  6723. if( !strcmpi(command+1,"cash") )
  6724. {
  6725. if( value > 0 ) {
  6726. if( (ret=pc_getcash(sd, value, 0)) >= 0){
  6727. sprintf(output, msg_txt(505), ret, sd->cashPoints);
  6728. clif_disp_onlyself(sd, output, strlen(output));
  6729. }
  6730. else clif_displaymessage(fd, msg_txt(149)); // Unable to decrease the number/value.
  6731. } else {
  6732. if( (ret=pc_paycash(sd, -value, 0)) >= 0){
  6733. sprintf(output, msg_txt(410), ret, sd->cashPoints);
  6734. clif_disp_onlyself(sd, output, strlen(output));
  6735. }
  6736. else clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  6737. }
  6738. }
  6739. else
  6740. { // @points
  6741. if( value > 0 ) {
  6742. if( (ret=pc_getcash(sd, 0, value)) >= 0){
  6743. sprintf(output, msg_txt(506), ret, sd->kafraPoints);
  6744. clif_disp_onlyself(sd, output, strlen(output));
  6745. }
  6746. else clif_displaymessage(fd, msg_txt(149)); // Unable to decrease the number/value.
  6747. } else {
  6748. if( (ret=pc_paycash(sd, -value, -value)) >= 0){
  6749. sprintf(output, msg_txt(411), ret, sd->kafraPoints);
  6750. clif_disp_onlyself(sd, output, strlen(output));
  6751. }
  6752. else clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  6753. }
  6754. }
  6755. return 0;
  6756. }
  6757. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6758. ACMD_FUNC(clone)
  6759. {
  6760. int x=0,y=0,flag=0,master=0,i=0;
  6761. struct map_session_data *pl_sd=NULL;
  6762. if (!message || !*message) {
  6763. clif_displaymessage(sd->fd,msg_txt(1323)); // You must enter a player name or ID.
  6764. return 0;
  6765. }
  6766. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6767. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6768. return 0;
  6769. }
  6770. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6771. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6772. return 0;
  6773. }
  6774. if (strcmpi(command+1, "clone") == 0)
  6775. flag = 1;
  6776. else if (strcmpi(command+1, "slaveclone") == 0) {
  6777. flag = 2;
  6778. if(pc_isdead(sd)){
  6779. clif_displaymessage(fd, msg_txt(129+flag*2));
  6780. return 0;
  6781. }
  6782. master = sd->bl.id;
  6783. if (battle_config.atc_slave_clone_limit
  6784. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6785. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6786. return 0;
  6787. }
  6788. }
  6789. do {
  6790. x = sd->bl.x + (rnd() % 10 - 5);
  6791. y = sd->bl.y + (rnd() % 10 - 5);
  6792. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6793. if (i >= 10) {
  6794. x = sd->bl.x;
  6795. y = sd->bl.y;
  6796. }
  6797. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6798. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6799. return 0;
  6800. }
  6801. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6802. return 0;
  6803. }
  6804. /*===================================
  6805. * Main chat [LuzZza]
  6806. * Usage: @main <on|off|message>
  6807. *-----------------------------------*/
  6808. ACMD_FUNC(main)
  6809. {
  6810. if( message[0] ) {
  6811. if(strcmpi(message, "on") == 0) {
  6812. if(!sd->state.mainchat) {
  6813. sd->state.mainchat = 1;
  6814. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6815. } else {
  6816. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6817. }
  6818. } else if(strcmpi(message, "off") == 0) {
  6819. if(sd->state.mainchat) {
  6820. sd->state.mainchat = 0;
  6821. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6822. } else {
  6823. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6824. }
  6825. } else {
  6826. if(!sd->state.mainchat) {
  6827. sd->state.mainchat = 1;
  6828. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6829. }
  6830. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6831. clif_displaymessage(fd, msg_txt(387));
  6832. return -1;
  6833. }
  6834. if ( battle_config.min_chat_delay ) {
  6835. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6836. return 0;
  6837. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6838. }
  6839. // send the message using inter-server system
  6840. intif_main_message( sd, message );
  6841. }
  6842. } else {
  6843. if(sd->state.mainchat)
  6844. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6845. else
  6846. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6847. }
  6848. return 0;
  6849. }
  6850. /*=====================================
  6851. * Autorejecting Invites/Deals [LuzZza]
  6852. * Usage: @noask
  6853. *-------------------------------------*/
  6854. ACMD_FUNC(noask)
  6855. {
  6856. if(sd->state.noask) {
  6857. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6858. sd->state.noask = 0;
  6859. } else {
  6860. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6861. sd->state.noask = 1;
  6862. }
  6863. return 0;
  6864. }
  6865. /*=====================================
  6866. * Send a @request message to all GMs of lowest_gm_level.
  6867. * Usage: @request <petition>
  6868. *-------------------------------------*/
  6869. ACMD_FUNC(request)
  6870. {
  6871. if (!message || !*message) {
  6872. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6873. return -1;
  6874. }
  6875. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6876. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6877. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6878. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6879. return 0;
  6880. }
  6881. /*==========================================
  6882. * Feel (SG save map) Reset [HiddenDragon]
  6883. *------------------------------------------*/
  6884. ACMD_FUNC(feelreset)
  6885. {
  6886. pc_resetfeel(sd);
  6887. clif_displaymessage(fd, msg_txt(1324)); // Reset 'Feeling' maps.
  6888. return 0;
  6889. }
  6890. /*==========================================
  6891. * AUCTION SYSTEM
  6892. *------------------------------------------*/
  6893. ACMD_FUNC(auction)
  6894. {
  6895. nullpo_ret(sd);
  6896. clif_Auction_openwindow(sd);
  6897. return 0;
  6898. }
  6899. /*==========================================
  6900. * Kill Steal Protection
  6901. *------------------------------------------*/
  6902. ACMD_FUNC(ksprotection)
  6903. {
  6904. nullpo_retr(-1,sd);
  6905. if( sd->state.noks ) {
  6906. sd->state.noks = 0;
  6907. clif_displaymessage(fd, msg_txt(1325)); // [ K.S Protection Inactive ]
  6908. }
  6909. else
  6910. {
  6911. if( !message || !*message || !strcmpi(message, "party") )
  6912. { // Default is Party
  6913. sd->state.noks = 2;
  6914. clif_displaymessage(fd, msg_txt(1326)); // [ K.S Protection Active - Option: Party ]
  6915. }
  6916. else if( !strcmpi(message, "self") )
  6917. {
  6918. sd->state.noks = 1;
  6919. clif_displaymessage(fd, msg_txt(1327)); // [ K.S Protection Active - Option: Self ]
  6920. }
  6921. else if( !strcmpi(message, "guild") )
  6922. {
  6923. sd->state.noks = 3;
  6924. clif_displaymessage(fd, msg_txt(1328)); // [ K.S Protection Active - Option: Guild ]
  6925. }
  6926. else
  6927. clif_displaymessage(fd, msg_txt(1329)); // Usage: @noks <self|party|guild>
  6928. }
  6929. return 0;
  6930. }
  6931. /*==========================================
  6932. * Map Kill Steal Protection Setting
  6933. *------------------------------------------*/
  6934. ACMD_FUNC(allowks)
  6935. {
  6936. nullpo_retr(-1,sd);
  6937. if( map[sd->bl.m].flag.allowks ) {
  6938. map[sd->bl.m].flag.allowks = 0;
  6939. clif_displaymessage(fd, msg_txt(1330)); // [ Map K.S Protection Active ]
  6940. } else {
  6941. map[sd->bl.m].flag.allowks = 1;
  6942. clif_displaymessage(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ]
  6943. }
  6944. return 0;
  6945. }
  6946. ACMD_FUNC(resetstat)
  6947. {
  6948. nullpo_retr(-1, sd);
  6949. pc_resetstate(sd);
  6950. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  6951. clif_displaymessage(fd, atcmd_output);
  6952. return 0;
  6953. }
  6954. ACMD_FUNC(resetskill)
  6955. {
  6956. nullpo_retr(-1,sd);
  6957. pc_resetskill(sd,1);
  6958. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  6959. clif_displaymessage(fd, atcmd_output);
  6960. return 0;
  6961. }
  6962. /*==========================================
  6963. * #storagelist: Displays the items list of a player's storage.
  6964. * #cartlist: Displays contents of target's cart.
  6965. * #itemlist: Displays contents of target's inventory.
  6966. *------------------------------------------*/
  6967. ACMD_FUNC(itemlist)
  6968. {
  6969. int i, j, count, counter;
  6970. const char* location;
  6971. const struct item* items;
  6972. int size;
  6973. StringBuf buf;
  6974. nullpo_retr(-1, sd);
  6975. if( strcmp(command+1, "storagelist") == 0 )
  6976. {
  6977. location = "storage";
  6978. items = sd->status.storage.items;
  6979. size = MAX_STORAGE;
  6980. }
  6981. else
  6982. if( strcmp(command+1, "cartlist") == 0 )
  6983. {
  6984. location = "cart";
  6985. items = sd->status.cart;
  6986. size = MAX_CART;
  6987. }
  6988. else
  6989. if( strcmp(command+1, "itemlist") == 0 )
  6990. {
  6991. location = "inventory";
  6992. items = sd->status.inventory;
  6993. size = MAX_INVENTORY;
  6994. }
  6995. else
  6996. return 1;
  6997. StringBuf_Init(&buf);
  6998. count = 0; // total slots occupied
  6999. counter = 0; // total items found
  7000. for( i = 0; i < size; ++i )
  7001. {
  7002. const struct item* it = &items[i];
  7003. struct item_data* itd;
  7004. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7005. continue;
  7006. counter += it->amount;
  7007. count++;
  7008. if( count == 1 )
  7009. {
  7010. StringBuf_Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7011. clif_displaymessage(fd, StringBuf_Value(&buf));
  7012. StringBuf_Clear(&buf);
  7013. }
  7014. if( it->refine )
  7015. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7016. else
  7017. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7018. if( it->equip )
  7019. {
  7020. char equipstr[CHAT_SIZE_MAX];
  7021. strcpy(equipstr, msg_txt(1333)); // | equipped:
  7022. if( it->equip & EQP_GARMENT )
  7023. strcat(equipstr, msg_txt(1334)); // garment,
  7024. if( it->equip & EQP_ACC_L )
  7025. strcat(equipstr, msg_txt(1335)); // left accessory,
  7026. if( it->equip & EQP_ARMOR )
  7027. strcat(equipstr, msg_txt(1336)); // body/armor,
  7028. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7029. strcat(equipstr, msg_txt(1337)); // right hand,
  7030. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7031. strcat(equipstr, msg_txt(1338)); // left hand,
  7032. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7033. strcat(equipstr, msg_txt(1339)); // both hands,
  7034. if( it->equip & EQP_SHOES )
  7035. strcat(equipstr, msg_txt(1340)); // feet,
  7036. if( it->equip & EQP_ACC_R )
  7037. strcat(equipstr, msg_txt(1341)); // right accessory,
  7038. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7039. strcat(equipstr, msg_txt(1342)); // lower head,
  7040. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7041. strcat(equipstr, msg_txt(1343)); // top head,
  7042. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7043. strcat(equipstr, msg_txt(1344)); // lower/top head,
  7044. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7045. strcat(equipstr, msg_txt(1345)); // mid head,
  7046. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7047. strcat(equipstr, msg_txt(1346)); // lower/mid head,
  7048. if( (it->equip & EQP_HELM) == EQP_HELM )
  7049. strcat(equipstr, msg_txt(1347)); // lower/mid/top head,
  7050. // remove final ', '
  7051. equipstr[strlen(equipstr) - 2] = '\0';
  7052. StringBuf_AppendStr(&buf, equipstr);
  7053. }
  7054. clif_displaymessage(fd, StringBuf_Value(&buf));
  7055. StringBuf_Clear(&buf);
  7056. if( it->card[0] == CARD0_PET )
  7057. {// pet egg
  7058. if (it->card[3])
  7059. StringBuf_Printf(&buf, msg_txt(1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7060. else
  7061. StringBuf_Printf(&buf, msg_txt(1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7062. }
  7063. else
  7064. if(it->card[0] == CARD0_FORGE)
  7065. {// forged item
  7066. StringBuf_Printf(&buf, msg_txt(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)
  7067. }
  7068. else
  7069. if(it->card[0] == CARD0_CREATE)
  7070. {// created item
  7071. StringBuf_Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7072. }
  7073. else
  7074. {// normal item
  7075. int counter2 = 0;
  7076. for( j = 0; j < itd->slot; ++j )
  7077. {
  7078. struct item_data* card;
  7079. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7080. continue;
  7081. counter2++;
  7082. if( counter2 == 1 )
  7083. StringBuf_AppendStr(&buf, msg_txt(1352)); // -> (card(s):
  7084. if( counter2 != 1 )
  7085. StringBuf_AppendStr(&buf, ", ");
  7086. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7087. }
  7088. if( counter2 > 0 )
  7089. StringBuf_AppendStr(&buf, ")");
  7090. }
  7091. if( StringBuf_Length(&buf) > 0 )
  7092. clif_displaymessage(fd, StringBuf_Value(&buf));
  7093. StringBuf_Clear(&buf);
  7094. }
  7095. if( count == 0 )
  7096. StringBuf_Printf(&buf, msg_txt(1353), location); // No item found in this player's %s.
  7097. else
  7098. StringBuf_Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots.
  7099. clif_displaymessage(fd, StringBuf_Value(&buf));
  7100. StringBuf_Destroy(&buf);
  7101. return 0;
  7102. }
  7103. ACMD_FUNC(stats)
  7104. {
  7105. char job_jobname[100];
  7106. char output[CHAT_SIZE_MAX];
  7107. int i;
  7108. struct {
  7109. const char* format;
  7110. int value;
  7111. } output_table[] = {
  7112. { "Base Level - %d", 0 },
  7113. { NULL, 0 },
  7114. { "Hp - %d", 0 },
  7115. { "MaxHp - %d", 0 },
  7116. { "Sp - %d", 0 },
  7117. { "MaxSp - %d", 0 },
  7118. { "Str - %3d", 0 },
  7119. { "Agi - %3d", 0 },
  7120. { "Vit - %3d", 0 },
  7121. { "Int - %3d", 0 },
  7122. { "Dex - %3d", 0 },
  7123. { "Luk - %3d", 0 },
  7124. { "Zeny - %d", 0 },
  7125. { "Free SK Points - %d", 0 },
  7126. { "JobChangeLvl (2nd) - %d", 0 },
  7127. { "JobChangeLvl (3rd) - %d", 0 },
  7128. { NULL, 0 }
  7129. };
  7130. memset(job_jobname, '\0', sizeof(job_jobname));
  7131. memset(output, '\0', sizeof(output));
  7132. //direct array initialization with variables is not standard C compliant.
  7133. output_table[0].value = sd->status.base_level;
  7134. output_table[1].format = job_jobname;
  7135. output_table[1].value = sd->status.job_level;
  7136. output_table[2].value = sd->status.hp;
  7137. output_table[3].value = sd->status.max_hp;
  7138. output_table[4].value = sd->status.sp;
  7139. output_table[5].value = sd->status.max_sp;
  7140. output_table[6].value = sd->status.str;
  7141. output_table[7].value = sd->status.agi;
  7142. output_table[8].value = sd->status.vit;
  7143. output_table[9].value = sd->status.int_;
  7144. output_table[10].value = sd->status.dex;
  7145. output_table[11].value = sd->status.luk;
  7146. output_table[12].value = sd->status.zeny;
  7147. output_table[13].value = sd->status.skill_point;
  7148. output_table[14].value = sd->change_level_2nd;
  7149. output_table[15].value = sd->change_level_3rd;
  7150. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7151. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7152. clif_displaymessage(fd, output);
  7153. for (i = 0; output_table[i].format != NULL; i++) {
  7154. sprintf(output, output_table[i].format, output_table[i].value);
  7155. clif_displaymessage(fd, output);
  7156. }
  7157. return 0;
  7158. }
  7159. ACMD_FUNC(delitem)
  7160. {
  7161. char item_name[100];
  7162. int nameid, amount = 0, total, idx;
  7163. struct item_data* id;
  7164. nullpo_retr(-1, sd);
  7165. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7166. {
  7167. clif_displaymessage(fd, msg_txt(1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  7168. return -1;
  7169. }
  7170. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7171. {
  7172. nameid = id->nameid;
  7173. }
  7174. else
  7175. {
  7176. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7177. return -1;
  7178. }
  7179. total = amount;
  7180. // delete items
  7181. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7182. {
  7183. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7184. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7185. {// delete pet
  7186. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7187. }
  7188. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7189. amount-= delamount;
  7190. }
  7191. // notify target
  7192. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7193. clif_displaymessage(sd->fd, atcmd_output);
  7194. // notify source
  7195. if( amount == total )
  7196. {
  7197. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7198. }
  7199. else if( amount )
  7200. {
  7201. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7202. clif_displaymessage(fd, atcmd_output);
  7203. }
  7204. else
  7205. {
  7206. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7207. clif_displaymessage(fd, atcmd_output);
  7208. }
  7209. return 0;
  7210. }
  7211. /*==========================================
  7212. * Custom Fonts
  7213. *------------------------------------------*/
  7214. ACMD_FUNC(font)
  7215. {
  7216. int font_id;
  7217. nullpo_retr(-1,sd);
  7218. font_id = atoi(message);
  7219. if( font_id == 0 )
  7220. {
  7221. if( sd->user_font )
  7222. {
  7223. sd->user_font = 0;
  7224. clif_displaymessage(fd, msg_txt(1356)); // Returning to normal font.
  7225. clif_font(sd);
  7226. }
  7227. else
  7228. {
  7229. clif_displaymessage(fd, msg_txt(1357)); // Use @font <1-9> to change your message font.
  7230. clif_displaymessage(fd, msg_txt(1358)); // Use 0 or no parameter to return to normal font.
  7231. }
  7232. }
  7233. else if( font_id < 0 || font_id > 9 )
  7234. clif_displaymessage(fd, msg_txt(1359)); // Invalid font. Use a value from 0 to 9.
  7235. else if( font_id != sd->user_font )
  7236. {
  7237. sd->user_font = font_id;
  7238. clif_font(sd);
  7239. clif_displaymessage(fd, msg_txt(1360)); // Font changed.
  7240. }
  7241. else
  7242. clif_displaymessage(fd, msg_txt(1361)); // Already using this font.
  7243. return 0;
  7244. }
  7245. /*==========================================
  7246. * type: 1 = commands (@), 2 = charcommands (#)
  7247. *------------------------------------------*/
  7248. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7249. {
  7250. char line_buff[CHATBOX_SIZE];
  7251. char* cur = line_buff;
  7252. AtCommandInfo* cmd;
  7253. DBIterator *iter = db_iterator(atcommand_db);
  7254. int count = 0;
  7255. memset(line_buff,' ',CHATBOX_SIZE);
  7256. line_buff[CHATBOX_SIZE-1] = 0;
  7257. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7258. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7259. unsigned int slen = 0;
  7260. switch( type ) {
  7261. case COMMAND_CHARCOMMAND:
  7262. if( cmd->char_groups[sd->group_pos] == 0 )
  7263. continue;
  7264. break;
  7265. case COMMAND_ATCOMMAND:
  7266. if( cmd->at_groups[sd->group_pos] == 0 )
  7267. continue;
  7268. break;
  7269. default:
  7270. continue;
  7271. }
  7272. slen = strlen(cmd->command);
  7273. // flush the text buffer if this command won't fit into it
  7274. if ( slen + cur - line_buff >= CHATBOX_SIZE )
  7275. {
  7276. clif_displaymessage(fd,line_buff);
  7277. cur = line_buff;
  7278. memset(line_buff,' ',CHATBOX_SIZE);
  7279. line_buff[CHATBOX_SIZE-1] = 0;
  7280. }
  7281. memcpy(cur,cmd->command,slen);
  7282. cur += slen+(10-slen%10);
  7283. count++;
  7284. }
  7285. dbi_destroy(iter);
  7286. clif_displaymessage(fd,line_buff);
  7287. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7288. clif_displaymessage(fd, atcmd_output);
  7289. return;
  7290. }
  7291. /*==========================================
  7292. * @commands Lists available @ commands to you
  7293. *------------------------------------------*/
  7294. ACMD_FUNC(commands)
  7295. {
  7296. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7297. return 0;
  7298. }
  7299. /*==========================================
  7300. * @charcommands Lists available # commands to you
  7301. *------------------------------------------*/
  7302. ACMD_FUNC(charcommands)
  7303. {
  7304. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7305. return 0;
  7306. }
  7307. /* for new mounts */
  7308. ACMD_FUNC(mount2) {
  7309. clif_displaymessage(sd->fd,msg_txt(1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7310. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7311. clif_displaymessage(sd->fd,msg_txt(1363)); // You have mounted.
  7312. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7313. } else {
  7314. clif_displaymessage(sd->fd,msg_txt(1364)); // You have released your mount.
  7315. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7316. }
  7317. return 0;
  7318. }
  7319. ACMD_FUNC(accinfo) {
  7320. char query[NAME_LENGTH];
  7321. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7322. clif_displaymessage(fd, msg_txt(1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7323. clif_displaymessage(fd, msg_txt(1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  7324. return -1;
  7325. }
  7326. //remove const type
  7327. safestrncpy(query, message, NAME_LENGTH);
  7328. intif_request_accinfo( sd->fd, sd->bl.id, sd->group_id, query );
  7329. return 0;
  7330. }
  7331. /* [Ind] */
  7332. ACMD_FUNC(set) {
  7333. char reg[32], val[128];
  7334. struct script_data* data;
  7335. int toset = 0;
  7336. bool is_str = false;
  7337. if( !message || !*message || (toset = sscanf(message, "%32s %128[^\n]s", reg, val)) < 1 ) {
  7338. clif_displaymessage(fd, msg_txt(1367)); // Usage: @set <variable name> <value>
  7339. clif_displaymessage(fd, msg_txt(1368)); // Usage: ex. "@set PoringCharVar 50"
  7340. clif_displaymessage(fd, msg_txt(1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7341. clif_displaymessage(fd, msg_txt(1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7342. return -1;
  7343. }
  7344. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7345. if( reg[0] == '.' ) {
  7346. clif_displaymessage(fd, msg_txt(1371)); // NPC variables may not be used with @set.
  7347. return -1;
  7348. } else if( reg[0] == '\'' ) {
  7349. clif_displaymessage(fd, msg_txt(1372)); // Instance variables may not be used with @set.
  7350. return -1;
  7351. }
  7352. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7353. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7354. if( is_str )
  7355. set_var(sd, reg, (void*) val);
  7356. else
  7357. set_var(sd, reg, (void*)__64BPRTSIZE((int)(atoi(val))));
  7358. }
  7359. CREATE(data, struct script_data,1);
  7360. if( is_str ) {// string variable
  7361. switch( reg[0] ) {
  7362. case '@':
  7363. data->u.str = pc_readregstr(sd, add_str(reg));
  7364. break;
  7365. case '$':
  7366. data->u.str = mapreg_readregstr(add_str(reg));
  7367. break;
  7368. case '#':
  7369. if( reg[1] == '#' )
  7370. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7371. else
  7372. data->u.str = pc_readaccountregstr(sd, reg);// local
  7373. break;
  7374. default:
  7375. data->u.str = pc_readglobalreg_str(sd, reg);
  7376. break;
  7377. }
  7378. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7379. data->type = C_CONSTSTR;
  7380. data->u.str = "";
  7381. } else {// duplicate string
  7382. data->type = C_STR;
  7383. data->u.str = aStrdup(data->u.str);
  7384. }
  7385. } else {// integer variable
  7386. data->type = C_INT;
  7387. switch( reg[0] ) {
  7388. case '@':
  7389. data->u.num = pc_readreg(sd, add_str(reg));
  7390. break;
  7391. case '$':
  7392. data->u.num = mapreg_readreg(add_str(reg));
  7393. break;
  7394. case '#':
  7395. if( reg[1] == '#' )
  7396. data->u.num = pc_readaccountreg2(sd, reg);// global
  7397. else
  7398. data->u.num = pc_readaccountreg(sd, reg);// local
  7399. break;
  7400. default:
  7401. data->u.num = pc_readglobalreg(sd, reg);
  7402. break;
  7403. }
  7404. }
  7405. switch( data->type ) {
  7406. case C_INT:
  7407. sprintf(atcmd_output,msg_txt(1373),reg,data->u.num); // %s value is now :%d
  7408. break;
  7409. case C_STR:
  7410. sprintf(atcmd_output,msg_txt(1374),reg,data->u.str); // %s value is now :%s
  7411. break;
  7412. case C_CONSTSTR:
  7413. sprintf(atcmd_output,msg_txt(1375),reg); // %s is empty
  7414. break;
  7415. default:
  7416. sprintf(atcmd_output,msg_txt(1376),reg,data->type); // %s data type is not supported :%u
  7417. break;
  7418. }
  7419. clif_displaymessage(fd, atcmd_output);
  7420. aFree(data);
  7421. return 0;
  7422. }
  7423. ACMD_FUNC(reloadquestdb) {
  7424. do_reload_quest();
  7425. clif_displaymessage(fd, msg_txt(1377)); // Quest database has been reloaded.
  7426. return 0;
  7427. }
  7428. ACMD_FUNC(addperm) {
  7429. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7430. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7431. int i;
  7432. if( !message || !*message ) {
  7433. sprintf(atcmd_output, msg_txt(1378),command); // Usage: %s <permission_name>
  7434. clif_displaymessage(fd, atcmd_output);
  7435. clif_displaymessage(fd, msg_txt(1379)); // -- Permission List
  7436. for( i = 0; i < perm_size; i++ ) {
  7437. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7438. clif_displaymessage(fd, atcmd_output);
  7439. }
  7440. return -1;
  7441. }
  7442. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7443. if( i == perm_size ) {
  7444. sprintf(atcmd_output,msg_txt(1380),message); // '%s' is not a known permission.
  7445. clif_displaymessage(fd, atcmd_output);
  7446. clif_displaymessage(fd, msg_txt(1379)); // -- Permission List
  7447. for( i = 0; i < perm_size; i++ ) {
  7448. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7449. clif_displaymessage(fd, atcmd_output);
  7450. }
  7451. return -1;
  7452. }
  7453. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7454. sprintf(atcmd_output, msg_txt(1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7455. clif_displaymessage(fd, atcmd_output);
  7456. return -1;
  7457. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7458. sprintf(atcmd_output, msg_txt(1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7459. clif_displaymessage(fd, atcmd_output);
  7460. sprintf(atcmd_output,msg_txt(1383),sd->status.name); // -- User '%s' Permissions
  7461. clif_displaymessage(fd, atcmd_output);
  7462. for( i = 0; i < perm_size; i++ ) {
  7463. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7464. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7465. clif_displaymessage(fd, atcmd_output);
  7466. }
  7467. }
  7468. return -1;
  7469. }
  7470. if( add )
  7471. sd->permissions |= pc_g_permission_name[i].permission;
  7472. else
  7473. sd->permissions &=~ pc_g_permission_name[i].permission;
  7474. sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7475. clif_displaymessage(fd, atcmd_output);
  7476. return 0;
  7477. }
  7478. ACMD_FUNC(unloadnpcfile) {
  7479. if( !message || !*message ) {
  7480. clif_displaymessage(fd, msg_txt(1385)); // Usage: @unloadnpcfile <file name>
  7481. return -1;
  7482. }
  7483. if( npc_unloadfile(message) )
  7484. clif_displaymessage(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7485. else {
  7486. clif_displaymessage(fd, msg_txt(1387)); // File not found.
  7487. return -1;
  7488. }
  7489. return 0;
  7490. }
  7491. ACMD_FUNC(cart) {
  7492. #define MC_CART_MDFY(x) \
  7493. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7494. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7495. sd->status.skill[MC_PUSHCART].flag = x?1:0;
  7496. int val = atoi(message);
  7497. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7498. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7499. sprintf(atcmd_output, msg_txt(1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7500. clif_displaymessage(fd, atcmd_output);
  7501. return -1;
  7502. }
  7503. if( val == 0 && !pc_iscarton(sd) ) {
  7504. clif_displaymessage(fd, msg_txt(1391)); // You do not possess a cart to be removed
  7505. return -1;
  7506. }
  7507. if( need_skill ) {
  7508. MC_CART_MDFY(1);
  7509. }
  7510. if( pc_setcart(sd, val) ) {
  7511. if( need_skill ) {
  7512. MC_CART_MDFY(0);
  7513. }
  7514. return -1;/* @cart failed */
  7515. }
  7516. if( need_skill ) {
  7517. MC_CART_MDFY(0);
  7518. }
  7519. clif_displaymessage(fd, msg_txt(1392)); // Cart Added
  7520. return 0;
  7521. #undef MC_CART_MDFY
  7522. }
  7523. /**
  7524. * Fills the reference of available commands in atcommand DBMap
  7525. **/
  7526. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL }
  7527. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL }
  7528. void atcommand_basecommands(void) {
  7529. /**
  7530. * Command reference list, place the base of your commands here
  7531. **/
  7532. AtCommandInfo atcommand_base[] = {
  7533. ACMD_DEF2("warp", mapmove),
  7534. ACMD_DEF(where),
  7535. ACMD_DEF(jumpto),
  7536. ACMD_DEF(jump),
  7537. ACMD_DEF(who),
  7538. ACMD_DEF2("who2", who),
  7539. ACMD_DEF2("who3", who),
  7540. ACMD_DEF2("whomap", who),
  7541. ACMD_DEF2("whomap2", who),
  7542. ACMD_DEF2("whomap3", who),
  7543. ACMD_DEF(whogm),
  7544. ACMD_DEF(save),
  7545. ACMD_DEF(load),
  7546. ACMD_DEF(speed),
  7547. ACMD_DEF(storage),
  7548. ACMD_DEF(guildstorage),
  7549. ACMD_DEF(option),
  7550. ACMD_DEF(hide), // + /hide
  7551. ACMD_DEF(jobchange),
  7552. ACMD_DEF(kill),
  7553. ACMD_DEF(alive),
  7554. ACMD_DEF(kami),
  7555. ACMD_DEF2("kamib", kami),
  7556. ACMD_DEF2("kamic", kami),
  7557. ACMD_DEF2("lkami", kami),
  7558. ACMD_DEF(heal),
  7559. ACMD_DEF(item),
  7560. ACMD_DEF(item2),
  7561. ACMD_DEF(itemreset),
  7562. ACMD_DEF(clearstorage),
  7563. ACMD_DEF(cleargstorage),
  7564. ACMD_DEF(clearcart),
  7565. ACMD_DEF2("blvl", baselevelup),
  7566. ACMD_DEF2("jlvl", joblevelup),
  7567. ACMD_DEF(help),
  7568. ACMD_DEF(pvpoff),
  7569. ACMD_DEF(pvpon),
  7570. ACMD_DEF(gvgoff),
  7571. ACMD_DEF(gvgon),
  7572. ACMD_DEF(model),
  7573. ACMD_DEF(go),
  7574. ACMD_DEF(monster),
  7575. ACMD_DEF2("monstersmall", monster),
  7576. ACMD_DEF2("monsterbig", monster),
  7577. ACMD_DEF(killmonster),
  7578. ACMD_DEF2("killmonster2", killmonster),
  7579. ACMD_DEF(refine),
  7580. ACMD_DEF(produce),
  7581. ACMD_DEF(memo),
  7582. ACMD_DEF(gat),
  7583. ACMD_DEF(displaystatus),
  7584. ACMD_DEF2("stpoint", statuspoint),
  7585. ACMD_DEF2("skpoint", skillpoint),
  7586. ACMD_DEF(zeny),
  7587. ACMD_DEF2("str", param),
  7588. ACMD_DEF2("agi", param),
  7589. ACMD_DEF2("vit", param),
  7590. ACMD_DEF2("int", param),
  7591. ACMD_DEF2("dex", param),
  7592. ACMD_DEF2("luk", param),
  7593. ACMD_DEF2("glvl", guildlevelup),
  7594. ACMD_DEF(makeegg),
  7595. ACMD_DEF(hatch),
  7596. ACMD_DEF(petfriendly),
  7597. ACMD_DEF(pethungry),
  7598. ACMD_DEF(petrename),
  7599. ACMD_DEF(recall), // + /recall
  7600. ACMD_DEF(night),
  7601. ACMD_DEF(day),
  7602. ACMD_DEF(doom),
  7603. ACMD_DEF(doommap),
  7604. ACMD_DEF(raise),
  7605. ACMD_DEF(raisemap),
  7606. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  7607. ACMD_DEF(kickall),
  7608. ACMD_DEF(allskill),
  7609. ACMD_DEF(questskill),
  7610. ACMD_DEF(lostskill),
  7611. ACMD_DEF(spiritball),
  7612. ACMD_DEF(party),
  7613. ACMD_DEF(guild),
  7614. ACMD_DEF(breakguild),
  7615. ACMD_DEF(agitstart),
  7616. ACMD_DEF(agitend),
  7617. ACMD_DEF(mapexit),
  7618. ACMD_DEF(idsearch),
  7619. ACMD_DEF(broadcast), // + /b and /nb
  7620. ACMD_DEF(localbroadcast), // + /lb and /nlb
  7621. ACMD_DEF(recallall),
  7622. ACMD_DEF(reloaditemdb),
  7623. ACMD_DEF(reloadmobdb),
  7624. ACMD_DEF(reloadskilldb),
  7625. ACMD_DEF(reloadscript),
  7626. ACMD_DEF(reloadatcommand),
  7627. ACMD_DEF(reloadbattleconf),
  7628. ACMD_DEF(reloadstatusdb),
  7629. ACMD_DEF(reloadpcdb),
  7630. ACMD_DEF(reloadmotd),
  7631. ACMD_DEF(mapinfo),
  7632. ACMD_DEF(dye),
  7633. ACMD_DEF2("hairstyle", hair_style),
  7634. ACMD_DEF2("haircolor", hair_color),
  7635. ACMD_DEF2("allstats", stat_all),
  7636. ACMD_DEF2("block", char_block),
  7637. ACMD_DEF2("ban", char_ban),
  7638. ACMD_DEF2("unblock", char_unblock),
  7639. ACMD_DEF2("unban", char_unban),
  7640. ACMD_DEF2("mount", mount_peco),
  7641. ACMD_DEF(guildspy),
  7642. ACMD_DEF(partyspy),
  7643. ACMD_DEF(repairall),
  7644. ACMD_DEF(guildrecall),
  7645. ACMD_DEF(partyrecall),
  7646. ACMD_DEF(nuke),
  7647. ACMD_DEF(shownpc),
  7648. ACMD_DEF(hidenpc),
  7649. ACMD_DEF(loadnpc),
  7650. ACMD_DEF(unloadnpc),
  7651. ACMD_DEF2("time", servertime),
  7652. ACMD_DEF(jail),
  7653. ACMD_DEF(unjail),
  7654. ACMD_DEF(jailfor),
  7655. ACMD_DEF(jailtime),
  7656. ACMD_DEF(disguise),
  7657. ACMD_DEF(undisguise),
  7658. ACMD_DEF(email),
  7659. ACMD_DEF(effect),
  7660. ACMD_DEF(follow),
  7661. ACMD_DEF(addwarp),
  7662. ACMD_DEF(skillon),
  7663. ACMD_DEF(skilloff),
  7664. ACMD_DEF(killer),
  7665. ACMD_DEF(npcmove),
  7666. ACMD_DEF(killable),
  7667. ACMD_DEF(dropall),
  7668. ACMD_DEF(storeall),
  7669. ACMD_DEF(skillid),
  7670. ACMD_DEF(useskill),
  7671. ACMD_DEF(displayskill),
  7672. ACMD_DEF(snow),
  7673. ACMD_DEF(sakura),
  7674. ACMD_DEF(clouds),
  7675. ACMD_DEF(clouds2),
  7676. ACMD_DEF(fog),
  7677. ACMD_DEF(fireworks),
  7678. ACMD_DEF(leaves),
  7679. ACMD_DEF(summon),
  7680. ACMD_DEF(adjgroup),
  7681. ACMD_DEF(trade),
  7682. ACMD_DEF(send),
  7683. ACMD_DEF(setbattleflag),
  7684. ACMD_DEF(unmute),
  7685. ACMD_DEF(clearweather),
  7686. ACMD_DEF(uptime),
  7687. ACMD_DEF(changesex),
  7688. ACMD_DEF(mute),
  7689. ACMD_DEF(refresh),
  7690. ACMD_DEF(refreshall),
  7691. ACMD_DEF(identify),
  7692. ACMD_DEF(gmotd),
  7693. ACMD_DEF(misceffect),
  7694. ACMD_DEF(mobsearch),
  7695. ACMD_DEF(cleanmap),
  7696. ACMD_DEF(cleanarea),
  7697. ACMD_DEF(npctalk),
  7698. ACMD_DEF(pettalk),
  7699. ACMD_DEF(users),
  7700. ACMD_DEF(reset),
  7701. ACMD_DEF(skilltree),
  7702. ACMD_DEF(marry),
  7703. ACMD_DEF(divorce),
  7704. ACMD_DEF(sound),
  7705. ACMD_DEF(undisguiseall),
  7706. ACMD_DEF(disguiseall),
  7707. ACMD_DEF(changelook),
  7708. ACMD_DEF(autoloot),
  7709. ACMD_DEF2("alootid", autolootitem),
  7710. ACMD_DEF(mobinfo),
  7711. ACMD_DEF(exp),
  7712. ACMD_DEF(version),
  7713. ACMD_DEF(mutearea),
  7714. ACMD_DEF(rates),
  7715. ACMD_DEF(iteminfo),
  7716. ACMD_DEF(whodrops),
  7717. ACMD_DEF(whereis),
  7718. ACMD_DEF(mapflag),
  7719. ACMD_DEF(me),
  7720. ACMD_DEF(monsterignore),
  7721. ACMD_DEF(fakename),
  7722. ACMD_DEF(size),
  7723. ACMD_DEF(showexp),
  7724. ACMD_DEF(showzeny),
  7725. ACMD_DEF(showdelay),
  7726. ACMD_DEF(autotrade),
  7727. ACMD_DEF(changegm),
  7728. ACMD_DEF(changeleader),
  7729. ACMD_DEF(partyoption),
  7730. ACMD_DEF(invite),
  7731. ACMD_DEF(duel),
  7732. ACMD_DEF(leave),
  7733. ACMD_DEF(accept),
  7734. ACMD_DEF(reject),
  7735. ACMD_DEF(main),
  7736. ACMD_DEF(clone),
  7737. ACMD_DEF2("slaveclone", clone),
  7738. ACMD_DEF2("evilclone", clone),
  7739. ACMD_DEF(tonpc),
  7740. ACMD_DEF(commands),
  7741. ACMD_DEF(noask),
  7742. ACMD_DEF(request),
  7743. ACMD_DEF(homlevel),
  7744. ACMD_DEF(homevolution),
  7745. ACMD_DEF(hommutate),
  7746. ACMD_DEF(makehomun),
  7747. ACMD_DEF(homfriendly),
  7748. ACMD_DEF(homhungry),
  7749. ACMD_DEF(homtalk),
  7750. ACMD_DEF(hominfo),
  7751. ACMD_DEF(homstats),
  7752. ACMD_DEF(homshuffle),
  7753. ACMD_DEF(showmobs),
  7754. ACMD_DEF(feelreset),
  7755. ACMD_DEF(auction),
  7756. ACMD_DEF(mail),
  7757. ACMD_DEF2("noks", ksprotection),
  7758. ACMD_DEF(allowks),
  7759. ACMD_DEF(cash),
  7760. ACMD_DEF2("points", cash),
  7761. ACMD_DEF(agitstart2),
  7762. ACMD_DEF(agitend2),
  7763. ACMD_DEF2("skreset", resetskill),
  7764. ACMD_DEF2("streset", resetstat),
  7765. ACMD_DEF2("storagelist", itemlist),
  7766. ACMD_DEF2("cartlist", itemlist),
  7767. ACMD_DEF2("itemlist", itemlist),
  7768. ACMD_DEF(stats),
  7769. ACMD_DEF(delitem),
  7770. ACMD_DEF(charcommands),
  7771. ACMD_DEF(font),
  7772. ACMD_DEF(accinfo),
  7773. ACMD_DEF(set),
  7774. ACMD_DEF(reloadquestdb),
  7775. ACMD_DEF(undisguiseguild),
  7776. ACMD_DEF(disguiseguild),
  7777. ACMD_DEF(sizeall),
  7778. ACMD_DEF(sizeguild),
  7779. ACMD_DEF(addperm),
  7780. ACMD_DEF2("rmvperm", addperm),
  7781. ACMD_DEF(unloadnpcfile),
  7782. ACMD_DEF(cart),
  7783. ACMD_DEF(mount2)
  7784. };
  7785. AtCommandInfo* atcommand;
  7786. int i;
  7787. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7788. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  7789. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  7790. continue;
  7791. }
  7792. CREATE(atcommand, AtCommandInfo, 1);
  7793. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  7794. atcommand->func = atcommand_base[i].func;
  7795. strdb_put(atcommand_db, atcommand->command, atcommand);
  7796. }
  7797. return;
  7798. }
  7799. /*==========================================
  7800. * Command lookup functions
  7801. *------------------------------------------*/
  7802. bool atcommand_exists(const char* name)
  7803. {
  7804. return strdb_exists(atcommand_db, name);
  7805. }
  7806. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  7807. {
  7808. if (strdb_exists(atcommand_db, name))
  7809. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7810. return NULL;
  7811. }
  7812. static const char* atcommand_checkalias(const char *aliasname)
  7813. {
  7814. AliasInfo *alias_info = NULL;
  7815. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  7816. return alias_info->command->command;
  7817. return aliasname;
  7818. }
  7819. /// AtCommand suggestion
  7820. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  7821. DBIterator* atcommand_iter;
  7822. DBIterator* alias_iter;
  7823. AtCommandInfo* command_info = NULL;
  7824. AliasInfo* alias_info = NULL;
  7825. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  7826. char* full_match[MAX_SUGGESTIONS];
  7827. char* suggestions[MAX_SUGGESTIONS];
  7828. char* match;
  7829. int prefix_count = 0, full_count = 0;
  7830. bool can_use;
  7831. if (!battle_config.atcommand_suggestions_enabled)
  7832. return;
  7833. atcommand_iter = db_iterator(atcommand_db);
  7834. alias_iter = db_iterator(atcommand_alias_db);
  7835. // Build the matches
  7836. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  7837. match = strstr(command_info->command, name);
  7838. can_use = pc_can_use_command(sd, command_info->command, type);
  7839. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  7840. suggestions[prefix_count] = command_info->command;
  7841. ++prefix_count;
  7842. }
  7843. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  7844. full_match[full_count] = command_info->command;
  7845. ++full_count;
  7846. }
  7847. }
  7848. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  7849. match = strstr(alias_info->alias, name);
  7850. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  7851. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  7852. suggestions[prefix_count] = alias_info->alias;
  7853. ++prefix_count;
  7854. }
  7855. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  7856. full_match[full_count] = alias_info->alias;
  7857. ++full_count;
  7858. }
  7859. }
  7860. if ((full_count+prefix_count) > 0) {
  7861. char buffer[512];
  7862. int i;
  7863. // Merge full match and prefix match results
  7864. if (prefix_count < MAX_SUGGESTIONS) {
  7865. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  7866. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  7867. }
  7868. // Build the suggestion string
  7869. strcpy(buffer, msg_txt(205));
  7870. strcat(buffer,"\n");
  7871. for(i=0; i < prefix_count; ++i) {
  7872. strcat(buffer,suggestions[i]);
  7873. strcat(buffer," ");
  7874. }
  7875. clif_displaymessage(sd->fd, buffer);
  7876. }
  7877. dbi_destroy(atcommand_iter);
  7878. dbi_destroy(alias_iter);
  7879. }
  7880. /// Executes an at-command.
  7881. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7882. {
  7883. char charname[NAME_LENGTH], params[100];
  7884. char charname2[NAME_LENGTH], params2[100];
  7885. char command[100];
  7886. char output[CHAT_SIZE_MAX];
  7887. //Reconstructed message
  7888. char atcmd_msg[CHAT_SIZE_MAX];
  7889. TBL_PC * ssd = NULL; //sd for target
  7890. AtCommandInfo * info;
  7891. nullpo_retr(false, sd);
  7892. //Shouldn't happen
  7893. if ( !message || !*message )
  7894. return false;
  7895. //Block NOCHAT but do not display it as a normal message
  7896. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7897. return true;
  7898. // skip 10/11-langtype's codepage indicator, if detected
  7899. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7900. message += 3;
  7901. //Should display as a normal message
  7902. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7903. return false;
  7904. // type value 0 = server invoked: bypass restrictions
  7905. // 1 = player invoked
  7906. if ( type == 1) {
  7907. //Commands are disabled on maps flagged as 'nocommand'
  7908. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  7909. clif_displaymessage(fd, msg_txt(143));
  7910. return false;
  7911. }
  7912. }
  7913. if (*message == charcommand_symbol) {
  7914. do {
  7915. int x, y, z;
  7916. //Checks to see if #command has a name or a name + parameters.
  7917. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7918. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7919. //z always has the value of the scan that was successful
  7920. z = ( x > 1 ) ? x : y;
  7921. //#command + name means the sufficient target was used and anything else after
  7922. //can be looked at by the actual command function since most scan to see if the
  7923. //right parameters are used.
  7924. if ( x > 2 ) {
  7925. sprintf(atcmd_msg, "%s %s", command, params);
  7926. break;
  7927. }
  7928. else if ( y > 2 ) {
  7929. sprintf(atcmd_msg, "%s %s", command, params2);
  7930. break;
  7931. }
  7932. //Regardless of what style the #command is used, if it's correct, it will always have
  7933. //this value if there is no parameter. Send it as just the #command
  7934. else if ( z == 2 ) {
  7935. sprintf(atcmd_msg, "%s", command);
  7936. break;
  7937. }
  7938. if( !pc_get_group_level(sd) ) {
  7939. if( x >= 1 || y >= 1 ) { /* we have command */
  7940. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  7941. 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 */
  7942. return false;
  7943. } else
  7944. return false;/* display as normal message */
  7945. }
  7946. sprintf(output, msg_txt(1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  7947. clif_displaymessage(fd, output);
  7948. return true;
  7949. } while(0);
  7950. }
  7951. else if (*message == atcommand_symbol) {
  7952. //atcmd_msg is constructed above differently for charcommands
  7953. //it's copied from message if not a charcommand so it can
  7954. //pass through the rest of the code compatible with both symbols
  7955. sprintf(atcmd_msg, "%s", message);
  7956. }
  7957. //Clearing these to be used once more.
  7958. memset(command, '\0', sizeof(command));
  7959. memset(params, '\0', sizeof(params));
  7960. //check to see if any params exist within this command
  7961. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7962. params[0] = '\0';
  7963. // @commands (script based)
  7964. if(type == 1 && atcmd_binding_count > 0) {
  7965. struct atcmd_binding_data * binding;
  7966. // Check if the command initiated is a character command
  7967. if (*message == charcommand_symbol &&
  7968. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  7969. sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
  7970. clif_displaymessage(fd, output);
  7971. return true;
  7972. }
  7973. // Get atcommand binding
  7974. binding = get_atcommandbind_byname(command);
  7975. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  7976. if( binding != NULL && binding->npc_event[0] &&
  7977. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  7978. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  7979. {
  7980. // Check if self or character invoking; if self == character invoked, then self invoke.
  7981. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  7982. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  7983. return true;
  7984. }
  7985. }
  7986. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7987. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  7988. if (info == NULL) {
  7989. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  7990. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7991. clif_displaymessage(fd, output);
  7992. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  7993. return true;
  7994. } else
  7995. return false;
  7996. }
  7997. // type == 1 : player invoked
  7998. if (type == 1) {
  7999. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8000. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8001. return false;
  8002. }
  8003. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8004. clif_displaymessage(fd, msg_txt(1393)); // You can't use commands while dead
  8005. return true;
  8006. }
  8007. }
  8008. // Check if target is valid only if confirmed that player can use command.
  8009. if (*message == charcommand_symbol &&
  8010. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8011. sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
  8012. clif_displaymessage(fd, output);
  8013. return true;
  8014. }
  8015. //Attempt to use the command
  8016. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8017. {
  8018. sprintf(output,msg_txt(154), command); // %s failed.
  8019. clif_displaymessage(fd, output);
  8020. return true;
  8021. }
  8022. //Log only if successful.
  8023. if ( *atcmd_msg == atcommand_symbol )
  8024. log_atcommand(sd, atcmd_msg);
  8025. else if ( *atcmd_msg == charcommand_symbol )
  8026. log_atcommand(sd, message);
  8027. return true;
  8028. }
  8029. /*==========================================
  8030. *
  8031. *------------------------------------------*/
  8032. static void atcommand_config_read(const char* config_filename)
  8033. {
  8034. config_setting_t *aliases = NULL, *help = NULL;
  8035. const char *symbol = NULL;
  8036. int num_aliases = 0;
  8037. if (conf_read_file(&atcommand_config, config_filename))
  8038. return;
  8039. // Command symbols
  8040. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8041. if (ISPRINT(*symbol) && // no control characters
  8042. *symbol != '/' && // symbol of client commands
  8043. *symbol != '%' && // symbol of party chat
  8044. *symbol != '$' && // symbol of guild chat
  8045. *symbol != charcommand_symbol)
  8046. atcommand_symbol = *symbol;
  8047. }
  8048. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8049. if (ISPRINT(*symbol) && // no control characters
  8050. *symbol != '/' && // symbol of client commands
  8051. *symbol != '%' && // symbol of party chat
  8052. *symbol != '$' && // symbol of guild chat
  8053. *symbol != atcommand_symbol)
  8054. charcommand_symbol = *symbol;
  8055. }
  8056. // Command aliases
  8057. aliases = config_lookup(&atcommand_config, "aliases");
  8058. if (aliases != NULL) {
  8059. int i = 0;
  8060. int count = config_setting_length(aliases);
  8061. for (i = 0; i < count; ++i) {
  8062. config_setting_t *command = NULL;
  8063. const char *commandname = NULL;
  8064. int j = 0, alias_count = 0;
  8065. AtCommandInfo *commandinfo = NULL;
  8066. command = config_setting_get_elem(aliases, i);
  8067. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8068. continue;
  8069. commandname = config_setting_name(command);
  8070. if (!atcommand_exists(commandname)) {
  8071. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8072. continue;
  8073. }
  8074. commandinfo = get_atcommandinfo_byname(commandname);
  8075. alias_count = config_setting_length(command);
  8076. for (j = 0; j < alias_count; ++j) {
  8077. const char *alias = config_setting_get_string_elem(command, j);
  8078. if (alias != NULL) {
  8079. AliasInfo *alias_info;
  8080. if (strdb_exists(atcommand_alias_db, alias)) {
  8081. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8082. continue;
  8083. }
  8084. CREATE(alias_info, AliasInfo, 1);
  8085. alias_info->command = commandinfo;
  8086. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8087. strdb_put(atcommand_alias_db, alias, alias_info);
  8088. ++num_aliases;
  8089. }
  8090. }
  8091. }
  8092. }
  8093. // Commands help
  8094. // We only check if all commands exist
  8095. help = config_lookup(&atcommand_config, "help");
  8096. if (help != NULL) {
  8097. int count = config_setting_length(help);
  8098. int i;
  8099. for (i = 0; i < count; ++i) {
  8100. config_setting_t *command = NULL;
  8101. const char *commandname = NULL;
  8102. command = config_setting_get_elem(help, i);
  8103. commandname = config_setting_name(command);
  8104. if (!atcommand_exists(commandname))
  8105. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8106. }
  8107. }
  8108. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8109. return;
  8110. }
  8111. void atcommand_db_load_groups(int* group_ids) {
  8112. DBIterator *iter = db_iterator(atcommand_db);
  8113. AtCommandInfo* cmd;
  8114. int i;
  8115. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8116. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8117. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8118. for(i = 0; i < pc_group_max; i++) {
  8119. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8120. cmd->at_groups[i] = 1;
  8121. else
  8122. cmd->at_groups[i] = 0;
  8123. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8124. cmd->char_groups[i] = 1;
  8125. else
  8126. cmd->char_groups[i] = 0;
  8127. }
  8128. }
  8129. dbi_destroy(iter);
  8130. return;
  8131. }
  8132. void atcommand_db_clear(void) {
  8133. if (atcommand_db != NULL) {
  8134. DBIterator *iter = db_iterator(atcommand_db);
  8135. AtCommandInfo* cmd;
  8136. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8137. aFree(cmd->at_groups);
  8138. aFree(cmd->char_groups);
  8139. }
  8140. dbi_destroy(iter);
  8141. db_destroy(atcommand_db);
  8142. }
  8143. if (atcommand_alias_db != NULL)
  8144. db_destroy(atcommand_alias_db);
  8145. config_destroy(&atcommand_config);
  8146. }
  8147. void atcommand_doload(void) {
  8148. atcommand_db_clear();
  8149. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8150. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8151. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8152. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8153. }
  8154. void do_init_atcommand(void) {
  8155. atcommand_doload();
  8156. }
  8157. void do_final_atcommand(void) {
  8158. atcommand_db_clear();
  8159. }