atcommand.c 275 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436
  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/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "atcommand.h"
  14. #include "battle.h"
  15. #include "chat.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "duel.h"
  19. #include "intif.h"
  20. #include "itemdb.h"
  21. #include "log.h"
  22. #include "map.h"
  23. #include "pc.h"
  24. #include "status.h"
  25. #include "skill.h"
  26. #include "mob.h"
  27. #include "npc.h"
  28. #include "pet.h"
  29. #include "homunculus.h"
  30. #include "mercenary.h"
  31. #include "party.h"
  32. #include "guild.h"
  33. #include "script.h"
  34. #include "trade.h"
  35. #include "unit.h"
  36. #ifndef TXT_ONLY
  37. #include "mail.h"
  38. #endif
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include <math.h>
  43. // extern variables
  44. char atcommand_symbol = '@'; // first char of the commands
  45. char charcommand_symbol = '#';
  46. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  47. // local declarations
  48. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  49. DBMap* atcommand_db = NULL;//name -> AtCommandInfo
  50. #define ATCOMMAND_LENGTH 50
  51. typedef struct AtCommandInfo {
  52. char command[ATCOMMAND_LENGTH];
  53. int level;
  54. int level2;
  55. AtCommandFunc func;
  56. } AtCommandInfo;
  57. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  58. ACMD_FUNC(commands);
  59. /*=========================================
  60. * Generic variables
  61. *-----------------------------------------*/
  62. char atcmd_output[CHAT_SIZE_MAX];
  63. char atcmd_player_name[NAME_LENGTH];
  64. char atcmd_temp[100];
  65. // compare function for sorting high to lowest
  66. int hightolow_compare (const void * a, const void * b)
  67. {
  68. return ( *(int*)b - *(int*)a );
  69. }
  70. // compare function for sorting lowest to highest
  71. int lowtohigh_compare (const void * a, const void * b)
  72. {
  73. return ( *(int*)a - *(int*)b );
  74. }
  75. //-----------------------------------------------------------
  76. // Return the message string of the specified number by [Yor]
  77. //-----------------------------------------------------------
  78. const char* msg_txt(int msg_number)
  79. {
  80. if (msg_number >= 0 && msg_number < MAX_MSG &&
  81. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  82. return msg_table[msg_number];
  83. return "??";
  84. }
  85. //-----------------------------------------------------------
  86. // Returns Players title (from msg_athena.conf) [Lupus]
  87. //-----------------------------------------------------------
  88. static char* player_title_txt(int level)
  89. {
  90. const char* format;
  91. format = (level >= battle_config.title_lvl8) ? msg_txt(342)
  92. : (level >= battle_config.title_lvl7) ? msg_txt(341)
  93. : (level >= battle_config.title_lvl6) ? msg_txt(340)
  94. : (level >= battle_config.title_lvl5) ? msg_txt(339)
  95. : (level >= battle_config.title_lvl4) ? msg_txt(338)
  96. : (level >= battle_config.title_lvl3) ? msg_txt(337)
  97. : (level >= battle_config.title_lvl2) ? msg_txt(336)
  98. : (level >= battle_config.title_lvl1) ? msg_txt(335)
  99. : "";
  100. sprintf(atcmd_temp, format, level);
  101. return atcmd_temp;
  102. }
  103. /*==========================================
  104. * Read Message Data
  105. *------------------------------------------*/
  106. int msg_config_read(const char* cfgName)
  107. {
  108. int msg_number;
  109. char line[1024], w1[1024], w2[1024];
  110. FILE *fp;
  111. static int called = 1;
  112. if ((fp = fopen(cfgName, "r")) == NULL) {
  113. ShowError("Messages file not found: %s\n", cfgName);
  114. return 1;
  115. }
  116. if ((--called) == 0)
  117. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  118. while(fgets(line, sizeof(line), fp))
  119. {
  120. if (line[0] == '/' && line[1] == '/')
  121. continue;
  122. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  123. continue;
  124. if (strcmpi(w1, "import") == 0)
  125. msg_config_read(w2);
  126. else
  127. {
  128. msg_number = atoi(w1);
  129. if (msg_number >= 0 && msg_number < MAX_MSG)
  130. {
  131. if (msg_table[msg_number] != NULL)
  132. aFree(msg_table[msg_number]);
  133. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  134. strcpy(msg_table[msg_number],w2);
  135. }
  136. }
  137. }
  138. fclose(fp);
  139. return 0;
  140. }
  141. /*==========================================
  142. * Cleanup Message Data
  143. *------------------------------------------*/
  144. void do_final_msg(void)
  145. {
  146. int i;
  147. for (i = 0; i < MAX_MSG; i++)
  148. aFree(msg_table[i]);
  149. }
  150. /*==========================================
  151. * @send (used for testing packet sends from the client)
  152. *------------------------------------------*/
  153. ACMD_FUNC(send)
  154. {
  155. int len=0,off,end,type;
  156. long num;
  157. (void)command; // not used
  158. // read message type as hex number (without the 0x)
  159. if(!message || !*message ||
  160. !((sscanf(message, "len %x", &type)==1 && (len=1))
  161. || sscanf(message, "%x", &type)==1) )
  162. {
  163. clif_displaymessage(fd, "Usage:");
  164. clif_displaymessage(fd, " @send len <packet hex number>");
  165. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  166. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  167. return -1;
  168. }
  169. #define PARSE_ERROR(error,p) \
  170. {\
  171. clif_displaymessage(fd, (error));\
  172. sprintf(atcmd_output, ">%s", (p));\
  173. clif_displaymessage(fd, atcmd_output);\
  174. }
  175. //define PARSE_ERROR
  176. #define CHECK_EOS(p) \
  177. if(*(p) == 0){\
  178. clif_displaymessage(fd, "Unexpected end of string");\
  179. return -1;\
  180. }
  181. //define CHECK_EOS
  182. #define SKIP_VALUE(p) \
  183. {\
  184. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  185. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  186. }
  187. //define SKIP_VALUE
  188. #define GET_VALUE(p,num) \
  189. {\
  190. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  191. PARSE_ERROR("Invalid number in:",(p));\
  192. return -1;\
  193. }\
  194. }
  195. //define GET_VALUE
  196. if (type > 0 && type < MAX_PACKET_DB) {
  197. if(len)
  198. {// show packet length
  199. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  200. clif_displaymessage(fd, atcmd_output);
  201. return 0;
  202. }
  203. len=packet_db[sd->packet_ver][type].len;
  204. off=2;
  205. if(len == 0)
  206. {// unknown packet - ERROR
  207. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  208. clif_displaymessage(fd, atcmd_output);
  209. return -1;
  210. } else if(len == -1)
  211. {// dynamic packet
  212. len=SHRT_MAX-4; // maximum length
  213. off=4;
  214. }
  215. WFIFOHEAD(fd, len);
  216. WFIFOW(fd,0)=TOW(type);
  217. // parse packet contents
  218. SKIP_VALUE(message);
  219. while(*message != 0 && off < len){
  220. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  221. {// default (byte)
  222. GET_VALUE(message,num);
  223. WFIFOB(fd,off)=TOB(num);
  224. ++off;
  225. } else if(TOUPPER(*message) == 'B')
  226. {// byte
  227. ++message;
  228. GET_VALUE(message,num);
  229. WFIFOB(fd,off)=TOB(num);
  230. ++off;
  231. } else if(TOUPPER(*message) == 'W')
  232. {// word (2 bytes)
  233. ++message;
  234. GET_VALUE(message,num);
  235. WFIFOW(fd,off)=TOW(num);
  236. off+=2;
  237. } else if(TOUPPER(*message) == 'L')
  238. {// long word (4 bytes)
  239. ++message;
  240. GET_VALUE(message,num);
  241. WFIFOL(fd,off)=TOL(num);
  242. off+=4;
  243. } else if(TOUPPER(*message) == 'S')
  244. {// string - escapes are valid
  245. // get string length - num <= 0 means not fixed length (default)
  246. ++message;
  247. if(*message == '"'){
  248. num=0;
  249. } else {
  250. GET_VALUE(message,num);
  251. while(*message != '"')
  252. {// find start of string
  253. if(*message == 0 || ISSPACE(*message)){
  254. PARSE_ERROR("Not a string:",message);
  255. return -1;
  256. }
  257. ++message;
  258. }
  259. }
  260. // parse string
  261. ++message;
  262. CHECK_EOS(message);
  263. end=(num<=0? 0: min(off+((int)num),len));
  264. for(; *message != '"' && (off < end || end == 0); ++off){
  265. if(*message == '\\'){
  266. ++message;
  267. CHECK_EOS(message);
  268. switch(*message){
  269. case 'a': num=0x07; break; // Bell
  270. case 'b': num=0x08; break; // Backspace
  271. case 't': num=0x09; break; // Horizontal tab
  272. case 'n': num=0x0A; break; // Line feed
  273. case 'v': num=0x0B; break; // Vertical tab
  274. case 'f': num=0x0C; break; // Form feed
  275. case 'r': num=0x0D; break; // Carriage return
  276. case 'e': num=0x1B; break; // Escape
  277. default: num=*message; break;
  278. case 'x': // Hexadecimal
  279. {
  280. ++message;
  281. CHECK_EOS(message);
  282. if(!ISXDIGIT(*message)){
  283. PARSE_ERROR("Not a hexadecimal digit:",message);
  284. return -1;
  285. }
  286. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  287. if(ISXDIGIT(*message)){
  288. ++message;
  289. CHECK_EOS(message);
  290. num<<=8;
  291. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  292. }
  293. WFIFOB(fd,off)=TOB(num);
  294. ++message;
  295. CHECK_EOS(message);
  296. continue;
  297. }
  298. case '0':
  299. case '1':
  300. case '2':
  301. case '3':
  302. case '4':
  303. case '5':
  304. case '6':
  305. case '7': // Octal
  306. {
  307. num=*message-'0'; // 1st octal digit
  308. ++message;
  309. CHECK_EOS(message);
  310. if(ISDIGIT(*message) && *message < '8'){
  311. num<<=3;
  312. num+=*message-'0'; // 2nd octal digit
  313. ++message;
  314. CHECK_EOS(message);
  315. if(ISDIGIT(*message) && *message < '8'){
  316. num<<=3;
  317. num+=*message-'0'; // 3rd octal digit
  318. ++message;
  319. CHECK_EOS(message);
  320. }
  321. }
  322. WFIFOB(fd,off)=TOB(num);
  323. continue;
  324. }
  325. }
  326. } else
  327. num=*message;
  328. WFIFOB(fd,off)=TOB(num);
  329. ++message;
  330. CHECK_EOS(message);
  331. }//for
  332. while(*message != '"')
  333. {// ignore extra characters
  334. ++message;
  335. CHECK_EOS(message);
  336. }
  337. // terminate the string
  338. if(off < end)
  339. {// fill the rest with 0's
  340. memset(WFIFOP(fd,off),0,end-off);
  341. off=end;
  342. }
  343. } else
  344. {// unknown
  345. PARSE_ERROR("Unknown type of value in:",message);
  346. return -1;
  347. }
  348. SKIP_VALUE(message);
  349. }
  350. if(packet_db[sd->packet_ver][type].len == -1)
  351. {// send dynamic packet
  352. WFIFOW(fd,2)=TOW(off);
  353. WFIFOSET(fd,off);
  354. } else
  355. {// send static packet
  356. if(off < len)
  357. memset(WFIFOP(fd,off),0,len-off);
  358. WFIFOSET(fd,len);
  359. }
  360. } else {
  361. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  362. return -1;
  363. }
  364. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  365. clif_displaymessage(fd, atcmd_output);
  366. return 0;
  367. #undef PARSE_ERROR
  368. #undef CHECK_EOS
  369. #undef SKIP_VALUE
  370. #undef GET_VALUE
  371. }
  372. /*==========================================
  373. * @rura, @warp, @mapmove
  374. *------------------------------------------*/
  375. ACMD_FUNC(mapmove)
  376. {
  377. char map_name[MAP_NAME_LENGTH_EXT];
  378. unsigned short mapindex;
  379. short x = 0, y = 0;
  380. int m = -1;
  381. nullpo_retr(-1, sd);
  382. memset(map_name, '\0', sizeof(map_name));
  383. if (!message || !*message ||
  384. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  385. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  386. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  387. return -1;
  388. }
  389. mapindex = mapindex_name2id(map_name);
  390. if (mapindex)
  391. m = map_mapindex2mapid(mapindex);
  392. if (!mapindex) { // m < 0 means on different server! [Kevin]
  393. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  394. return -1;
  395. }
  396. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  397. { //This is to prevent the pc_setpos call from printing an error.
  398. clif_displaymessage(fd, msg_txt(2));
  399. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  400. x = y = 0; //Invalid cell, use random spot.
  401. }
  402. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  403. clif_displaymessage(fd, msg_txt(247));
  404. return -1;
  405. }
  406. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  407. clif_displaymessage(fd, msg_txt(248));
  408. return -1;
  409. }
  410. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  411. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  412. return -1;
  413. }
  414. clif_displaymessage(fd, msg_txt(0)); // Warped.
  415. return 0;
  416. }
  417. /*==========================================
  418. * Displays where a character is. Corrected version by Silent. [Skotlex]
  419. *------------------------------------------*/
  420. ACMD_FUNC(where)
  421. {
  422. struct map_session_data* pl_sd;
  423. nullpo_retr(-1, sd);
  424. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  425. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  426. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  427. return -1;
  428. }
  429. pl_sd = map_nick2sd(atcmd_player_name);
  430. if( pl_sd == NULL
  431. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  432. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  433. ) {
  434. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  435. return -1;
  436. }
  437. 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);
  438. clif_displaymessage(fd, atcmd_output);
  439. return 0;
  440. }
  441. /*==========================================
  442. *
  443. *------------------------------------------*/
  444. ACMD_FUNC(jumpto)
  445. {
  446. struct map_session_data *pl_sd = NULL;
  447. nullpo_retr(-1, sd);
  448. if (!message || !*message) {
  449. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  450. return -1;
  451. }
  452. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  453. {
  454. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  455. return -1;
  456. }
  457. if (pl_sd == sd)
  458. {
  459. clif_displaymessage(fd, "But you are already where you are...");
  460. return -1;
  461. }
  462. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  463. {
  464. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  465. return -1;
  466. }
  467. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  468. {
  469. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  470. return -1;
  471. }
  472. if( pc_isdead(sd) )
  473. {
  474. clif_displaymessage(fd, "You cannot use this command when dead.");
  475. return -1;
  476. }
  477. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  478. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  479. clif_displaymessage(fd, atcmd_output);
  480. return 0;
  481. }
  482. /*==========================================
  483. *
  484. *------------------------------------------*/
  485. ACMD_FUNC(jump)
  486. {
  487. short x = 0, y = 0;
  488. nullpo_retr(-1, sd);
  489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  490. sscanf(message, "%hd %hd", &x, &y);
  491. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  492. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  493. return -1;
  494. }
  495. if( pc_isdead(sd) )
  496. {
  497. clif_displaymessage(fd, "You cannot use this command when dead.");
  498. return -1;
  499. }
  500. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  501. { //This is to prevent the pc_setpos call from printing an error.
  502. clif_displaymessage(fd, msg_txt(2));
  503. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  504. x = y = 0; //Invalid cell, use random spot.
  505. }
  506. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  507. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  508. clif_displaymessage(fd, atcmd_output);
  509. return 0;
  510. }
  511. /*==========================================
  512. * @who3 = Player name, his location
  513. *------------------------------------------*/
  514. ACMD_FUNC(who3)
  515. {
  516. char temp0[100];
  517. struct map_session_data *pl_sd;
  518. struct s_mapiterator* iter;
  519. int j, count;
  520. int pl_GM_level, GM_level;
  521. char match_text[100];
  522. char player_name[NAME_LENGTH];
  523. nullpo_retr(-1, sd);
  524. memset(atcmd_output, '\0', sizeof(atcmd_output));
  525. memset(match_text, '\0', sizeof(match_text));
  526. memset(player_name, '\0', sizeof(player_name));
  527. if (sscanf(message, "%99[^\n]", match_text) < 1)
  528. strcpy(match_text, "");
  529. for (j = 0; match_text[j]; j++)
  530. match_text[j] = TOLOWER(match_text[j]);
  531. count = 0;
  532. GM_level = pc_isGM(sd);
  533. iter = mapit_getallusers();
  534. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  535. {
  536. pl_GM_level = pc_isGM(pl_sd);
  537. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  538. {// you can look only lower or same level
  539. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  540. for (j = 0; player_name[j]; j++)
  541. player_name[j] = TOLOWER(player_name[j]);
  542. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  543. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  544. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  545. } else {
  546. atcmd_output[0]=0;
  547. }
  548. //Player name
  549. sprintf(temp0, msg_txt(343), pl_sd->status.name);
  550. strcat(atcmd_output,temp0);
  551. //Player title, if exists
  552. if (pl_GM_level > 0) {
  553. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  554. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  555. strcat(atcmd_output,temp0);
  556. }
  557. //Players Location: map x y
  558. sprintf(temp0, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  559. strcat(atcmd_output,temp0);
  560. clif_displaymessage(fd, atcmd_output);
  561. count++;
  562. }
  563. }
  564. }
  565. mapit_free(iter);
  566. if (count == 0)
  567. clif_displaymessage(fd, msg_txt(28)); // No player found.
  568. else if (count == 1)
  569. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  570. else {
  571. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  572. clif_displaymessage(fd, atcmd_output);
  573. }
  574. return 0;
  575. }
  576. /*==========================================
  577. * Player name, BLevel, Job,
  578. *------------------------------------------*/
  579. ACMD_FUNC(who2)
  580. {
  581. char temp0[100];
  582. struct map_session_data *pl_sd;
  583. struct s_mapiterator* iter;
  584. int j, count;
  585. int pl_GM_level, GM_level;
  586. char match_text[100];
  587. char player_name[NAME_LENGTH];
  588. nullpo_retr(-1, sd);
  589. memset(atcmd_output, '\0', sizeof(atcmd_output));
  590. memset(match_text, '\0', sizeof(match_text));
  591. memset(player_name, '\0', sizeof(player_name));
  592. if (sscanf(message, "%99[^\n]", match_text) < 1)
  593. strcpy(match_text, "");
  594. for (j = 0; match_text[j]; j++)
  595. match_text[j] = TOLOWER(match_text[j]);
  596. count = 0;
  597. GM_level = pc_isGM(sd);
  598. iter = mapit_getallusers();
  599. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  600. {
  601. pl_GM_level = pc_isGM(pl_sd);
  602. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  603. {// you can look only lower or same level
  604. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  605. for (j = 0; player_name[j]; j++)
  606. player_name[j] = TOLOWER(player_name[j]);
  607. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  608. //Players Name
  609. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  610. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  611. //Player title, if exists
  612. if (pl_GM_level > 0) {
  613. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  614. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  615. strcat(atcmd_output,temp0);
  616. }
  617. //Players Base Level / Job name
  618. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  619. sprintf(temp0, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  620. strcat(atcmd_output,temp0);
  621. clif_displaymessage(fd, atcmd_output);
  622. count++;
  623. }
  624. }
  625. }
  626. mapit_free(iter);
  627. if (count == 0)
  628. clif_displaymessage(fd, msg_txt(28)); // No player found.
  629. else if (count == 1)
  630. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  631. else {
  632. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  633. clif_displaymessage(fd, atcmd_output);
  634. }
  635. return 0;
  636. }
  637. /*==========================================
  638. * Player name, Playrs Party / Guild name
  639. *------------------------------------------*/
  640. ACMD_FUNC(who)
  641. {
  642. char temp0[100];
  643. struct map_session_data *pl_sd;
  644. struct s_mapiterator* iter;
  645. int j, count;
  646. int pl_GM_level, GM_level;
  647. char match_text[100];
  648. char player_name[NAME_LENGTH];
  649. struct guild *g;
  650. struct party_data *p;
  651. nullpo_retr(-1, sd);
  652. memset(temp0, '\0', sizeof(temp0));
  653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  654. memset(match_text, '\0', sizeof(match_text));
  655. memset(player_name, '\0', sizeof(player_name));
  656. if (sscanf(message, "%99[^\n]", match_text) < 1)
  657. strcpy(match_text, "");
  658. for (j = 0; match_text[j]; j++)
  659. match_text[j] = TOLOWER(match_text[j]);
  660. count = 0;
  661. GM_level = pc_isGM(sd);
  662. iter = mapit_getallusers();
  663. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  664. {
  665. pl_GM_level = pc_isGM(pl_sd);
  666. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  667. {// you can look only lower or same level
  668. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  669. for (j = 0; player_name[j]; j++)
  670. player_name[j] = TOLOWER(player_name[j]);
  671. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  672. g = guild_search(pl_sd->status.guild_id);
  673. p = party_search(pl_sd->status.party_id);
  674. //Players Name
  675. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  676. //Player title, if exists
  677. if (pl_GM_level > 0) {
  678. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  679. strcat(atcmd_output,temp0);
  680. }
  681. //Players Party if exists
  682. if (p != NULL) {
  683. //sprintf(temp0," | Party: '%s'", p->name);
  684. sprintf(temp0, msg_txt(345), p->party.name);
  685. strcat(atcmd_output,temp0);
  686. }
  687. //Players Guild if exists
  688. if (g != NULL) {
  689. //sprintf(temp0," | Guild: '%s'", g->name);
  690. sprintf(temp0, msg_txt(346), g->name);
  691. strcat(atcmd_output,temp0);
  692. }
  693. clif_displaymessage(fd, atcmd_output);
  694. count++;
  695. }
  696. }
  697. }
  698. mapit_free(iter);
  699. if (count == 0)
  700. clif_displaymessage(fd, msg_txt(28)); // No player found.
  701. else if (count == 1)
  702. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  703. else {
  704. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  705. clif_displaymessage(fd, atcmd_output);
  706. }
  707. return 0;
  708. }
  709. /*==========================================
  710. *
  711. *------------------------------------------*/
  712. ACMD_FUNC(whomap3)
  713. {
  714. struct map_session_data *pl_sd;
  715. struct s_mapiterator* iter;
  716. int count;
  717. int pl_GM_level, GM_level;
  718. int map_id;
  719. char map_name[MAP_NAME_LENGTH_EXT];
  720. memset(atcmd_output, '\0', sizeof(atcmd_output));
  721. memset(map_name, '\0', sizeof(map_name));
  722. if (!message || !*message)
  723. map_id = sd->bl.m;
  724. else {
  725. sscanf(message, "%15s", map_name);
  726. if ((map_id = map_mapname2mapid(map_name)) < 0)
  727. map_id = sd->bl.m;
  728. }
  729. count = 0;
  730. GM_level = pc_isGM(sd);
  731. iter = mapit_getallusers();
  732. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  733. {
  734. pl_GM_level = pc_isGM(pl_sd);
  735. if( pl_sd->bl.m != map_id )
  736. continue;
  737. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  738. continue;
  739. if (pl_GM_level > 0)
  740. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  741. else
  742. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  743. clif_displaymessage(fd, atcmd_output);
  744. count++;
  745. }
  746. mapit_free(iter);
  747. if (count == 0)
  748. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  749. else if (count == 1)
  750. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  751. else {
  752. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  753. }
  754. clif_displaymessage(fd, atcmd_output);
  755. return 0;
  756. }
  757. /*==========================================
  758. *
  759. *------------------------------------------*/
  760. ACMD_FUNC(whomap2)
  761. {
  762. struct map_session_data *pl_sd;
  763. struct s_mapiterator* iter;
  764. int count;
  765. int pl_GM_level, GM_level;
  766. int map_id = 0;
  767. char map_name[MAP_NAME_LENGTH_EXT];
  768. nullpo_retr(-1, sd);
  769. memset(atcmd_output, '\0', sizeof(atcmd_output));
  770. memset(map_name, '\0', sizeof(map_name));
  771. if (!message || !*message)
  772. map_id = sd->bl.m;
  773. else {
  774. sscanf(message, "%15s", map_name);
  775. if ((map_id = map_mapname2mapid(map_name)) < 0)
  776. map_id = sd->bl.m;
  777. }
  778. count = 0;
  779. GM_level = pc_isGM(sd);
  780. iter = mapit_getallusers();
  781. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  782. {
  783. pl_GM_level = pc_isGM(pl_sd);
  784. if( pl_sd->bl.m != map_id )
  785. continue;
  786. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  787. continue;
  788. if (pl_GM_level > 0)
  789. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  790. else
  791. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  792. clif_displaymessage(fd, atcmd_output);
  793. count++;
  794. }
  795. mapit_free(iter);
  796. if (count == 0)
  797. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  798. else if (count == 1)
  799. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  800. else {
  801. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  802. }
  803. clif_displaymessage(fd, atcmd_output);
  804. return 0;
  805. }
  806. /*==========================================
  807. *
  808. *------------------------------------------*/
  809. ACMD_FUNC(whomap)
  810. {
  811. char temp0[100];
  812. char temp1[100];
  813. struct map_session_data *pl_sd;
  814. struct s_mapiterator* iter;
  815. int count;
  816. int pl_GM_level, GM_level;
  817. int map_id = 0;
  818. char map_name[MAP_NAME_LENGTH_EXT];
  819. struct guild *g;
  820. struct party_data *p;
  821. nullpo_retr(-1, sd);
  822. memset(temp0, '\0', sizeof(temp0));
  823. memset(temp1, '\0', sizeof(temp1));
  824. memset(atcmd_output, '\0', sizeof(atcmd_output));
  825. memset(map_name, '\0', sizeof(map_name));
  826. if (!message || !*message)
  827. map_id = sd->bl.m;
  828. else {
  829. sscanf(message, "%15s", map_name);
  830. if ((map_id = map_mapname2mapid(map_name)) < 0)
  831. map_id = sd->bl.m;
  832. }
  833. count = 0;
  834. GM_level = pc_isGM(sd);
  835. iter = mapit_getallusers();
  836. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  837. {
  838. pl_GM_level = pc_isGM(pl_sd);
  839. if( pl_sd->bl.m != map_id )
  840. continue;
  841. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  842. continue;
  843. g = guild_search(pl_sd->status.guild_id);
  844. if (g == NULL)
  845. sprintf(temp1, "None");
  846. else
  847. sprintf(temp1, "%s", g->name);
  848. p = party_search(pl_sd->status.party_id);
  849. if (p == NULL)
  850. sprintf(temp0, "None");
  851. else
  852. sprintf(temp0, "%s", p->party.name);
  853. if (pl_GM_level > 0)
  854. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  855. else
  856. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  857. clif_displaymessage(fd, atcmd_output);
  858. count++;
  859. }
  860. mapit_free(iter);
  861. if (count == 0)
  862. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  863. else if (count == 1)
  864. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  865. else {
  866. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  867. }
  868. clif_displaymessage(fd, atcmd_output);
  869. return 0;
  870. }
  871. /*==========================================
  872. *
  873. *------------------------------------------*/
  874. ACMD_FUNC(whogm)
  875. {
  876. struct map_session_data* pl_sd;
  877. struct s_mapiterator* iter;
  878. int j, count;
  879. int pl_GM_level, GM_level;
  880. char match_text[CHAT_SIZE_MAX];
  881. char player_name[NAME_LENGTH];
  882. struct guild *g;
  883. struct party_data *p;
  884. nullpo_retr(-1, sd);
  885. memset(atcmd_output, '\0', sizeof(atcmd_output));
  886. memset(match_text, '\0', sizeof(match_text));
  887. memset(player_name, '\0', sizeof(player_name));
  888. if (sscanf(message, "%199[^\n]", match_text) < 1)
  889. strcpy(match_text, "");
  890. for (j = 0; match_text[j]; j++)
  891. match_text[j] = TOLOWER(match_text[j]);
  892. count = 0;
  893. GM_level = pc_isGM(sd);
  894. iter = mapit_getallusers();
  895. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  896. {
  897. pl_GM_level = pc_isGM(pl_sd);
  898. if (!pl_GM_level)
  899. continue;
  900. if (match_text[0])
  901. {
  902. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  903. for (j = 0; player_name[j]; j++)
  904. player_name[j] = TOLOWER(player_name[j]);
  905. // search with no case sensitive
  906. if (strstr(player_name, match_text) == NULL)
  907. continue;
  908. }
  909. if (pl_GM_level > GM_level) {
  910. if (pl_sd->sc.option & OPTION_INVISIBLE)
  911. continue;
  912. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  913. clif_displaymessage(fd, atcmd_output);
  914. count++;
  915. continue;
  916. }
  917. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  918. pl_sd->status.name, pl_GM_level,
  919. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  920. clif_displaymessage(fd, atcmd_output);
  921. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  922. pl_sd->status.base_level,
  923. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  924. clif_displaymessage(fd, atcmd_output);
  925. p = party_search(pl_sd->status.party_id);
  926. g = guild_search(pl_sd->status.guild_id);
  927. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  928. p?p->party.name:"None", g?g->name:"None");
  929. clif_displaymessage(fd, atcmd_output);
  930. count++;
  931. }
  932. mapit_free(iter);
  933. if (count == 0)
  934. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  935. else if (count == 1)
  936. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  937. else {
  938. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  939. clif_displaymessage(fd, atcmd_output);
  940. }
  941. return 0;
  942. }
  943. /*==========================================
  944. *
  945. *------------------------------------------*/
  946. ACMD_FUNC(save)
  947. {
  948. nullpo_retr(-1, sd);
  949. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  950. if (sd->status.pet_id > 0 && sd->pd)
  951. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  952. chrif_save(sd,0);
  953. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  954. return 0;
  955. }
  956. /*==========================================
  957. *
  958. *------------------------------------------*/
  959. ACMD_FUNC(load)
  960. {
  961. int m;
  962. nullpo_retr(-1, sd);
  963. m = map_mapindex2mapid(sd->status.save_point.map);
  964. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  965. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  966. return -1;
  967. }
  968. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  969. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  970. return -1;
  971. }
  972. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  973. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  974. return 0;
  975. }
  976. /*==========================================
  977. *
  978. *------------------------------------------*/
  979. ACMD_FUNC(speed)
  980. {
  981. int speed;
  982. nullpo_retr(-1, sd);
  983. memset(atcmd_output, '\0', sizeof(atcmd_output));
  984. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  985. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  986. clif_displaymessage(fd, atcmd_output);
  987. return -1;
  988. }
  989. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  990. status_calc_bl(&sd->bl, SCB_SPEED);
  991. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  992. return 0;
  993. }
  994. /*==========================================
  995. *
  996. *------------------------------------------*/
  997. ACMD_FUNC(storage)
  998. {
  999. nullpo_retr(-1, sd);
  1000. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  1001. return -1;
  1002. if (storage_storageopen(sd) == 1)
  1003. { //Already open.
  1004. clif_displaymessage(fd, msg_txt(250));
  1005. return -1;
  1006. }
  1007. clif_displaymessage(fd, "Storage opened.");
  1008. return 0;
  1009. }
  1010. /*==========================================
  1011. *
  1012. *------------------------------------------*/
  1013. ACMD_FUNC(guildstorage)
  1014. {
  1015. nullpo_retr(-1, sd);
  1016. if (!sd->status.guild_id) {
  1017. clif_displaymessage(fd, msg_txt(252));
  1018. return -1;
  1019. }
  1020. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  1021. return -1;
  1022. if (sd->state.storage_flag == 1) {
  1023. clif_displaymessage(fd, msg_txt(250));
  1024. return -1;
  1025. }
  1026. if (sd->state.storage_flag == 2) {
  1027. clif_displaymessage(fd, msg_txt(251));
  1028. return -1;
  1029. }
  1030. storage_guild_storageopen(sd);
  1031. clif_displaymessage(fd, "Guild storage opened.");
  1032. return 0;
  1033. }
  1034. /*==========================================
  1035. *
  1036. *------------------------------------------*/
  1037. ACMD_FUNC(option)
  1038. {
  1039. int param1 = 0, param2 = 0, param3 = 0;
  1040. nullpo_retr(-1, sd);
  1041. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1042. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1043. return -1;
  1044. }
  1045. sd->sc.opt1 = param1;
  1046. sd->sc.opt2 = param2;
  1047. pc_setoption(sd, param3);
  1048. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1049. return 0;
  1050. }
  1051. /*==========================================
  1052. *
  1053. *------------------------------------------*/
  1054. ACMD_FUNC(hide)
  1055. {
  1056. nullpo_retr(-1, sd);
  1057. if (sd->sc.option & OPTION_INVISIBLE) {
  1058. sd->sc.option &= ~OPTION_INVISIBLE;
  1059. if (sd->disguise)
  1060. status_set_viewdata(&sd->bl, sd->disguise);
  1061. else
  1062. status_set_viewdata(&sd->bl, sd->status.class_);
  1063. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1064. if( map[sd->bl.m].flag.pvp )
  1065. {// increment the number of pvp players on the map
  1066. map[sd->bl.m].users_pvp++;
  1067. if( !map[sd->bl.m].flag.pvp_nocalcrank )
  1068. {// register the player for ranking calculations
  1069. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  1070. }
  1071. }
  1072. //bugreport:2266
  1073. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  1074. } else {
  1075. sd->sc.option |= OPTION_INVISIBLE;
  1076. sd->vd.class_ = INVISIBLE_CLASS;
  1077. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1078. if( map[sd->bl.m].flag.pvp )
  1079. {// decrement the number of pvp players on the map
  1080. map[sd->bl.m].users_pvp--;
  1081. if( !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  1082. {// unregister the player for ranking
  1083. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  1084. sd->pvp_timer = INVALID_TIMER;
  1085. }
  1086. }
  1087. }
  1088. clif_changeoption(&sd->bl);
  1089. return 0;
  1090. }
  1091. /*==========================================
  1092. * Changes a character's class
  1093. *------------------------------------------*/
  1094. ACMD_FUNC(jobchange)
  1095. {
  1096. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1097. int job = 0, upper = 0;
  1098. nullpo_retr(-1, sd);
  1099. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1100. {
  1101. int i, found = 0;
  1102. const struct { char name[24]; int id; } jobs[] = {
  1103. { "novice", 0 },
  1104. { "swordsman", 1 },
  1105. { "mage", 2 },
  1106. { "archer", 3 },
  1107. { "acolyte", 4 },
  1108. { "merchant", 5 },
  1109. { "thief", 6 },
  1110. { "knight", 7 },
  1111. { "priest", 8 },
  1112. { "priestess", 8 },
  1113. { "wizard", 9 },
  1114. { "blacksmith", 10 },
  1115. { "hunter", 11 },
  1116. { "assassin", 12 },
  1117. { "crusader", 14 },
  1118. { "monk", 15 },
  1119. { "sage", 16 },
  1120. { "rogue", 17 },
  1121. { "alchemist", 18 },
  1122. { "bard", 19 },
  1123. { "dancer", 20 },
  1124. { "super novice", 23 },
  1125. { "supernovice", 23 },
  1126. { "gunslinger", 24 },
  1127. { "gunner", 24 },
  1128. { "ninja", 25 },
  1129. { "high novice", 4001 },
  1130. { "swordsman high", 4002 },
  1131. { "mage high", 4003 },
  1132. { "archer high", 4004 },
  1133. { "acolyte high", 4005 },
  1134. { "merchant high", 4006 },
  1135. { "thief high", 4007 },
  1136. { "lord knight", 4008 },
  1137. { "high priest", 4009 },
  1138. { "high priestess", 4009 },
  1139. { "high wizard", 4010 },
  1140. { "whitesmith", 4011 },
  1141. { "sniper", 4012 },
  1142. { "assassin cross", 4013 },
  1143. { "paladin", 4015 },
  1144. { "champion", 4016 },
  1145. { "professor", 4017 },
  1146. { "stalker", 4018 },
  1147. { "creator", 4019 },
  1148. { "clown", 4020 },
  1149. { "gypsy", 4021 },
  1150. { "baby novice", 4023 },
  1151. { "baby swordsman", 4024 },
  1152. { "baby mage", 4025 },
  1153. { "baby archer", 4026 },
  1154. { "baby acolyte", 4027 },
  1155. { "baby merchant", 4028 },
  1156. { "baby thief", 4029 },
  1157. { "baby knight", 4030 },
  1158. { "baby priest", 4031 },
  1159. { "baby priestess", 4031 },
  1160. { "baby wizard", 4032 },
  1161. { "baby blacksmith",4033 },
  1162. { "baby hunter", 4034 },
  1163. { "baby assassin", 4035 },
  1164. { "baby crusader", 4037 },
  1165. { "baby monk", 4038 },
  1166. { "baby sage", 4039 },
  1167. { "baby rogue", 4040 },
  1168. { "baby alchemist", 4041 },
  1169. { "baby bard", 4042 },
  1170. { "baby dancer", 4043 },
  1171. { "super baby", 4045 },
  1172. { "taekwon", 4046 },
  1173. { "taekwon boy", 4046 },
  1174. { "taekwon girl", 4046 },
  1175. { "star gladiator", 4047 },
  1176. { "soul linker", 4049 },
  1177. { "rune knight", 4054 },
  1178. { "warlock", 4055 },
  1179. { "ranger", 4056 },
  1180. { "arch bishop", 4057 },
  1181. { "mechanic", 4058 },
  1182. { "guillotine", 4059 },
  1183. { "rune knight (Trans)", 4060 },
  1184. { "warlock (Trans)", 4061 },
  1185. { "ranger (Trans)", 4062 },
  1186. { "arch bishop (Trans)", 4063 },
  1187. { "mechanic (Trans)", 4064 },
  1188. { "guillotine (Trans)", 4065 },
  1189. { "royal guard", 4066 },
  1190. { "sorcerer", 4067 },
  1191. { "minstrel", 4068 },
  1192. { "wanderer", 4069 },
  1193. { "sura", 4070 },
  1194. { "genetic", 4071 },
  1195. { "shadow chaser", 4072 },
  1196. { "royal guard (Trans)", 4073 },
  1197. { "sorcerer (Trans)", 4074 },
  1198. { "minstrel (Trans)", 4075 },
  1199. { "wanderer (Trans)", 4076 },
  1200. { "sura (Trans)", 4077 },
  1201. { "genetic (Trans)", 4078 },
  1202. { "shadow chaser (Trans)", 4079 },
  1203. };
  1204. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1205. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1206. job = jobs[i].id;
  1207. upper = 0;
  1208. found = 1;
  1209. break;
  1210. }
  1211. }
  1212. if (!found) {
  1213. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1214. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1215. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1216. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1217. clif_displaymessage(fd, "----- 2nd Class -----");
  1218. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1219. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1220. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1221. clif_displaymessage(fd, " 20 Dancer");
  1222. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1223. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1224. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1225. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1226. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1227. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1228. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1229. clif_displaymessage(fd, "4021 Gypsy");
  1230. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1231. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1232. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1233. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1234. clif_displaymessage(fd, "4072 Shadow Chaser");
  1235. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1236. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1237. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1238. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1239. clif_displaymessage(fd, "4079 Shadow Chaser");
  1240. clif_displaymessage(fd, "----- Expanded Class -----");
  1241. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1242. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1243. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1244. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1245. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1246. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1247. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1248. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1249. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1250. clif_displaymessage(fd, "4045 Super Baby");
  1251. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1252. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1253. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1254. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1255. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1256. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1257. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1258. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1259. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1260. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1261. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1262. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1263. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1264. return -1;
  1265. }
  1266. }
  1267. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27
  1268. || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1269. ) // Deny direct transformation into dummy jobs
  1270. return 0;
  1271. if (pcdb_checkid(job))
  1272. {
  1273. if (pc_jobchange(sd, job, upper) == 0)
  1274. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1275. else {
  1276. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1277. return -1;
  1278. }
  1279. } else {
  1280. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1281. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1282. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1283. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1284. clif_displaymessage(fd, "----- 2nd Class -----");
  1285. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1286. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1287. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1288. clif_displaymessage(fd, " 20 Dancer");
  1289. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1290. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1291. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1292. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1293. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1294. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1295. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1296. clif_displaymessage(fd, "4021 Gypsy");
  1297. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1298. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1299. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1300. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1301. clif_displaymessage(fd, "4072 Shadow Chaser");
  1302. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1303. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1304. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1305. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1306. clif_displaymessage(fd, "4079 Shadow Chaser");
  1307. clif_displaymessage(fd, "----- Expanded Class -----");
  1308. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1309. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1310. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1311. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1312. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1313. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1314. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1315. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1316. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1317. clif_displaymessage(fd, "4045 Super Baby");
  1318. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1319. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1320. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1321. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1322. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1323. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1324. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1325. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1326. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1327. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1328. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1329. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1330. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1331. return -1;
  1332. }
  1333. return 0;
  1334. }
  1335. /*==========================================
  1336. *
  1337. *------------------------------------------*/
  1338. ACMD_FUNC(die)
  1339. {
  1340. nullpo_retr(-1, sd);
  1341. clif_specialeffect(&sd->bl,450,SELF);
  1342. status_kill(&sd->bl);
  1343. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1344. return 0;
  1345. }
  1346. /*==========================================
  1347. *
  1348. *------------------------------------------*/
  1349. ACMD_FUNC(kill)
  1350. {
  1351. struct map_session_data *pl_sd;
  1352. nullpo_retr(-1, sd);
  1353. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1354. if (!message || !*message) {
  1355. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1356. return -1;
  1357. }
  1358. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1359. {
  1360. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1361. return -1;
  1362. }
  1363. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1364. { // you can kill only lower or same level
  1365. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1366. return -1;
  1367. }
  1368. status_kill(&pl_sd->bl);
  1369. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1370. if (fd != pl_sd->fd)
  1371. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1372. return 0;
  1373. }
  1374. /*==========================================
  1375. *
  1376. *------------------------------------------*/
  1377. ACMD_FUNC(alive)
  1378. {
  1379. nullpo_retr(-1, sd);
  1380. if (!status_revive(&sd->bl, 100, 100))
  1381. {
  1382. clif_displaymessage(fd, "You're not dead.");
  1383. return -1;
  1384. }
  1385. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1386. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1387. return 0;
  1388. }
  1389. /*==========================================
  1390. * +kamic [LuzZza]
  1391. *------------------------------------------*/
  1392. ACMD_FUNC(kami)
  1393. {
  1394. unsigned long color=0;
  1395. nullpo_retr(-1, sd);
  1396. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1397. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1398. if (!message || !*message) {
  1399. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1400. return -1;
  1401. }
  1402. sscanf(message, "%199[^\n]", atcmd_output);
  1403. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1404. } else {
  1405. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1406. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1407. return -1;
  1408. }
  1409. if(color > 0xFFFFFF) {
  1410. clif_displaymessage(fd, "Invalid color.");
  1411. return -1;
  1412. }
  1413. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1414. }
  1415. return 0;
  1416. }
  1417. /*==========================================
  1418. *
  1419. *------------------------------------------*/
  1420. ACMD_FUNC(heal)
  1421. {
  1422. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1423. nullpo_retr(-1, sd);
  1424. sscanf(message, "%d %d", &hp, &sp);
  1425. // some overflow checks
  1426. if( hp == INT_MIN ) hp++;
  1427. if( sp == INT_MIN ) sp++;
  1428. if ( hp == 0 && sp == 0 ) {
  1429. if (!status_percent_heal(&sd->bl, 100, 100))
  1430. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1431. else
  1432. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1433. return 0;
  1434. }
  1435. if ( hp > 0 && sp >= 0 ) {
  1436. if(!status_heal(&sd->bl, hp, sp, 0))
  1437. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1438. else
  1439. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1440. return 0;
  1441. }
  1442. if ( hp < 0 && sp <= 0 ) {
  1443. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1444. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1445. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1446. return 0;
  1447. }
  1448. //Opposing signs.
  1449. if ( hp ) {
  1450. if (hp > 0)
  1451. status_heal(&sd->bl, hp, 0, 0);
  1452. else {
  1453. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1454. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1455. }
  1456. }
  1457. if ( sp ) {
  1458. if (sp > 0)
  1459. status_heal(&sd->bl, 0, sp, 0);
  1460. else
  1461. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1462. }
  1463. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1464. return 0;
  1465. }
  1466. /*==========================================
  1467. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1468. *------------------------------------------*/
  1469. ACMD_FUNC(item)
  1470. {
  1471. char item_name[100];
  1472. int number = 0, item_id, flag;
  1473. struct item item_tmp;
  1474. struct item_data *item_data;
  1475. int get_count, i;
  1476. nullpo_retr(-1, sd);
  1477. memset(item_name, '\0', sizeof(item_name));
  1478. if (!message || !*message || (
  1479. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1480. sscanf(message, "%99s %d", item_name, &number) < 1
  1481. )) {
  1482. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1483. return -1;
  1484. }
  1485. if (number <= 0)
  1486. number = 1;
  1487. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1488. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1489. {
  1490. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1491. return -1;
  1492. }
  1493. item_id = item_data->nameid;
  1494. get_count = number;
  1495. //Check if it's stackable.
  1496. if (!itemdb_isstackable2(item_data))
  1497. get_count = 1;
  1498. for (i = 0; i < number; i += get_count) {
  1499. // if not pet egg
  1500. if (!pet_create_egg(sd, item_id)) {
  1501. memset(&item_tmp, 0, sizeof(item_tmp));
  1502. item_tmp.nameid = item_id;
  1503. item_tmp.identify = 1;
  1504. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1505. clif_additem(sd, 0, 0, flag);
  1506. }
  1507. }
  1508. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1509. return 0;
  1510. }
  1511. /*==========================================
  1512. *
  1513. *------------------------------------------*/
  1514. ACMD_FUNC(item2)
  1515. {
  1516. struct item item_tmp;
  1517. struct item_data *item_data;
  1518. char item_name[100];
  1519. int item_id, number = 0;
  1520. int identify = 0, refine = 0, attr = 0;
  1521. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1522. int flag;
  1523. int loop, get_count, i;
  1524. nullpo_retr(-1, sd);
  1525. memset(item_name, '\0', sizeof(item_name));
  1526. if (!message || !*message || (
  1527. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1528. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1529. )) {
  1530. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1531. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1532. return -1;
  1533. }
  1534. if (number <= 0)
  1535. number = 1;
  1536. item_id = 0;
  1537. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1538. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1539. item_id = item_data->nameid;
  1540. if (item_id > 500) {
  1541. loop = 1;
  1542. get_count = number;
  1543. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1544. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1545. loop = number;
  1546. get_count = 1;
  1547. if (item_data->type == IT_PETEGG) {
  1548. identify = 1;
  1549. refine = 0;
  1550. }
  1551. if (item_data->type == IT_PETARMOR)
  1552. refine = 0;
  1553. if (refine > MAX_REFINE)
  1554. refine = MAX_REFINE;
  1555. } else {
  1556. identify = 1;
  1557. refine = attr = 0;
  1558. }
  1559. for (i = 0; i < loop; i++) {
  1560. memset(&item_tmp, 0, sizeof(item_tmp));
  1561. item_tmp.nameid = item_id;
  1562. item_tmp.identify = identify;
  1563. item_tmp.refine = refine;
  1564. item_tmp.attribute = attr;
  1565. item_tmp.card[0] = c1;
  1566. item_tmp.card[1] = c2;
  1567. item_tmp.card[2] = c3;
  1568. item_tmp.card[3] = c4;
  1569. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1570. clif_additem(sd, 0, 0, flag);
  1571. }
  1572. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1573. } else {
  1574. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1575. return -1;
  1576. }
  1577. return 0;
  1578. }
  1579. /*==========================================
  1580. *
  1581. *------------------------------------------*/
  1582. ACMD_FUNC(itemreset)
  1583. {
  1584. int i;
  1585. nullpo_retr(-1, sd);
  1586. for (i = 0; i < MAX_INVENTORY; i++) {
  1587. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1588. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1589. }
  1590. }
  1591. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1592. return 0;
  1593. }
  1594. /*==========================================
  1595. * Atcommand @lvlup
  1596. *------------------------------------------*/
  1597. ACMD_FUNC(baselevelup)
  1598. {
  1599. int level=0, i=0, status_point=0;
  1600. nullpo_retr(-1, sd);
  1601. level = atoi(message);
  1602. if (!message || !*message || !level) {
  1603. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1604. return -1;
  1605. }
  1606. if (level > 0) {
  1607. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1608. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1609. return -1;
  1610. } // End Addition
  1611. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1612. level = pc_maxbaselv(sd) - sd->status.base_level;
  1613. for (i = 0; i < level; i++)
  1614. status_point += pc_gets_status_point(sd->status.base_level + i);
  1615. sd->status.status_point += status_point;
  1616. sd->status.base_level += (unsigned int)level;
  1617. status_percent_heal(&sd->bl, 100, 100);
  1618. clif_misceffect(&sd->bl, 0);
  1619. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1620. } else {
  1621. if (sd->status.base_level == 1) {
  1622. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1623. return -1;
  1624. }
  1625. level*=-1;
  1626. if ((unsigned int)level >= sd->status.base_level)
  1627. level = sd->status.base_level-1;
  1628. for (i = 0; i > -level; i--)
  1629. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1630. if (sd->status.status_point < status_point)
  1631. pc_resetstate(sd);
  1632. if (sd->status.status_point < status_point)
  1633. sd->status.status_point = 0;
  1634. else
  1635. sd->status.status_point -= status_point;
  1636. sd->status.base_level -= (unsigned int)level;
  1637. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1638. }
  1639. sd->status.base_exp = 0;
  1640. clif_updatestatus(sd, SP_STATUSPOINT);
  1641. clif_updatestatus(sd, SP_BASELEVEL);
  1642. clif_updatestatus(sd, SP_BASEEXP);
  1643. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1644. status_calc_pc(sd, 0);
  1645. if(sd->status.party_id)
  1646. party_send_levelup(sd);
  1647. return 0;
  1648. }
  1649. /*==========================================
  1650. *
  1651. *------------------------------------------*/
  1652. ACMD_FUNC(joblevelup)
  1653. {
  1654. int level=0;
  1655. nullpo_retr(-1, sd);
  1656. level = atoi(message);
  1657. if (!message || !*message || !level) {
  1658. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1659. return -1;
  1660. }
  1661. if (level > 0) {
  1662. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1663. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1664. return -1;
  1665. }
  1666. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1667. level = pc_maxjoblv(sd) - sd->status.job_level;
  1668. sd->status.job_level += (unsigned int)level;
  1669. sd->status.skill_point += level;
  1670. clif_misceffect(&sd->bl, 1);
  1671. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1672. } else {
  1673. if (sd->status.job_level == 1) {
  1674. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1675. return -1;
  1676. }
  1677. level *=-1;
  1678. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1679. level = sd->status.job_level-1;
  1680. sd->status.job_level -= (unsigned int)level;
  1681. if (sd->status.skill_point < level)
  1682. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1683. if (sd->status.skill_point < level)
  1684. sd->status.skill_point = 0;
  1685. else
  1686. sd->status.skill_point -= level;
  1687. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1688. }
  1689. sd->status.job_exp = 0;
  1690. clif_updatestatus(sd, SP_JOBLEVEL);
  1691. clif_updatestatus(sd, SP_JOBEXP);
  1692. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1693. clif_updatestatus(sd, SP_SKILLPOINT);
  1694. status_calc_pc(sd, 0);
  1695. return 0;
  1696. }
  1697. /*==========================================
  1698. * @help
  1699. *------------------------------------------*/
  1700. ACMD_FUNC(help)
  1701. {
  1702. char buf[2048], w1[2048], w2[2048];
  1703. int i, gm_level;
  1704. FILE* fp;
  1705. nullpo_retr(-1, sd);
  1706. memset(buf, '\0', sizeof(buf));
  1707. if ((fp = fopen(help_txt, "r")) != NULL) {
  1708. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1709. gm_level = pc_isGM(sd);
  1710. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1711. if (buf[0] == '/' && buf[1] == '/')
  1712. continue;
  1713. for (i = 0; buf[i] != '\0'; i++) {
  1714. if (buf[i] == '\r' || buf[i] == '\n') {
  1715. buf[i] = '\0';
  1716. break;
  1717. }
  1718. }
  1719. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1720. clif_displaymessage(fd, buf);
  1721. else if (gm_level >= atoi(w1))
  1722. clif_displaymessage(fd, w2);
  1723. }
  1724. fclose(fp);
  1725. } else {
  1726. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1727. return -1;
  1728. }
  1729. return 0;
  1730. }
  1731. /*==========================================
  1732. * @help2 - Char commands [Kayla]
  1733. *------------------------------------------*/
  1734. ACMD_FUNC(help2)
  1735. {
  1736. char buf[2048], w1[2048], w2[2048];
  1737. int i, gm_level;
  1738. FILE* fp;
  1739. nullpo_retr(-1, sd);
  1740. memset(buf, '\0', sizeof(buf));
  1741. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1742. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1743. gm_level = pc_isGM(sd);
  1744. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1745. if (buf[0] == '/' && buf[1] == '/')
  1746. continue;
  1747. for (i = 0; buf[i] != '\0'; i++) {
  1748. if (buf[i] == '\r' || buf[i] == '\n') {
  1749. buf[i] = '\0';
  1750. break;
  1751. }
  1752. }
  1753. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1754. clif_displaymessage(fd, buf);
  1755. else if (gm_level >= atoi(w1))
  1756. clif_displaymessage(fd, w2);
  1757. }
  1758. fclose(fp);
  1759. } else {
  1760. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1761. return -1;
  1762. }
  1763. return 0;
  1764. }
  1765. // helper function, used in foreach calls to stop auto-attack timers
  1766. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1767. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1768. {
  1769. struct unit_data *ud = unit_bl2ud(bl);
  1770. int id = va_arg(ap, int);
  1771. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1772. {
  1773. unit_stop_attack(bl);
  1774. return 1;
  1775. }
  1776. return 0;
  1777. }
  1778. /*==========================================
  1779. *
  1780. *------------------------------------------*/
  1781. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1782. {
  1783. TBL_PC* sd = (TBL_PC*)bl;
  1784. clif_pvpset(sd, 0, 0, 2);
  1785. if (sd->pvp_timer != INVALID_TIMER) {
  1786. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1787. sd->pvp_timer = INVALID_TIMER;
  1788. }
  1789. return 0;
  1790. }
  1791. ACMD_FUNC(pvpoff)
  1792. {
  1793. nullpo_retr(-1, sd);
  1794. if (!map[sd->bl.m].flag.pvp) {
  1795. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1796. return -1;
  1797. }
  1798. map[sd->bl.m].flag.pvp = 0;
  1799. if (!battle_config.pk_mode)
  1800. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1801. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1802. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1803. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1804. return 0;
  1805. }
  1806. /*==========================================
  1807. *
  1808. *------------------------------------------*/
  1809. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1810. {
  1811. TBL_PC* sd = (TBL_PC*)bl;
  1812. if (sd->pvp_timer == INVALID_TIMER) {
  1813. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1814. sd->pvp_rank = 0;
  1815. sd->pvp_lastusers = 0;
  1816. sd->pvp_point = 5;
  1817. sd->pvp_won = 0;
  1818. sd->pvp_lost = 0;
  1819. }
  1820. return 0;
  1821. }
  1822. ACMD_FUNC(pvpon)
  1823. {
  1824. nullpo_retr(-1, sd);
  1825. if (map[sd->bl.m].flag.pvp) {
  1826. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1827. return -1;
  1828. }
  1829. map[sd->bl.m].flag.pvp = 1;
  1830. if (!battle_config.pk_mode)
  1831. {// display pvp circle and rank
  1832. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1833. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1834. }
  1835. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1836. return 0;
  1837. }
  1838. /*==========================================
  1839. *
  1840. *------------------------------------------*/
  1841. ACMD_FUNC(gvgoff)
  1842. {
  1843. nullpo_retr(-1, sd);
  1844. if (!map[sd->bl.m].flag.gvg) {
  1845. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1846. return -1;
  1847. }
  1848. map[sd->bl.m].flag.gvg = 0;
  1849. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1850. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1851. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1852. return 0;
  1853. }
  1854. /*==========================================
  1855. *
  1856. *------------------------------------------*/
  1857. ACMD_FUNC(gvgon)
  1858. {
  1859. nullpo_retr(-1, sd);
  1860. if (map[sd->bl.m].flag.gvg) {
  1861. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1862. return -1;
  1863. }
  1864. map[sd->bl.m].flag.gvg = 1;
  1865. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1866. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1867. return 0;
  1868. }
  1869. /*==========================================
  1870. *
  1871. *------------------------------------------*/
  1872. ACMD_FUNC(model)
  1873. {
  1874. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1875. nullpo_retr(-1, sd);
  1876. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1877. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1878. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1879. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1880. clif_displaymessage(fd, atcmd_output);
  1881. return -1;
  1882. }
  1883. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1884. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1885. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1886. pc_changelook(sd, LOOK_HAIR, hair_style);
  1887. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1888. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1889. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1890. } else {
  1891. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1892. return -1;
  1893. }
  1894. return 0;
  1895. }
  1896. /*==========================================
  1897. * @dye && @ccolor
  1898. *------------------------------------------*/
  1899. ACMD_FUNC(dye)
  1900. {
  1901. int cloth_color = 0;
  1902. nullpo_retr(-1, sd);
  1903. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1904. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1905. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1906. clif_displaymessage(fd, atcmd_output);
  1907. return -1;
  1908. }
  1909. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1910. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1911. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1912. } else {
  1913. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1914. return -1;
  1915. }
  1916. return 0;
  1917. }
  1918. /*==========================================
  1919. * @hairstyle && @hstyle
  1920. *------------------------------------------*/
  1921. ACMD_FUNC(hair_style)
  1922. {
  1923. int hair_style = 0;
  1924. nullpo_retr(-1, sd);
  1925. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1926. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1927. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1928. clif_displaymessage(fd, atcmd_output);
  1929. return -1;
  1930. }
  1931. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1932. pc_changelook(sd, LOOK_HAIR, hair_style);
  1933. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1934. } else {
  1935. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1936. return -1;
  1937. }
  1938. return 0;
  1939. }
  1940. /*==========================================
  1941. * @haircolor && @hcolor
  1942. *------------------------------------------*/
  1943. ACMD_FUNC(hair_color)
  1944. {
  1945. int hair_color = 0;
  1946. nullpo_retr(-1, sd);
  1947. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1948. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1949. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1950. clif_displaymessage(fd, atcmd_output);
  1951. return -1;
  1952. }
  1953. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1954. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1955. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1956. } else {
  1957. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1958. return -1;
  1959. }
  1960. return 0;
  1961. }
  1962. /*==========================================
  1963. * @go [city_number or city_name] - Updated by Harbin
  1964. *------------------------------------------*/
  1965. ACMD_FUNC(go)
  1966. {
  1967. int i;
  1968. int town;
  1969. char map_name[MAP_NAME_LENGTH];
  1970. int m;
  1971. const struct {
  1972. char map[MAP_NAME_LENGTH];
  1973. int x, y;
  1974. } data[] = {
  1975. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1976. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1977. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1978. { MAP_PAYON, 162, 233 }, // 3=Payon
  1979. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1980. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1981. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1982. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1983. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1984. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1985. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1986. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1987. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1988. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1989. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1990. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1991. { MAP_JAIL, 23, 61 }, // 16=Prison
  1992. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1993. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1994. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1995. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1996. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1997. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1998. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1999. { MAP_VEINS, 216, 123 }, // 24=Veins
  2000. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  2001. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  2002. { MAP_MANUK, 282, 138 }, // 27=Manuk
  2003. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  2004. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  2005. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  2006. { MAP_MORA, 44, 151 }, // 31=Mora
  2007. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  2008. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  2009. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  2010. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  2011. };
  2012. nullpo_retr(-1, sd);
  2013. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  2014. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2015. return 0;
  2016. }
  2017. memset(map_name, '\0', sizeof(map_name));
  2018. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2019. // get the number
  2020. town = atoi(message);
  2021. // if no value, display all value
  2022. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  2023. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  2024. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  2025. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2026. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2027. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2028. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  2029. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  2030. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2031. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2032. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2033. clif_displaymessage(fd, " 24=Veins 25=Moscovia 26=Midgard Camp");
  2034. clif_displaymessage(fd, " 27=Manuk 28=Splendide 29=Brasilis");
  2035. clif_displaymessage(fd, " 30=El Dicastes 31=Mora 32=Dewata");
  2036. clif_displaymessage(fd, " 33=Malangdo Island 34=Malaya Port 35=Eclage");
  2037. return -1;
  2038. }
  2039. // get possible name of the city
  2040. map_name[MAP_NAME_LENGTH-1] = '\0';
  2041. for (i = 0; map_name[i]; i++)
  2042. map_name[i] = TOLOWER(map_name[i]);
  2043. // try to identify the map name
  2044. if (strncmp(map_name, "prontera", 3) == 0) {
  2045. town = 0;
  2046. } else if (strncmp(map_name, "morocc", 3) == 0) {
  2047. town = 1;
  2048. } else if (strncmp(map_name, "geffen", 3) == 0) {
  2049. town = 2;
  2050. } else if (strncmp(map_name, "payon", 3) == 0 ||
  2051. strncmp(map_name, "paion", 3) == 0) {
  2052. town = 3;
  2053. } else if (strncmp(map_name, "alberta", 3) == 0) {
  2054. town = 4;
  2055. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  2056. strncmp(map_name, "islude", 3) == 0) {
  2057. town = 5;
  2058. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2059. strcmp(map_name, "al") == 0) {
  2060. town = 6;
  2061. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  2062. strcmp(map_name, "christmas") == 0 ||
  2063. strncmp(map_name, "xmas", 3) == 0 ||
  2064. strncmp(map_name, "x-mas", 3) == 0) {
  2065. town = 7;
  2066. } else if (strncmp(map_name, "comodo", 3) == 0) {
  2067. town = 8;
  2068. } else if (strncmp(map_name, "yuno", 3) == 0) {
  2069. town = 9;
  2070. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  2071. town = 10;
  2072. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  2073. town = 11;
  2074. } else if (strncmp(map_name, "umbala", 3) == 0) {
  2075. town = 12;
  2076. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  2077. town = 13;
  2078. } else if (strncmp(map_name, "louyang", 3) == 0) {
  2079. town = 14;
  2080. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  2081. strncmp(map_name, "startpoint", 3) == 0 ||
  2082. strncmp(map_name, "begining", 3) == 0) {
  2083. town = 15;
  2084. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2085. strncmp(map_name, "prison", 3) == 0 ||
  2086. strncmp(map_name, "jails", 3) == 0) {
  2087. town = 16;
  2088. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2089. strncmp(map_name, "jawai", 3) == 0) {
  2090. town = 17;
  2091. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2092. strncmp(map_name, "ayotaya", 3) == 0) {
  2093. town = 18;
  2094. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2095. strncmp(map_name, "ainbroch", 5) == 0) {
  2096. town = 19;
  2097. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2098. town = 20;
  2099. } else if (strncmp(map_name, "einbech", 3) == 0) {
  2100. town = 21;
  2101. } else if (strncmp(map_name, "hugel", 3) == 0) {
  2102. town = 22;
  2103. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2104. town = 23;
  2105. } else if (strncmp(map_name, "veins", 3) == 0) {
  2106. town = 24;
  2107. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  2108. town = 25;
  2109. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  2110. town = 26;
  2111. } else if (strncmp(map_name, "manuk", 3) == 0) {
  2112. town = 27;
  2113. } else if (strncmp(map_name, "splendide", 3) == 0) {
  2114. town = 28;
  2115. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  2116. town = 29;
  2117. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  2118. town = 30;
  2119. } else if (strncmp(map_name, "mora", 3) == 0) {
  2120. town = 31;
  2121. } else if (strncmp(map_name, "dewata", 3) == 0) {
  2122. town = 32;
  2123. } else if (strncmp(map_name, "malangdo", 3) == 0) {
  2124. town = 33;
  2125. } else if (strncmp(map_name, "malaya", 3) == 0) {
  2126. town = 34;
  2127. } else if (strncmp(map_name, "eclage", 3) == 0) {
  2128. town = 35;
  2129. }
  2130. if (town >= 0 && town < ARRAYLENGTH(data))
  2131. {
  2132. m = map_mapname2mapid(data[town].map);
  2133. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2134. clif_displaymessage(fd, msg_txt(247));
  2135. return -1;
  2136. }
  2137. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2138. clif_displaymessage(fd, msg_txt(248));
  2139. return -1;
  2140. }
  2141. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  2142. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2143. } else {
  2144. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2145. return -1;
  2146. }
  2147. } else { // if you arrive here, you have an error in town variable when reading of names
  2148. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2149. return -1;
  2150. }
  2151. return 0;
  2152. }
  2153. /*==========================================
  2154. *
  2155. *------------------------------------------*/
  2156. ACMD_FUNC(monster)
  2157. {
  2158. char name[NAME_LENGTH];
  2159. char monster[NAME_LENGTH];
  2160. int mob_id;
  2161. int number = 0;
  2162. int count;
  2163. int i, k, range;
  2164. short mx, my;
  2165. nullpo_retr(-1, sd);
  2166. memset(name, '\0', sizeof(name));
  2167. memset(monster, '\0', sizeof(monster));
  2168. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2169. if (!message || !*message) {
  2170. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2171. return -1;
  2172. }
  2173. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2174. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2175. //All data can be left as it is.
  2176. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2177. //Here, it is possible name was not given and we are using monster for it.
  2178. if (count < 3) //Blank mob's name.
  2179. name[0] = '\0';
  2180. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2181. //All data can be left as it is.
  2182. } else if (sscanf(message, "%23s", monster) > 0) {
  2183. //As before, name may be already filled.
  2184. name[0] = '\0';
  2185. } else {
  2186. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2187. return -1;
  2188. }
  2189. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2190. mob_id = mobdb_checkid(atoi(monster));
  2191. if (mob_id == 0) {
  2192. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2193. return -1;
  2194. }
  2195. if (mob_id == MOBID_EMPERIUM) {
  2196. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2197. return -1;
  2198. }
  2199. if (number <= 0)
  2200. number = 1;
  2201. if( !name[0] )
  2202. strcpy(name, "--ja--");
  2203. // 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
  2204. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2205. number = battle_config.atc_spawn_quantity_limit;
  2206. if (battle_config.etc_log)
  2207. 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);
  2208. count = 0;
  2209. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2210. for (i = 0; i < number; i++) {
  2211. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2212. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2213. count += (k != 0) ? 1 : 0;
  2214. }
  2215. if (count != 0)
  2216. if (number == count)
  2217. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2218. else {
  2219. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2220. clif_displaymessage(fd, atcmd_output);
  2221. }
  2222. else {
  2223. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2224. return -1;
  2225. }
  2226. return 0;
  2227. }
  2228. // small monster spawning [Valaris]
  2229. ACMD_FUNC(monstersmall)
  2230. {
  2231. char name[NAME_LENGTH] = "";
  2232. char monster[NAME_LENGTH] = "";
  2233. int mob_id = 0;
  2234. int number = 0;
  2235. int x = 0;
  2236. int y = 0;
  2237. int count;
  2238. int i;
  2239. nullpo_retr(-1, sd);
  2240. if (!message || !*message) {
  2241. clif_displaymessage(fd, "Give a monster name/id please.");
  2242. return -1;
  2243. }
  2244. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2245. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2246. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2247. clif_displaymessage(fd, "Give a monster name/id please.");
  2248. return -1;
  2249. }
  2250. // If monster identifier/name argument is a name
  2251. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2252. mob_id = atoi(monster);
  2253. if (mob_id == 0) {
  2254. clif_displaymessage(fd, msg_txt(40));
  2255. return -1;
  2256. }
  2257. if (mob_id == MOBID_EMPERIUM) {
  2258. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2259. return -1;
  2260. }
  2261. if (mobdb_checkid(mob_id) == 0) {
  2262. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2263. return -1;
  2264. }
  2265. if (number <= 0)
  2266. number = 1;
  2267. if( !name[0] )
  2268. strcpy(name, "--ja--");
  2269. // 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
  2270. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2271. number = battle_config.atc_spawn_quantity_limit;
  2272. count = 0;
  2273. for (i = 0; i < number; i++) {
  2274. int mx, my;
  2275. if (x <= 0)
  2276. mx = sd->bl.x + (rand() % 11 - 5);
  2277. else
  2278. mx = x;
  2279. if (y <= 0)
  2280. my = sd->bl.y + (rand() % 11 - 5);
  2281. else
  2282. my = y;
  2283. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2284. }
  2285. if (count != 0)
  2286. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2287. else
  2288. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2289. return 0;
  2290. }
  2291. // big monster spawning [Valaris]
  2292. ACMD_FUNC(monsterbig)
  2293. {
  2294. char name[NAME_LENGTH] = "";
  2295. char monster[NAME_LENGTH] = "";
  2296. int mob_id = 0;
  2297. int number = 0;
  2298. int x = 0;
  2299. int y = 0;
  2300. int count;
  2301. int i;
  2302. nullpo_retr(-1, sd);
  2303. if (!message || !*message) {
  2304. clif_displaymessage(fd, "Give a monster name/id please.");
  2305. return -1;
  2306. }
  2307. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2308. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2309. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2310. clif_displaymessage(fd, "Give a monster name/id please.");
  2311. return -1;
  2312. }
  2313. // If monster identifier/name argument is a name
  2314. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2315. mob_id = atoi(monster);
  2316. if (mob_id == 0) {
  2317. clif_displaymessage(fd, msg_txt(40));
  2318. return -1;
  2319. }
  2320. if (mob_id == MOBID_EMPERIUM) {
  2321. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2322. return -1;
  2323. }
  2324. if (mobdb_checkid(mob_id) == 0) {
  2325. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2326. return -1;
  2327. }
  2328. if (number <= 0)
  2329. number = 1;
  2330. if( !name[0] )
  2331. strcpy(name, "--ja--");
  2332. // 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
  2333. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2334. number = battle_config.atc_spawn_quantity_limit;
  2335. count = 0;
  2336. for (i = 0; i < number; i++) {
  2337. int mx, my;
  2338. if (x <= 0)
  2339. mx = sd->bl.x + (rand() % 11 - 5);
  2340. else
  2341. mx = x;
  2342. if (y <= 0)
  2343. my = sd->bl.y + (rand() % 11 - 5);
  2344. else
  2345. my = y;
  2346. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2347. }
  2348. if (count != 0)
  2349. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2350. else
  2351. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2352. return 0;
  2353. }
  2354. /*==========================================
  2355. *
  2356. *------------------------------------------*/
  2357. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2358. {
  2359. struct mob_data *md;
  2360. int flag;
  2361. nullpo_ret(md=(struct mob_data *)bl);
  2362. flag = va_arg(ap, int);
  2363. if (md->guardian_data)
  2364. return 0; //Do not touch WoE mobs!
  2365. if (flag)
  2366. status_zap(bl,md->status.hp, 0);
  2367. else
  2368. status_kill(bl);
  2369. return 1;
  2370. }
  2371. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2372. {
  2373. int map_id;
  2374. char map_name[MAP_NAME_LENGTH_EXT];
  2375. if (!sd) return;
  2376. memset(map_name, '\0', sizeof(map_name));
  2377. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2378. map_id = sd->bl.m;
  2379. else {
  2380. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2381. map_id = sd->bl.m;
  2382. }
  2383. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2384. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2385. return;
  2386. }
  2387. ACMD_FUNC(killmonster)
  2388. {
  2389. atcommand_killmonster_sub(fd, sd, message, 1);
  2390. return 0;
  2391. }
  2392. /*==========================================
  2393. *
  2394. *------------------------------------------*/
  2395. ACMD_FUNC(killmonster2)
  2396. {
  2397. atcommand_killmonster_sub(fd, sd, message, 0);
  2398. return 0;
  2399. }
  2400. /*==========================================
  2401. *
  2402. *------------------------------------------*/
  2403. ACMD_FUNC(refine)
  2404. {
  2405. int i,j, position = 0, refine = 0, current_position, final_refine;
  2406. int count;
  2407. nullpo_retr(-1, sd);
  2408. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2409. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2410. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2411. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2412. clif_displaymessage(fd, atcmd_output);
  2413. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2414. clif_displaymessage(fd, atcmd_output);
  2415. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2416. clif_displaymessage(fd, atcmd_output);
  2417. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2418. clif_displaymessage(fd, atcmd_output);
  2419. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2420. clif_displaymessage(fd, atcmd_output);
  2421. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2422. clif_displaymessage(fd, atcmd_output);
  2423. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2424. clif_displaymessage(fd, atcmd_output);
  2425. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2426. clif_displaymessage(fd, atcmd_output);
  2427. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2428. clif_displaymessage(fd, atcmd_output);
  2429. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2430. clif_displaymessage(fd, atcmd_output);
  2431. return -1;
  2432. }
  2433. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2434. count = 0;
  2435. for (j = 0; j < EQI_MAX-1; j++) {
  2436. if ((i = sd->equip_index[j]) < 0)
  2437. continue;
  2438. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2439. continue;
  2440. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2441. continue;
  2442. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2443. continue;
  2444. if(position && !(sd->status.inventory[i].equip & position))
  2445. continue;
  2446. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2447. if (sd->status.inventory[i].refine != final_refine) {
  2448. sd->status.inventory[i].refine = final_refine;
  2449. current_position = sd->status.inventory[i].equip;
  2450. pc_unequipitem(sd, i, 3);
  2451. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2452. clif_delitem(sd, i, 1, 3);
  2453. clif_additem(sd, i, 1, 0);
  2454. pc_equipitem(sd, i, current_position);
  2455. clif_misceffect(&sd->bl, 3);
  2456. count++;
  2457. }
  2458. }
  2459. if (count == 0)
  2460. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2461. else if (count == 1)
  2462. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2463. else {
  2464. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2465. clif_displaymessage(fd, atcmd_output);
  2466. }
  2467. return 0;
  2468. }
  2469. /*==========================================
  2470. *
  2471. *------------------------------------------*/
  2472. ACMD_FUNC(produce)
  2473. {
  2474. char item_name[100];
  2475. int item_id, attribute = 0, star = 0;
  2476. int flag = 0;
  2477. struct item_data *item_data;
  2478. struct item tmp_item;
  2479. nullpo_retr(-1, sd);
  2480. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2481. memset(item_name, '\0', sizeof(item_name));
  2482. if (!message || !*message || (
  2483. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2484. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2485. )) {
  2486. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2487. return -1;
  2488. }
  2489. item_id = 0;
  2490. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2491. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2492. {
  2493. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2494. return -1;
  2495. }
  2496. item_id = item_data->nameid;
  2497. if (itemdb_isequip2(item_data)) {
  2498. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2499. attribute = ATTRIBUTE_NORMAL;
  2500. if (star < MIN_STAR || star > MAX_STAR)
  2501. star = 0;
  2502. memset(&tmp_item, 0, sizeof tmp_item);
  2503. tmp_item.nameid = item_id;
  2504. tmp_item.amount = 1;
  2505. tmp_item.identify = 1;
  2506. tmp_item.card[0] = CARD0_FORGE;
  2507. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2508. ((star*5) << 8) + attribute:0;
  2509. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2510. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2511. clif_produceeffect(sd, 0, item_id);
  2512. clif_misceffect(&sd->bl, 3);
  2513. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2514. clif_additem(sd, 0, 0, flag);
  2515. } else {
  2516. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2517. clif_displaymessage(fd, atcmd_output);
  2518. return -1;
  2519. }
  2520. return 0;
  2521. }
  2522. /*==========================================
  2523. *
  2524. *------------------------------------------*/
  2525. ACMD_FUNC(memo)
  2526. {
  2527. int position = 0;
  2528. nullpo_retr(-1, sd);
  2529. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2530. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2531. {
  2532. int i;
  2533. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2534. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2535. {
  2536. if( sd->status.memo_point[i].map )
  2537. 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);
  2538. else
  2539. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2540. clif_displaymessage(sd->fd, atcmd_output);
  2541. }
  2542. return 0;
  2543. }
  2544. if( position < 0 || position >= MAX_MEMOPOINTS )
  2545. {
  2546. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2547. clif_displaymessage(fd, atcmd_output);
  2548. return -1;
  2549. }
  2550. pc_memo(sd, position);
  2551. return 0;
  2552. }
  2553. /*==========================================
  2554. *
  2555. *------------------------------------------*/
  2556. ACMD_FUNC(gat)
  2557. {
  2558. int y;
  2559. nullpo_retr(-1, sd);
  2560. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2561. for (y = 2; y >= -2; y--) {
  2562. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2563. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2564. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2565. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2566. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2567. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2568. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2569. clif_displaymessage(fd, atcmd_output);
  2570. }
  2571. return 0;
  2572. }
  2573. /*==========================================
  2574. *
  2575. *------------------------------------------*/
  2576. ACMD_FUNC(displaystatus)
  2577. {
  2578. int i, type, flag, tick;
  2579. nullpo_retr(-1, sd);
  2580. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2581. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2582. return -1;
  2583. }
  2584. if (i < 2) flag = 1;
  2585. if (i < 3) tick = 0;
  2586. clif_status_change(&sd->bl, type, flag, tick, 0, 0, 0);
  2587. return 0;
  2588. }
  2589. /*==========================================
  2590. * @stpoint (Rewritten by [Yor])
  2591. *------------------------------------------*/
  2592. ACMD_FUNC(statuspoint)
  2593. {
  2594. int point;
  2595. unsigned int new_status_point;
  2596. if (!message || !*message || (point = atoi(message)) == 0) {
  2597. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2598. return -1;
  2599. }
  2600. if(point < 0)
  2601. {
  2602. if(sd->status.status_point < (unsigned int)(-point))
  2603. {
  2604. new_status_point = 0;
  2605. }
  2606. else
  2607. {
  2608. new_status_point = sd->status.status_point + point;
  2609. }
  2610. }
  2611. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2612. {
  2613. new_status_point = UINT_MAX;
  2614. }
  2615. else
  2616. {
  2617. new_status_point = sd->status.status_point + point;
  2618. }
  2619. if (new_status_point != sd->status.status_point) {
  2620. sd->status.status_point = new_status_point;
  2621. clif_updatestatus(sd, SP_STATUSPOINT);
  2622. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2623. } else {
  2624. if (point < 0)
  2625. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2626. else
  2627. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2628. return -1;
  2629. }
  2630. return 0;
  2631. }
  2632. /*==========================================
  2633. * @skpoint (Rewritten by [Yor])
  2634. *------------------------------------------*/
  2635. ACMD_FUNC(skillpoint)
  2636. {
  2637. int point;
  2638. unsigned int new_skill_point;
  2639. nullpo_retr(-1, sd);
  2640. if (!message || !*message || (point = atoi(message)) == 0) {
  2641. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2642. return -1;
  2643. }
  2644. if(point < 0)
  2645. {
  2646. if(sd->status.skill_point < (unsigned int)(-point))
  2647. {
  2648. new_skill_point = 0;
  2649. }
  2650. else
  2651. {
  2652. new_skill_point = sd->status.skill_point + point;
  2653. }
  2654. }
  2655. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2656. {
  2657. new_skill_point = UINT_MAX;
  2658. }
  2659. else
  2660. {
  2661. new_skill_point = sd->status.skill_point + point;
  2662. }
  2663. if (new_skill_point != sd->status.skill_point) {
  2664. sd->status.skill_point = new_skill_point;
  2665. clif_updatestatus(sd, SP_SKILLPOINT);
  2666. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2667. } else {
  2668. if (point < 0)
  2669. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2670. else
  2671. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2672. return -1;
  2673. }
  2674. return 0;
  2675. }
  2676. /*==========================================
  2677. * @zeny (Rewritten by [Yor])
  2678. *------------------------------------------*/
  2679. ACMD_FUNC(zeny)
  2680. {
  2681. int zeny, new_zeny;
  2682. nullpo_retr(-1, sd);
  2683. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2684. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2685. return -1;
  2686. }
  2687. new_zeny = sd->status.zeny + zeny;
  2688. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2689. new_zeny = MAX_ZENY;
  2690. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2691. new_zeny = 0;
  2692. if (new_zeny != sd->status.zeny) {
  2693. sd->status.zeny = new_zeny;
  2694. clif_updatestatus(sd, SP_ZENY);
  2695. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2696. } else {
  2697. if (zeny < 0)
  2698. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2699. else
  2700. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2701. return -1;
  2702. }
  2703. return 0;
  2704. }
  2705. /*==========================================
  2706. *
  2707. *------------------------------------------*/
  2708. ACMD_FUNC(param)
  2709. {
  2710. int i, value = 0, new_value, max;
  2711. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2712. short* status[6];
  2713. //we don't use direct initialization because it isn't part of the c standard.
  2714. nullpo_retr(-1, sd);
  2715. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2716. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2717. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2718. clif_displaymessage(fd, atcmd_output);
  2719. return -1;
  2720. }
  2721. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2722. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2723. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2724. clif_displaymessage(fd, atcmd_output);
  2725. return -1;
  2726. }
  2727. status[0] = &sd->status.str;
  2728. status[1] = &sd->status.agi;
  2729. status[2] = &sd->status.vit;
  2730. status[3] = &sd->status.int_;
  2731. status[4] = &sd->status.dex;
  2732. status[5] = &sd->status.luk;
  2733. if( battle_config.atcommand_max_stat_bypass )
  2734. max = SHRT_MAX;
  2735. else
  2736. max = pc_maxparameter(sd);
  2737. if(value < 0 && *status[i] <= -value) {
  2738. new_value = 1;
  2739. } else if(max - *status[i] < value) {
  2740. new_value = max;
  2741. } else {
  2742. new_value = *status[i] + value;
  2743. }
  2744. if (new_value != *status[i]) {
  2745. *status[i] = new_value;
  2746. clif_updatestatus(sd, SP_STR + i);
  2747. clif_updatestatus(sd, SP_USTR + i);
  2748. status_calc_pc(sd, 0);
  2749. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2750. } else {
  2751. if (value < 0)
  2752. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2753. else
  2754. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2755. return -1;
  2756. }
  2757. return 0;
  2758. }
  2759. /*==========================================
  2760. * Stat all by fritz (rewritten by [Yor])
  2761. *------------------------------------------*/
  2762. ACMD_FUNC(stat_all)
  2763. {
  2764. int index, count, value, max, new_value;
  2765. short* status[6];
  2766. //we don't use direct initialization because it isn't part of the c standard.
  2767. nullpo_retr(-1, sd);
  2768. status[0] = &sd->status.str;
  2769. status[1] = &sd->status.agi;
  2770. status[2] = &sd->status.vit;
  2771. status[3] = &sd->status.int_;
  2772. status[4] = &sd->status.dex;
  2773. status[5] = &sd->status.luk;
  2774. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2775. value = pc_maxparameter(sd);
  2776. max = pc_maxparameter(sd);
  2777. } else {
  2778. if( battle_config.atcommand_max_stat_bypass )
  2779. max = SHRT_MAX;
  2780. else
  2781. max = pc_maxparameter(sd);
  2782. }
  2783. count = 0;
  2784. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2785. if (value > 0 && *status[index] > max - value)
  2786. new_value = max;
  2787. else if (value < 0 && *status[index] <= -value)
  2788. new_value = 1;
  2789. else
  2790. new_value = *status[index] +value;
  2791. if (new_value != (int)*status[index]) {
  2792. *status[index] = new_value;
  2793. clif_updatestatus(sd, SP_STR + index);
  2794. clif_updatestatus(sd, SP_USTR + index);
  2795. count++;
  2796. }
  2797. }
  2798. if (count > 0) { // if at least 1 stat modified
  2799. status_calc_pc(sd, 0);
  2800. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2801. } else {
  2802. if (value < 0)
  2803. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2804. else
  2805. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2806. return -1;
  2807. }
  2808. return 0;
  2809. }
  2810. /*==========================================
  2811. *
  2812. *------------------------------------------*/
  2813. ACMD_FUNC(guildlevelup)
  2814. {
  2815. int level = 0;
  2816. short added_level;
  2817. struct guild *guild_info;
  2818. nullpo_retr(-1, sd);
  2819. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2820. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2821. return -1;
  2822. }
  2823. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2824. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2825. return -1;
  2826. }
  2827. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2828. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2829. // return -1;
  2830. //}
  2831. added_level = (short)level;
  2832. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2833. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2834. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2835. added_level = 1 - guild_info->guild_lv;
  2836. if (added_level != 0) {
  2837. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2838. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2839. } else {
  2840. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2841. return -1;
  2842. }
  2843. return 0;
  2844. }
  2845. /*==========================================
  2846. *
  2847. *------------------------------------------*/
  2848. ACMD_FUNC(makeegg)
  2849. {
  2850. struct item_data *item_data;
  2851. int id, pet_id;
  2852. nullpo_retr(-1, sd);
  2853. if (!message || !*message) {
  2854. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2855. return -1;
  2856. }
  2857. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2858. id = item_data->nameid;
  2859. else
  2860. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2861. ;
  2862. else
  2863. id = atoi(message);
  2864. pet_id = search_petDB_index(id, PET_CLASS);
  2865. if (pet_id < 0)
  2866. pet_id = search_petDB_index(id, PET_EGG);
  2867. if (pet_id >= 0) {
  2868. sd->catch_target_class = pet_db[pet_id].class_;
  2869. intif_create_pet(
  2870. sd->status.account_id, sd->status.char_id,
  2871. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2872. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2873. 100, 0, 1, pet_db[pet_id].jname);
  2874. } else {
  2875. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2876. return -1;
  2877. }
  2878. return 0;
  2879. }
  2880. /*==========================================
  2881. *
  2882. *------------------------------------------*/
  2883. ACMD_FUNC(hatch)
  2884. {
  2885. nullpo_retr(-1, sd);
  2886. if (sd->status.pet_id <= 0)
  2887. clif_sendegg(sd);
  2888. else {
  2889. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2890. return -1;
  2891. }
  2892. return 0;
  2893. }
  2894. /*==========================================
  2895. *
  2896. *------------------------------------------*/
  2897. ACMD_FUNC(petfriendly)
  2898. {
  2899. int friendly;
  2900. struct pet_data *pd;
  2901. nullpo_retr(-1, sd);
  2902. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2903. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2904. return -1;
  2905. }
  2906. pd = sd->pd;
  2907. if (!pd) {
  2908. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2909. return -1;
  2910. }
  2911. if (friendly < 0 || friendly > 1000)
  2912. {
  2913. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2914. return -1;
  2915. }
  2916. if (friendly == pd->pet.intimate) {
  2917. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2918. return -1;
  2919. }
  2920. pet_set_intimate(pd, friendly);
  2921. clif_send_petstatus(sd);
  2922. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2923. return 0;
  2924. }
  2925. /*==========================================
  2926. *
  2927. *------------------------------------------*/
  2928. ACMD_FUNC(pethungry)
  2929. {
  2930. int hungry;
  2931. struct pet_data *pd;
  2932. nullpo_retr(-1, sd);
  2933. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2934. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2935. return -1;
  2936. }
  2937. pd = sd->pd;
  2938. if (!sd->status.pet_id || !pd) {
  2939. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2940. return -1;
  2941. }
  2942. if (hungry < 0 || hungry > 100) {
  2943. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2944. return -1;
  2945. }
  2946. if (hungry == pd->pet.hungry) {
  2947. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2948. return -1;
  2949. }
  2950. pd->pet.hungry = hungry;
  2951. clif_send_petstatus(sd);
  2952. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2953. return 0;
  2954. }
  2955. /*==========================================
  2956. *
  2957. *------------------------------------------*/
  2958. ACMD_FUNC(petrename)
  2959. {
  2960. struct pet_data *pd;
  2961. nullpo_retr(-1, sd);
  2962. if (!sd->status.pet_id || !sd->pd) {
  2963. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2964. return -1;
  2965. }
  2966. pd = sd->pd;
  2967. if (!pd->pet.rename_flag) {
  2968. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2969. return -1;
  2970. }
  2971. pd->pet.rename_flag = 0;
  2972. intif_save_petdata(sd->status.account_id, &pd->pet);
  2973. clif_send_petstatus(sd);
  2974. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2975. return 0;
  2976. }
  2977. /*==========================================
  2978. *
  2979. *------------------------------------------*/
  2980. ACMD_FUNC(recall)
  2981. {
  2982. struct map_session_data *pl_sd = NULL;
  2983. nullpo_retr(-1, sd);
  2984. if (!message || !*message) {
  2985. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2986. return -1;
  2987. }
  2988. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2989. {
  2990. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2991. return -1;
  2992. }
  2993. if (pl_sd == sd)
  2994. {
  2995. clif_displaymessage(fd, "You are already where you are...");
  2996. return -1;
  2997. }
  2998. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2999. {
  3000. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  3001. return -1;
  3002. }
  3003. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3004. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3005. return -1;
  3006. }
  3007. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3008. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3009. return -1;
  3010. }
  3011. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3012. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  3013. clif_displaymessage(fd, atcmd_output);
  3014. return 0;
  3015. }
  3016. /*==========================================
  3017. * charblock command (usage: charblock <player_name>)
  3018. * This command do a definitiv ban on a player
  3019. *------------------------------------------*/
  3020. ACMD_FUNC(char_block)
  3021. {
  3022. nullpo_retr(-1, sd);
  3023. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3024. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3025. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3026. return -1;
  3027. }
  3028. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3029. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3030. return 0;
  3031. }
  3032. /*==========================================
  3033. * charban command (usage: charban <time> <player_name>)
  3034. * This command do a limited ban on a player
  3035. * Time is done as follows:
  3036. * Adjustment value (-1, 1, +1, etc...)
  3037. * Modified element:
  3038. * a or y: year
  3039. * m: month
  3040. * j or d: day
  3041. * h: hour
  3042. * mn: minute
  3043. * s: second
  3044. * <example> @ban +1m-2mn1s-6y test_player
  3045. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3046. *------------------------------------------*/
  3047. ACMD_FUNC(char_ban)
  3048. {
  3049. char * modif_p;
  3050. int year, month, day, hour, minute, second, value;
  3051. nullpo_retr(-1, sd);
  3052. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3053. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3054. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3055. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3056. return -1;
  3057. }
  3058. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3059. modif_p = atcmd_output;
  3060. year = month = day = hour = minute = second = 0;
  3061. while (modif_p[0] != '\0') {
  3062. value = atoi(modif_p);
  3063. if (value == 0)
  3064. modif_p++;
  3065. else {
  3066. if (modif_p[0] == '-' || modif_p[0] == '+')
  3067. modif_p++;
  3068. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3069. modif_p++;
  3070. if (modif_p[0] == 's') {
  3071. second = value;
  3072. modif_p++;
  3073. } else if (modif_p[0] == 'n') {
  3074. minute = value;
  3075. modif_p++;
  3076. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3077. minute = value;
  3078. modif_p = modif_p + 2;
  3079. } else if (modif_p[0] == 'h') {
  3080. hour = value;
  3081. modif_p++;
  3082. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3083. day = value;
  3084. modif_p++;
  3085. } else if (modif_p[0] == 'm') {
  3086. month = value;
  3087. modif_p++;
  3088. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3089. year = value;
  3090. modif_p++;
  3091. } else if (modif_p[0] != '\0') {
  3092. modif_p++;
  3093. }
  3094. }
  3095. }
  3096. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3097. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3098. return -1;
  3099. }
  3100. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3101. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3102. return 0;
  3103. }
  3104. /*==========================================
  3105. * charunblock command (usage: charunblock <player_name>)
  3106. *------------------------------------------*/
  3107. ACMD_FUNC(char_unblock)
  3108. {
  3109. nullpo_retr(-1, sd);
  3110. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3111. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3112. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3113. return -1;
  3114. }
  3115. // send answer to login server via char-server
  3116. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3117. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3118. return 0;
  3119. }
  3120. /*==========================================
  3121. * charunban command (usage: charunban <player_name>)
  3122. *------------------------------------------*/
  3123. ACMD_FUNC(char_unban)
  3124. {
  3125. nullpo_retr(-1, sd);
  3126. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3127. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3128. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3129. return -1;
  3130. }
  3131. // send answer to login server via char-server
  3132. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3133. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3134. return 0;
  3135. }
  3136. /*==========================================
  3137. *
  3138. *------------------------------------------*/
  3139. ACMD_FUNC(night)
  3140. {
  3141. nullpo_retr(-1, sd);
  3142. if (night_flag != 1) {
  3143. map_night_timer(night_timer_tid, 0, 0, 1);
  3144. } else {
  3145. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  3146. return -1;
  3147. }
  3148. return 0;
  3149. }
  3150. /*==========================================
  3151. *
  3152. *------------------------------------------*/
  3153. ACMD_FUNC(day)
  3154. {
  3155. nullpo_retr(-1, sd);
  3156. if (night_flag != 0) {
  3157. map_day_timer(day_timer_tid, 0, 0, 1);
  3158. } else {
  3159. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  3160. return -1;
  3161. }
  3162. return 0;
  3163. }
  3164. /*==========================================
  3165. *
  3166. *------------------------------------------*/
  3167. ACMD_FUNC(doom)
  3168. {
  3169. struct map_session_data* pl_sd;
  3170. struct s_mapiterator* iter;
  3171. nullpo_retr(-1, sd);
  3172. iter = mapit_getallusers();
  3173. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3174. {
  3175. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3176. {
  3177. status_kill(&pl_sd->bl);
  3178. clif_specialeffect(&pl_sd->bl,450,AREA);
  3179. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3180. }
  3181. }
  3182. mapit_free(iter);
  3183. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3184. return 0;
  3185. }
  3186. /*==========================================
  3187. *
  3188. *------------------------------------------*/
  3189. ACMD_FUNC(doommap)
  3190. {
  3191. struct map_session_data* pl_sd;
  3192. struct s_mapiterator* iter;
  3193. nullpo_retr(-1, sd);
  3194. iter = mapit_getallusers();
  3195. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3196. {
  3197. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3198. {
  3199. status_kill(&pl_sd->bl);
  3200. clif_specialeffect(&pl_sd->bl,450,AREA);
  3201. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3202. }
  3203. }
  3204. mapit_free(iter);
  3205. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3206. return 0;
  3207. }
  3208. /*==========================================
  3209. *
  3210. *------------------------------------------*/
  3211. static void atcommand_raise_sub(struct map_session_data* sd)
  3212. {
  3213. if (!status_isdead(&sd->bl))
  3214. return;
  3215. if(!status_revive(&sd->bl, 100, 100))
  3216. return;
  3217. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3218. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3219. }
  3220. /*==========================================
  3221. *
  3222. *------------------------------------------*/
  3223. ACMD_FUNC(raise)
  3224. {
  3225. struct map_session_data* pl_sd;
  3226. struct s_mapiterator* iter;
  3227. nullpo_retr(-1, sd);
  3228. iter = mapit_getallusers();
  3229. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3230. atcommand_raise_sub(pl_sd);
  3231. mapit_free(iter);
  3232. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3233. return 0;
  3234. }
  3235. /*==========================================
  3236. *
  3237. *------------------------------------------*/
  3238. ACMD_FUNC(raisemap)
  3239. {
  3240. struct map_session_data* pl_sd;
  3241. struct s_mapiterator* iter;
  3242. nullpo_retr(-1, sd);
  3243. iter = mapit_getallusers();
  3244. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3245. if (sd->bl.m == pl_sd->bl.m)
  3246. atcommand_raise_sub(pl_sd);
  3247. mapit_free(iter);
  3248. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3249. return 0;
  3250. }
  3251. /*==========================================
  3252. *
  3253. *------------------------------------------*/
  3254. ACMD_FUNC(kick)
  3255. {
  3256. struct map_session_data *pl_sd;
  3257. nullpo_retr(-1, sd);
  3258. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3259. if (!message || !*message) {
  3260. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3261. return -1;
  3262. }
  3263. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3264. {
  3265. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3266. return -1;
  3267. }
  3268. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3269. {
  3270. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3271. return -1;
  3272. }
  3273. clif_GM_kick(sd, pl_sd);
  3274. return 0;
  3275. }
  3276. /*==========================================
  3277. *
  3278. *------------------------------------------*/
  3279. ACMD_FUNC(kickall)
  3280. {
  3281. struct map_session_data* pl_sd;
  3282. struct s_mapiterator* iter;
  3283. nullpo_retr(-1, sd);
  3284. iter = mapit_getallusers();
  3285. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3286. {
  3287. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3288. if (sd->status.account_id != pl_sd->status.account_id)
  3289. clif_GM_kick(NULL, pl_sd);
  3290. }
  3291. }
  3292. mapit_free(iter);
  3293. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3294. return 0;
  3295. }
  3296. /*==========================================
  3297. *
  3298. *------------------------------------------*/
  3299. ACMD_FUNC(allskill)
  3300. {
  3301. nullpo_retr(-1, sd);
  3302. pc_allskillup(sd); // all skills
  3303. sd->status.skill_point = 0; // 0 skill points
  3304. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3305. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3306. return 0;
  3307. }
  3308. /*==========================================
  3309. *
  3310. *------------------------------------------*/
  3311. ACMD_FUNC(questskill)
  3312. {
  3313. int skill_id;
  3314. nullpo_retr(-1, sd);
  3315. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3316. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3317. return -1;
  3318. }
  3319. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3320. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3321. return -1;
  3322. }
  3323. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3324. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3325. return -1;
  3326. }
  3327. if (pc_checkskill(sd, skill_id) > 0) {
  3328. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3329. return -1;
  3330. }
  3331. pc_skill(sd, skill_id, 1, 0);
  3332. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3333. return 0;
  3334. }
  3335. /*==========================================
  3336. *
  3337. *------------------------------------------*/
  3338. ACMD_FUNC(lostskill)
  3339. {
  3340. int skill_id;
  3341. nullpo_retr(-1, sd);
  3342. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3343. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3344. return -1;
  3345. }
  3346. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3347. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3348. return -1;
  3349. }
  3350. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3351. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3352. return -1;
  3353. }
  3354. if (pc_checkskill(sd, skill_id) == 0) {
  3355. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3356. return -1;
  3357. }
  3358. sd->status.skill[skill_id].lv = 0;
  3359. sd->status.skill[skill_id].flag = 0;
  3360. clif_deleteskill(sd,skill_id);
  3361. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3362. return 0;
  3363. }
  3364. /*==========================================
  3365. *
  3366. *------------------------------------------*/
  3367. ACMD_FUNC(spiritball)
  3368. {
  3369. int max_spiritballs;
  3370. int number;
  3371. nullpo_retr(-1, sd);
  3372. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3373. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3374. {
  3375. char msg[CHAT_SIZE_MAX];
  3376. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3377. clif_displaymessage(fd, msg);
  3378. return -1;
  3379. }
  3380. if( sd->spiritball > 0 )
  3381. pc_delspiritball(sd, sd->spiritball, 1);
  3382. sd->spiritball = number;
  3383. clif_spiritball(sd);
  3384. // no message, player can look the difference
  3385. return 0;
  3386. }
  3387. /*==========================================
  3388. *
  3389. *------------------------------------------*/
  3390. ACMD_FUNC(party)
  3391. {
  3392. char party[NAME_LENGTH];
  3393. nullpo_retr(-1, sd);
  3394. memset(party, '\0', sizeof(party));
  3395. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3396. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3397. return -1;
  3398. }
  3399. party_create(sd, party, 0, 0);
  3400. return 0;
  3401. }
  3402. /*==========================================
  3403. *
  3404. *------------------------------------------*/
  3405. ACMD_FUNC(guild)
  3406. {
  3407. char guild[NAME_LENGTH];
  3408. int prev;
  3409. nullpo_retr(-1, sd);
  3410. memset(guild, '\0', sizeof(guild));
  3411. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3412. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3413. return -1;
  3414. }
  3415. prev = battle_config.guild_emperium_check;
  3416. battle_config.guild_emperium_check = 0;
  3417. guild_create(sd, guild);
  3418. battle_config.guild_emperium_check = prev;
  3419. return 0;
  3420. }
  3421. /*==========================================
  3422. *
  3423. *------------------------------------------*/
  3424. ACMD_FUNC(agitstart)
  3425. {
  3426. nullpo_retr(-1, sd);
  3427. if (agit_flag == 1) {
  3428. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3429. return -1;
  3430. }
  3431. agit_flag = 1;
  3432. guild_agit_start();
  3433. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3434. return 0;
  3435. }
  3436. /*==========================================
  3437. *
  3438. *------------------------------------------*/
  3439. ACMD_FUNC(agitstart2)
  3440. {
  3441. nullpo_retr(-1, sd);
  3442. if (agit2_flag == 1) {
  3443. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3444. return -1;
  3445. }
  3446. agit2_flag = 1;
  3447. guild_agit2_start();
  3448. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3449. return 0;
  3450. }
  3451. /*==========================================
  3452. *
  3453. *------------------------------------------*/
  3454. ACMD_FUNC(agitend)
  3455. {
  3456. nullpo_retr(-1, sd);
  3457. if (agit_flag == 0) {
  3458. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3459. return -1;
  3460. }
  3461. agit_flag = 0;
  3462. guild_agit_end();
  3463. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3464. return 0;
  3465. }
  3466. /*==========================================
  3467. *
  3468. *------------------------------------------*/
  3469. ACMD_FUNC(agitend2)
  3470. {
  3471. nullpo_retr(-1, sd);
  3472. if (agit2_flag == 0) {
  3473. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3474. return -1;
  3475. }
  3476. agit2_flag = 0;
  3477. guild_agit2_end();
  3478. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3479. return 0;
  3480. }
  3481. /*==========================================
  3482. * @mapexit - shuts down the map server
  3483. *------------------------------------------*/
  3484. ACMD_FUNC(mapexit)
  3485. {
  3486. nullpo_retr(-1, sd);
  3487. do_shutdown();
  3488. return 0;
  3489. }
  3490. /*==========================================
  3491. * idsearch <part_of_name>: revrited by [Yor]
  3492. *------------------------------------------*/
  3493. ACMD_FUNC(idsearch)
  3494. {
  3495. char item_name[100];
  3496. unsigned int i, match;
  3497. struct item_data *item_array[MAX_SEARCH];
  3498. nullpo_retr(-1, sd);
  3499. memset(item_name, '\0', sizeof(item_name));
  3500. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3501. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3502. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3503. return -1;
  3504. }
  3505. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3506. clif_displaymessage(fd, atcmd_output);
  3507. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3508. if (match > MAX_SEARCH) {
  3509. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3510. clif_displaymessage(fd, atcmd_output);
  3511. match = MAX_SEARCH;
  3512. }
  3513. for(i = 0; i < match; i++) {
  3514. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3515. clif_displaymessage(fd, atcmd_output);
  3516. }
  3517. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3518. clif_displaymessage(fd, atcmd_output);
  3519. return 0;
  3520. }
  3521. /*==========================================
  3522. * Recall All Characters Online To Your Location
  3523. *------------------------------------------*/
  3524. ACMD_FUNC(recallall)
  3525. {
  3526. struct map_session_data* pl_sd;
  3527. struct s_mapiterator* iter;
  3528. int count;
  3529. nullpo_retr(-1, sd);
  3530. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3531. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3532. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3533. return -1;
  3534. }
  3535. count = 0;
  3536. iter = mapit_getallusers();
  3537. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3538. {
  3539. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3540. {
  3541. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3542. count++;
  3543. else {
  3544. if (pc_isdead(pl_sd)) { //Wake them up
  3545. pc_setstand(pl_sd);
  3546. pc_setrestartvalue(pl_sd,1);
  3547. }
  3548. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3549. }
  3550. }
  3551. }
  3552. mapit_free(iter);
  3553. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3554. if (count) {
  3555. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3556. clif_displaymessage(fd, atcmd_output);
  3557. }
  3558. return 0;
  3559. }
  3560. /*==========================================
  3561. * Recall online characters of a guild to your location
  3562. *------------------------------------------*/
  3563. ACMD_FUNC(guildrecall)
  3564. {
  3565. struct map_session_data* pl_sd;
  3566. struct s_mapiterator* iter;
  3567. int count;
  3568. char guild_name[NAME_LENGTH];
  3569. struct guild *g;
  3570. nullpo_retr(-1, sd);
  3571. memset(guild_name, '\0', sizeof(guild_name));
  3572. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3573. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3574. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3575. return -1;
  3576. }
  3577. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3578. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3579. return -1;
  3580. }
  3581. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3582. (g = guild_search(atoi(message))) == NULL)
  3583. {
  3584. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3585. return -1;
  3586. }
  3587. count = 0;
  3588. iter = mapit_getallusers();
  3589. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3590. {
  3591. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3592. {
  3593. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3594. continue; //Skip GMs greater than you.
  3595. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3596. count++;
  3597. else
  3598. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3599. }
  3600. }
  3601. mapit_free(iter);
  3602. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3603. clif_displaymessage(fd, atcmd_output);
  3604. if (count) {
  3605. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3606. clif_displaymessage(fd, atcmd_output);
  3607. }
  3608. return 0;
  3609. }
  3610. /*==========================================
  3611. * Recall online characters of a party to your location
  3612. *------------------------------------------*/
  3613. ACMD_FUNC(partyrecall)
  3614. {
  3615. struct map_session_data* pl_sd;
  3616. struct s_mapiterator* iter;
  3617. char party_name[NAME_LENGTH];
  3618. struct party_data *p;
  3619. int count;
  3620. nullpo_retr(-1, sd);
  3621. memset(party_name, '\0', sizeof(party_name));
  3622. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3623. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3624. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3625. return -1;
  3626. }
  3627. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3628. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3629. return -1;
  3630. }
  3631. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3632. (p = party_search(atoi(message))) == NULL)
  3633. {
  3634. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3635. return -1;
  3636. }
  3637. count = 0;
  3638. iter = mapit_getallusers();
  3639. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3640. {
  3641. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3642. {
  3643. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3644. continue; //Skip GMs greater than you.
  3645. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3646. count++;
  3647. else
  3648. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3649. }
  3650. }
  3651. mapit_free(iter);
  3652. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3653. clif_displaymessage(fd, atcmd_output);
  3654. if (count) {
  3655. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3656. clif_displaymessage(fd, atcmd_output);
  3657. }
  3658. return 0;
  3659. }
  3660. /*==========================================
  3661. *
  3662. *------------------------------------------*/
  3663. ACMD_FUNC(reloaditemdb)
  3664. {
  3665. nullpo_retr(-1, sd);
  3666. itemdb_reload();
  3667. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3668. return 0;
  3669. }
  3670. /*==========================================
  3671. *
  3672. *------------------------------------------*/
  3673. ACMD_FUNC(reloadmobdb)
  3674. {
  3675. nullpo_retr(-1, sd);
  3676. mob_reload();
  3677. read_petdb();
  3678. merc_reload();
  3679. read_mercenarydb();
  3680. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3681. return 0;
  3682. }
  3683. /*==========================================
  3684. *
  3685. *------------------------------------------*/
  3686. ACMD_FUNC(reloadskilldb)
  3687. {
  3688. nullpo_retr(-1, sd);
  3689. skill_reload();
  3690. merc_skill_reload();
  3691. read_mercenary_skilldb();
  3692. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3693. return 0;
  3694. }
  3695. /*==========================================
  3696. * @reloadatcommand - reloads atcommand_athena.conf
  3697. *------------------------------------------*/
  3698. void atcommand_doload();
  3699. ACMD_FUNC(reloadatcommand) {
  3700. atcommand_doload();
  3701. clif_displaymessage(fd, msg_txt(254));
  3702. return 0;
  3703. }
  3704. /*==========================================
  3705. * @reloadbattleconf - reloads battle_athena.conf
  3706. *------------------------------------------*/
  3707. ACMD_FUNC(reloadbattleconf)
  3708. {
  3709. struct Battle_Config prev_config;
  3710. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3711. battle_config_read(BATTLE_CONF_FILENAME);
  3712. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3713. || prev_config.item_rate_common != battle_config.item_rate_common
  3714. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3715. || prev_config.item_rate_card != battle_config.item_rate_card
  3716. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3717. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3718. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3719. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3720. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3721. || prev_config.item_rate_use != battle_config.item_rate_use
  3722. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3723. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3724. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3725. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3726. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3727. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3728. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3729. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3730. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3731. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3732. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3733. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3734. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3735. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3736. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3737. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3738. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3739. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3740. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3741. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3742. )
  3743. { // Exp or Drop rates changed.
  3744. mob_reload(); //Needed as well so rate changes take effect.
  3745. #ifndef TXT_ONLY
  3746. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3747. #endif
  3748. }
  3749. clif_displaymessage(fd, msg_txt(255));
  3750. return 0;
  3751. }
  3752. /*==========================================
  3753. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3754. *------------------------------------------*/
  3755. ACMD_FUNC(reloadstatusdb)
  3756. {
  3757. status_readdb();
  3758. clif_displaymessage(fd, msg_txt(256));
  3759. return 0;
  3760. }
  3761. /*==========================================
  3762. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3763. *------------------------------------------*/
  3764. ACMD_FUNC(reloadpcdb)
  3765. {
  3766. pc_readdb();
  3767. clif_displaymessage(fd, msg_txt(257));
  3768. return 0;
  3769. }
  3770. /*==========================================
  3771. * @reloadmotd - reloads motd.txt
  3772. *------------------------------------------*/
  3773. ACMD_FUNC(reloadmotd)
  3774. {
  3775. pc_read_motd();
  3776. clif_displaymessage(fd, msg_txt(268));
  3777. return 0;
  3778. }
  3779. /*==========================================
  3780. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3781. *------------------------------------------*/
  3782. ACMD_FUNC(reloadscript)
  3783. {
  3784. nullpo_retr(-1, sd);
  3785. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3786. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3787. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3788. flush_fifos();
  3789. script_reload();
  3790. npc_reload();
  3791. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3792. return 0;
  3793. }
  3794. /*==========================================
  3795. * @mapinfo [0-3] <map name> by MC_Cameri
  3796. * => Shows information about the map [map name]
  3797. * 0 = no additional information
  3798. * 1 = Show users in that map and their location
  3799. * 2 = Shows NPCs in that map
  3800. * 3 = Shows the shops/chats in that map (not implemented)
  3801. *------------------------------------------*/
  3802. ACMD_FUNC(mapinfo)
  3803. {
  3804. struct map_session_data* pl_sd;
  3805. struct s_mapiterator* iter;
  3806. struct npc_data *nd = NULL;
  3807. struct chat_data *cd = NULL;
  3808. char direction[12];
  3809. int i, m_id, chat_num, list = 0;
  3810. unsigned short m_index;
  3811. char mapname[24];
  3812. nullpo_retr(-1, sd);
  3813. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3814. memset(mapname, '\0', sizeof(mapname));
  3815. memset(direction, '\0', sizeof(direction));
  3816. sscanf(message, "%d %23[^\n]", &list, mapname);
  3817. if (list < 0 || list > 3) {
  3818. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3819. return -1;
  3820. }
  3821. if (mapname[0] == '\0') {
  3822. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3823. m_id = map_mapindex2mapid(sd->mapindex);
  3824. } else {
  3825. m_id = map_mapname2mapid(mapname);
  3826. }
  3827. if (m_id < 0) {
  3828. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3829. return -1;
  3830. }
  3831. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3832. clif_displaymessage(fd, "------ Map Info ------");
  3833. // count chats (for initial message)
  3834. chat_num = 0;
  3835. iter = mapit_getallusers();
  3836. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3837. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3838. chat_num++;
  3839. mapit_free(iter);
  3840. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
  3841. clif_displaymessage(fd, atcmd_output);
  3842. clif_displaymessage(fd, "------ Map Flags ------");
  3843. if (map[m_id].flag.town)
  3844. clif_displaymessage(fd, "Town Map");
  3845. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3846. clif_displaymessage(fd, "Autotrade Enabled");
  3847. else
  3848. clif_displaymessage(fd, "Autotrade Disabled");
  3849. if (map[m_id].flag.battleground)
  3850. clif_displaymessage(fd, "Battlegrounds ON");
  3851. strcpy(atcmd_output,"PvP Flags: ");
  3852. if (map[m_id].flag.pvp)
  3853. strcat(atcmd_output, "Pvp ON | ");
  3854. if (map[m_id].flag.pvp_noguild)
  3855. strcat(atcmd_output, "NoGuild | ");
  3856. if (map[m_id].flag.pvp_noparty)
  3857. strcat(atcmd_output, "NoParty | ");
  3858. if (map[m_id].flag.pvp_nightmaredrop)
  3859. strcat(atcmd_output, "NightmareDrop | ");
  3860. if (map[m_id].flag.pvp_nocalcrank)
  3861. strcat(atcmd_output, "NoCalcRank | ");
  3862. clif_displaymessage(fd, atcmd_output);
  3863. strcpy(atcmd_output,"GvG Flags: ");
  3864. if (map[m_id].flag.gvg)
  3865. strcat(atcmd_output, "GvG ON | ");
  3866. if (map[m_id].flag.gvg_dungeon)
  3867. strcat(atcmd_output, "GvG Dungeon | ");
  3868. if (map[m_id].flag.gvg_castle)
  3869. strcat(atcmd_output, "GvG Castle | ");
  3870. if (map[m_id].flag.gvg_noparty)
  3871. strcat(atcmd_output, "NoParty | ");
  3872. clif_displaymessage(fd, atcmd_output);
  3873. strcpy(atcmd_output,"Teleport Flags: ");
  3874. if (map[m_id].flag.noteleport)
  3875. strcat(atcmd_output, "NoTeleport | ");
  3876. if (map[m_id].flag.monster_noteleport)
  3877. strcat(atcmd_output, "Monster NoTeleport | ");
  3878. if (map[m_id].flag.nowarp)
  3879. strcat(atcmd_output, "NoWarp | ");
  3880. if (map[m_id].flag.nowarpto)
  3881. strcat(atcmd_output, "NoWarpTo | ");
  3882. if (map[m_id].flag.noreturn)
  3883. strcat(atcmd_output, "NoReturn | ");
  3884. if (map[m_id].flag.nogo)
  3885. strcat(atcmd_output, "NoGo | ");
  3886. if (map[m_id].flag.nomemo)
  3887. strcat(atcmd_output, "NoMemo | ");
  3888. clif_displaymessage(fd, atcmd_output);
  3889. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  3890. clif_displaymessage(fd, atcmd_output);
  3891. if (map[m_id].flag.nosave) {
  3892. if (!map[m_id].save.map)
  3893. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3894. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3895. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3896. else
  3897. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3898. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3899. clif_displaymessage(fd, atcmd_output);
  3900. }
  3901. strcpy(atcmd_output,"Weather Flags: ");
  3902. if (map[m_id].flag.snow)
  3903. strcat(atcmd_output, "Snow | ");
  3904. if (map[m_id].flag.fog)
  3905. strcat(atcmd_output, "Fog | ");
  3906. if (map[m_id].flag.sakura)
  3907. strcat(atcmd_output, "Sakura | ");
  3908. if (map[m_id].flag.clouds)
  3909. strcat(atcmd_output, "Clouds | ");
  3910. if (map[m_id].flag.clouds2)
  3911. strcat(atcmd_output, "Clouds2 | ");
  3912. if (map[m_id].flag.fireworks)
  3913. strcat(atcmd_output, "Fireworks | ");
  3914. if (map[m_id].flag.leaves)
  3915. strcat(atcmd_output, "Leaves | ");
  3916. /**
  3917. * No longer available, keeping here just in case it's back someday. [Ind]
  3918. **/
  3919. //if (map[m_id].flag.rain)
  3920. // strcat(atcmd_output, "Rain | ");
  3921. if (map[m_id].flag.nightenabled)
  3922. strcat(atcmd_output, "Displays Night | ");
  3923. clif_displaymessage(fd, atcmd_output);
  3924. strcpy(atcmd_output,"Other Flags: ");
  3925. if (map[m_id].flag.nobranch)
  3926. strcat(atcmd_output, "NoBranch | ");
  3927. if (map[m_id].flag.notrade)
  3928. strcat(atcmd_output, "NoTrade | ");
  3929. if (map[m_id].flag.novending)
  3930. strcat(atcmd_output, "NoVending | ");
  3931. if (map[m_id].flag.nodrop)
  3932. strcat(atcmd_output, "NoDrop | ");
  3933. if (map[m_id].flag.noskill)
  3934. strcat(atcmd_output, "NoSkill | ");
  3935. if (map[m_id].flag.noicewall)
  3936. strcat(atcmd_output, "NoIcewall | ");
  3937. if (map[m_id].flag.allowks)
  3938. strcat(atcmd_output, "AllowKS | ");
  3939. if (map[m_id].flag.reset)
  3940. strcat(atcmd_output, "Reset | ");
  3941. clif_displaymessage(fd, atcmd_output);
  3942. strcpy(atcmd_output,"Other Flags: ");
  3943. if (map[m_id].nocommand)
  3944. strcat(atcmd_output, "NoCommand | ");
  3945. if (map[m_id].flag.nobaseexp)
  3946. strcat(atcmd_output, "NoBaseEXP | ");
  3947. if (map[m_id].flag.nojobexp)
  3948. strcat(atcmd_output, "NoJobEXP | ");
  3949. if (map[m_id].flag.nomobloot)
  3950. strcat(atcmd_output, "NoMobLoot | ");
  3951. if (map[m_id].flag.nomvploot)
  3952. strcat(atcmd_output, "NoMVPLoot | ");
  3953. if (map[m_id].flag.partylock)
  3954. strcat(atcmd_output, "PartyLock | ");
  3955. if (map[m_id].flag.guildlock)
  3956. strcat(atcmd_output, "GuildLock | ");
  3957. clif_displaymessage(fd, atcmd_output);
  3958. switch (list) {
  3959. case 0:
  3960. // Do nothing. It's list 0, no additional display.
  3961. break;
  3962. case 1:
  3963. clif_displaymessage(fd, "----- Players in Map -----");
  3964. iter = mapit_getallusers();
  3965. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3966. {
  3967. if (pl_sd->mapindex == m_index) {
  3968. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3969. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3970. clif_displaymessage(fd, atcmd_output);
  3971. }
  3972. }
  3973. mapit_free(iter);
  3974. break;
  3975. case 2:
  3976. clif_displaymessage(fd, "----- NPCs in Map -----");
  3977. for (i = 0; i < map[m_id].npc_num;)
  3978. {
  3979. nd = map[m_id].npc[i];
  3980. switch(nd->ud.dir) {
  3981. case 0: strcpy(direction, "North"); break;
  3982. case 1: strcpy(direction, "North West"); break;
  3983. case 2: strcpy(direction, "West"); break;
  3984. case 3: strcpy(direction, "South West"); break;
  3985. case 4: strcpy(direction, "South"); break;
  3986. case 5: strcpy(direction, "South East"); break;
  3987. case 6: strcpy(direction, "East"); break;
  3988. case 7: strcpy(direction, "North East"); break;
  3989. case 9: strcpy(direction, "North"); break;
  3990. default: strcpy(direction, "Unknown"); break;
  3991. }
  3992. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3993. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3994. clif_displaymessage(fd, atcmd_output);
  3995. }
  3996. break;
  3997. case 3:
  3998. clif_displaymessage(fd, "----- Chats in Map -----");
  3999. iter = mapit_getallusers();
  4000. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4001. {
  4002. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  4003. pl_sd->mapindex == m_index &&
  4004. cd->usersd[0] == pl_sd)
  4005. {
  4006. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  4007. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4008. clif_displaymessage(fd, atcmd_output);
  4009. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4010. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4011. clif_displaymessage(fd, atcmd_output);
  4012. }
  4013. }
  4014. mapit_free(iter);
  4015. break;
  4016. default: // normally impossible to arrive here
  4017. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4018. return -1;
  4019. break;
  4020. }
  4021. return 0;
  4022. }
  4023. /*==========================================
  4024. *
  4025. *------------------------------------------*/
  4026. ACMD_FUNC(mount_peco)
  4027. {
  4028. nullpo_retr(-1, sd);
  4029. if( pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4030. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  4031. clif_displaymessage(sd->fd,"You have mounted your Dragon");
  4032. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  4033. } else {
  4034. clif_displaymessage(sd->fd,"You have released your Dragon");
  4035. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  4036. }
  4037. return 0;
  4038. }
  4039. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4040. if( !(sd->sc.option&OPTION_MADOGEAR) ) {
  4041. clif_displaymessage(sd->fd,"You have mounted your Mado Gear");
  4042. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  4043. } else {
  4044. clif_displaymessage(sd->fd,"You have released your Mado Gear");
  4045. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  4046. }
  4047. return 0;
  4048. }
  4049. if (!pc_isriding(sd)) { // if actually no peco
  4050. if (!pc_checkskill(sd, KN_RIDING))
  4051. {
  4052. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  4053. return -1;
  4054. }
  4055. if (sd->disguise)
  4056. {
  4057. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  4058. return -1;
  4059. }
  4060. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4061. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  4062. } else { //Dismount
  4063. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4064. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  4065. }
  4066. return 0;
  4067. }
  4068. /*==========================================
  4069. *Spy Commands by Syrus22
  4070. *------------------------------------------*/
  4071. ACMD_FUNC(guildspy)
  4072. {
  4073. char guild_name[NAME_LENGTH];
  4074. struct guild *g;
  4075. nullpo_retr(-1, sd);
  4076. memset(guild_name, '\0', sizeof(guild_name));
  4077. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4078. if (!enable_spy)
  4079. {
  4080. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4081. return -1;
  4082. }
  4083. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4084. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4085. return -1;
  4086. }
  4087. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4088. (g = guild_search(atoi(message))) != NULL) {
  4089. if (sd->guildspy == g->guild_id) {
  4090. sd->guildspy = 0;
  4091. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4092. clif_displaymessage(fd, atcmd_output);
  4093. } else {
  4094. sd->guildspy = g->guild_id;
  4095. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4096. clif_displaymessage(fd, atcmd_output);
  4097. }
  4098. } else {
  4099. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  4100. return -1;
  4101. }
  4102. return 0;
  4103. }
  4104. /*==========================================
  4105. *
  4106. *------------------------------------------*/
  4107. ACMD_FUNC(partyspy)
  4108. {
  4109. char party_name[NAME_LENGTH];
  4110. struct party_data *p;
  4111. nullpo_retr(-1, sd);
  4112. memset(party_name, '\0', sizeof(party_name));
  4113. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4114. if (!enable_spy)
  4115. {
  4116. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4117. return -1;
  4118. }
  4119. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4120. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4121. return -1;
  4122. }
  4123. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4124. (p = party_search(atoi(message))) != NULL) {
  4125. if (sd->partyspy == p->party.party_id) {
  4126. sd->partyspy = 0;
  4127. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4128. clif_displaymessage(fd, atcmd_output);
  4129. } else {
  4130. sd->partyspy = p->party.party_id;
  4131. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4132. clif_displaymessage(fd, atcmd_output);
  4133. }
  4134. } else {
  4135. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  4136. return -1;
  4137. }
  4138. return 0;
  4139. }
  4140. /*==========================================
  4141. * @repairall [Valaris]
  4142. *------------------------------------------*/
  4143. ACMD_FUNC(repairall)
  4144. {
  4145. int count, i;
  4146. nullpo_retr(-1, sd);
  4147. count = 0;
  4148. for (i = 0; i < MAX_INVENTORY; i++) {
  4149. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4150. sd->status.inventory[i].attribute = 0;
  4151. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4152. count++;
  4153. }
  4154. }
  4155. if (count > 0) {
  4156. clif_misceffect(&sd->bl, 3);
  4157. clif_equiplist(sd);
  4158. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4159. } else {
  4160. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4161. return -1;
  4162. }
  4163. return 0;
  4164. }
  4165. /*==========================================
  4166. * @nuke [Valaris]
  4167. *------------------------------------------*/
  4168. ACMD_FUNC(nuke)
  4169. {
  4170. struct map_session_data *pl_sd;
  4171. nullpo_retr(-1, sd);
  4172. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4173. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4174. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4175. return -1;
  4176. }
  4177. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4178. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4179. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4180. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4181. } else {
  4182. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4183. return -1;
  4184. }
  4185. } else {
  4186. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4187. return -1;
  4188. }
  4189. return 0;
  4190. }
  4191. /*==========================================
  4192. * @tonpc
  4193. *------------------------------------------*/
  4194. ACMD_FUNC(tonpc)
  4195. {
  4196. char npcname[NAME_LENGTH+1];
  4197. struct npc_data *nd;
  4198. nullpo_retr(-1, sd);
  4199. memset(npcname, 0, sizeof(npcname));
  4200. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4201. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4202. return -1;
  4203. }
  4204. if ((nd = npc_name2id(npcname)) != NULL) {
  4205. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4206. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4207. else
  4208. return -1;
  4209. } else {
  4210. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4211. return -1;
  4212. }
  4213. return 0;
  4214. }
  4215. /*==========================================
  4216. *
  4217. *------------------------------------------*/
  4218. ACMD_FUNC(shownpc)
  4219. {
  4220. char NPCname[NAME_LENGTH+1];
  4221. nullpo_retr(-1, sd);
  4222. memset(NPCname, '\0', sizeof(NPCname));
  4223. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4224. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4225. return -1;
  4226. }
  4227. if (npc_name2id(NPCname) != NULL) {
  4228. npc_enable(NPCname, 1);
  4229. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4230. } else {
  4231. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4232. return -1;
  4233. }
  4234. return 0;
  4235. }
  4236. /*==========================================
  4237. *
  4238. *------------------------------------------*/
  4239. ACMD_FUNC(hidenpc)
  4240. {
  4241. char NPCname[NAME_LENGTH+1];
  4242. nullpo_retr(-1, sd);
  4243. memset(NPCname, '\0', sizeof(NPCname));
  4244. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4245. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4246. return -1;
  4247. }
  4248. if (npc_name2id(NPCname) == NULL) {
  4249. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4250. return -1;
  4251. }
  4252. npc_enable(NPCname, 0);
  4253. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4254. return 0;
  4255. }
  4256. ACMD_FUNC(loadnpc)
  4257. {
  4258. FILE *fp;
  4259. if (!message || !*message) {
  4260. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4261. return -1;
  4262. }
  4263. // check if script file exists
  4264. if ((fp = fopen(message, "r")) == NULL) {
  4265. clif_displaymessage(fd, msg_txt(261));
  4266. return -1;
  4267. }
  4268. fclose(fp);
  4269. // add to list of script sources and run it
  4270. npc_addsrcfile(message);
  4271. npc_parsesrcfile(message);
  4272. npc_read_event_script();
  4273. clif_displaymessage(fd, msg_txt(262));
  4274. return 0;
  4275. }
  4276. ACMD_FUNC(unloadnpc)
  4277. {
  4278. struct npc_data *nd;
  4279. char NPCname[NAME_LENGTH+1];
  4280. nullpo_retr(-1, sd);
  4281. memset(NPCname, '\0', sizeof(NPCname));
  4282. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4283. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4284. return -1;
  4285. }
  4286. if ((nd = npc_name2id(NPCname)) == NULL) {
  4287. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4288. return -1;
  4289. }
  4290. npc_unload_duplicates(nd);
  4291. npc_unload(nd);
  4292. npc_read_event_script();
  4293. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4294. return 0;
  4295. }
  4296. /*==========================================
  4297. * time in txt for time command (by [Yor])
  4298. *------------------------------------------*/
  4299. char* txt_time(unsigned int duration)
  4300. {
  4301. int days, hours, minutes, seconds;
  4302. char temp[CHAT_SIZE_MAX];
  4303. static char temp1[CHAT_SIZE_MAX];
  4304. memset(temp, '\0', sizeof(temp));
  4305. memset(temp1, '\0', sizeof(temp1));
  4306. days = duration / (60 * 60 * 24);
  4307. duration = duration - (60 * 60 * 24 * days);
  4308. hours = duration / (60 * 60);
  4309. duration = duration - (60 * 60 * hours);
  4310. minutes = duration / 60;
  4311. seconds = duration - (60 * minutes);
  4312. if (days < 2)
  4313. sprintf(temp, msg_txt(219), days); // %d day
  4314. else
  4315. sprintf(temp, msg_txt(220), days); // %d days
  4316. if (hours < 2)
  4317. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4318. else
  4319. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4320. if (minutes < 2)
  4321. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4322. else
  4323. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4324. if (seconds < 2)
  4325. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4326. else
  4327. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4328. return temp1;
  4329. }
  4330. /*==========================================
  4331. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4332. * Calculation management of GM modification (@day/@night GM commands) is done
  4333. *------------------------------------------*/
  4334. ACMD_FUNC(servertime)
  4335. {
  4336. const struct TimerData * timer_data;
  4337. const struct TimerData * timer_data2;
  4338. time_t time_server; // variable for number of seconds (used with time() function)
  4339. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4340. char temp[CHAT_SIZE_MAX];
  4341. nullpo_retr(-1, sd);
  4342. memset(temp, '\0', sizeof(temp));
  4343. time(&time_server); // get time in seconds since 1/1/1970
  4344. datetime = localtime(&time_server); // convert seconds in structure
  4345. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4346. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4347. clif_displaymessage(fd, temp);
  4348. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4349. if (night_flag == 0)
  4350. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4351. else
  4352. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4353. } else if (battle_config.night_duration == 0)
  4354. if (night_flag == 1) { // we start with night
  4355. timer_data = get_timer(day_timer_tid);
  4356. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4357. clif_displaymessage(fd, temp);
  4358. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4359. } else
  4360. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4361. else if (battle_config.day_duration == 0)
  4362. if (night_flag == 0) { // we start with day
  4363. timer_data = get_timer(night_timer_tid);
  4364. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4365. clif_displaymessage(fd, temp);
  4366. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4367. } else
  4368. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4369. else {
  4370. if (night_flag == 0) {
  4371. timer_data = get_timer(night_timer_tid);
  4372. timer_data2 = get_timer(day_timer_tid);
  4373. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4374. clif_displaymessage(fd, temp);
  4375. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4376. 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.
  4377. else
  4378. 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.
  4379. clif_displaymessage(fd, temp);
  4380. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4381. clif_displaymessage(fd, temp);
  4382. } else {
  4383. timer_data = get_timer(day_timer_tid);
  4384. timer_data2 = get_timer(night_timer_tid);
  4385. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4386. clif_displaymessage(fd, temp);
  4387. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4388. 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.
  4389. else
  4390. 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.
  4391. clif_displaymessage(fd, temp);
  4392. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4393. clif_displaymessage(fd, temp);
  4394. }
  4395. }
  4396. return 0;
  4397. }
  4398. //Added by Coltaro
  4399. //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...).
  4400. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4401. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4402. {
  4403. const int factor_year = 518400; //12*30*24*60 = 518400
  4404. const int factor_month = 43200; //30*24*60 = 43200
  4405. const int factor_day = 1440; //24*60 = 1440
  4406. const int factor_hour = 60;
  4407. *year = jailtime/factor_year;
  4408. jailtime -= *year*factor_year;
  4409. *month = jailtime/factor_month;
  4410. jailtime -= *month*factor_month;
  4411. *day = jailtime/factor_day;
  4412. jailtime -= *day*factor_day;
  4413. *hour = jailtime/factor_hour;
  4414. jailtime -= *hour*factor_hour;
  4415. *minute = jailtime;
  4416. *year = *year > 0? *year : 0;
  4417. *month = *month > 0? *month : 0;
  4418. *day = *day > 0? *day : 0;
  4419. *hour = *hour > 0? *hour : 0;
  4420. *minute = *minute > 0? *minute : 0;
  4421. return;
  4422. }
  4423. /*==========================================
  4424. * @jail <char_name> by [Yor]
  4425. * Special warp! No check with nowarp and nowarpto flag
  4426. *------------------------------------------*/
  4427. ACMD_FUNC(jail)
  4428. {
  4429. struct map_session_data *pl_sd;
  4430. int x, y;
  4431. unsigned short m_index;
  4432. nullpo_retr(-1, sd);
  4433. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4434. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4435. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4436. return -1;
  4437. }
  4438. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4439. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4440. return -1;
  4441. }
  4442. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4443. { // you can jail only lower or same GM
  4444. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4445. return -1;
  4446. }
  4447. if (pl_sd->sc.data[SC_JAILED])
  4448. {
  4449. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4450. return -1;
  4451. }
  4452. switch(rand() % 2) { //Jail Locations
  4453. case 0:
  4454. m_index = mapindex_name2id(MAP_JAIL);
  4455. x = 24;
  4456. y = 75;
  4457. break;
  4458. default:
  4459. m_index = mapindex_name2id(MAP_JAIL);
  4460. x = 49;
  4461. y = 75;
  4462. break;
  4463. }
  4464. //Duration of INT_MAX to specify infinity.
  4465. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4466. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4467. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4468. return 0;
  4469. }
  4470. /*==========================================
  4471. * @unjail/@discharge <char_name> by [Yor]
  4472. * Special warp! No check with nowarp and nowarpto flag
  4473. *------------------------------------------*/
  4474. ACMD_FUNC(unjail)
  4475. {
  4476. struct map_session_data *pl_sd;
  4477. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4478. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4479. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4480. return -1;
  4481. }
  4482. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4483. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4484. return -1;
  4485. }
  4486. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4487. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4488. return -1;
  4489. }
  4490. if (!pl_sd->sc.data[SC_JAILED])
  4491. {
  4492. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4493. return -1;
  4494. }
  4495. //Reset jail time to 1 sec.
  4496. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4497. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4498. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4499. return 0;
  4500. }
  4501. ACMD_FUNC(jailfor)
  4502. {
  4503. struct map_session_data *pl_sd = NULL;
  4504. int year, month, day, hour, minute, value;
  4505. char * modif_p;
  4506. int jailtime = 0,x,y;
  4507. short m_index = 0;
  4508. nullpo_retr(-1, sd);
  4509. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4510. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4511. return -1;
  4512. }
  4513. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4514. modif_p = atcmd_output;
  4515. year = month = day = hour = minute = 0;
  4516. while (modif_p[0] != '\0') {
  4517. value = atoi(modif_p);
  4518. if (value == 0)
  4519. modif_p++;
  4520. else {
  4521. if (modif_p[0] == '-' || modif_p[0] == '+')
  4522. modif_p++;
  4523. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4524. modif_p++;
  4525. if (modif_p[0] == 'n') {
  4526. minute = value;
  4527. modif_p++;
  4528. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4529. minute = value;
  4530. modif_p = modif_p + 2;
  4531. } else if (modif_p[0] == 'h') {
  4532. hour = value;
  4533. modif_p++;
  4534. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4535. day = value;
  4536. modif_p++;
  4537. } else if (modif_p[0] == 'm') {
  4538. month = value;
  4539. modif_p++;
  4540. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4541. year = value;
  4542. modif_p++;
  4543. } else if (modif_p[0] != '\0') {
  4544. modif_p++;
  4545. }
  4546. }
  4547. }
  4548. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4549. clif_displaymessage(fd, "Invalid time for jail command.");
  4550. return -1;
  4551. }
  4552. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4553. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4554. return -1;
  4555. }
  4556. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4557. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4558. return -1;
  4559. }
  4560. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4561. if(jailtime==0) {
  4562. clif_displaymessage(fd, "Invalid time for jail command.");
  4563. return -1;
  4564. }
  4565. //Added by Coltaro
  4566. if(pl_sd->sc.data[SC_JAILED] &&
  4567. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4568. { //Update the player's jail time
  4569. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4570. if (jailtime <= 0) {
  4571. jailtime = 0;
  4572. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4573. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4574. } else {
  4575. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4576. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4577. clif_displaymessage(pl_sd->fd, atcmd_output);
  4578. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4579. clif_displaymessage(fd, atcmd_output);
  4580. }
  4581. } else if (jailtime < 0) {
  4582. clif_displaymessage(fd, "Invalid time for jail command.");
  4583. return -1;
  4584. }
  4585. //Jail locations, add more as you wish.
  4586. switch(rand()%2)
  4587. {
  4588. case 1: //Jail #1
  4589. m_index = mapindex_name2id(MAP_JAIL);
  4590. x = 49; y = 75;
  4591. break;
  4592. default: //Default Jail
  4593. m_index = mapindex_name2id(MAP_JAIL);
  4594. x = 24; y = 75;
  4595. break;
  4596. }
  4597. 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).
  4598. return 0;
  4599. }
  4600. //By Coltaro
  4601. ACMD_FUNC(jailtime)
  4602. {
  4603. int year, month, day, hour, minute;
  4604. nullpo_retr(-1, sd);
  4605. if (!sd->sc.data[SC_JAILED]) {
  4606. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4607. return -1;
  4608. }
  4609. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4610. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4611. return 0;
  4612. }
  4613. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4614. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4615. return -1;
  4616. }
  4617. //Get remaining jail time
  4618. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4619. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4620. clif_displaymessage(fd, atcmd_output);
  4621. return 0;
  4622. }
  4623. /*==========================================
  4624. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4625. *------------------------------------------*/
  4626. ACMD_FUNC(disguise)
  4627. {
  4628. int id = 0;
  4629. nullpo_retr(-1, sd);
  4630. if (!message || !*message) {
  4631. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4632. return -1;
  4633. }
  4634. if ((id = atoi(message)) > 0)
  4635. { //Acquired an ID
  4636. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4637. id = 0; //Invalid id for either mobs or npcs.
  4638. } else { //Acquired a Name
  4639. if ((id = mobdb_searchname(message)) == 0)
  4640. {
  4641. struct npc_data* nd = npc_name2id(message);
  4642. if (nd != NULL)
  4643. id = nd->class_;
  4644. }
  4645. }
  4646. if (id == 0)
  4647. {
  4648. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4649. return -1;
  4650. }
  4651. if(pc_isriding(sd))
  4652. {
  4653. //FIXME: wrong message [ultramage]
  4654. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4655. return -1;
  4656. }
  4657. pc_disguise(sd, id);
  4658. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4659. return 0;
  4660. }
  4661. /*==========================================
  4662. * DisguiseAll
  4663. *------------------------------------------*/
  4664. ACMD_FUNC(disguiseall)
  4665. {
  4666. int mob_id=0;
  4667. struct map_session_data *pl_sd;
  4668. struct s_mapiterator* iter;
  4669. nullpo_retr(-1, sd);
  4670. if (!message || !*message) {
  4671. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4672. return -1;
  4673. }
  4674. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4675. mob_id = atoi(message);
  4676. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4677. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4678. return -1;
  4679. }
  4680. iter = mapit_getallusers();
  4681. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4682. pc_disguise(pl_sd, mob_id);
  4683. mapit_free(iter);
  4684. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4685. return 0;
  4686. }
  4687. /*==========================================
  4688. * @undisguise by [Yor]
  4689. *------------------------------------------*/
  4690. ACMD_FUNC(undisguise)
  4691. {
  4692. nullpo_retr(-1, sd);
  4693. if (sd->disguise) {
  4694. pc_disguise(sd, 0);
  4695. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4696. } else {
  4697. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4698. return -1;
  4699. }
  4700. return 0;
  4701. }
  4702. /*==========================================
  4703. * UndisguiseAll
  4704. *------------------------------------------*/
  4705. ACMD_FUNC(undisguiseall)
  4706. {
  4707. struct map_session_data *pl_sd;
  4708. struct s_mapiterator* iter;
  4709. nullpo_retr(-1, sd);
  4710. iter = mapit_getallusers();
  4711. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4712. if( pl_sd->disguise )
  4713. pc_disguise(pl_sd, 0);
  4714. mapit_free(iter);
  4715. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4716. return 0;
  4717. }
  4718. /*==========================================
  4719. * @exp by [Skotlex]
  4720. *------------------------------------------*/
  4721. ACMD_FUNC(exp)
  4722. {
  4723. char output[CHAT_SIZE_MAX];
  4724. double nextb, nextj;
  4725. nullpo_retr(-1, sd);
  4726. memset(output, '\0', sizeof(output));
  4727. nextb = pc_nextbaseexp(sd);
  4728. if (nextb)
  4729. nextb = sd->status.base_exp*100.0/nextb;
  4730. nextj = pc_nextjobexp(sd);
  4731. if (nextj)
  4732. nextj = sd->status.job_exp*100.0/nextj;
  4733. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4734. clif_displaymessage(fd, output);
  4735. return 0;
  4736. }
  4737. /*==========================================
  4738. * @broadcast by [Valaris]
  4739. *------------------------------------------*/
  4740. ACMD_FUNC(broadcast)
  4741. {
  4742. nullpo_retr(-1, sd);
  4743. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4744. if (!message || !*message) {
  4745. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4746. return -1;
  4747. }
  4748. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4749. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4750. return 0;
  4751. }
  4752. /*==========================================
  4753. * @localbroadcast by [Valaris]
  4754. *------------------------------------------*/
  4755. ACMD_FUNC(localbroadcast)
  4756. {
  4757. nullpo_retr(-1, sd);
  4758. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4759. if (!message || !*message) {
  4760. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4761. return -1;
  4762. }
  4763. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4764. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4765. return 0;
  4766. }
  4767. /*==========================================
  4768. * @email <actual@email> <new@email> by [Yor]
  4769. *------------------------------------------*/
  4770. ACMD_FUNC(email)
  4771. {
  4772. char actual_email[100];
  4773. char new_email[100];
  4774. nullpo_retr(-1, sd);
  4775. memset(actual_email, '\0', sizeof(actual_email));
  4776. memset(new_email, '\0', sizeof(new_email));
  4777. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4778. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4779. return -1;
  4780. }
  4781. if (e_mail_check(actual_email) == 0) {
  4782. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4783. return -1;
  4784. } else if (e_mail_check(new_email) == 0) {
  4785. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4786. return -1;
  4787. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4788. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4789. return -1;
  4790. } else if (strcmpi(actual_email, new_email) == 0) {
  4791. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4792. return -1;
  4793. }
  4794. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4795. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4796. return 0;
  4797. }
  4798. /*==========================================
  4799. *@effect
  4800. *------------------------------------------*/
  4801. ACMD_FUNC(effect)
  4802. {
  4803. int type = 0, flag = 0;
  4804. nullpo_retr(-1, sd);
  4805. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4806. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4807. return -1;
  4808. }
  4809. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4810. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4811. return 0;
  4812. }
  4813. /*==========================================
  4814. * @killer by MouseJstr
  4815. * enable killing players even when not in pvp
  4816. *------------------------------------------*/
  4817. ACMD_FUNC(killer)
  4818. {
  4819. nullpo_retr(-1, sd);
  4820. sd->state.killer = !sd->state.killer;
  4821. if(sd->state.killer)
  4822. clif_displaymessage(fd, msg_txt(241));
  4823. else {
  4824. clif_displaymessage(fd, msg_txt(287));
  4825. pc_stop_attack(sd);
  4826. }
  4827. return 0;
  4828. }
  4829. /*==========================================
  4830. * @killable by MouseJstr
  4831. * enable other people killing you
  4832. *------------------------------------------*/
  4833. ACMD_FUNC(killable)
  4834. {
  4835. nullpo_retr(-1, sd);
  4836. sd->state.killable = !sd->state.killable;
  4837. if(sd->state.killable)
  4838. clif_displaymessage(fd, msg_txt(242));
  4839. else {
  4840. clif_displaymessage(fd, msg_txt(288));
  4841. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4842. }
  4843. return 0;
  4844. }
  4845. /*==========================================
  4846. * @skillon by MouseJstr
  4847. * turn skills on for the map
  4848. *------------------------------------------*/
  4849. ACMD_FUNC(skillon)
  4850. {
  4851. nullpo_retr(-1, sd);
  4852. map[sd->bl.m].flag.noskill = 0;
  4853. clif_displaymessage(fd, msg_txt(244));
  4854. return 0;
  4855. }
  4856. /*==========================================
  4857. * @skilloff by MouseJstr
  4858. * Turn skills off on the map
  4859. *------------------------------------------*/
  4860. ACMD_FUNC(skilloff)
  4861. {
  4862. nullpo_retr(-1, sd);
  4863. map[sd->bl.m].flag.noskill = 1;
  4864. clif_displaymessage(fd, msg_txt(243));
  4865. return 0;
  4866. }
  4867. /*==========================================
  4868. * @npcmove by MouseJstr
  4869. * move a npc
  4870. *------------------------------------------*/
  4871. ACMD_FUNC(npcmove)
  4872. {
  4873. int x = 0, y = 0, m;
  4874. struct npc_data *nd = 0;
  4875. nullpo_retr(-1, sd);
  4876. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4877. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4878. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4879. return -1;
  4880. }
  4881. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4882. {
  4883. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4884. return -1;
  4885. }
  4886. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4887. {
  4888. clif_displaymessage(fd, "NPC is not on this map.");
  4889. return -1; //Not on a map.
  4890. }
  4891. x = cap_value(x, 0, map[m].xs-1);
  4892. y = cap_value(y, 0, map[m].ys-1);
  4893. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4894. map_moveblock(&nd->bl, x, y, gettick());
  4895. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4896. clif_displaymessage(fd, "NPC moved.");
  4897. return 0;
  4898. }
  4899. /*==========================================
  4900. * @addwarp by MouseJstr
  4901. * Create a new static warp point.
  4902. *------------------------------------------*/
  4903. ACMD_FUNC(addwarp)
  4904. {
  4905. char mapname[32];
  4906. int x,y;
  4907. unsigned short m;
  4908. struct npc_data* nd;
  4909. nullpo_retr(-1, sd);
  4910. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4911. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4912. return -1;
  4913. }
  4914. m = mapindex_name2id(mapname);
  4915. if( m == 0 )
  4916. {
  4917. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4918. clif_displaymessage(fd, atcmd_output);
  4919. return -1;
  4920. }
  4921. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4922. if( nd == NULL )
  4923. return -1;
  4924. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4925. clif_displaymessage(fd, atcmd_output);
  4926. return 0;
  4927. }
  4928. /*==========================================
  4929. * @follow by [MouseJstr]
  4930. * Follow a player .. staying no more then 5 spaces away
  4931. *------------------------------------------*/
  4932. ACMD_FUNC(follow)
  4933. {
  4934. struct map_session_data *pl_sd = NULL;
  4935. nullpo_retr(-1, sd);
  4936. if (!message || !*message) {
  4937. if (sd->followtarget == -1)
  4938. return -1;
  4939. pc_stop_following (sd);
  4940. clif_displaymessage(fd, "Follow mode OFF.");
  4941. return 0;
  4942. }
  4943. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4944. {
  4945. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4946. return -1;
  4947. }
  4948. if (sd->followtarget == pl_sd->bl.id) {
  4949. pc_stop_following (sd);
  4950. clif_displaymessage(fd, "Follow mode OFF.");
  4951. } else {
  4952. pc_follow(sd, pl_sd->bl.id);
  4953. clif_displaymessage(fd, "Follow mode ON.");
  4954. }
  4955. return 0;
  4956. }
  4957. /*==========================================
  4958. * @dropall by [MouseJstr]
  4959. * Drop all your possession on the ground
  4960. *------------------------------------------*/
  4961. ACMD_FUNC(dropall)
  4962. {
  4963. int i;
  4964. nullpo_retr(-1, sd);
  4965. for (i = 0; i < MAX_INVENTORY; i++) {
  4966. if (sd->status.inventory[i].amount) {
  4967. if(sd->status.inventory[i].equip != 0)
  4968. pc_unequipitem(sd, i, 3);
  4969. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4970. }
  4971. }
  4972. return 0;
  4973. }
  4974. /*==========================================
  4975. * @storeall by [MouseJstr]
  4976. * Put everything into storage
  4977. *------------------------------------------*/
  4978. ACMD_FUNC(storeall)
  4979. {
  4980. int i;
  4981. nullpo_retr(-1, sd);
  4982. if (sd->state.storage_flag != 1)
  4983. { //Open storage.
  4984. if( storage_storageopen(sd) == 1 ) {
  4985. clif_displaymessage(fd, "You can't open the storage currently.");
  4986. return -1;
  4987. }
  4988. }
  4989. for (i = 0; i < MAX_INVENTORY; i++) {
  4990. if (sd->status.inventory[i].amount) {
  4991. if(sd->status.inventory[i].equip != 0)
  4992. pc_unequipitem(sd, i, 3);
  4993. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4994. }
  4995. }
  4996. storage_storageclose(sd);
  4997. clif_displaymessage(fd, "It is done");
  4998. return 0;
  4999. }
  5000. /*==========================================
  5001. * @skillid by [MouseJstr]
  5002. * lookup a skill by name
  5003. *------------------------------------------*/
  5004. ACMD_FUNC(skillid)
  5005. {
  5006. int skillen, idx;
  5007. nullpo_retr(-1, sd);
  5008. if (!message || !*message)
  5009. {
  5010. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  5011. return -1;
  5012. }
  5013. skillen = strlen(message);
  5014. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  5015. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  5016. {
  5017. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5018. clif_displaymessage(fd, atcmd_output);
  5019. }
  5020. }
  5021. return 0;
  5022. }
  5023. /*==========================================
  5024. * @useskill by [MouseJstr]
  5025. * A way of using skills without having to find them in the skills menu
  5026. *------------------------------------------*/
  5027. ACMD_FUNC(useskill)
  5028. {
  5029. struct map_session_data *pl_sd = NULL;
  5030. struct block_list *bl;
  5031. int skillnum;
  5032. int skilllv;
  5033. char target[100];
  5034. nullpo_retr(-1, sd);
  5035. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5036. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5037. return -1;
  5038. }
  5039. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5040. {
  5041. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5042. return -1;
  5043. }
  5044. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5045. {
  5046. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5047. return -1;
  5048. }
  5049. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  5050. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5051. bl = &sd->hd->bl;
  5052. else
  5053. bl = &sd->bl;
  5054. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5055. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5056. else
  5057. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5058. return 0;
  5059. }
  5060. /*==========================================
  5061. * @displayskill by [Skotlex]
  5062. * Debug command to locate new skill IDs. It sends the
  5063. * three possible skill-effect packets to the area.
  5064. *------------------------------------------*/
  5065. ACMD_FUNC(displayskill)
  5066. {
  5067. struct status_data * status;
  5068. unsigned int tick;
  5069. int skillnum;
  5070. int skilllv = 1;
  5071. nullpo_retr(-1, sd);
  5072. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5073. {
  5074. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5075. return -1;
  5076. }
  5077. status = status_get_status_data(&sd->bl);
  5078. tick = gettick();
  5079. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  5080. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5081. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5082. return 0;
  5083. }
  5084. /*==========================================
  5085. * @skilltree by [MouseJstr]
  5086. * prints the skill tree for a player required to get to a skill
  5087. *------------------------------------------*/
  5088. ACMD_FUNC(skilltree)
  5089. {
  5090. struct map_session_data *pl_sd = NULL;
  5091. int skillnum;
  5092. int meets, j, c=0;
  5093. char target[NAME_LENGTH];
  5094. struct skill_tree_entry *ent;
  5095. nullpo_retr(-1, sd);
  5096. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5097. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5098. return -1;
  5099. }
  5100. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5101. {
  5102. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5103. return -1;
  5104. }
  5105. c = pc_calc_skilltree_normalize_job(pl_sd);
  5106. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5107. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, 1));
  5108. clif_displaymessage(fd, atcmd_output);
  5109. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  5110. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5111. {
  5112. sprintf(atcmd_output, "I do not believe the player can use that skill");
  5113. clif_displaymessage(fd, atcmd_output);
  5114. return 0;
  5115. }
  5116. ent = &skill_tree[c][j];
  5117. meets = 1;
  5118. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5119. {
  5120. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5121. {
  5122. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  5123. clif_displaymessage(fd, atcmd_output);
  5124. meets = 0;
  5125. }
  5126. }
  5127. if (meets == 1) {
  5128. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5129. clif_displaymessage(fd, atcmd_output);
  5130. }
  5131. return 0;
  5132. }
  5133. // Hand a ring with partners name on it to this char
  5134. void getring (struct map_session_data* sd)
  5135. {
  5136. int flag, item_id;
  5137. struct item item_tmp;
  5138. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5139. memset(&item_tmp, 0, sizeof(item_tmp));
  5140. item_tmp.nameid = item_id;
  5141. item_tmp.identify = 1;
  5142. item_tmp.card[0] = 255;
  5143. item_tmp.card[2] = sd->status.partner_id;
  5144. item_tmp.card[3] = sd->status.partner_id >> 16;
  5145. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5146. clif_additem(sd,0,0,flag);
  5147. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5148. }
  5149. }
  5150. /*==========================================
  5151. * @marry by [MouseJstr], fixed by Lupus
  5152. * Marry two players
  5153. *------------------------------------------*/
  5154. ACMD_FUNC(marry)
  5155. {
  5156. struct map_session_data *pl_sd1 = NULL;
  5157. struct map_session_data *pl_sd2 = NULL;
  5158. char player1[128], player2[128]; //Length used for return error msgs
  5159. nullpo_retr(-1, sd);
  5160. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5161. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5162. return -1;
  5163. }
  5164. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5165. sprintf(player2, "Cannot find player '%s' online", player1);
  5166. clif_displaymessage(fd, player2);
  5167. return -1;
  5168. }
  5169. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5170. sprintf(player1, "Cannot find player '%s' online", player2);
  5171. clif_displaymessage(fd, player1);
  5172. return -1;
  5173. }
  5174. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5175. clif_displaymessage(fd, "They are married.. wish them well");
  5176. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5177. // Auto-give named rings (Aru)
  5178. getring (pl_sd1);
  5179. getring (pl_sd2);
  5180. return 0;
  5181. }
  5182. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5183. return -1;
  5184. }
  5185. /*==========================================
  5186. * @divorce by [MouseJstr], fixed by [Lupus]
  5187. * divorce two players
  5188. *------------------------------------------*/
  5189. ACMD_FUNC(divorce)
  5190. {
  5191. struct map_session_data *pl_sd = NULL;
  5192. nullpo_retr(-1, sd);
  5193. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5194. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5195. return -1;
  5196. }
  5197. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5198. {
  5199. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5200. return -1;
  5201. }
  5202. if (pc_divorce(pl_sd) != 0) {
  5203. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5204. clif_displaymessage(fd, atcmd_output);
  5205. return -1;
  5206. }
  5207. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5208. clif_displaymessage(fd, atcmd_output);
  5209. return 0;
  5210. }
  5211. /*==========================================
  5212. * @changelook by [Celest]
  5213. *------------------------------------------*/
  5214. ACMD_FUNC(changelook)
  5215. {
  5216. int i, j = 0, k = 0;
  5217. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5218. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5219. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5220. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5221. return -1;
  5222. } else if (i == 2) {
  5223. if (j < 1) j = 1;
  5224. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5225. j = pos[j - 1];
  5226. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5227. k = j; // swap
  5228. j = LOOK_HEAD_TOP;
  5229. }
  5230. clif_changelook(&sd->bl,j,k);
  5231. return 0;
  5232. }
  5233. /*==========================================
  5234. * @autotrade by durf [Lupus] [Paradox924X]
  5235. * Turns on/off Autotrade for a specific player
  5236. *------------------------------------------*/
  5237. ACMD_FUNC(autotrade)
  5238. {
  5239. nullpo_retr(-1, sd);
  5240. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5241. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5242. return -1;
  5243. }
  5244. if( pc_isdead(sd) ) {
  5245. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  5246. return -1;
  5247. }
  5248. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5249. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  5250. return -1;
  5251. }
  5252. sd->state.autotrade = 1;
  5253. if( battle_config.at_timeout )
  5254. {
  5255. int timeout = atoi(message);
  5256. 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);
  5257. }
  5258. clif_authfail_fd(fd, 15);
  5259. return 0;
  5260. }
  5261. /*==========================================
  5262. * @changegm by durf (changed by Lupus)
  5263. * Changes Master of your Guild to a specified guild member
  5264. *------------------------------------------*/
  5265. ACMD_FUNC(changegm)
  5266. {
  5267. struct guild *g;
  5268. struct map_session_data *pl_sd;
  5269. nullpo_retr(-1, sd);
  5270. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5271. {
  5272. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5273. return -1;
  5274. }
  5275. if( map[sd->bl.m].flag.guildlock )
  5276. {
  5277. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5278. return -1;
  5279. }
  5280. if( !message[0] )
  5281. {
  5282. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5283. return -1;
  5284. }
  5285. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5286. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5287. return -1;
  5288. }
  5289. guild_gm_change(sd->status.guild_id, pl_sd);
  5290. return 0;
  5291. }
  5292. /*==========================================
  5293. * @changeleader by Skotlex
  5294. * Changes the leader of a party.
  5295. *------------------------------------------*/
  5296. ACMD_FUNC(changeleader)
  5297. {
  5298. nullpo_retr(-1, sd);
  5299. if( !message[0] )
  5300. {
  5301. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5302. return -1;
  5303. }
  5304. if (party_changeleader(sd, map_nick2sd((char *) message)))
  5305. return 0;
  5306. return -1;
  5307. }
  5308. /*==========================================
  5309. * @partyoption by Skotlex
  5310. * Used to change the item share setting of a party.
  5311. *------------------------------------------*/
  5312. ACMD_FUNC(partyoption)
  5313. {
  5314. struct party_data *p;
  5315. int mi, option;
  5316. char w1[16], w2[16];
  5317. nullpo_retr(-1, sd);
  5318. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5319. {
  5320. clif_displaymessage(fd, msg_txt(282));
  5321. return -1;
  5322. }
  5323. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5324. if (mi == MAX_PARTY)
  5325. return -1; //Shouldn't happen
  5326. if (!p->party.member[mi].leader)
  5327. {
  5328. clif_displaymessage(fd, msg_txt(282));
  5329. return -1;
  5330. }
  5331. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5332. {
  5333. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5334. return -1;
  5335. }
  5336. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5337. //Change item share type.
  5338. if (option != p->party.item)
  5339. party_changeoption(sd, p->party.exp, option);
  5340. else
  5341. clif_displaymessage(fd, msg_txt(286));
  5342. return 0;
  5343. }
  5344. /*==========================================
  5345. * @autoloot by Upa-Kun
  5346. * Turns on/off AutoLoot for a specific player
  5347. *------------------------------------------*/
  5348. ACMD_FUNC(autoloot)
  5349. {
  5350. int rate;
  5351. double drate;
  5352. nullpo_retr(-1, sd);
  5353. // autoloot command without value
  5354. if(!message || !*message)
  5355. {
  5356. if (sd->state.autoloot)
  5357. rate = 0;
  5358. else
  5359. rate = 10000;
  5360. } else {
  5361. drate = atof(message);
  5362. rate = (int)(drate*100);
  5363. }
  5364. if (rate < 0) rate = 0;
  5365. if (rate > 10000) rate = 10000;
  5366. sd->state.autoloot = rate;
  5367. if (sd->state.autoloot) {
  5368. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5369. clif_displaymessage(fd, atcmd_output);
  5370. }else
  5371. clif_displaymessage(fd, "Autoloot is now off.");
  5372. return 0;
  5373. }
  5374. /*==========================================
  5375. * @alootid
  5376. *------------------------------------------*/
  5377. ACMD_FUNC(autolootitem)
  5378. {
  5379. struct item_data *item_data = NULL;
  5380. if (!message || !*message) {
  5381. if (sd->state.autolootid) {
  5382. sd->state.autolootid = 0;
  5383. clif_displaymessage(fd, "Autolootitem has been turned OFF.");
  5384. } else
  5385. clif_displaymessage(fd, "Please, enter item name or it's ID (usage: @alootid <item_name_or_ID>).");
  5386. return -1;
  5387. }
  5388. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5389. item_data = itemdb_searchname(message);
  5390. if (!item_data) {
  5391. // No items founds in the DB with Id or Name
  5392. clif_displaymessage(fd, "Item not found.");
  5393. return -1;
  5394. }
  5395. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  5396. sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d)",
  5397. item_data->name, item_data->jname, item_data->nameid);
  5398. clif_displaymessage(fd, atcmd_output);
  5399. return 0;
  5400. }
  5401. /**
  5402. * No longer available, keeping here just in case it's back someday. [Ind]
  5403. **/
  5404. /*==========================================
  5405. * It is made to rain.
  5406. *------------------------------------------*/
  5407. //ACMD_FUNC(rain)
  5408. //{
  5409. // nullpo_retr(-1, sd);
  5410. // if (map[sd->bl.m].flag.rain) {
  5411. // map[sd->bl.m].flag.rain=0;
  5412. // clif_weather(sd->bl.m);
  5413. // clif_displaymessage(fd, "The rain has stopped.");
  5414. // } else {
  5415. // map[sd->bl.m].flag.rain=1;
  5416. // clif_weather(sd->bl.m);
  5417. // clif_displaymessage(fd, "It is made to rain.");
  5418. // }
  5419. // return 0;
  5420. //}
  5421. /*==========================================
  5422. * It is made to snow.
  5423. *------------------------------------------*/
  5424. ACMD_FUNC(snow)
  5425. {
  5426. nullpo_retr(-1, sd);
  5427. if (map[sd->bl.m].flag.snow) {
  5428. map[sd->bl.m].flag.snow=0;
  5429. clif_weather(sd->bl.m);
  5430. clif_displaymessage(fd, "Snow has stopped falling.");
  5431. } else {
  5432. map[sd->bl.m].flag.snow=1;
  5433. clif_weather(sd->bl.m);
  5434. clif_displaymessage(fd, "It is made to snow.");
  5435. }
  5436. return 0;
  5437. }
  5438. /*==========================================
  5439. * Cherry tree snowstorm is made to fall. (Sakura)
  5440. *------------------------------------------*/
  5441. ACMD_FUNC(sakura)
  5442. {
  5443. nullpo_retr(-1, sd);
  5444. if (map[sd->bl.m].flag.sakura) {
  5445. map[sd->bl.m].flag.sakura=0;
  5446. clif_weather(sd->bl.m);
  5447. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5448. } else {
  5449. map[sd->bl.m].flag.sakura=1;
  5450. clif_weather(sd->bl.m);
  5451. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5452. }
  5453. return 0;
  5454. }
  5455. /*==========================================
  5456. * Clouds appear.
  5457. *------------------------------------------*/
  5458. ACMD_FUNC(clouds)
  5459. {
  5460. nullpo_retr(-1, sd);
  5461. if (map[sd->bl.m].flag.clouds) {
  5462. map[sd->bl.m].flag.clouds=0;
  5463. clif_weather(sd->bl.m);
  5464. clif_displaymessage(fd, "The clouds has disappear.");
  5465. } else {
  5466. map[sd->bl.m].flag.clouds=1;
  5467. clif_weather(sd->bl.m);
  5468. clif_displaymessage(fd, "Clouds appear.");
  5469. }
  5470. return 0;
  5471. }
  5472. /*==========================================
  5473. * Different type of clouds using effect 516
  5474. *------------------------------------------*/
  5475. ACMD_FUNC(clouds2)
  5476. {
  5477. nullpo_retr(-1, sd);
  5478. if (map[sd->bl.m].flag.clouds2) {
  5479. map[sd->bl.m].flag.clouds2=0;
  5480. clif_weather(sd->bl.m);
  5481. clif_displaymessage(fd, "The alternative clouds disappear.");
  5482. } else {
  5483. map[sd->bl.m].flag.clouds2=1;
  5484. clif_weather(sd->bl.m);
  5485. clif_displaymessage(fd, "Alternative clouds appear.");
  5486. }
  5487. return 0;
  5488. }
  5489. /*==========================================
  5490. * Fog hangs over.
  5491. *------------------------------------------*/
  5492. ACMD_FUNC(fog)
  5493. {
  5494. nullpo_retr(-1, sd);
  5495. if (map[sd->bl.m].flag.fog) {
  5496. map[sd->bl.m].flag.fog=0;
  5497. clif_weather(sd->bl.m);
  5498. clif_displaymessage(fd, "The fog has gone.");
  5499. } else {
  5500. map[sd->bl.m].flag.fog=1;
  5501. clif_weather(sd->bl.m);
  5502. clif_displaymessage(fd, "Fog hangs over.");
  5503. }
  5504. return 0;
  5505. }
  5506. /*==========================================
  5507. * Fallen leaves fall.
  5508. *------------------------------------------*/
  5509. ACMD_FUNC(leaves)
  5510. {
  5511. nullpo_retr(-1, sd);
  5512. if (map[sd->bl.m].flag.leaves) {
  5513. map[sd->bl.m].flag.leaves=0;
  5514. clif_weather(sd->bl.m);
  5515. clif_displaymessage(fd, "Leaves no longer fall.");
  5516. } else {
  5517. map[sd->bl.m].flag.leaves=1;
  5518. clif_weather(sd->bl.m);
  5519. clif_displaymessage(fd, "Fallen leaves fall.");
  5520. }
  5521. return 0;
  5522. }
  5523. /*==========================================
  5524. * Fireworks appear.
  5525. *------------------------------------------*/
  5526. ACMD_FUNC(fireworks)
  5527. {
  5528. nullpo_retr(-1, sd);
  5529. if (map[sd->bl.m].flag.fireworks) {
  5530. map[sd->bl.m].flag.fireworks=0;
  5531. clif_weather(sd->bl.m);
  5532. clif_displaymessage(fd, "Fireworks are ended.");
  5533. } else {
  5534. map[sd->bl.m].flag.fireworks=1;
  5535. clif_weather(sd->bl.m);
  5536. clif_displaymessage(fd, "Fireworks are launched.");
  5537. }
  5538. return 0;
  5539. }
  5540. /*==========================================
  5541. * Clearing Weather Effects by Dexity
  5542. *------------------------------------------*/
  5543. ACMD_FUNC(clearweather)
  5544. {
  5545. nullpo_retr(-1, sd);
  5546. /**
  5547. * No longer available, keeping here just in case it's back someday. [Ind]
  5548. **/
  5549. //map[sd->bl.m].flag.rain=0;
  5550. map[sd->bl.m].flag.snow=0;
  5551. map[sd->bl.m].flag.sakura=0;
  5552. map[sd->bl.m].flag.clouds=0;
  5553. map[sd->bl.m].flag.clouds2=0;
  5554. map[sd->bl.m].flag.fog=0;
  5555. map[sd->bl.m].flag.fireworks=0;
  5556. map[sd->bl.m].flag.leaves=0;
  5557. clif_weather(sd->bl.m);
  5558. clif_displaymessage(fd, msg_txt(291));
  5559. return 0;
  5560. }
  5561. /*===============================================================
  5562. * Sound Command - plays a sound for everyone around! [Codemaster]
  5563. *---------------------------------------------------------------*/
  5564. ACMD_FUNC(sound)
  5565. {
  5566. char sound_file[100];
  5567. memset(sound_file, '\0', sizeof(sound_file));
  5568. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5569. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5570. return -1;
  5571. }
  5572. if(strstr(sound_file, ".wav") == NULL)
  5573. strcat(sound_file, ".wav");
  5574. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5575. return 0;
  5576. }
  5577. /*==========================================
  5578. * MOB Search
  5579. *------------------------------------------*/
  5580. ACMD_FUNC(mobsearch)
  5581. {
  5582. char mob_name[100];
  5583. int mob_id;
  5584. int number = 0;
  5585. struct s_mapiterator* it;
  5586. nullpo_retr(-1, sd);
  5587. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5588. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5589. return -1;
  5590. }
  5591. if ((mob_id = atoi(mob_name)) == 0)
  5592. mob_id = mobdb_searchname(mob_name);
  5593. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5594. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5595. clif_displaymessage(fd, atcmd_output);
  5596. return -1;
  5597. }
  5598. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5599. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5600. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5601. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5602. clif_displaymessage(fd, atcmd_output);
  5603. it = mapit_geteachmob();
  5604. for(;;)
  5605. {
  5606. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5607. if( md == NULL )
  5608. break;// no more mobs
  5609. if( md->bl.m != sd->bl.m )
  5610. continue;
  5611. if( mob_id != -1 && md->class_ != mob_id )
  5612. continue;
  5613. ++number;
  5614. if( md->spawn_timer == INVALID_TIMER )
  5615. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5616. else
  5617. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5618. clif_displaymessage(fd, atcmd_output);
  5619. }
  5620. mapit_free(it);
  5621. return 0;
  5622. }
  5623. /*==========================================
  5624. * @cleanmap - cleans items on the ground
  5625. *------------------------------------------*/
  5626. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5627. {
  5628. nullpo_ret(bl);
  5629. map_clearflooritem(bl->id);
  5630. return 0;
  5631. }
  5632. ACMD_FUNC(cleanmap)
  5633. {
  5634. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5635. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5636. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5637. BL_ITEM);
  5638. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5639. return 0;
  5640. }
  5641. /*==========================================
  5642. * make a NPC/PET talk
  5643. * @npctalkc [SnakeDrak]
  5644. *------------------------------------------*/
  5645. ACMD_FUNC(npctalk)
  5646. {
  5647. char name[NAME_LENGTH],mes[100],temp[100];
  5648. struct npc_data *nd;
  5649. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5650. unsigned long color=0;
  5651. if (sd->sc.count && //no "chatting" while muted.
  5652. (sd->sc.data[SC_BERSERK] ||
  5653. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5654. return -1;
  5655. if(!ifcolor) {
  5656. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5657. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5658. return -1;
  5659. }
  5660. }
  5661. else {
  5662. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5663. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  5664. return -1;
  5665. }
  5666. }
  5667. if (!(nd = npc_name2id(name))) {
  5668. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5669. return -1;
  5670. }
  5671. strtok(name, "#"); // discard extra name identifier if present
  5672. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5673. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5674. else clif_message(&nd->bl, temp);
  5675. return 0;
  5676. }
  5677. ACMD_FUNC(pettalk)
  5678. {
  5679. char mes[100],temp[100];
  5680. struct pet_data *pd;
  5681. nullpo_retr(-1, sd);
  5682. if(!sd->status.pet_id || !(pd=sd->pd))
  5683. {
  5684. clif_displaymessage(fd, msg_txt(184));
  5685. return -1;
  5686. }
  5687. if (sd->sc.count && //no "chatting" while muted.
  5688. (sd->sc.data[SC_BERSERK] ||
  5689. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5690. return -1;
  5691. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5692. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5693. return -1;
  5694. }
  5695. if (message[0] == '/')
  5696. {// pet emotion processing
  5697. const char* emo[] = {
  5698. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5699. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5700. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5701. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5702. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5703. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5704. };
  5705. int i;
  5706. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5707. if( i < ARRAYLENGTH(emo) )
  5708. {
  5709. clif_emotion(&pd->bl, i);
  5710. return 0;
  5711. }
  5712. }
  5713. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5714. clif_message(&pd->bl, temp);
  5715. return 0;
  5716. }
  5717. /// @users - displays the number of players present on each map (and percentage)
  5718. /// #users displays on the target user instead of self
  5719. ACMD_FUNC(users)
  5720. {
  5721. char buf[CHAT_SIZE_MAX];
  5722. int i;
  5723. int users[MAX_MAPINDEX];
  5724. int users_all;
  5725. struct s_mapiterator* iter;
  5726. memset(users, 0, sizeof(users));
  5727. users_all = 0;
  5728. // count users on each map
  5729. iter = mapit_getallusers();
  5730. for(;;)
  5731. {
  5732. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5733. if( sd2 == NULL )
  5734. break;// no more users
  5735. if( sd2->mapindex >= MAX_MAPINDEX )
  5736. continue;// invalid mapindex
  5737. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5738. if( users_all < INT_MAX ) ++users_all;
  5739. }
  5740. mapit_free(iter);
  5741. // display results for each map
  5742. for( i = 0; i < MAX_MAPINDEX; ++i )
  5743. {
  5744. if( users[i] == 0 )
  5745. continue;// empty
  5746. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5747. clif_displaymessage(sd->fd, buf);
  5748. }
  5749. // display overall count
  5750. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5751. clif_displaymessage(sd->fd, buf);
  5752. return 0;
  5753. }
  5754. /*==========================================
  5755. *
  5756. *------------------------------------------*/
  5757. ACMD_FUNC(reset)
  5758. {
  5759. pc_resetstate(sd);
  5760. pc_resetskill(sd,1);
  5761. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5762. clif_displaymessage(fd, atcmd_output);
  5763. return 0;
  5764. }
  5765. /*==========================================
  5766. *
  5767. *------------------------------------------*/
  5768. ACMD_FUNC(summon)
  5769. {
  5770. char name[NAME_LENGTH];
  5771. int mob_id = 0;
  5772. int duration = 0;
  5773. struct mob_data *md;
  5774. unsigned int tick=gettick();
  5775. nullpo_retr(-1, sd);
  5776. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5777. {
  5778. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5779. return -1;
  5780. }
  5781. if (duration < 1)
  5782. duration =1;
  5783. else if (duration > 60)
  5784. duration =60;
  5785. if ((mob_id = atoi(name)) == 0)
  5786. mob_id = mobdb_searchname(name);
  5787. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5788. {
  5789. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5790. return -1;
  5791. }
  5792. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5793. if(!md)
  5794. return -1;
  5795. md->master_id=sd->bl.id;
  5796. md->special_state.ai=1;
  5797. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5798. clif_specialeffect(&md->bl,344,AREA);
  5799. mob_spawn(md);
  5800. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5801. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5802. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5803. return 0;
  5804. }
  5805. /*==========================================
  5806. * @adjcmdlvl by [MouseJstr]
  5807. *
  5808. * Temp adjust the GM level required to use a GM command
  5809. * Useful during beta testing to allow players to use GM commands for short periods of time
  5810. *------------------------------------------*/
  5811. ACMD_FUNC(adjcmdlvl)
  5812. {
  5813. int newlev, newremotelev;
  5814. char name[100];
  5815. AtCommandInfo* cmd;
  5816. nullpo_retr(-1, sd);
  5817. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  5818. {
  5819. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  5820. return -1;
  5821. }
  5822. cmd = get_atcommandinfo_byname(name);
  5823. if (cmd == NULL)
  5824. {
  5825. clif_displaymessage(fd, "@command not found.");
  5826. return -1;
  5827. }
  5828. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  5829. {
  5830. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5831. return -1;
  5832. }
  5833. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  5834. {
  5835. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5836. return -1;
  5837. }
  5838. else
  5839. {
  5840. cmd->level = newlev;
  5841. cmd->level2 = newremotelev;
  5842. clif_displaymessage(fd, "@command level changed.");
  5843. return 0;
  5844. }
  5845. }
  5846. /*==========================================
  5847. * @adjgmlvl by [MouseJstr]
  5848. * Create a temp GM
  5849. * Useful during beta testing to allow players to use GM commands for short periods of time
  5850. *------------------------------------------*/
  5851. ACMD_FUNC(adjgmlvl)
  5852. {
  5853. int newlev;
  5854. char user[NAME_LENGTH];
  5855. struct map_session_data *pl_sd;
  5856. nullpo_retr(-1, sd);
  5857. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5858. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5859. return -1;
  5860. }
  5861. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5862. {
  5863. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5864. return -1;
  5865. }
  5866. pl_sd->gmlevel = newlev;
  5867. return 0;
  5868. }
  5869. /*==========================================
  5870. * @trade by [MouseJstr]
  5871. * Open a trade window with a remote player
  5872. *------------------------------------------*/
  5873. ACMD_FUNC(trade)
  5874. {
  5875. struct map_session_data *pl_sd = NULL;
  5876. nullpo_retr(-1, sd);
  5877. if (!message || !*message) {
  5878. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5879. return -1;
  5880. }
  5881. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5882. {
  5883. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5884. return -1;
  5885. }
  5886. trade_traderequest(sd, pl_sd);
  5887. return 0;
  5888. }
  5889. /*==========================================
  5890. * @setbattleflag by [MouseJstr]
  5891. * set a battle_config flag without having to reboot
  5892. *------------------------------------------*/
  5893. ACMD_FUNC(setbattleflag)
  5894. {
  5895. char flag[128], value[128];
  5896. nullpo_retr(-1, sd);
  5897. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5898. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5899. return -1;
  5900. }
  5901. if (battle_set_value(flag, value) == 0)
  5902. {
  5903. clif_displaymessage(fd, "unknown battle_config flag");
  5904. return -1;
  5905. }
  5906. clif_displaymessage(fd, "battle_config set as requested");
  5907. return 0;
  5908. }
  5909. /*==========================================
  5910. * @unmute [Valaris]
  5911. *------------------------------------------*/
  5912. ACMD_FUNC(unmute)
  5913. {
  5914. struct map_session_data *pl_sd = NULL;
  5915. nullpo_retr(-1, sd);
  5916. if (!message || !*message) {
  5917. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5918. return -1;
  5919. }
  5920. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5921. {
  5922. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5923. return -1;
  5924. }
  5925. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5926. clif_displaymessage(sd->fd,"Player is not muted");
  5927. return -1;
  5928. }
  5929. pl_sd->status.manner = 0;
  5930. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5931. clif_displaymessage(sd->fd,"Player unmuted");
  5932. return 0;
  5933. }
  5934. /*==========================================
  5935. * @uptime by MC Cameri
  5936. *------------------------------------------*/
  5937. ACMD_FUNC(uptime)
  5938. {
  5939. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5940. minute = 60, days = 0, hours = 0, minutes = 0;
  5941. nullpo_retr(-1, sd);
  5942. seconds = get_uptime();
  5943. days = seconds/day;
  5944. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5945. hours = seconds/hour;
  5946. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5947. minutes = seconds/minute;
  5948. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5949. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5950. clif_displaymessage(fd, atcmd_output);
  5951. return 0;
  5952. }
  5953. /*==========================================
  5954. * @changesex <sex>
  5955. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5956. *------------------------------------------*/
  5957. ACMD_FUNC(changesex)
  5958. {
  5959. nullpo_retr(-1, sd);
  5960. chrif_changesex(sd);
  5961. return 0;
  5962. }
  5963. /*================================================
  5964. * @mute - Mutes a player for a set amount of time
  5965. *------------------------------------------------*/
  5966. ACMD_FUNC(mute)
  5967. {
  5968. struct map_session_data *pl_sd = NULL;
  5969. int manner;
  5970. nullpo_retr(-1, sd);
  5971. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5972. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5973. return -1;
  5974. }
  5975. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5976. {
  5977. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5978. return -1;
  5979. }
  5980. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5981. {
  5982. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5983. return -1;
  5984. }
  5985. clif_manner_message(sd, 0);
  5986. clif_manner_message(pl_sd, 5);
  5987. if( pl_sd->status.manner < manner ) {
  5988. pl_sd->status.manner -= manner;
  5989. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5990. } else {
  5991. pl_sd->status.manner = 0;
  5992. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5993. }
  5994. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5995. return 0;
  5996. }
  5997. /*==========================================
  5998. * @refresh (like @jumpto <<yourself>>)
  5999. *------------------------------------------*/
  6000. ACMD_FUNC(refresh)
  6001. {
  6002. nullpo_retr(-1, sd);
  6003. clif_refresh(sd);
  6004. return 0;
  6005. }
  6006. /*==========================================
  6007. * @identify
  6008. * => GM's magnifier.
  6009. *------------------------------------------*/
  6010. ACMD_FUNC(identify)
  6011. {
  6012. int i,num;
  6013. nullpo_retr(-1, sd);
  6014. for(i=num=0;i<MAX_INVENTORY;i++){
  6015. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6016. num++;
  6017. }
  6018. }
  6019. if (num > 0) {
  6020. clif_item_identify_list(sd);
  6021. } else {
  6022. clif_displaymessage(fd,"There are no items to appraise.");
  6023. }
  6024. return 0;
  6025. }
  6026. /*==========================================
  6027. * @gmotd (Global MOTD)
  6028. * by davidsiaw :P
  6029. *------------------------------------------*/
  6030. ACMD_FUNC(gmotd)
  6031. {
  6032. char buf[CHAT_SIZE_MAX];
  6033. size_t len;
  6034. FILE* fp;
  6035. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6036. {
  6037. while( fgets(buf, sizeof(buf), fp) )
  6038. {
  6039. if( buf[0] == '/' && buf[1] == '/' )
  6040. {
  6041. continue;
  6042. }
  6043. len = strlen(buf);
  6044. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6045. {// strip trailing EOL characters
  6046. len--;
  6047. }
  6048. if( len )
  6049. {
  6050. buf[len] = 0;
  6051. intif_broadcast(buf, len+1, 0);
  6052. }
  6053. }
  6054. fclose(fp);
  6055. }
  6056. return 0;
  6057. }
  6058. ACMD_FUNC(misceffect)
  6059. {
  6060. int effect = 0;
  6061. nullpo_retr(-1, sd);
  6062. if (!message || !*message)
  6063. return -1;
  6064. if (sscanf(message, "%d", &effect) < 1)
  6065. return -1;
  6066. clif_misceffect(&sd->bl,effect);
  6067. return 0;
  6068. }
  6069. /*==========================================
  6070. * MAIL SYSTEM
  6071. *------------------------------------------*/
  6072. ACMD_FUNC(mail)
  6073. {
  6074. nullpo_ret(sd);
  6075. #ifndef TXT_ONLY
  6076. mail_openmail(sd);
  6077. #endif
  6078. return 0;
  6079. }
  6080. /*==========================================
  6081. * Show Monster DB Info v 1.0
  6082. * originally by [Lupus] eAthena
  6083. *------------------------------------------*/
  6084. ACMD_FUNC(mobinfo)
  6085. {
  6086. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  6087. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  6088. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  6089. char atcmd_output2[CHAT_SIZE_MAX];
  6090. struct item_data *item_data;
  6091. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6092. int count;
  6093. int i, j, k;
  6094. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6095. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6096. if (!message || !*message) {
  6097. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  6098. return -1;
  6099. }
  6100. // If monster identifier/name argument is a name
  6101. if ((i = mobdb_checkid(atoi(message))))
  6102. {
  6103. mob_array[0] = mob_db(i);
  6104. count = 1;
  6105. } else
  6106. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6107. if (!count) {
  6108. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6109. return -1;
  6110. }
  6111. if (count > MAX_SEARCH) {
  6112. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6113. clif_displaymessage(fd, atcmd_output);
  6114. count = MAX_SEARCH;
  6115. }
  6116. for (k = 0; k < count; k++) {
  6117. mob = mob_array[k];
  6118. // stats
  6119. if (mob->mexp)
  6120. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6121. else
  6122. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6123. clif_displaymessage(fd, atcmd_output);
  6124. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  6125. clif_displaymessage(fd, atcmd_output);
  6126. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  6127. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  6128. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6129. clif_displaymessage(fd, atcmd_output);
  6130. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  6131. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6132. mob->range2 , mob->range3, msize[mob->status.size],
  6133. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6134. clif_displaymessage(fd, atcmd_output);
  6135. // drops
  6136. clif_displaymessage(fd, " Drops:");
  6137. strcpy(atcmd_output, " ");
  6138. j = 0;
  6139. for (i = 0; i < MAX_MOB_DROP; i++) {
  6140. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6141. continue;
  6142. if (item_data->slot)
  6143. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  6144. else
  6145. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  6146. strcat(atcmd_output, atcmd_output2);
  6147. if (++j % 3 == 0) {
  6148. clif_displaymessage(fd, atcmd_output);
  6149. strcpy(atcmd_output, " ");
  6150. }
  6151. }
  6152. if (j == 0)
  6153. clif_displaymessage(fd, "This monster has no drops.");
  6154. else if (j % 3 != 0)
  6155. clif_displaymessage(fd, atcmd_output);
  6156. // mvp
  6157. if (mob->mexp) {
  6158. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  6159. clif_displaymessage(fd, atcmd_output);
  6160. strcpy(atcmd_output, " MVP Items:");
  6161. j = 0;
  6162. for (i = 0; i < 3; i++) {
  6163. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6164. continue;
  6165. if (mob->mvpitem[i].p > 0) {
  6166. j++;
  6167. if (j == 1)
  6168. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6169. else
  6170. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6171. strcat(atcmd_output, atcmd_output2);
  6172. }
  6173. }
  6174. if (j == 0)
  6175. clif_displaymessage(fd, "This monster has no MVP prizes.");
  6176. else
  6177. clif_displaymessage(fd, atcmd_output);
  6178. }
  6179. }
  6180. return 0;
  6181. }
  6182. /*=========================================
  6183. * @showmobs by KarLaeda
  6184. * => For 5 sec displays the mobs on minimap
  6185. *------------------------------------------*/
  6186. int atshowmobs_timer(int tid, unsigned int tick, int id, intptr_t data)
  6187. {
  6188. struct map_session_data* sd = map_id2sd(id);
  6189. if( sd == NULL )
  6190. return 0;
  6191. // remove indicator
  6192. clif_viewpoint(sd, 1, 2, 0, 0, (int)data, 0xFFFFFF);
  6193. return 1;
  6194. }
  6195. ACMD_FUNC(showmobs)
  6196. {
  6197. char mob_name[100];
  6198. int mob_id;
  6199. int number = 0;
  6200. struct s_mapiterator* it;
  6201. nullpo_retr(-1, sd);
  6202. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6203. return -1;
  6204. if((mob_id = atoi(mob_name)) == 0)
  6205. mob_id = mobdb_searchname(mob_name);
  6206. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6207. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6208. clif_displaymessage(fd, atcmd_output);
  6209. return 0;
  6210. }
  6211. // Uncomment the following line to show mini-bosses & MVP.
  6212. //#define SHOW_MVP
  6213. #ifndef SHOW_MVP
  6214. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6215. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6216. clif_displaymessage(fd, atcmd_output);
  6217. return 0;
  6218. }
  6219. #endif
  6220. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6221. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6222. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6223. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6224. mob_name, mapindex_id2name(sd->mapindex));
  6225. clif_displaymessage(fd, atcmd_output);
  6226. it = mapit_geteachmob();
  6227. for(;;)
  6228. {
  6229. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6230. if( md == NULL )
  6231. break;// no more mobs
  6232. if( md->bl.m != sd->bl.m )
  6233. continue;
  6234. if( mob_id != -1 && md->class_ != mob_id )
  6235. continue;
  6236. if( md->special_state.ai || md->master_id )
  6237. continue; // hide slaves and player summoned mobs
  6238. if( md->spawn_timer != INVALID_TIMER )
  6239. continue; // hide mobs waiting for respawn
  6240. ++number;
  6241. clif_viewpoint(sd, 1, 1, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6242. add_timer(gettick()+5000, atshowmobs_timer, sd->bl.id, number);
  6243. }
  6244. mapit_free(it);
  6245. return 0;
  6246. }
  6247. /*==========================================
  6248. * homunculus level up [orn]
  6249. *------------------------------------------*/
  6250. ACMD_FUNC(homlevel)
  6251. {
  6252. TBL_HOM * hd;
  6253. int level = 0, i = 0;
  6254. nullpo_retr(-1, sd);
  6255. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6256. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  6257. return -1;
  6258. }
  6259. if ( !merc_is_hom_active(sd->hd) ) {
  6260. clif_displaymessage(fd, "You do not have a homunculus.");
  6261. return -1;
  6262. }
  6263. hd = sd->hd;
  6264. for (i = 1; i <= level && hd->exp_next; i++){
  6265. hd->homunculus.exp += hd->exp_next;
  6266. merc_hom_levelup(hd);
  6267. }
  6268. status_calc_homunculus(hd,0);
  6269. status_percent_heal(&hd->bl, 100, 100);
  6270. clif_specialeffect(&hd->bl,568,AREA);
  6271. return 0;
  6272. }
  6273. /*==========================================
  6274. * homunculus evolution H [orn]
  6275. *------------------------------------------*/
  6276. ACMD_FUNC(homevolution)
  6277. {
  6278. nullpo_retr(-1, sd);
  6279. if ( !merc_is_hom_active(sd->hd) ) {
  6280. clif_displaymessage(fd, "You do not have a homunculus.");
  6281. return -1;
  6282. }
  6283. if ( !merc_hom_evolution(sd->hd) ) {
  6284. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6285. return -1;
  6286. }
  6287. return 0;
  6288. }
  6289. /*==========================================
  6290. * call choosen homunculus [orn]
  6291. *------------------------------------------*/
  6292. ACMD_FUNC(makehomun)
  6293. {
  6294. int homunid;
  6295. nullpo_retr(-1, sd);
  6296. if ( sd->status.hom_id ) {
  6297. clif_displaymessage(fd, msg_txt(450));
  6298. return -1;
  6299. }
  6300. if (!message || !*message) {
  6301. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6302. return -1;
  6303. }
  6304. homunid = atoi(message);
  6305. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6306. {
  6307. clif_displaymessage(fd, "Invalid Homunculus id.");
  6308. return -1;
  6309. }
  6310. merc_create_homunculus_request(sd,homunid);
  6311. return 0;
  6312. }
  6313. /*==========================================
  6314. * modify homunculus intimacy [orn]
  6315. *------------------------------------------*/
  6316. ACMD_FUNC(homfriendly)
  6317. {
  6318. int friendly = 0;
  6319. nullpo_retr(-1, sd);
  6320. if ( !merc_is_hom_active(sd->hd) ) {
  6321. clif_displaymessage(fd, "You do not have a homunculus.");
  6322. return -1;
  6323. }
  6324. if (!message || !*message) {
  6325. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6326. return -1;
  6327. }
  6328. friendly = atoi(message);
  6329. friendly = cap_value(friendly, 0, 1000);
  6330. sd->hd->homunculus.intimacy = friendly * 100 ;
  6331. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6332. return 0;
  6333. }
  6334. /*==========================================
  6335. * modify homunculus hunger [orn]
  6336. *------------------------------------------*/
  6337. ACMD_FUNC(homhungry)
  6338. {
  6339. int hungry = 0;
  6340. nullpo_retr(-1, sd);
  6341. if ( !merc_is_hom_active(sd->hd) ) {
  6342. clif_displaymessage(fd, "You do not have a homunculus.");
  6343. return -1;
  6344. }
  6345. if (!message || !*message) {
  6346. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6347. return -1;
  6348. }
  6349. hungry = atoi(message);
  6350. hungry = cap_value(hungry, 0, 100);
  6351. sd->hd->homunculus.hunger = hungry;
  6352. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6353. return 0;
  6354. }
  6355. /*==========================================
  6356. * make the homunculus speak [orn]
  6357. *------------------------------------------*/
  6358. ACMD_FUNC(homtalk)
  6359. {
  6360. char mes[100],temp[100];
  6361. nullpo_retr(-1, sd);
  6362. if (sd->sc.count && //no "chatting" while muted.
  6363. (sd->sc.data[SC_BERSERK] ||
  6364. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6365. return -1;
  6366. if ( !merc_is_hom_active(sd->hd) ) {
  6367. clif_displaymessage(fd, "You do not have a homunculus.");
  6368. return -1;
  6369. }
  6370. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6371. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6372. return -1;
  6373. }
  6374. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6375. clif_message(&sd->hd->bl, temp);
  6376. return 0;
  6377. }
  6378. /*==========================================
  6379. * Show homunculus stats
  6380. *------------------------------------------*/
  6381. ACMD_FUNC(hominfo)
  6382. {
  6383. struct homun_data *hd;
  6384. struct status_data *status;
  6385. nullpo_retr(-1, sd);
  6386. if ( !merc_is_hom_active(sd->hd) ) {
  6387. clif_displaymessage(fd, "You do not have a homunculus.");
  6388. return -1;
  6389. }
  6390. hd = sd->hd;
  6391. status = status_get_status_data(&hd->bl);
  6392. clif_displaymessage(fd, "Homunculus stats :");
  6393. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6394. status->hp, status->max_hp, status->sp, status->max_sp);
  6395. clif_displaymessage(fd, atcmd_output);
  6396. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6397. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6398. clif_displaymessage(fd, atcmd_output);
  6399. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6400. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6401. clif_displaymessage(fd, atcmd_output);
  6402. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6403. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6404. status->str, status->agi, status->vit,
  6405. status->int_, status->dex, status->luk);
  6406. clif_displaymessage(fd, atcmd_output);
  6407. return 0;
  6408. }
  6409. ACMD_FUNC(homstats)
  6410. {
  6411. struct homun_data *hd;
  6412. struct s_homunculus_db *db;
  6413. struct s_homunculus *hom;
  6414. int lv, min, max, evo;
  6415. nullpo_retr(-1, sd);
  6416. if ( !merc_is_hom_active(sd->hd) ) {
  6417. clif_displaymessage(fd, "You do not have a homunculus.");
  6418. return -1;
  6419. }
  6420. hd = sd->hd;
  6421. hom = &hd->homunculus;
  6422. db = hd->homunculusDB;
  6423. lv = hom->level;
  6424. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6425. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6426. clif_displaymessage(fd, atcmd_output);
  6427. lv--; //Since the first increase is at level 2.
  6428. evo = (hom->class_ == db->evo_class);
  6429. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6430. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6431. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6432. clif_displaymessage(fd, atcmd_output);
  6433. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6434. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6435. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6436. clif_displaymessage(fd, atcmd_output);
  6437. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6438. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6439. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6440. clif_displaymessage(fd, atcmd_output);
  6441. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6442. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6443. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6444. clif_displaymessage(fd, atcmd_output);
  6445. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6446. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6447. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6448. clif_displaymessage(fd, atcmd_output);
  6449. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6450. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6451. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6452. clif_displaymessage(fd, atcmd_output);
  6453. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6454. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6455. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6456. clif_displaymessage(fd, atcmd_output);
  6457. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6458. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6459. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6460. clif_displaymessage(fd, atcmd_output);
  6461. return 0;
  6462. }
  6463. ACMD_FUNC(homshuffle)
  6464. {
  6465. nullpo_retr(-1, sd);
  6466. if(!sd->hd)
  6467. return -1; // nothing to do
  6468. if(!merc_hom_shuffle(sd->hd))
  6469. return -1;
  6470. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6471. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6472. return 0;
  6473. }
  6474. /*==========================================
  6475. * Show Items DB Info v 1.0
  6476. * originally by [Lupus] eAthena
  6477. *------------------------------------------*/
  6478. ACMD_FUNC(iteminfo)
  6479. {
  6480. struct item_data *item_data, *item_array[MAX_SEARCH];
  6481. int i, count = 1;
  6482. if (!message || !*message) {
  6483. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6484. return -1;
  6485. }
  6486. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6487. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6488. if (!count) {
  6489. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6490. return -1;
  6491. }
  6492. if (count > MAX_SEARCH) {
  6493. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6494. clif_displaymessage(fd, atcmd_output);
  6495. count = MAX_SEARCH;
  6496. }
  6497. for (i = 0; i < count; i++) {
  6498. item_data = item_array[i];
  6499. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6500. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6501. itemdb_typename(item_data->type),
  6502. (item_data->script==NULL)? "None" : "With script"
  6503. );
  6504. clif_displaymessage(fd, atcmd_output);
  6505. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  6506. clif_displaymessage(fd, atcmd_output);
  6507. if (item_data->maxchance == -1)
  6508. strcpy(atcmd_output, " - Available in the shops only.");
  6509. else if (item_data->maxchance)
  6510. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6511. else
  6512. strcpy(atcmd_output, " - Monsters don't drop this item.");
  6513. clif_displaymessage(fd, atcmd_output);
  6514. }
  6515. return 0;
  6516. }
  6517. /*==========================================
  6518. * Show who drops the item.
  6519. *------------------------------------------*/
  6520. ACMD_FUNC(whodrops)
  6521. {
  6522. struct item_data *item_data, *item_array[MAX_SEARCH];
  6523. int i,j, count = 1;
  6524. if (!message || !*message) {
  6525. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6526. return -1;
  6527. }
  6528. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6529. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6530. if (!count) {
  6531. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6532. return -1;
  6533. }
  6534. if (count > MAX_SEARCH) {
  6535. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6536. clif_displaymessage(fd, atcmd_output);
  6537. count = MAX_SEARCH;
  6538. }
  6539. for (i = 0; i < count; i++) {
  6540. item_data = item_array[i];
  6541. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6542. clif_displaymessage(fd, atcmd_output);
  6543. if (item_data->mob[0].chance == 0) {
  6544. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6545. clif_displaymessage(fd, atcmd_output);
  6546. } else {
  6547. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6548. clif_displaymessage(fd, atcmd_output);
  6549. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6550. {
  6551. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6552. clif_displaymessage(fd, atcmd_output);
  6553. }
  6554. }
  6555. }
  6556. return 0;
  6557. }
  6558. ACMD_FUNC(whereis)
  6559. {
  6560. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6561. int count;
  6562. int i, j, k;
  6563. if (!message || !*message) {
  6564. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6565. return -1;
  6566. }
  6567. // If monster identifier/name argument is a name
  6568. if ((i = mobdb_checkid(atoi(message))))
  6569. {
  6570. mob_array[0] = mob_db(i);
  6571. count = 1;
  6572. } else
  6573. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6574. if (!count) {
  6575. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6576. return -1;
  6577. }
  6578. if (count > MAX_SEARCH) {
  6579. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6580. clif_displaymessage(fd, atcmd_output);
  6581. count = MAX_SEARCH;
  6582. }
  6583. for (k = 0; k < count; k++) {
  6584. mob = mob_array[k];
  6585. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6586. clif_displaymessage(fd, atcmd_output);
  6587. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6588. {
  6589. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6590. if (j < 0) continue;
  6591. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6592. clif_displaymessage(fd, atcmd_output);
  6593. }
  6594. if (i == 0)
  6595. clif_displaymessage(fd, "This monster does not spawn normally.");
  6596. }
  6597. return 0;
  6598. }
  6599. /*==========================================
  6600. * @adopt by [Veider]
  6601. * adopt a novice
  6602. *------------------------------------------*/
  6603. ACMD_FUNC(adopt)
  6604. {
  6605. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6606. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6607. char output[CHAT_SIZE_MAX];
  6608. nullpo_retr(-1, sd);
  6609. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6610. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6611. return -1;
  6612. }
  6613. if (battle_config.etc_log)
  6614. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6615. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6616. sprintf(output, "Cannot find player %s online", player1);
  6617. clif_displaymessage(fd, output);
  6618. return -1;
  6619. }
  6620. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6621. sprintf(output, "Cannot find player %s online", player2);
  6622. clif_displaymessage(fd, output);
  6623. return -1;
  6624. }
  6625. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6626. sprintf(output, "Cannot find player %s online", player3);
  6627. clif_displaymessage(fd, output);
  6628. return -1;
  6629. }
  6630. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6631. return -1;
  6632. }
  6633. clif_displaymessage(fd, "They are family... wish them luck");
  6634. return 0;
  6635. }
  6636. ACMD_FUNC(version)
  6637. {
  6638. const char * revision;
  6639. if ((revision = get_svn_revision()) != 0) {
  6640. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6641. clif_displaymessage(fd,atcmd_output);
  6642. } else
  6643. clif_displaymessage(fd,"Cannot determine SVN revision");
  6644. return 0;
  6645. }
  6646. /*==========================================
  6647. * @mutearea by MouseJstr
  6648. *------------------------------------------*/
  6649. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6650. {
  6651. int time, id;
  6652. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6653. if (pl_sd == NULL)
  6654. return 0;
  6655. id = va_arg(ap, int);
  6656. time = va_arg(ap, int);
  6657. if (id != bl->id && !pc_isGM(pl_sd)) {
  6658. pl_sd->status.manner -= time;
  6659. if (pl_sd->status.manner < 0)
  6660. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6661. else
  6662. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6663. }
  6664. return 0;
  6665. }
  6666. ACMD_FUNC(mutearea)
  6667. {
  6668. int time;
  6669. nullpo_ret(sd);
  6670. if (!message || !*message) {
  6671. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6672. return -1;
  6673. }
  6674. time = atoi(message);
  6675. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6676. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6677. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6678. return 0;
  6679. }
  6680. ACMD_FUNC(rates)
  6681. {
  6682. char buf[CHAT_SIZE_MAX];
  6683. nullpo_ret(sd);
  6684. memset(buf, '\0', sizeof(buf));
  6685. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  6686. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6687. clif_displaymessage(fd, buf);
  6688. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6689. 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.);
  6690. clif_displaymessage(fd, buf);
  6691. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6692. 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.);
  6693. clif_displaymessage(fd, buf);
  6694. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  6695. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6696. clif_displaymessage(fd, buf);
  6697. return 0;
  6698. }
  6699. /*==========================================
  6700. * @me by lordalfa
  6701. * => Displays the OUTPUT string on top of the Visible players Heads.
  6702. *------------------------------------------*/
  6703. ACMD_FUNC(me)
  6704. {
  6705. char tempmes[CHAT_SIZE_MAX];
  6706. nullpo_retr(-1, sd);
  6707. memset(tempmes, '\0', sizeof(tempmes));
  6708. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6709. if (sd->sc.count && //no "chatting" while muted.
  6710. (sd->sc.data[SC_BERSERK] ||
  6711. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6712. return -1;
  6713. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6714. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6715. return -1;
  6716. }
  6717. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6718. clif_disp_overhead(sd, atcmd_output);
  6719. return 0;
  6720. }
  6721. /*==========================================
  6722. * @size
  6723. * => Resize your character sprite. [Valaris]
  6724. *------------------------------------------*/
  6725. ACMD_FUNC(size)
  6726. {
  6727. int size=0;
  6728. nullpo_retr(-1, sd);
  6729. size = atoi(message);
  6730. if(sd->state.size) {
  6731. sd->state.size=0;
  6732. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6733. }
  6734. if(size==1) {
  6735. sd->state.size=1;
  6736. clif_specialeffect(&sd->bl,420,AREA);
  6737. } else if(size==2) {
  6738. sd->state.size=2;
  6739. clif_specialeffect(&sd->bl,422,AREA);
  6740. }
  6741. return 0;
  6742. }
  6743. /*==========================================
  6744. * @monsterignore
  6745. * => Makes monsters ignore you. [Valaris]
  6746. *------------------------------------------*/
  6747. ACMD_FUNC(monsterignore)
  6748. {
  6749. nullpo_retr(-1, sd);
  6750. if (!sd->state.monster_ignore) {
  6751. sd->state.monster_ignore = 1;
  6752. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6753. } else {
  6754. sd->state.monster_ignore = 0;
  6755. clif_displaymessage(sd->fd, "Returned to normal state.");
  6756. }
  6757. return 0;
  6758. }
  6759. /*==========================================
  6760. * @fakename
  6761. * => Gives your character a fake name. [Valaris]
  6762. *------------------------------------------*/
  6763. ACMD_FUNC(fakename)
  6764. {
  6765. nullpo_retr(-1, sd);
  6766. if( !message || !*message )
  6767. {
  6768. if( sd->fakename[0] )
  6769. {
  6770. sd->fakename[0] = '\0';
  6771. clif_charnameack(0, &sd->bl);
  6772. clif_displaymessage(sd->fd, "Returned to real name.");
  6773. return 0;
  6774. }
  6775. clif_displaymessage(sd->fd, "You must enter a name.");
  6776. return -1;
  6777. }
  6778. if( strlen(message) < 2 )
  6779. {
  6780. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  6781. return -1;
  6782. }
  6783. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6784. clif_charnameack(0, &sd->bl);
  6785. clif_displaymessage(sd->fd, "Fake name enabled.");
  6786. return 0;
  6787. }
  6788. /*==========================================
  6789. * Ragnarok Resources
  6790. *------------------------------------------*/
  6791. ACMD_FUNC(mapflag) {
  6792. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6793. #define setflag( cmd ) \
  6794. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6795. map[ sd->bl.m ].flag.cmd = flag;\
  6796. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6797. clif_displaymessage(sd->fd,atcmd_output);\
  6798. return 0;\
  6799. }
  6800. unsigned char flag_name[100];
  6801. int flag=9,i;
  6802. nullpo_retr(-1, sd);
  6803. memset(flag_name, '\0', sizeof(flag_name));
  6804. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6805. clif_displaymessage(sd->fd,"Enabled Mapflags in this map:");
  6806. clif_displaymessage(sd->fd,"----------------------------------");
  6807. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6808. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6809. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6810. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6811. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6812. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6813. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6814. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6815. checkflag(nogo); checkflag(nobaseexp);
  6816. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6817. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6818. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6819. clif_displaymessage(sd->fd," ");
  6820. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off 1=On)");
  6821. clif_displaymessage(sd->fd,"Use: \"@mapflag available\" to list the available mapflags");
  6822. return 1;
  6823. }
  6824. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6825. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6826. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6827. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6828. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6829. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6830. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6831. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6832. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6833. setflag(nogo); setflag(nobaseexp);
  6834. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6835. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6836. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6837. clif_displaymessage(sd->fd,"Invalid flag name or flag");
  6838. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off | 1=On)");
  6839. clif_displaymessage(sd->fd,"Available Flags:");
  6840. clif_displaymessage(sd->fd,"----------------------------------");
  6841. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6842. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6843. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6844. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6845. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6846. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6847. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6848. #undef checkflag
  6849. #undef setflag
  6850. return 0;
  6851. }
  6852. /*===================================
  6853. * Remove some messages
  6854. *-----------------------------------*/
  6855. ACMD_FUNC(showexp)
  6856. {
  6857. if (sd->state.showexp) {
  6858. sd->state.showexp = 0;
  6859. clif_displaymessage(fd, "Gained exp will not be shown.");
  6860. return 0;
  6861. }
  6862. sd->state.showexp = 1;
  6863. clif_displaymessage(fd, "Gained exp is now shown");
  6864. return 0;
  6865. }
  6866. ACMD_FUNC(showzeny)
  6867. {
  6868. if (sd->state.showzeny) {
  6869. sd->state.showzeny = 0;
  6870. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6871. return 0;
  6872. }
  6873. sd->state.showzeny = 1;
  6874. clif_displaymessage(fd, "Gained zeny is now shown");
  6875. return 0;
  6876. }
  6877. ACMD_FUNC(showdelay)
  6878. {
  6879. if (sd->state.showdelay) {
  6880. sd->state.showdelay = 0;
  6881. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6882. return 0;
  6883. }
  6884. sd->state.showdelay = 1;
  6885. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6886. return 0;
  6887. }
  6888. /*==========================================
  6889. * Duel organizing functions [LuzZza]
  6890. *
  6891. * @duel [limit|nick] - create a duel
  6892. * @invite <nick> - invite player
  6893. * @accept - accept invitation
  6894. * @reject - reject invitation
  6895. * @leave - leave duel
  6896. *------------------------------------------*/
  6897. ACMD_FUNC(invite)
  6898. {
  6899. unsigned int did = sd->duel_group;
  6900. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6901. if(did <= 0) {
  6902. // "Duel: @invite without @duel."
  6903. clif_displaymessage(fd, msg_txt(350));
  6904. return 0;
  6905. }
  6906. if(duel_list[did].max_players_limit > 0 &&
  6907. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6908. // "Duel: Limit of players is reached."
  6909. clif_displaymessage(fd, msg_txt(351));
  6910. return 0;
  6911. }
  6912. if(target_sd == NULL) {
  6913. // "Duel: Player not found."
  6914. clif_displaymessage(fd, msg_txt(352));
  6915. return 0;
  6916. }
  6917. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6918. // "Duel: Player already in duel."
  6919. clif_displaymessage(fd, msg_txt(353));
  6920. return 0;
  6921. }
  6922. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6923. {
  6924. sprintf(atcmd_output, msg_txt(364), message);
  6925. clif_displaymessage(fd, atcmd_output);
  6926. return 0;
  6927. }
  6928. duel_invite(did, sd, target_sd);
  6929. // "Duel: Invitation has been sent."
  6930. clif_displaymessage(fd, msg_txt(354));
  6931. return 0;
  6932. }
  6933. ACMD_FUNC(duel)
  6934. {
  6935. char output[CHAT_SIZE_MAX];
  6936. unsigned int maxpl=0, newduel;
  6937. struct map_session_data *target_sd;
  6938. if(sd->duel_group > 0) {
  6939. duel_showinfo(sd->duel_group, sd);
  6940. return 0;
  6941. }
  6942. if(sd->duel_invite > 0) {
  6943. // "Duel: @duel without @reject."
  6944. clif_displaymessage(fd, msg_txt(355));
  6945. return 0;
  6946. }
  6947. if(!duel_checktime(sd)) {
  6948. // "Duel: You can take part in duel only one time per %d minutes."
  6949. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6950. clif_displaymessage(fd, output);
  6951. return 0;
  6952. }
  6953. if( message[0] ) {
  6954. if(sscanf(message, "%d", &maxpl) >= 1) {
  6955. if(maxpl < 2 || maxpl > 65535) {
  6956. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6957. return 0;
  6958. }
  6959. duel_create(sd, maxpl);
  6960. } else {
  6961. target_sd = map_nick2sd((char *)message);
  6962. if(target_sd != NULL) {
  6963. if((newduel = duel_create(sd, 2)) != -1) {
  6964. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6965. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6966. return 0;
  6967. }
  6968. duel_invite(newduel, sd, target_sd);
  6969. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6970. }
  6971. } else {
  6972. // "Duel: Player not found."
  6973. clif_displaymessage(fd, msg_txt(352));
  6974. return 0;
  6975. }
  6976. }
  6977. } else
  6978. duel_create(sd, 0);
  6979. return 0;
  6980. }
  6981. ACMD_FUNC(leave)
  6982. {
  6983. if(sd->duel_group <= 0) {
  6984. // "Duel: @leave without @duel."
  6985. clif_displaymessage(fd, msg_txt(358));
  6986. return 0;
  6987. }
  6988. duel_leave(sd->duel_group, sd);
  6989. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6990. return 0;
  6991. }
  6992. ACMD_FUNC(accept)
  6993. {
  6994. char output[CHAT_SIZE_MAX];
  6995. if(!duel_checktime(sd)) {
  6996. // "Duel: You can take part in duel only one time per %d minutes."
  6997. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6998. clif_displaymessage(fd, output);
  6999. return 0;
  7000. }
  7001. if(sd->duel_invite <= 0) {
  7002. // "Duel: @accept without invititation."
  7003. clif_displaymessage(fd, msg_txt(360));
  7004. return 0;
  7005. }
  7006. 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 )
  7007. {
  7008. // "Duel: Limit of players is reached."
  7009. clif_displaymessage(fd, msg_txt(351));
  7010. return 0;
  7011. }
  7012. duel_accept(sd->duel_invite, sd);
  7013. // "Duel: Invitation has been accepted."
  7014. clif_displaymessage(fd, msg_txt(361));
  7015. return 0;
  7016. }
  7017. ACMD_FUNC(reject)
  7018. {
  7019. if(sd->duel_invite <= 0) {
  7020. // "Duel: @reject without invititation."
  7021. clif_displaymessage(fd, msg_txt(362));
  7022. return 0;
  7023. }
  7024. duel_reject(sd->duel_invite, sd);
  7025. // "Duel: Invitation has been rejected."
  7026. clif_displaymessage(fd, msg_txt(363));
  7027. return 0;
  7028. }
  7029. /*===================================
  7030. * Cash Points
  7031. *-----------------------------------*/
  7032. ACMD_FUNC(cash)
  7033. {
  7034. char output[128];
  7035. int value;
  7036. nullpo_retr(-1, sd);
  7037. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7038. clif_displaymessage(fd, "Please, enter an amount.");
  7039. return -1;
  7040. }
  7041. if( !strcmpi(command+1,"cash") )
  7042. {
  7043. if( value > 0 ) {
  7044. pc_getcash(sd, value, 0);
  7045. sprintf(output, msg_txt(505), value, sd->cashPoints);
  7046. clif_disp_onlyself(sd, output, strlen(output));
  7047. } else {
  7048. pc_paycash(sd, -value, 0);
  7049. sprintf(output, msg_txt(410), value, sd->cashPoints);
  7050. clif_disp_onlyself(sd, output, strlen(output));
  7051. }
  7052. }
  7053. else
  7054. { // @points
  7055. if( value > 0 ) {
  7056. pc_getcash(sd, 0, value);
  7057. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  7058. clif_disp_onlyself(sd, output, strlen(output));
  7059. } else {
  7060. pc_paycash(sd, -value, -value);
  7061. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  7062. clif_disp_onlyself(sd, output, strlen(output));
  7063. }
  7064. }
  7065. return 0;
  7066. }
  7067. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7068. ACMD_FUNC(clone)
  7069. {
  7070. int x=0,y=0,flag=0,master=0,i=0;
  7071. struct map_session_data *pl_sd=NULL;
  7072. if (!message || !*message) {
  7073. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  7074. return 0;
  7075. }
  7076. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7077. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7078. return 0;
  7079. }
  7080. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  7081. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  7082. return 0;
  7083. }
  7084. if (strcmpi(command+1, "clone") == 0)
  7085. flag = 1;
  7086. else if (strcmpi(command+1, "slaveclone") == 0) {
  7087. flag = 2;
  7088. master = sd->bl.id;
  7089. if (battle_config.atc_slave_clone_limit
  7090. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7091. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  7092. return 0;
  7093. }
  7094. }
  7095. do {
  7096. x = sd->bl.x + (rand() % 10 - 5);
  7097. y = sd->bl.y + (rand() % 10 - 5);
  7098. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7099. if (i >= 10) {
  7100. x = sd->bl.x;
  7101. y = sd->bl.y;
  7102. }
  7103. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7104. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7105. return 0;
  7106. }
  7107. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7108. return 0;
  7109. }
  7110. /*===================================
  7111. * Main chat [LuzZza]
  7112. * Usage: @main <on|off|message>
  7113. *-----------------------------------*/
  7114. ACMD_FUNC(main)
  7115. {
  7116. if( message[0] ) {
  7117. if(strcmpi(message, "on") == 0) {
  7118. if(!sd->state.mainchat) {
  7119. sd->state.mainchat = 1;
  7120. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7121. } else {
  7122. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  7123. }
  7124. } else if(strcmpi(message, "off") == 0) {
  7125. if(sd->state.mainchat) {
  7126. sd->state.mainchat = 0;
  7127. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  7128. } else {
  7129. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  7130. }
  7131. } else {
  7132. if(!sd->state.mainchat) {
  7133. sd->state.mainchat = 1;
  7134. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7135. }
  7136. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  7137. clif_displaymessage(fd, msg_txt(387));
  7138. return -1;
  7139. }
  7140. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  7141. // I use 0xFE000000 color for signalizing that this message is
  7142. // main chat message. 0xFE000000 is invalid color, same using
  7143. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  7144. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
  7145. // Chat logging type 'M' / Main Chat
  7146. log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  7147. }
  7148. } else {
  7149. if(sd->state.mainchat)
  7150. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  7151. else
  7152. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  7153. }
  7154. return 0;
  7155. }
  7156. /*=====================================
  7157. * Autorejecting Invites/Deals [LuzZza]
  7158. * Usage: @noask
  7159. *-------------------------------------*/
  7160. ACMD_FUNC(noask)
  7161. {
  7162. if(sd->state.noask) {
  7163. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  7164. sd->state.noask = 0;
  7165. } else {
  7166. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  7167. sd->state.noask = 1;
  7168. }
  7169. return 0;
  7170. }
  7171. /*=====================================
  7172. * Send a @request message to all GMs of lowest_gm_level.
  7173. * Usage: @request <petition>
  7174. *-------------------------------------*/
  7175. ACMD_FUNC(request)
  7176. {
  7177. if (!message || !*message) {
  7178. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  7179. return -1;
  7180. }
  7181. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  7182. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  7183. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7184. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  7185. return 0;
  7186. }
  7187. /*==========================================
  7188. * Feel (SG save map) Reset [HiddenDragon]
  7189. *------------------------------------------*/
  7190. ACMD_FUNC(feelreset)
  7191. {
  7192. pc_resetfeel(sd);
  7193. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  7194. return 0;
  7195. }
  7196. /*==========================================
  7197. * AUCTION SYSTEM
  7198. *------------------------------------------*/
  7199. ACMD_FUNC(auction)
  7200. {
  7201. nullpo_ret(sd);
  7202. #ifndef TXT_ONLY
  7203. clif_Auction_openwindow(sd);
  7204. #endif
  7205. return 0;
  7206. }
  7207. /*==========================================
  7208. * Kill Steal Protection
  7209. *------------------------------------------*/
  7210. ACMD_FUNC(ksprotection)
  7211. {
  7212. nullpo_retr(-1,sd);
  7213. if( sd->state.noks ) {
  7214. sd->state.noks = 0;
  7215. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  7216. }
  7217. else
  7218. {
  7219. if( !message || !*message || !strcmpi(message, "party") )
  7220. { // Default is Party
  7221. sd->state.noks = 2;
  7222. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7223. }
  7224. else if( !strcmpi(message, "self") )
  7225. {
  7226. sd->state.noks = 1;
  7227. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7228. }
  7229. else if( !strcmpi(message, "guild") )
  7230. {
  7231. sd->state.noks = 3;
  7232. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7233. }
  7234. else
  7235. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  7236. }
  7237. clif_displaymessage(fd, atcmd_output);
  7238. return 0;
  7239. }
  7240. /*==========================================
  7241. * Map Kill Steal Protection Setting
  7242. *------------------------------------------*/
  7243. ACMD_FUNC(allowks)
  7244. {
  7245. nullpo_retr(-1,sd);
  7246. if( map[sd->bl.m].flag.allowks ) {
  7247. map[sd->bl.m].flag.allowks = 0;
  7248. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7249. } else {
  7250. map[sd->bl.m].flag.allowks = 1;
  7251. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7252. }
  7253. clif_displaymessage(fd, atcmd_output);
  7254. return 0;
  7255. }
  7256. ACMD_FUNC(resetstat)
  7257. {
  7258. nullpo_retr(-1, sd);
  7259. pc_resetstate(sd);
  7260. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  7261. clif_displaymessage(fd, atcmd_output);
  7262. return 0;
  7263. }
  7264. ACMD_FUNC(resetskill)
  7265. {
  7266. nullpo_retr(-1,sd);
  7267. pc_resetskill(sd,1);
  7268. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  7269. clif_displaymessage(fd, atcmd_output);
  7270. return 0;
  7271. }
  7272. /*==========================================
  7273. * #storagelist: Displays the items list of a player's storage.
  7274. * #cartlist: Displays contents of target's cart.
  7275. * #itemlist: Displays contents of target's inventory.
  7276. *------------------------------------------*/
  7277. ACMD_FUNC(itemlist)
  7278. {
  7279. int i, j, count, counter;
  7280. const char* location;
  7281. const struct item* items;
  7282. int size;
  7283. StringBuf buf;
  7284. nullpo_retr(-1, sd);
  7285. if( strcmp(command+1, "storagelist") == 0 )
  7286. {
  7287. location = "storage";
  7288. items = sd->status.storage.items;
  7289. size = MAX_STORAGE;
  7290. }
  7291. else
  7292. if( strcmp(command+1, "cartlist") == 0 )
  7293. {
  7294. location = "cart";
  7295. items = sd->status.cart;
  7296. size = MAX_CART;
  7297. }
  7298. else
  7299. if( strcmp(command+1, "itemlist") == 0 )
  7300. {
  7301. location = "inventory";
  7302. items = sd->status.inventory;
  7303. size = MAX_INVENTORY;
  7304. }
  7305. else
  7306. return 1;
  7307. StringBuf_Init(&buf);
  7308. count = 0; // total slots occupied
  7309. counter = 0; // total items found
  7310. for( i = 0; i < size; ++i )
  7311. {
  7312. const struct item* it = &items[i];
  7313. struct item_data* itd;
  7314. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7315. continue;
  7316. counter += it->amount;
  7317. count++;
  7318. if( count == 1 )
  7319. {
  7320. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  7321. clif_displaymessage(fd, StringBuf_Value(&buf));
  7322. StringBuf_Clear(&buf);
  7323. }
  7324. if( it->refine )
  7325. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7326. else
  7327. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7328. if( it->equip )
  7329. {
  7330. char equipstr[CHAT_SIZE_MAX];
  7331. strcpy(equipstr, " | equipped: ");
  7332. if( it->equip & EQP_GARMENT )
  7333. strcat(equipstr, "garment, ");
  7334. if( it->equip & EQP_ACC_L )
  7335. strcat(equipstr, "left accessory, ");
  7336. if( it->equip & EQP_ARMOR )
  7337. strcat(equipstr, "body/armor, ");
  7338. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7339. strcat(equipstr, "right hand, ");
  7340. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7341. strcat(equipstr, "left hand, ");
  7342. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7343. strcat(equipstr, "both hands, ");
  7344. if( it->equip & EQP_SHOES )
  7345. strcat(equipstr, "feet, ");
  7346. if( it->equip & EQP_ACC_R )
  7347. strcat(equipstr, "right accessory, ");
  7348. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7349. strcat(equipstr, "lower head, ");
  7350. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7351. strcat(equipstr, "top head, ");
  7352. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7353. strcat(equipstr, "lower/top head, ");
  7354. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7355. strcat(equipstr, "mid head, ");
  7356. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7357. strcat(equipstr, "lower/mid head, ");
  7358. if( (it->equip & EQP_HELM) == EQP_HELM )
  7359. strcat(equipstr, "lower/mid/top head, ");
  7360. // remove final ', '
  7361. equipstr[strlen(equipstr) - 2] = '\0';
  7362. StringBuf_AppendStr(&buf, equipstr);
  7363. }
  7364. clif_displaymessage(fd, StringBuf_Value(&buf));
  7365. StringBuf_Clear(&buf);
  7366. if( it->card[0] == CARD0_PET )
  7367. {// pet egg
  7368. if (it->card[3])
  7369. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7370. else
  7371. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7372. }
  7373. else
  7374. if(it->card[0] == CARD0_FORGE)
  7375. {// forged item
  7376. StringBuf_Printf(&buf, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f);
  7377. }
  7378. else
  7379. if(it->card[0] == CARD0_CREATE)
  7380. {// created item
  7381. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  7382. }
  7383. else
  7384. {// normal item
  7385. int counter2 = 0;
  7386. for( j = 0; j < itd->slot; ++j )
  7387. {
  7388. struct item_data* card;
  7389. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7390. continue;
  7391. counter2++;
  7392. if( counter2 == 1 )
  7393. StringBuf_AppendStr(&buf, " -> (card(s): ");
  7394. if( counter2 != 1 )
  7395. StringBuf_AppendStr(&buf, ", ");
  7396. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7397. }
  7398. if( counter2 > 0 )
  7399. StringBuf_AppendStr(&buf, ")");
  7400. }
  7401. if( StringBuf_Length(&buf) > 0 )
  7402. clif_displaymessage(fd, StringBuf_Value(&buf));
  7403. StringBuf_Clear(&buf);
  7404. }
  7405. if( count == 0 )
  7406. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  7407. else
  7408. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  7409. clif_displaymessage(fd, StringBuf_Value(&buf));
  7410. StringBuf_Destroy(&buf);
  7411. return 0;
  7412. }
  7413. ACMD_FUNC(stats)
  7414. {
  7415. char job_jobname[100];
  7416. char output[CHAT_SIZE_MAX];
  7417. int i;
  7418. struct {
  7419. const char* format;
  7420. int value;
  7421. } output_table[] = {
  7422. { "Base Level - %d", 0 },
  7423. { NULL, 0 },
  7424. { "Hp - %d", 0 },
  7425. { "MaxHp - %d", 0 },
  7426. { "Sp - %d", 0 },
  7427. { "MaxSp - %d", 0 },
  7428. { "Str - %3d", 0 },
  7429. { "Agi - %3d", 0 },
  7430. { "Vit - %3d", 0 },
  7431. { "Int - %3d", 0 },
  7432. { "Dex - %3d", 0 },
  7433. { "Luk - %3d", 0 },
  7434. { "Zeny - %d", 0 },
  7435. { "Free SK Points - %d", 0 },
  7436. { "JobChangeLvl - %d", 0 },
  7437. { NULL, 0 }
  7438. };
  7439. memset(job_jobname, '\0', sizeof(job_jobname));
  7440. memset(output, '\0', sizeof(output));
  7441. //direct array initialization with variables is not standard C compliant.
  7442. output_table[0].value = sd->status.base_level;
  7443. output_table[1].format = job_jobname;
  7444. output_table[1].value = sd->status.job_level;
  7445. output_table[2].value = sd->status.hp;
  7446. output_table[3].value = sd->status.max_hp;
  7447. output_table[4].value = sd->status.sp;
  7448. output_table[5].value = sd->status.max_sp;
  7449. output_table[6].value = sd->status.str;
  7450. output_table[7].value = sd->status.agi;
  7451. output_table[8].value = sd->status.vit;
  7452. output_table[9].value = sd->status.int_;
  7453. output_table[10].value = sd->status.dex;
  7454. output_table[11].value = sd->status.luk;
  7455. output_table[12].value = sd->status.zeny;
  7456. output_table[13].value = sd->status.skill_point;
  7457. output_table[14].value = sd->change_level;
  7458. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7459. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7460. clif_displaymessage(fd, output);
  7461. for (i = 0; output_table[i].format != NULL; i++) {
  7462. sprintf(output, output_table[i].format, output_table[i].value);
  7463. clif_displaymessage(fd, output);
  7464. }
  7465. return 0;
  7466. }
  7467. ACMD_FUNC(delitem)
  7468. {
  7469. char item_name[100];
  7470. int nameid, amount = 0, total, idx;
  7471. struct item_data* id;
  7472. nullpo_retr(-1, sd);
  7473. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7474. {
  7475. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  7476. return -1;
  7477. }
  7478. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7479. {
  7480. nameid = id->nameid;
  7481. }
  7482. else
  7483. {
  7484. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7485. return -1;
  7486. }
  7487. total = amount;
  7488. // delete items
  7489. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7490. {
  7491. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7492. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7493. {// delete pet
  7494. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7495. }
  7496. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7497. amount-= delamount;
  7498. }
  7499. // notify target
  7500. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7501. clif_displaymessage(sd->fd, atcmd_output);
  7502. // notify source
  7503. if( amount == total )
  7504. {
  7505. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7506. }
  7507. else if( amount )
  7508. {
  7509. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7510. clif_displaymessage(fd, atcmd_output);
  7511. }
  7512. else
  7513. {
  7514. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7515. clif_displaymessage(fd, atcmd_output);
  7516. }
  7517. return 0;
  7518. }
  7519. /*==========================================
  7520. * Custom Fonts
  7521. *------------------------------------------*/
  7522. ACMD_FUNC(font)
  7523. {
  7524. int font_id;
  7525. nullpo_retr(-1,sd);
  7526. font_id = atoi(message);
  7527. if( font_id == 0 )
  7528. {
  7529. if( sd->user_font )
  7530. {
  7531. sd->user_font = 0;
  7532. clif_displaymessage(fd, "Returning to normal font.");
  7533. clif_font(sd);
  7534. }
  7535. else
  7536. {
  7537. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  7538. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  7539. }
  7540. }
  7541. else if( font_id < 0 || font_id > 9 )
  7542. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  7543. else if( font_id != sd->user_font )
  7544. {
  7545. sd->user_font = font_id;
  7546. clif_font(sd);
  7547. clif_displaymessage(fd, "Font changed.");
  7548. }
  7549. else
  7550. clif_displaymessage(fd, "Already using this font.");
  7551. return 0;
  7552. }
  7553. ACMD_FUNC(new_mount) {
  7554. clif_displaymessage(sd->fd,"NOTICE: If you crash with mount your LUA is outdated");
  7555. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7556. clif_displaymessage(sd->fd,"You have mounted.");
  7557. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7558. } else {
  7559. clif_displaymessage(sd->fd,"You have released your mount");
  7560. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7561. }
  7562. return 0;
  7563. }
  7564. /**
  7565. * Fills the reference of available commands in atcommand DBMap
  7566. **/
  7567. void atcommand_basecommands(void) {
  7568. /**
  7569. * Command reference list, place the base of your commands here
  7570. * Dev note: I'd love to get rid of this, if you have a better idea on this please share with the poor mortals
  7571. **/
  7572. AtCommandInfo atcommand_base[] = {
  7573. { "warp", 40,40, atcommand_mapmove }, // + /mm
  7574. { "where", 1,1, atcommand_where },
  7575. { "goto", 20,20, atcommand_jumpto }, // + /shift
  7576. { "jump", 40,40, atcommand_jump },
  7577. { "who", 20,20, atcommand_who },
  7578. { "who2", 20,20, atcommand_who2 },
  7579. { "who3", 20,20, atcommand_who3 },
  7580. { "whomap", 20,20, atcommand_whomap },
  7581. { "whomap2", 20,20, atcommand_whomap2 },
  7582. { "whomap3", 20,20, atcommand_whomap3 },
  7583. { "whogm", 20,20, atcommand_whogm },
  7584. { "save", 40,40, atcommand_save },
  7585. { "load", 40,40, atcommand_load },
  7586. { "speed", 40,40, atcommand_speed },
  7587. { "storage", 1,1, atcommand_storage },
  7588. { "gstorage", 50,50, atcommand_guildstorage },
  7589. { "option", 40,40, atcommand_option },
  7590. { "hide", 40,40, atcommand_hide }, // + /hide
  7591. { "job", 40,40, atcommand_jobchange },
  7592. { "die", 1,1, atcommand_die },
  7593. { "kill", 60,60, atcommand_kill },
  7594. { "alive", 60,60, atcommand_alive },
  7595. { "kami", 40,40, atcommand_kami },
  7596. { "kamib", 40,40, atcommand_kami },
  7597. { "kamic", 40,40, atcommand_kami },
  7598. { "heal", 40,60, atcommand_heal },
  7599. { "item", 60,60, atcommand_item },
  7600. { "item2", 60,60, atcommand_item2 },
  7601. { "itemreset", 40,40, atcommand_itemreset },
  7602. { "blvl", 60,60, atcommand_baselevelup },
  7603. { "jlvl", 60,60, atcommand_joblevelup },
  7604. { "help", 20,20, atcommand_help },
  7605. { "help2", 20,20, atcommand_help2 },
  7606. { "pvpoff", 40,40, atcommand_pvpoff },
  7607. { "pvpon", 40,40, atcommand_pvpon },
  7608. { "gvgoff", 40,40, atcommand_gvgoff },
  7609. { "gvgon", 40,40, atcommand_gvgon },
  7610. { "model", 20,20, atcommand_model },
  7611. { "go", 10,10, atcommand_go },
  7612. { "monster", 50,50, atcommand_monster },
  7613. { "monstersmall", 50,50, atcommand_monstersmall },
  7614. { "monsterbig", 50,50, atcommand_monsterbig },
  7615. { "killmonster", 60,60, atcommand_killmonster },
  7616. { "killmonster2", 40,40, atcommand_killmonster2 },
  7617. { "refine", 60,60, atcommand_refine },
  7618. { "produce", 60,60, atcommand_produce },
  7619. { "memo", 40,40, atcommand_memo },
  7620. { "gat", 99,99, atcommand_gat },
  7621. { "displaystatus", 99,99, atcommand_displaystatus },
  7622. { "stpoint", 60,60, atcommand_statuspoint },
  7623. { "skpoint", 60,60, atcommand_skillpoint },
  7624. { "zeny", 60,60, atcommand_zeny },
  7625. { "str", 60,60, atcommand_param },
  7626. { "agi", 60,60, atcommand_param },
  7627. { "vit", 60,60, atcommand_param },
  7628. { "int", 60,60, atcommand_param },
  7629. { "dex", 60,60, atcommand_param },
  7630. { "luk", 60,60, atcommand_param },
  7631. { "glvl", 60,60, atcommand_guildlevelup },
  7632. { "makeegg", 60,60, atcommand_makeegg },
  7633. { "hatch", 60,60, atcommand_hatch },
  7634. { "petfriendly", 40,40, atcommand_petfriendly },
  7635. { "pethungry", 40,40, atcommand_pethungry },
  7636. { "petrename", 1,1, atcommand_petrename },
  7637. { "recall", 60,60, atcommand_recall }, // + /recall
  7638. { "night", 80,80, atcommand_night },
  7639. { "day", 80,80, atcommand_day },
  7640. { "doom", 80,80, atcommand_doom },
  7641. { "doommap", 80,80, atcommand_doommap },
  7642. { "raise", 80,80, atcommand_raise },
  7643. { "raisemap", 80,80, atcommand_raisemap },
  7644. { "kick", 20,20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7645. { "kickall", 99,99, atcommand_kickall },
  7646. { "allskill", 60,60, atcommand_allskill },
  7647. { "questskill", 40,40, atcommand_questskill },
  7648. { "lostskill", 40,40, atcommand_lostskill },
  7649. { "spiritball", 40,40, atcommand_spiritball },
  7650. { "party", 1,1, atcommand_party },
  7651. { "guild", 50,50, atcommand_guild },
  7652. { "agitstart", 60,60, atcommand_agitstart },
  7653. { "agitend", 60,60, atcommand_agitend },
  7654. { "mapexit", 99,99, atcommand_mapexit },
  7655. { "idsearch", 60,60, atcommand_idsearch },
  7656. { "broadcast", 40,40, atcommand_broadcast }, // + /b and /nb
  7657. { "localbroadcast", 40,40, atcommand_localbroadcast }, // + /lb and /nlb
  7658. { "recallall", 80,80, atcommand_recallall },
  7659. { "reloaditemdb", 99,99, atcommand_reloaditemdb },
  7660. { "reloadmobdb", 99,99, atcommand_reloadmobdb },
  7661. { "reloadskilldb", 99,99, atcommand_reloadskilldb },
  7662. { "reloadscript", 99,99, atcommand_reloadscript },
  7663. { "reloadatcommand", 99,99, atcommand_reloadatcommand },
  7664. { "reloadbattleconf", 99,99, atcommand_reloadbattleconf },
  7665. { "reloadstatusdb", 99,99, atcommand_reloadstatusdb },
  7666. { "reloadpcdb", 99,99, atcommand_reloadpcdb },
  7667. { "reloadmotd", 99,99, atcommand_reloadmotd },
  7668. { "mapinfo", 99,99, atcommand_mapinfo },
  7669. { "dye", 40,40, atcommand_dye },
  7670. { "hairstyle", 40,40, atcommand_hair_style },
  7671. { "haircolor", 40,40, atcommand_hair_color },
  7672. { "allstats", 60,60, atcommand_stat_all },
  7673. { "block", 60,60, atcommand_char_block },
  7674. { "ban", 60,60, atcommand_char_ban },
  7675. { "unblock", 60,60, atcommand_char_unblock },
  7676. { "unban", 60,60, atcommand_char_unban },
  7677. { "mount", 20,20, atcommand_mount_peco },
  7678. { "guildspy", 60,60, atcommand_guildspy },
  7679. { "partyspy", 60,60, atcommand_partyspy },
  7680. { "repairall", 60,60, atcommand_repairall },
  7681. { "guildrecall", 60,60, atcommand_guildrecall },
  7682. { "partyrecall", 60,60, atcommand_partyrecall },
  7683. { "nuke", 60,60, atcommand_nuke },
  7684. { "shownpc", 80,80, atcommand_shownpc },
  7685. { "hidenpc", 80,80, atcommand_hidenpc },
  7686. { "loadnpc", 80,80, atcommand_loadnpc },
  7687. { "unloadnpc", 80,80, atcommand_unloadnpc },
  7688. { "time", 1,1, atcommand_servertime },
  7689. { "jail", 60,60, atcommand_jail },
  7690. { "unjail", 60,60, atcommand_unjail },
  7691. { "jailfor", 60,60, atcommand_jailfor },
  7692. { "jailtime", 1,1, atcommand_jailtime },
  7693. { "disguise", 20,20, atcommand_disguise },
  7694. { "undisguise", 20,20, atcommand_undisguise },
  7695. { "email", 1,1, atcommand_email },
  7696. { "effect", 40,40, atcommand_effect },
  7697. { "follow", 20,20, atcommand_follow },
  7698. { "addwarp", 60,60, atcommand_addwarp },
  7699. { "skillon", 80,80, atcommand_skillon },
  7700. { "skilloff", 80,80, atcommand_skilloff },
  7701. { "killer", 60,60, atcommand_killer },
  7702. { "npcmove", 80,80, atcommand_npcmove },
  7703. { "killable", 40,40, atcommand_killable },
  7704. { "dropall", 40,40, atcommand_dropall },
  7705. { "storeall", 40,40, atcommand_storeall },
  7706. { "skillid", 40,40, atcommand_skillid },
  7707. { "useskill", 40,40, atcommand_useskill },
  7708. { "displayskill", 99,99, atcommand_displayskill },
  7709. { "snow", 99,99, atcommand_snow },
  7710. { "sakura", 99,99, atcommand_sakura },
  7711. { "clouds", 99,99, atcommand_clouds },
  7712. { "clouds2", 99,99, atcommand_clouds2 },
  7713. { "fog", 99,99, atcommand_fog },
  7714. { "fireworks", 99,99, atcommand_fireworks },
  7715. { "leaves", 99,99, atcommand_leaves },
  7716. { "summon", 60,60, atcommand_summon },
  7717. { "adjgmlvl", 99,99, atcommand_adjgmlvl },
  7718. { "adjcmdlvl", 99,99, atcommand_adjcmdlvl },
  7719. { "trade", 60,60, atcommand_trade },
  7720. { "send", 99,99, atcommand_send },
  7721. { "setbattleflag", 99,99, atcommand_setbattleflag },
  7722. { "unmute", 80,80, atcommand_unmute },
  7723. { "clearweather", 99,99, atcommand_clearweather },
  7724. { "uptime", 1,1, atcommand_uptime },
  7725. { "changesex", 60,60, atcommand_changesex },
  7726. { "mute", 80,80, atcommand_mute },
  7727. { "refresh", 1,1, atcommand_refresh },
  7728. { "identify", 40,40, atcommand_identify },
  7729. { "gmotd", 20,20, atcommand_gmotd },
  7730. { "misceffect", 50,50, atcommand_misceffect },
  7731. { "mobsearch", 10,10, atcommand_mobsearch },
  7732. { "cleanmap", 40,40, atcommand_cleanmap },
  7733. { "npctalk", 20,20, atcommand_npctalk },
  7734. { "pettalk", 10,10, atcommand_pettalk },
  7735. { "users", 40,40, atcommand_users },
  7736. { "reset", 40,40, atcommand_reset },
  7737. { "skilltree", 40,40, atcommand_skilltree },
  7738. { "marry", 40,40, atcommand_marry },
  7739. { "divorce", 40,40, atcommand_divorce },
  7740. { "sound", 40,40, atcommand_sound },
  7741. { "undisguiseall", 99,99, atcommand_undisguiseall },
  7742. { "disguiseall", 99,99, atcommand_disguiseall },
  7743. { "changelook", 60,60, atcommand_changelook },
  7744. { "autoloot", 10,10, atcommand_autoloot },
  7745. { "alootid", 10,10, atcommand_autolootitem },
  7746. { "monsterinfo", 1,1, atcommand_mobinfo },
  7747. { "exp", 1,1, atcommand_exp },
  7748. { "adopt", 40,40, atcommand_adopt },
  7749. { "version", 1,1, atcommand_version },
  7750. { "mutearea", 99,99, atcommand_mutearea },
  7751. { "rates", 1,1, atcommand_rates },
  7752. { "iteminfo", 1,1, atcommand_iteminfo },
  7753. { "whodrops", 1,1, atcommand_whodrops },
  7754. { "whereis", 10,10, atcommand_whereis },
  7755. { "mapflag", 99,99, atcommand_mapflag },
  7756. { "me", 20,20, atcommand_me },
  7757. { "battleignore", 99,99, atcommand_monsterignore },
  7758. { "fakename", 20,20, atcommand_fakename },
  7759. { "size", 20,20, atcommand_size },
  7760. { "showexp", 10,10, atcommand_showexp},
  7761. { "showzeny", 10,10, atcommand_showzeny},
  7762. { "showdelay", 1,1, atcommand_showdelay},
  7763. { "autotrade", 10,10, atcommand_autotrade },
  7764. { "changegm", 10,10, atcommand_changegm },
  7765. { "changeleader", 10,10, atcommand_changeleader },
  7766. { "partyoption", 10,10, atcommand_partyoption},
  7767. { "invite", 1,1, atcommand_invite },
  7768. { "duel", 1,1, atcommand_duel },
  7769. { "leave", 1,1, atcommand_leave },
  7770. { "accept", 1,1, atcommand_accept },
  7771. { "reject", 1,1, atcommand_reject },
  7772. { "main", 1,1, atcommand_main },
  7773. { "clone", 50,50, atcommand_clone },
  7774. { "slaveclone", 50,50, atcommand_clone },
  7775. { "evilclone", 50,50, atcommand_clone },
  7776. { "tonpc", 40,40, atcommand_tonpc },
  7777. { "commands", 1,1, atcommand_commands },
  7778. { "noask", 1,1, atcommand_noask },
  7779. { "request", 20,20, atcommand_request },
  7780. { "hlvl", 60,60, atcommand_homlevel },
  7781. { "homevolve", 60,60, atcommand_homevolution },
  7782. { "makehomun", 60,60, atcommand_makehomun },
  7783. { "homfriendly", 60,60, atcommand_homfriendly },
  7784. { "homhungry", 60,60, atcommand_homhungry },
  7785. { "homtalk", 10,10, atcommand_homtalk },
  7786. { "hominfo", 1,1, atcommand_hominfo },
  7787. { "homstats", 1,1, atcommand_homstats },
  7788. { "homshuffle", 60,60, atcommand_homshuffle },
  7789. { "showmobs", 10,10, atcommand_showmobs },
  7790. { "feelreset", 10,10, atcommand_feelreset },
  7791. { "auction", 1,1, atcommand_auction },
  7792. { "mail", 1,1, atcommand_mail },
  7793. { "noks", 1,1, atcommand_ksprotection },
  7794. { "allowks", 40,40, atcommand_allowks },
  7795. { "cash", 60,60, atcommand_cash },
  7796. { "points", 60,60, atcommand_cash },
  7797. { "agitstart2", 60,60, atcommand_agitstart2 },
  7798. { "agitend2", 60,60, atcommand_agitend2 },
  7799. { "skreset", 60,60, atcommand_resetskill },
  7800. { "streset", 60,60, atcommand_resetstat },
  7801. { "storagelist", 40,40, atcommand_itemlist },
  7802. { "cartlist", 40,40, atcommand_itemlist },
  7803. { "itemlist", 40,40, atcommand_itemlist },
  7804. { "stats", 40,40, atcommand_stats },
  7805. { "delitem", 60,60, atcommand_delitem },
  7806. { "charcommands", 1,1, atcommand_commands },
  7807. { "font", 1,1, atcommand_font },
  7808. /**
  7809. * For Testing Purposes, not going to be here after we're done.
  7810. **/
  7811. { "newmount", 0,99, atcommand_new_mount },
  7812. };
  7813. AtCommandInfo* atcommand;
  7814. int i;
  7815. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7816. CREATE(atcommand, AtCommandInfo, 1);
  7817. safestrncpy(atcommand->command,atcommand_base[i].command,sizeof(atcommand->command));
  7818. atcommand->level = atcommand_base[i].level;
  7819. atcommand->level2 = atcommand_base[i].level2;
  7820. atcommand->func = atcommand_base[i].func;
  7821. strdb_put(atcommand_db, atcommand->command, atcommand);
  7822. }
  7823. return;
  7824. }
  7825. /*==========================================
  7826. * Command lookup functions
  7827. *------------------------------------------*/
  7828. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  7829. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  7830. if( strdb_exists(atcommand_db,name) )
  7831. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7832. return NULL;
  7833. }
  7834. /*==========================================
  7835. * Retrieve the command's required gm level
  7836. *------------------------------------------*/
  7837. int get_atcommand_level(const char* name) {
  7838. AtCommandInfo* info = (AtCommandInfo*)strdb_get(atcommand_db, name);
  7839. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7840. }
  7841. /// Executes an at-command.
  7842. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7843. {
  7844. char charname[NAME_LENGTH], params[100];
  7845. char charname2[NAME_LENGTH], params2[100];
  7846. char command[100];
  7847. char output[CHAT_SIZE_MAX];
  7848. int x, y, z;
  7849. int lv = 0;
  7850. //Reconstructed message
  7851. char atcmd_msg[CHAT_SIZE_MAX];
  7852. TBL_PC * ssd = NULL; //sd for target
  7853. AtCommandInfo * info;
  7854. nullpo_retr(false, sd);
  7855. //Shouldn't happen
  7856. if( !message || !*message )
  7857. return false;
  7858. //Block NOCHAT but do not display it as a normal message
  7859. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7860. return true;
  7861. // skip 10/11-langtype's codepage indicator, if detected
  7862. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7863. message += 3;
  7864. //Should display as a normal message
  7865. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7866. return false;
  7867. // type value 0 = server invoked: bypass restrictions
  7868. // 1 = player invoked
  7869. if( type )
  7870. {
  7871. //Commands are disabled on maps flagged as 'nocommand'
  7872. if( map[sd->bl.m].nocommand && pc_isGM(sd) < map[sd->bl.m].nocommand )
  7873. {
  7874. clif_displaymessage(fd, msg_txt(143));
  7875. return false;
  7876. }
  7877. //Displays as a normal message for Non-GMs
  7878. if( battle_config.atc_gmonly != 0 && pc_isGM(sd) == 0 )
  7879. return false;
  7880. }
  7881. while (*message == charcommand_symbol)
  7882. {
  7883. //Checks to see if #command has a name or a name + parameters.
  7884. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7885. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7886. //z always has the value of the scan that was successful
  7887. z = ( x > 1 ) ? x : y;
  7888. if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) ) {
  7889. if( pc_isGM(sd) ) {
  7890. sprintf(output, "%s failed. Player not found.", command);
  7891. clif_displaymessage(fd, output);
  7892. } else {
  7893. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7894. clif_displaymessage(fd, output);
  7895. }
  7896. return true;
  7897. }
  7898. //#command + name means the sufficient target was used and anything else after
  7899. //can be looked at by the actual command function since most scan to see if the
  7900. //right parameters are used.
  7901. if ( x > 2 ) {
  7902. sprintf(atcmd_msg, "%s %s", command, params);
  7903. break;
  7904. }
  7905. else if ( y > 2 ) {
  7906. sprintf(atcmd_msg, "%s %s", command, params2);
  7907. break;
  7908. }
  7909. //Regardless of what style the #command is used, if it's correct, it will always have
  7910. //this value if there is no parameter. Send it as just the #command
  7911. else if ( z == 2 ) {
  7912. sprintf(atcmd_msg, "%s", command);
  7913. break;
  7914. }
  7915. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7916. clif_displaymessage(fd, output);
  7917. return true;
  7918. }
  7919. if (*message == atcommand_symbol) {
  7920. //atcmd_msg is constructed above differently for charcommands
  7921. //it's copied from message if not a charcommand so it can
  7922. //pass through the rest of the code compatible with both symbols
  7923. sprintf(atcmd_msg, "%s", message);
  7924. }
  7925. //Clearing these to be used once more.
  7926. memset(command, '\0', sizeof(command));
  7927. memset(params, '\0', sizeof(params));
  7928. //check to see if any params exist within this command
  7929. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7930. params[0] = '\0';
  7931. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7932. if( (info = (AtCommandInfo*)strdb_get(atcommand_db, command+1)) == NULL || info->func == NULL || ( type && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2)) ) )
  7933. {
  7934. if( pc_isGM(sd) ) {
  7935. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7936. clif_displaymessage(fd, output);
  7937. return true;
  7938. } else
  7939. return false;
  7940. }
  7941. //Log atcommands
  7942. if( *atcmd_msg == atcommand_symbol )
  7943. log_atcommand(sd, info->level, atcmd_msg);
  7944. //Log Charcommands
  7945. else if( *atcmd_msg == charcommand_symbol && ssd != NULL )
  7946. log_atcommand(sd, info->level2, message);
  7947. //Attempt to use the command
  7948. if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
  7949. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  7950. {
  7951. sprintf(output,msg_txt(154), command); // %s failed.
  7952. clif_displaymessage(fd, output);
  7953. }
  7954. if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
  7955. return true;
  7956. }
  7957. /**
  7958. * Splits and parses command aliases field
  7959. * Note: I'm not good (at all) with string manipulation, if you think you can improve, please do. I beg you.
  7960. **/
  7961. void atcommand_parse_aliases(char aliases[1024],AtCommandInfo* base) {
  7962. char *str[99], *p;
  7963. int i, max = 0;
  7964. p = aliases;
  7965. while( ISSPACE(*p) )//trim
  7966. ++p;
  7967. //I assume nobody is getting over 98 alises in the same command lol
  7968. for( i = 0; i < 99; i++ ) {
  7969. str[i] = p;
  7970. p = strchr(p,',');
  7971. if( p == NULL ) {
  7972. max = i+1;
  7973. break;// comma not found
  7974. }
  7975. *p = '\0';
  7976. ++p;
  7977. }
  7978. if( !str[0] )//no aliases at all
  7979. return;
  7980. for(i = 0; i < max;i++) {
  7981. AtCommandInfo* atcommand = NULL;
  7982. normalize_name(str[i]," ");//trim over
  7983. if( (atcommand = strdb_get(atcommand_db, str[i])) ) {
  7984. atcommand->level = base->level;
  7985. atcommand->level2 = base->level2;
  7986. continue;
  7987. }
  7988. CREATE(atcommand, AtCommandInfo, 1);
  7989. safestrncpy(atcommand->command,str[i],sizeof(atcommand->command));
  7990. atcommand->level = base->level;
  7991. atcommand->level2 = base->level2;
  7992. atcommand->func = base->func;
  7993. strdb_put(atcommand_db, atcommand->command, atcommand);
  7994. }
  7995. return;
  7996. }
  7997. /*==========================================
  7998. *
  7999. *------------------------------------------*/
  8000. int atcommand_config_read(const char* cfgName)
  8001. {
  8002. char line[1024], w1[1024], w2[1024], w3[1024], w4[1024];
  8003. AtCommandInfo* p;
  8004. FILE* fp;
  8005. int i;
  8006. if( (fp = fopen(cfgName, "r")) == NULL ) {
  8007. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  8008. return 1;
  8009. }
  8010. while( fgets(line, sizeof(line), fp) ) {
  8011. if( line[0] == '/' && line[1] == '/' )
  8012. continue;
  8013. if( ( i = sscanf(line,"%1023[^:]:%1023[^,],%1023[^[][%1023[^]]",w1,w2,w3,w4) ) >= 3 ) {
  8014. if( ( p = (AtCommandInfo*)strdb_get(atcommand_db, w1) ) != NULL ) {
  8015. p->level = atoi(w2);//update @level
  8016. p->level2 = atoi(w3);//update #level
  8017. /**
  8018. * Parse the alises
  8019. **/
  8020. if( i == 4 )
  8021. atcommand_parse_aliases(w4,p);
  8022. continue;//we're done move on
  8023. }
  8024. } else if( strcmpi(w1, "import") != 0 && strcmpi(w1, "command_symbol") != 0 && strcmpi(w1, "char_symbol") != 0 ) {
  8025. if( i > 1 )
  8026. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  8027. continue;
  8028. }
  8029. normalize_name(w2," ");//trim
  8030. if( strcmpi(w1, "import") == 0 )
  8031. atcommand_config_read(w2);
  8032. else if( strcmpi(w1, "command_symbol") == 0 &&
  8033. w2[0] > 31 && // control characters
  8034. w2[0] != '/' && // symbol of standard ragnarok GM commands
  8035. w2[0] != '%' && // symbol of party chat speaking
  8036. w2[0] != '$' && // symbol of guild chat speaking
  8037. w2[0] != '#' ) // remote symbol
  8038. atcommand_symbol = w2[0];
  8039. else if( strcmpi(w1, "char_symbol") == 0 &&
  8040. w2[0] > 31 &&
  8041. w2[0] != '/' &&
  8042. w2[0] != '%' &&
  8043. w2[0] != '$' &&
  8044. w2[0] != '@' )
  8045. charcommand_symbol = w2[0];
  8046. }
  8047. fclose(fp);
  8048. return 0;
  8049. }
  8050. static int atcommand_db_free(DBKey key,void *data,va_list va) {
  8051. aFree((AtCommandInfo*)data);
  8052. return 1;
  8053. }
  8054. void atcommand_db_clear() {
  8055. atcommand_db->foreach(atcommand_db,atcommand_db_free);
  8056. db_destroy(atcommand_db);
  8057. return;
  8058. }
  8059. void atcommand_doload() {
  8060. if( atcommand_db != NULL )
  8061. atcommand_db_clear();
  8062. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY, 0);
  8063. atcommand_basecommands();//fills initial atcommand_db with known commands
  8064. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8065. return;
  8066. }
  8067. void do_init_atcommand() {
  8068. atcommand_doload();
  8069. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  8070. return;
  8071. }
  8072. void do_final_atcommand() {
  8073. atcommand_db_clear();
  8074. return;
  8075. }
  8076. // commands that need to go _after_ the commands table
  8077. /*==========================================
  8078. * @commands Lists available @ commands to you
  8079. *------------------------------------------*/
  8080. ACMD_FUNC(commands)
  8081. {
  8082. char line_buff[CHATBOX_SIZE];
  8083. int gm_lvl = pc_isGM(sd), count = 0;
  8084. char* cur = line_buff;
  8085. AtCommandInfo* cmd;
  8086. DBIterator* iter = atcommand_db->iterator(atcommand_db);
  8087. memset(line_buff,' ',CHATBOX_SIZE);
  8088. line_buff[CHATBOX_SIZE-1] = 0;
  8089. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  8090. for( cmd = (AtCommandInfo*)iter->first(iter,NULL); iter->exists(iter); cmd = (AtCommandInfo*)iter->next(iter,NULL) ) {
  8091. unsigned int slen;
  8092. if( gm_lvl < cmd->level && stristr(command,"commands") )
  8093. continue;
  8094. if( gm_lvl < cmd->level2 && stristr(command,"charcommands") )
  8095. continue;
  8096. slen = strlen(cmd->command);
  8097. // flush the text buffer if this command won't fit into it
  8098. if( slen + cur - line_buff >= CHATBOX_SIZE )
  8099. {
  8100. clif_displaymessage(fd,line_buff);
  8101. cur = line_buff;
  8102. memset(line_buff,' ',CHATBOX_SIZE);
  8103. line_buff[CHATBOX_SIZE-1] = 0;
  8104. }
  8105. memcpy(cur,cmd->command,slen);
  8106. cur += slen+(10-slen%10);
  8107. count++;
  8108. }
  8109. iter->destroy(iter);
  8110. clif_displaymessage(fd,line_buff);
  8111. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  8112. clif_displaymessage(fd, atcmd_output);
  8113. return 0;
  8114. }