atcommand.c 286 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220
  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 "intif.h"
  19. #include "itemdb.h"
  20. #include "log.h"
  21. #include "map.h"
  22. #include "pc.h"
  23. #include "status.h"
  24. #include "skill.h"
  25. #include "mob.h"
  26. #include "npc.h"
  27. #include "pet.h"
  28. #include "homunculus.h"
  29. #include "mercenary.h"
  30. #include "party.h"
  31. #include "guild.h"
  32. #include "script.h"
  33. #include "trade.h"
  34. #include "unit.h"
  35. #ifndef TXT_ONLY
  36. #include "mail.h"
  37. #endif
  38. #include <stdio.h>
  39. #include <stdlib.h>
  40. #include <string.h>
  41. #include <math.h>
  42. // extern variables
  43. char atcommand_symbol = '@'; // first char of the commands
  44. char charcommand_symbol = '#';
  45. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  46. // local declarations
  47. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  48. typedef struct AtCommandInfo
  49. {
  50. const char* command;
  51. int level;
  52. int level2;
  53. AtCommandFunc func;
  54. } AtCommandInfo;
  55. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  56. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  57. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message);
  58. /*=========================================
  59. * Generic variables
  60. *-----------------------------------------*/
  61. char atcmd_output[200];
  62. char atcmd_player_name[NAME_LENGTH];
  63. char atcmd_temp[100];
  64. // compare function for sorting high to lowest
  65. int hightolow_compare (const void * a, const void * b)
  66. {
  67. return ( *(int*)b - *(int*)a );
  68. }
  69. // compare function for sorting lowest to highest
  70. int lowtohigh_compare (const void * a, const void * b)
  71. {
  72. return ( *(int*)a - *(int*)b );
  73. }
  74. //-----------------------------------------------------------
  75. // Return the message string of the specified number by [Yor]
  76. //-----------------------------------------------------------
  77. char* msg_txt(int msg_number)
  78. {
  79. if (msg_number >= 0 && msg_number < MAX_MSG &&
  80. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  81. return msg_table[msg_number];
  82. return "??";
  83. }
  84. //-----------------------------------------------------------
  85. // Returns Players title (from msg_athena.conf) [Lupus]
  86. //-----------------------------------------------------------
  87. static char* player_title_txt(int level)
  88. {
  89. const char* format;
  90. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  91. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  92. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  93. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  94. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  95. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  96. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  97. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  98. : "";
  99. sprintf(atcmd_temp, format, level);
  100. return atcmd_temp;
  101. }
  102. /*==========================================
  103. * Read Message Data
  104. *------------------------------------------*/
  105. int msg_config_read(const char* cfgName)
  106. {
  107. int msg_number;
  108. char line[1024], w1[1024], w2[1024];
  109. FILE *fp;
  110. static int called = 1;
  111. if ((fp = fopen(cfgName, "r")) == NULL) {
  112. ShowError("Messages file not found: %s\n", cfgName);
  113. return 1;
  114. }
  115. if ((--called) == 0)
  116. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  117. while(fgets(line, sizeof(line), fp))
  118. {
  119. if (line[0] == '/' && line[1] == '/')
  120. continue;
  121. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  122. continue;
  123. if (strcmpi(w1, "import") == 0)
  124. msg_config_read(w2);
  125. else
  126. {
  127. msg_number = atoi(w1);
  128. if (msg_number >= 0 && msg_number < MAX_MSG)
  129. {
  130. if (msg_table[msg_number] != NULL)
  131. aFree(msg_table[msg_number]);
  132. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  133. strcpy(msg_table[msg_number],w2);
  134. }
  135. }
  136. }
  137. fclose(fp);
  138. return 0;
  139. }
  140. /*==========================================
  141. * Cleanup Message Data
  142. *------------------------------------------*/
  143. void do_final_msg(void)
  144. {
  145. int i;
  146. for (i = 0; i < MAX_MSG; i++)
  147. aFree(msg_table[i]);
  148. }
  149. /*==========================================
  150. * @send (used for testing packet sends from the client)
  151. *------------------------------------------*/
  152. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  153. {
  154. int len=0,off,end,type;
  155. long num;
  156. (void)command; // not used
  157. // read message type as hex number (without the 0x)
  158. if(!message || !*message ||
  159. !((sscanf(message, "len %x", &type)==1 && (len=1))
  160. || sscanf(message, "%x", &type)==1) )
  161. {
  162. clif_displaymessage(fd, "Usage:");
  163. clif_displaymessage(fd, " @send len <packet hex number>");
  164. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  165. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  166. return -1;
  167. }
  168. #define PARSE_ERROR(error,p) \
  169. {\
  170. clif_displaymessage(fd, (error));\
  171. sprintf(atcmd_output, ">%s", (p));\
  172. clif_displaymessage(fd, atcmd_output);\
  173. }
  174. //define PARSE_ERROR
  175. #define CHECK_EOS(p) \
  176. if(*(p) == 0){\
  177. clif_displaymessage(fd, "Unexpected end of string");\
  178. return -1;\
  179. }
  180. //define CHECK_EOS
  181. #define SKIP_VALUE(p) \
  182. {\
  183. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  184. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  185. }
  186. //define SKIP_VALUE
  187. #define GET_VALUE(p,num) \
  188. {\
  189. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  190. PARSE_ERROR("Invalid number in:",(p));\
  191. return -1;\
  192. }\
  193. }
  194. //define GET_VALUE
  195. if (type > 0 && type < MAX_PACKET_DB) {
  196. if(len)
  197. {// show packet length
  198. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  199. clif_displaymessage(fd, atcmd_output);
  200. return 0;
  201. }
  202. len=packet_db[sd->packet_ver][type].len;
  203. off=2;
  204. if(len == 0)
  205. {// unknown packet - ERROR
  206. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  207. clif_displaymessage(fd, atcmd_output);
  208. return -1;
  209. } else if(len == -1)
  210. {// dynamic packet
  211. len=SHRT_MAX-4; // maximum length
  212. off=4;
  213. }
  214. WFIFOHEAD(fd, len);
  215. WFIFOW(fd,0)=TOW(type);
  216. // parse packet contents
  217. SKIP_VALUE(message);
  218. while(*message != 0 && off < len){
  219. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  220. {// default (byte)
  221. GET_VALUE(message,num);
  222. WFIFOB(fd,off)=TOB(num);
  223. ++off;
  224. } else if(TOUPPER(*message) == 'B')
  225. {// byte
  226. ++message;
  227. GET_VALUE(message,num);
  228. WFIFOB(fd,off)=TOB(num);
  229. ++off;
  230. } else if(TOUPPER(*message) == 'W')
  231. {// word (2 bytes)
  232. ++message;
  233. GET_VALUE(message,num);
  234. WFIFOW(fd,off)=TOW(num);
  235. off+=2;
  236. } else if(TOUPPER(*message) == 'L')
  237. {// long word (4 bytes)
  238. ++message;
  239. GET_VALUE(message,num);
  240. WFIFOL(fd,off)=TOL(num);
  241. off+=4;
  242. } else if(TOUPPER(*message) == 'S')
  243. {// string - escapes are valid
  244. // get string length - num <= 0 means not fixed length (default)
  245. ++message;
  246. if(*message == '"'){
  247. num=0;
  248. } else {
  249. GET_VALUE(message,num);
  250. while(*message != '"')
  251. {// find start of string
  252. if(*message == 0 || ISSPACE(*message)){
  253. PARSE_ERROR("Not a string:",message);
  254. return -1;
  255. }
  256. ++message;
  257. }
  258. }
  259. // parse string
  260. ++message;
  261. CHECK_EOS(message);
  262. end=(num<=0? 0: min(off+((int)num),len));
  263. for(; *message != '"' && (off < end || end == 0); ++off){
  264. if(*message == '\\'){
  265. ++message;
  266. CHECK_EOS(message);
  267. switch(*message){
  268. case 'a': num=0x07; break; // Bell
  269. case 'b': num=0x08; break; // Backspace
  270. case 't': num=0x09; break; // Horizontal tab
  271. case 'n': num=0x0A; break; // Line feed
  272. case 'v': num=0x0B; break; // Vertical tab
  273. case 'f': num=0x0C; break; // Form feed
  274. case 'r': num=0x0D; break; // Carriage return
  275. case 'e': num=0x1B; break; // Escape
  276. default: num=*message; break;
  277. case 'x': // Hexadecimal
  278. {
  279. ++message;
  280. CHECK_EOS(message);
  281. if(!ISXDIGIT(*message)){
  282. PARSE_ERROR("Not a hexadecimal digit:",message);
  283. return -1;
  284. }
  285. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  286. if(ISXDIGIT(*message)){
  287. ++message;
  288. CHECK_EOS(message);
  289. num<<=8;
  290. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  291. }
  292. WFIFOB(fd,off)=TOB(num);
  293. ++message;
  294. CHECK_EOS(message);
  295. continue;
  296. }
  297. case '0':
  298. case '1':
  299. case '2':
  300. case '3':
  301. case '4':
  302. case '5':
  303. case '6':
  304. case '7': // Octal
  305. {
  306. num=*message-'0'; // 1st octal digit
  307. ++message;
  308. CHECK_EOS(message);
  309. if(ISDIGIT(*message) && *message < '8'){
  310. num<<=3;
  311. num+=*message-'0'; // 2nd octal digit
  312. ++message;
  313. CHECK_EOS(message);
  314. if(ISDIGIT(*message) && *message < '8'){
  315. num<<=3;
  316. num+=*message-'0'; // 3rd octal digit
  317. ++message;
  318. CHECK_EOS(message);
  319. }
  320. }
  321. WFIFOB(fd,off)=TOB(num);
  322. continue;
  323. }
  324. }
  325. } else
  326. num=*message;
  327. WFIFOB(fd,off)=TOB(num);
  328. ++message;
  329. CHECK_EOS(message);
  330. }//for
  331. while(*message != '"')
  332. {// ignore extra characters
  333. ++message;
  334. CHECK_EOS(message);
  335. }
  336. // terminate the string
  337. if(off < end)
  338. {// fill the rest with 0's
  339. memset(WFIFOP(fd,off),0,end-off);
  340. off=end;
  341. }
  342. } else
  343. {// unknown
  344. PARSE_ERROR("Unknown type of value in:",message);
  345. return -1;
  346. }
  347. SKIP_VALUE(message);
  348. }
  349. if(packet_db[sd->packet_ver][type].len == -1)
  350. {// send dynamic packet
  351. WFIFOW(fd,2)=TOW(off);
  352. WFIFOSET(fd,off);
  353. } else
  354. {// send static packet
  355. if(off < len)
  356. memset(WFIFOP(fd,off),0,len-off);
  357. WFIFOSET(fd,len);
  358. }
  359. } else {
  360. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  361. return -1;
  362. }
  363. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  364. clif_displaymessage(fd, atcmd_output);
  365. return 0;
  366. #undef PARSE_ERROR
  367. #undef CHECK_EOS
  368. #undef SKIP_VALUE
  369. #undef GET_VALUE
  370. }
  371. /*==========================================
  372. * @rura, @warp, @mapmove
  373. *------------------------------------------*/
  374. int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  375. {
  376. char map_name[MAP_NAME_LENGTH_EXT];
  377. unsigned short mapindex;
  378. int x = 0, y = 0;
  379. int m = -1;
  380. nullpo_retr(-1, sd);
  381. memset(map_name, '\0', sizeof(map_name));
  382. if (!message || !*message ||
  383. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  384. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  385. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  386. return -1;
  387. }
  388. mapindex = mapindex_name2id(map_name);
  389. if (mapindex)
  390. m = map_mapindex2mapid(mapindex);
  391. if (!mapindex) { // m < 0 means on different server! [Kevin]
  392. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  393. return -1;
  394. }
  395. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  396. { //This is to prevent the pc_setpos call from printing an error.
  397. clif_displaymessage(fd, msg_txt(2));
  398. x = y = 0; //Invalid cell, use random spot.
  399. }
  400. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  401. clif_displaymessage(fd, msg_txt(247));
  402. return -1;
  403. }
  404. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  405. clif_displaymessage(fd, msg_txt(248));
  406. return -1;
  407. }
  408. if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
  409. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  410. return -1;
  411. }
  412. clif_displaymessage(fd, msg_txt(0)); // Warped.
  413. return 0;
  414. }
  415. /*==========================================
  416. * Displays where a character is. Corrected version by Silent. [Skotlex]
  417. *------------------------------------------*/
  418. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  419. {
  420. struct map_session_data* pl_sd;
  421. nullpo_retr(-1, sd);
  422. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  423. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  424. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  425. return -1;
  426. }
  427. pl_sd = map_nick2sd(atcmd_player_name);
  428. if( pl_sd == NULL
  429. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  430. || (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))
  431. ) {
  432. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  433. return -1;
  434. }
  435. 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);
  436. clif_displaymessage(fd, atcmd_output);
  437. return 0;
  438. }
  439. /*==========================================
  440. *
  441. *------------------------------------------*/
  442. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  443. {
  444. struct map_session_data *pl_sd = NULL;
  445. nullpo_retr(-1, sd);
  446. if (!message || !*message) {
  447. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  448. return -1;
  449. }
  450. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  451. {
  452. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  453. return -1;
  454. }
  455. if (pl_sd == sd)
  456. {
  457. clif_displaymessage(fd, "But you are already where you are...");
  458. return -1;
  459. }
  460. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  461. {
  462. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  463. return -1;
  464. }
  465. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  466. {
  467. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  468. return -1;
  469. }
  470. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  471. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  472. clif_displaymessage(fd, atcmd_output);
  473. return 0;
  474. }
  475. /*==========================================
  476. *
  477. *------------------------------------------*/
  478. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  479. {
  480. int x = 0, y = 0;
  481. nullpo_retr(-1, sd);
  482. memset(atcmd_output, '\0', sizeof(atcmd_output));
  483. sscanf(message, "%d %d", &x, &y);
  484. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  485. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  486. return -1;
  487. }
  488. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  489. { //This is to prevent the pc_setpos call from printing an error.
  490. clif_displaymessage(fd, msg_txt(2));
  491. x = y = 0; //Invalid cell, use random spot.
  492. }
  493. pc_setpos(sd, sd->mapindex, x, y, 3);
  494. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  495. clif_displaymessage(fd, atcmd_output);
  496. return 0;
  497. }
  498. /*==========================================
  499. * @who3 = Player name, his location
  500. *------------------------------------------*/
  501. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  502. {
  503. char temp0[100];
  504. struct map_session_data *pl_sd;
  505. struct s_mapiterator* iter;
  506. int j, count;
  507. int pl_GM_level, GM_level;
  508. char match_text[100];
  509. char player_name[NAME_LENGTH];
  510. nullpo_retr(-1, sd);
  511. memset(atcmd_output, '\0', sizeof(atcmd_output));
  512. memset(match_text, '\0', sizeof(match_text));
  513. memset(player_name, '\0', sizeof(player_name));
  514. if (sscanf(message, "%99[^\n]", match_text) < 1)
  515. strcpy(match_text, "");
  516. for (j = 0; match_text[j]; j++)
  517. match_text[j] = TOLOWER(match_text[j]);
  518. count = 0;
  519. GM_level = pc_isGM(sd);
  520. iter = mapit_getallusers();
  521. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  522. {
  523. pl_GM_level = pc_isGM(pl_sd);
  524. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  525. {// you can look only lower or same level
  526. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  527. for (j = 0; player_name[j]; j++)
  528. player_name[j] = TOLOWER(player_name[j]);
  529. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  530. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  531. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  532. } else {
  533. atcmd_output[0]=0;
  534. }
  535. //Player name
  536. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  537. strcat(atcmd_output,temp0);
  538. //Player title, if exists
  539. if (pl_GM_level > 0) {
  540. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  541. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  542. strcat(atcmd_output,temp0);
  543. }
  544. //Players Location: map x y
  545. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  546. strcat(atcmd_output,temp0);
  547. clif_displaymessage(fd, atcmd_output);
  548. count++;
  549. }
  550. }
  551. }
  552. mapit_free(iter);
  553. if (count == 0)
  554. clif_displaymessage(fd, msg_txt(28)); // No player found.
  555. else if (count == 1)
  556. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  557. else {
  558. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  559. clif_displaymessage(fd, atcmd_output);
  560. }
  561. return 0;
  562. }
  563. /*==========================================
  564. * Player name, BLevel, Job,
  565. *------------------------------------------*/
  566. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  567. {
  568. char temp0[100];
  569. struct map_session_data *pl_sd;
  570. struct s_mapiterator* iter;
  571. int j, count;
  572. int pl_GM_level, GM_level;
  573. char match_text[100];
  574. char player_name[NAME_LENGTH];
  575. nullpo_retr(-1, sd);
  576. memset(atcmd_output, '\0', sizeof(atcmd_output));
  577. memset(match_text, '\0', sizeof(match_text));
  578. memset(player_name, '\0', sizeof(player_name));
  579. if (sscanf(message, "%99[^\n]", match_text) < 1)
  580. strcpy(match_text, "");
  581. for (j = 0; match_text[j]; j++)
  582. match_text[j] = TOLOWER(match_text[j]);
  583. count = 0;
  584. GM_level = pc_isGM(sd);
  585. iter = mapit_getallusers();
  586. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  587. {
  588. pl_GM_level = pc_isGM(pl_sd);
  589. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  590. {// you can look only lower or same level
  591. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  592. for (j = 0; player_name[j]; j++)
  593. player_name[j] = TOLOWER(player_name[j]);
  594. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  595. //Players Name
  596. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  597. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  598. //Player title, if exists
  599. if (pl_GM_level > 0) {
  600. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  601. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  602. strcat(atcmd_output,temp0);
  603. }
  604. //Players Base Level / Job name
  605. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  606. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  607. strcat(atcmd_output,temp0);
  608. clif_displaymessage(fd, atcmd_output);
  609. count++;
  610. }
  611. }
  612. }
  613. mapit_free(iter);
  614. if (count == 0)
  615. clif_displaymessage(fd, msg_txt(28)); // No player found.
  616. else if (count == 1)
  617. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  618. else {
  619. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  620. clif_displaymessage(fd, atcmd_output);
  621. }
  622. return 0;
  623. }
  624. /*==========================================
  625. * Player name, Playrs Party / Guild name
  626. *------------------------------------------*/
  627. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  628. {
  629. char temp0[100];
  630. struct map_session_data *pl_sd;
  631. struct s_mapiterator* iter;
  632. int j, count;
  633. int pl_GM_level, GM_level;
  634. char match_text[100];
  635. char player_name[NAME_LENGTH];
  636. struct guild *g;
  637. struct party_data *p;
  638. nullpo_retr(-1, sd);
  639. memset(temp0, '\0', sizeof(temp0));
  640. memset(atcmd_output, '\0', sizeof(atcmd_output));
  641. memset(match_text, '\0', sizeof(match_text));
  642. memset(player_name, '\0', sizeof(player_name));
  643. if (sscanf(message, "%99[^\n]", match_text) < 1)
  644. strcpy(match_text, "");
  645. for (j = 0; match_text[j]; j++)
  646. match_text[j] = TOLOWER(match_text[j]);
  647. count = 0;
  648. GM_level = pc_isGM(sd);
  649. iter = mapit_getallusers();
  650. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  651. {
  652. pl_GM_level = pc_isGM(pl_sd);
  653. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  654. {// you can look only lower or same level
  655. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  656. for (j = 0; player_name[j]; j++)
  657. player_name[j] = TOLOWER(player_name[j]);
  658. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  659. g = guild_search(pl_sd->status.guild_id);
  660. p = party_search(pl_sd->status.party_id);
  661. //Players Name
  662. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  663. //Player title, if exists
  664. if (pl_GM_level > 0) {
  665. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  666. strcat(atcmd_output,temp0);
  667. }
  668. //Players Party if exists
  669. if (p != NULL) {
  670. //sprintf(temp0," | Party: '%s'", p->name);
  671. sprintf(temp0, msg_txt(335), p->party.name);
  672. strcat(atcmd_output,temp0);
  673. }
  674. //Players Guild if exists
  675. if (g != NULL) {
  676. //sprintf(temp0," | Guild: '%s'", g->name);
  677. sprintf(temp0, msg_txt(336), g->name);
  678. strcat(atcmd_output,temp0);
  679. }
  680. clif_displaymessage(fd, atcmd_output);
  681. count++;
  682. }
  683. }
  684. }
  685. mapit_free(iter);
  686. if (count == 0)
  687. clif_displaymessage(fd, msg_txt(28)); // No player found.
  688. else if (count == 1)
  689. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  690. else {
  691. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  692. clif_displaymessage(fd, atcmd_output);
  693. }
  694. return 0;
  695. }
  696. /*==========================================
  697. *
  698. *------------------------------------------*/
  699. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  700. {
  701. struct map_session_data *pl_sd;
  702. struct s_mapiterator* iter;
  703. int count;
  704. int pl_GM_level, GM_level;
  705. int map_id;
  706. char map_name[MAP_NAME_LENGTH_EXT];
  707. memset(atcmd_output, '\0', sizeof(atcmd_output));
  708. memset(map_name, '\0', sizeof(map_name));
  709. if (!message || !*message)
  710. map_id = sd->bl.m;
  711. else {
  712. sscanf(message, "%15s", map_name);
  713. if ((map_id = map_mapname2mapid(map_name)) < 0)
  714. map_id = sd->bl.m;
  715. }
  716. count = 0;
  717. GM_level = pc_isGM(sd);
  718. iter = mapit_getallusers();
  719. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  720. {
  721. pl_GM_level = pc_isGM(pl_sd);
  722. if( pl_sd->bl.m != map_id )
  723. continue;
  724. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  725. continue;
  726. if (pl_GM_level > 0)
  727. 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);
  728. else
  729. 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);
  730. clif_displaymessage(fd, atcmd_output);
  731. count++;
  732. }
  733. mapit_free(iter);
  734. if (count == 0)
  735. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  736. else if (count == 1)
  737. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  738. else {
  739. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  740. }
  741. clif_displaymessage(fd, atcmd_output);
  742. return 0;
  743. }
  744. /*==========================================
  745. *
  746. *------------------------------------------*/
  747. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  748. {
  749. struct map_session_data *pl_sd;
  750. struct s_mapiterator* iter;
  751. int count;
  752. int pl_GM_level, GM_level;
  753. int map_id = 0;
  754. char map_name[MAP_NAME_LENGTH_EXT];
  755. nullpo_retr(-1, sd);
  756. memset(atcmd_output, '\0', sizeof(atcmd_output));
  757. memset(map_name, '\0', sizeof(map_name));
  758. if (!message || !*message)
  759. map_id = sd->bl.m;
  760. else {
  761. sscanf(message, "%15s", map_name);
  762. if ((map_id = map_mapname2mapid(map_name)) < 0)
  763. map_id = sd->bl.m;
  764. }
  765. count = 0;
  766. GM_level = pc_isGM(sd);
  767. iter = mapit_getallusers();
  768. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  769. {
  770. pl_GM_level = pc_isGM(pl_sd);
  771. if( pl_sd->bl.m != map_id )
  772. continue;
  773. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  774. continue;
  775. if (pl_GM_level > 0)
  776. 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);
  777. else
  778. 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);
  779. clif_displaymessage(fd, atcmd_output);
  780. count++;
  781. }
  782. mapit_free(iter);
  783. if (count == 0)
  784. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  785. else if (count == 1)
  786. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  787. else {
  788. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  789. }
  790. clif_displaymessage(fd, atcmd_output);
  791. return 0;
  792. }
  793. /*==========================================
  794. *
  795. *------------------------------------------*/
  796. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  797. {
  798. char temp0[100];
  799. char temp1[100];
  800. struct map_session_data *pl_sd;
  801. struct s_mapiterator* iter;
  802. int count;
  803. int pl_GM_level, GM_level;
  804. int map_id = 0;
  805. char map_name[MAP_NAME_LENGTH_EXT];
  806. struct guild *g;
  807. struct party_data *p;
  808. nullpo_retr(-1, sd);
  809. memset(temp0, '\0', sizeof(temp0));
  810. memset(temp1, '\0', sizeof(temp1));
  811. memset(atcmd_output, '\0', sizeof(atcmd_output));
  812. memset(map_name, '\0', sizeof(map_name));
  813. if (!message || !*message)
  814. map_id = sd->bl.m;
  815. else {
  816. sscanf(message, "%15s", map_name);
  817. if ((map_id = map_mapname2mapid(map_name)) < 0)
  818. map_id = sd->bl.m;
  819. }
  820. count = 0;
  821. GM_level = pc_isGM(sd);
  822. iter = mapit_getallusers();
  823. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  824. {
  825. pl_GM_level = pc_isGM(pl_sd);
  826. if( pl_sd->bl.m != map_id )
  827. continue;
  828. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  829. continue;
  830. g = guild_search(pl_sd->status.guild_id);
  831. if (g == NULL)
  832. sprintf(temp1, "None");
  833. else
  834. sprintf(temp1, "%s", g->name);
  835. p = party_search(pl_sd->status.party_id);
  836. if (p == NULL)
  837. sprintf(temp0, "None");
  838. else
  839. sprintf(temp0, "%s", p->party.name);
  840. if (pl_GM_level > 0)
  841. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  842. else
  843. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  844. clif_displaymessage(fd, atcmd_output);
  845. count++;
  846. }
  847. mapit_free(iter);
  848. if (count == 0)
  849. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  850. else if (count == 1)
  851. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  852. else {
  853. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  854. }
  855. clif_displaymessage(fd, atcmd_output);
  856. return 0;
  857. }
  858. /*==========================================
  859. *
  860. *------------------------------------------*/
  861. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  862. {
  863. struct map_session_data* pl_sd;
  864. struct s_mapiterator* iter;
  865. int j, count;
  866. int pl_GM_level, GM_level;
  867. char match_text[200];
  868. char player_name[NAME_LENGTH];
  869. struct guild *g;
  870. struct party_data *p;
  871. nullpo_retr(-1, sd);
  872. memset(atcmd_output, '\0', sizeof(atcmd_output));
  873. memset(match_text, '\0', sizeof(match_text));
  874. memset(player_name, '\0', sizeof(player_name));
  875. if (sscanf(message, "%199[^\n]", match_text) < 1)
  876. strcpy(match_text, "");
  877. for (j = 0; match_text[j]; j++)
  878. match_text[j] = TOLOWER(match_text[j]);
  879. count = 0;
  880. GM_level = pc_isGM(sd);
  881. iter = mapit_getallusers();
  882. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  883. {
  884. pl_GM_level = pc_isGM(pl_sd);
  885. if (!pl_GM_level)
  886. continue;
  887. if (match_text[0])
  888. {
  889. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  890. for (j = 0; player_name[j]; j++)
  891. player_name[j] = TOLOWER(player_name[j]);
  892. // search with no case sensitive
  893. if (strstr(player_name, match_text) == NULL)
  894. continue;
  895. }
  896. if (pl_GM_level > GM_level) {
  897. if (pl_sd->sc.option & OPTION_INVISIBLE)
  898. continue;
  899. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  900. clif_displaymessage(fd, atcmd_output);
  901. count++;
  902. continue;
  903. }
  904. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  905. pl_sd->status.name, pl_GM_level,
  906. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  907. clif_displaymessage(fd, atcmd_output);
  908. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  909. pl_sd->status.base_level,
  910. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  911. clif_displaymessage(fd, atcmd_output);
  912. p = party_search(pl_sd->status.party_id);
  913. g = guild_search(pl_sd->status.guild_id);
  914. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  915. p?p->party.name:"None", g?g->name:"None");
  916. clif_displaymessage(fd, atcmd_output);
  917. count++;
  918. }
  919. mapit_free(iter);
  920. if (count == 0)
  921. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  922. else if (count == 1)
  923. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  924. else {
  925. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  926. clif_displaymessage(fd, atcmd_output);
  927. }
  928. return 0;
  929. }
  930. /*==========================================
  931. *
  932. *------------------------------------------*/
  933. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  934. {
  935. nullpo_retr(-1, sd);
  936. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  937. if (sd->status.pet_id > 0 && sd->pd)
  938. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  939. chrif_save(sd,0);
  940. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  941. return 0;
  942. }
  943. /*==========================================
  944. *
  945. *------------------------------------------*/
  946. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  947. {
  948. int m;
  949. nullpo_retr(-1, sd);
  950. m = map_mapindex2mapid(sd->status.save_point.map);
  951. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  952. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  953. return -1;
  954. }
  955. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  956. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  957. return -1;
  958. }
  959. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  960. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  961. return 0;
  962. }
  963. /*==========================================
  964. *
  965. *------------------------------------------*/
  966. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  967. {
  968. int speed;
  969. nullpo_retr(-1, sd);
  970. memset(atcmd_output, '\0', sizeof(atcmd_output));
  971. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  972. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  973. clif_displaymessage(fd, atcmd_output);
  974. return -1;
  975. }
  976. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  977. status_calc_bl(&sd->bl, SCB_SPEED);
  978. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  979. return 0;
  980. }
  981. /*==========================================
  982. *
  983. *------------------------------------------*/
  984. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  985. {
  986. nullpo_retr(-1, sd);
  987. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  988. return -1;
  989. if (storage_storageopen(sd) == 1)
  990. { //Already open.
  991. clif_displaymessage(fd, msg_txt(250));
  992. return -1;
  993. }
  994. clif_displaymessage(fd, "Storage opened.");
  995. return 0;
  996. }
  997. /*==========================================
  998. *
  999. *------------------------------------------*/
  1000. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1001. {
  1002. nullpo_retr(-1, sd);
  1003. if (!sd->status.guild_id) {
  1004. clif_displaymessage(fd, msg_txt(252));
  1005. return -1;
  1006. }
  1007. if (sd->npc_id || sd->vender_id || sd->state.trading)
  1008. return -1;
  1009. if (sd->state.storage_flag == 1) {
  1010. clif_displaymessage(fd, msg_txt(250));
  1011. return -1;
  1012. }
  1013. if (sd->state.storage_flag == 2) {
  1014. clif_displaymessage(fd, msg_txt(251));
  1015. return -1;
  1016. }
  1017. storage_guild_storageopen(sd);
  1018. clif_displaymessage(fd, "Guild storage opened.");
  1019. return 0;
  1020. }
  1021. /*==========================================
  1022. *
  1023. *------------------------------------------*/
  1024. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1025. {
  1026. int param1 = 0, param2 = 0, param3 = 0;
  1027. nullpo_retr(-1, sd);
  1028. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1029. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1030. return -1;
  1031. }
  1032. sd->sc.opt1 = param1;
  1033. sd->sc.opt2 = param2;
  1034. pc_setoption(sd, param3);
  1035. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1036. return 0;
  1037. }
  1038. /*==========================================
  1039. *
  1040. *------------------------------------------*/
  1041. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1042. {
  1043. nullpo_retr(-1, sd);
  1044. if (sd->sc.option & OPTION_INVISIBLE) {
  1045. sd->sc.option &= ~OPTION_INVISIBLE;
  1046. if (sd->disguise)
  1047. status_set_viewdata(&sd->bl, sd->disguise);
  1048. else
  1049. status_set_viewdata(&sd->bl, sd->status.class_);
  1050. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1051. } else {
  1052. sd->sc.option |= OPTION_INVISIBLE;
  1053. sd->vd.class_ = INVISIBLE_CLASS;
  1054. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1055. }
  1056. clif_changeoption(&sd->bl);
  1057. return 0;
  1058. }
  1059. /*==========================================
  1060. * Changes a character's class
  1061. *------------------------------------------*/
  1062. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1063. {
  1064. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1065. int job = 0, upper = 0;
  1066. nullpo_retr(-1, sd);
  1067. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1068. {
  1069. int i, found = 0;
  1070. const struct { char name[16]; int id; } jobs[] = {
  1071. { "novice", 0 },
  1072. { "swordsman", 1 },
  1073. { "mage", 2 },
  1074. { "archer", 3 },
  1075. { "acolyte", 4 },
  1076. { "merchant", 5 },
  1077. { "thief", 6 },
  1078. { "knight", 7 },
  1079. { "priest", 8 },
  1080. { "priestess", 8 },
  1081. { "wizard", 9 },
  1082. { "blacksmith", 10 },
  1083. { "hunter", 11 },
  1084. { "assassin", 12 },
  1085. { "crusader", 14 },
  1086. { "monk", 15 },
  1087. { "sage", 16 },
  1088. { "rogue", 17 },
  1089. { "alchemist", 18 },
  1090. { "bard", 19 },
  1091. { "dancer", 20 },
  1092. { "super novice", 23 },
  1093. { "supernovice", 23 },
  1094. { "gunslinger", 24 },
  1095. { "gunner", 24 },
  1096. { "ninja", 25 },
  1097. { "high novice", 4001 },
  1098. { "swordsman high", 4002 },
  1099. { "mage high", 4003 },
  1100. { "archer high", 4004 },
  1101. { "acolyte high", 4005 },
  1102. { "merchant high", 4006 },
  1103. { "thief high", 4007 },
  1104. { "lord knight", 4008 },
  1105. { "high priest", 4009 },
  1106. { "high priestess", 4009 },
  1107. { "high wizard", 4010 },
  1108. { "whitesmith", 4011 },
  1109. { "sniper", 4012 },
  1110. { "assassin cross", 4013 },
  1111. { "paladin", 4015 },
  1112. { "champion", 4016 },
  1113. { "professor", 4017 },
  1114. { "stalker", 4018 },
  1115. { "creator", 4019 },
  1116. { "clown", 4020 },
  1117. { "gypsy", 4021 },
  1118. { "baby novice", 4023 },
  1119. { "baby swordsman", 4024 },
  1120. { "baby mage", 4025 },
  1121. { "baby archer", 4026 },
  1122. { "baby acolyte", 4027 },
  1123. { "baby merchant", 4028 },
  1124. { "baby thief", 4029 },
  1125. { "baby knight", 4030 },
  1126. { "baby priest", 4031 },
  1127. { "baby priestess", 4031 },
  1128. { "baby wizard", 4032 },
  1129. { "baby blacksmith",4033 },
  1130. { "baby hunter", 4034 },
  1131. { "baby assassin", 4035 },
  1132. { "baby crusader", 4037 },
  1133. { "baby monk", 4038 },
  1134. { "baby sage", 4039 },
  1135. { "baby rogue", 4040 },
  1136. { "baby alchemist", 4041 },
  1137. { "baby bard", 4042 },
  1138. { "baby dancer", 4043 },
  1139. { "super baby", 4045 },
  1140. { "taekwon", 4046 },
  1141. { "taekwon boy", 4046 },
  1142. { "taekwon girl", 4046 },
  1143. { "star gladiator", 4047 },
  1144. { "soul linker", 4049 },
  1145. };
  1146. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1147. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1148. job = jobs[i].id;
  1149. upper = 0;
  1150. found = 1;
  1151. break;
  1152. }
  1153. }
  1154. if (!found) {
  1155. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1156. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1157. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1158. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1159. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1160. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1161. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1162. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1163. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1164. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1165. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1166. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1167. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1168. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1169. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1170. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1171. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1172. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1173. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1174. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1175. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1176. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1177. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1178. return -1;
  1179. }
  1180. }
  1181. if (job == 37 ||job == 45)
  1182. return 0;
  1183. if (pcdb_checkid(job))
  1184. {
  1185. if (pc_jobchange(sd, job, upper) == 0)
  1186. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1187. else {
  1188. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1189. return -1;
  1190. }
  1191. } else {
  1192. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1193. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1194. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1195. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1196. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1197. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1198. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1199. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1200. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1201. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1202. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1203. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1204. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1205. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1206. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1207. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1208. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1209. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1210. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1211. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1212. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1213. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1214. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1215. return -1;
  1216. }
  1217. return 0;
  1218. }
  1219. /*==========================================
  1220. *
  1221. *------------------------------------------*/
  1222. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1223. {
  1224. nullpo_retr(-1, sd);
  1225. clif_specialeffect(&sd->bl,450,SELF);
  1226. status_kill(&sd->bl);
  1227. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1228. return 0;
  1229. }
  1230. /*==========================================
  1231. *
  1232. *------------------------------------------*/
  1233. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1234. {
  1235. struct map_session_data *pl_sd;
  1236. nullpo_retr(-1, sd);
  1237. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1238. if (!message || !*message) {
  1239. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1240. return -1;
  1241. }
  1242. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1243. {
  1244. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1245. return -1;
  1246. }
  1247. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1248. { // you can kill only lower or same level
  1249. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1250. return -1;
  1251. }
  1252. status_kill(&pl_sd->bl);
  1253. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1254. if (fd != pl_sd->fd)
  1255. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1256. return 0;
  1257. }
  1258. /*==========================================
  1259. *
  1260. *------------------------------------------*/
  1261. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1262. {
  1263. nullpo_retr(-1, sd);
  1264. if (!status_revive(&sd->bl, 100, 100))
  1265. {
  1266. clif_displaymessage(fd, "You're not dead.");
  1267. return -1;
  1268. }
  1269. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1270. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1271. return 0;
  1272. }
  1273. /*==========================================
  1274. * +kamic [LuzZza]
  1275. *------------------------------------------*/
  1276. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1277. {
  1278. unsigned long color=0;
  1279. nullpo_retr(-1, sd);
  1280. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1281. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1282. if (!message || !*message) {
  1283. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1284. return -1;
  1285. }
  1286. sscanf(message, "%199[^\n]", atcmd_output);
  1287. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1288. } else {
  1289. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1290. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1291. return -1;
  1292. }
  1293. if(color > 0xFFFFFF) {
  1294. clif_displaymessage(fd, "Invalid color.");
  1295. return -1;
  1296. }
  1297. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  1298. }
  1299. return 0;
  1300. }
  1301. /*==========================================
  1302. *
  1303. *------------------------------------------*/
  1304. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1305. {
  1306. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1307. nullpo_retr(-1, sd);
  1308. sscanf(message, "%d %d", &hp, &sp);
  1309. // some overflow checks
  1310. if( hp == INT_MIN ) hp++;
  1311. if( sp == INT_MIN ) sp++;
  1312. if ( hp == 0 && sp == 0 ) {
  1313. if (!status_percent_heal(&sd->bl, 100, 100))
  1314. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1315. else
  1316. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1317. return 0;
  1318. }
  1319. if ( hp > 0 && sp >= 0 ) {
  1320. if(!status_heal(&sd->bl, hp, sp, 0))
  1321. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1322. else
  1323. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1324. return 0;
  1325. }
  1326. if ( hp < 0 && sp <= 0 ) {
  1327. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1328. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1329. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1330. return 0;
  1331. }
  1332. //Opposing signs.
  1333. if ( hp ) {
  1334. if (hp > 0)
  1335. status_heal(&sd->bl, hp, 0, 0);
  1336. else {
  1337. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1338. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1339. }
  1340. }
  1341. if ( sp ) {
  1342. if (sp > 0)
  1343. status_heal(&sd->bl, 0, sp, 0);
  1344. else
  1345. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1346. }
  1347. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1348. return 0;
  1349. }
  1350. /*==========================================
  1351. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1352. *------------------------------------------*/
  1353. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1354. {
  1355. char item_name[100];
  1356. int number = 0, item_id, flag;
  1357. struct item item_tmp;
  1358. struct item_data *item_data;
  1359. int get_count, i;
  1360. nullpo_retr(-1, sd);
  1361. memset(item_name, '\0', sizeof(item_name));
  1362. if (!message || !*message || (
  1363. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1364. sscanf(message, "%99s %d", item_name, &number) < 1
  1365. )) {
  1366. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1367. return -1;
  1368. }
  1369. if (number <= 0)
  1370. number = 1;
  1371. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1372. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1373. {
  1374. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1375. return -1;
  1376. }
  1377. item_id = item_data->nameid;
  1378. get_count = number;
  1379. //Check if it's stackable.
  1380. if (!itemdb_isstackable2(item_data))
  1381. get_count = 1;
  1382. for (i = 0; i < number; i += get_count) {
  1383. // if not pet egg
  1384. if (!pet_create_egg(sd, item_id)) {
  1385. memset(&item_tmp, 0, sizeof(item_tmp));
  1386. item_tmp.nameid = item_id;
  1387. item_tmp.identify = 1;
  1388. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1389. clif_additem(sd, 0, 0, flag);
  1390. }
  1391. }
  1392. //Logs (A)dmins items [Lupus]
  1393. if(log_config.enable_logs&0x400)
  1394. log_pick_pc(sd, "A", item_id, number, NULL);
  1395. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1396. return 0;
  1397. }
  1398. /*==========================================
  1399. *
  1400. *------------------------------------------*/
  1401. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1402. {
  1403. struct item item_tmp;
  1404. struct item_data *item_data;
  1405. char item_name[100];
  1406. int item_id, number = 0;
  1407. int identify = 0, refine = 0, attr = 0;
  1408. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1409. int flag;
  1410. int loop, get_count, i;
  1411. nullpo_retr(-1, sd);
  1412. memset(item_name, '\0', sizeof(item_name));
  1413. if (!message || !*message || (
  1414. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1415. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1416. )) {
  1417. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1418. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1419. return -1;
  1420. }
  1421. if (number <= 0)
  1422. number = 1;
  1423. item_id = 0;
  1424. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1425. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1426. item_id = item_data->nameid;
  1427. if (item_id > 500) {
  1428. loop = 1;
  1429. get_count = number;
  1430. if (item_data->type == 4 || item_data->type == 5 ||
  1431. item_data->type == 7 || item_data->type == 8) {
  1432. loop = number;
  1433. get_count = 1;
  1434. if (item_data->type == 7) {
  1435. identify = 1;
  1436. refine = 0;
  1437. }
  1438. if (item_data->type == 8)
  1439. refine = 0;
  1440. if (refine > 10)
  1441. refine = 10;
  1442. } else {
  1443. identify = 1;
  1444. refine = attr = 0;
  1445. }
  1446. for (i = 0; i < loop; i++) {
  1447. memset(&item_tmp, 0, sizeof(item_tmp));
  1448. item_tmp.nameid = item_id;
  1449. item_tmp.identify = identify;
  1450. item_tmp.refine = refine;
  1451. item_tmp.attribute = attr;
  1452. item_tmp.card[0] = c1;
  1453. item_tmp.card[1] = c2;
  1454. item_tmp.card[2] = c3;
  1455. item_tmp.card[3] = c4;
  1456. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1457. clif_additem(sd, 0, 0, flag);
  1458. }
  1459. //Logs (A)dmins items [Lupus]
  1460. if(log_config.enable_logs&0x400)
  1461. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  1462. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1463. } else {
  1464. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1465. return -1;
  1466. }
  1467. return 0;
  1468. }
  1469. /*==========================================
  1470. *
  1471. *------------------------------------------*/
  1472. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1473. {
  1474. int i;
  1475. nullpo_retr(-1, sd);
  1476. for (i = 0; i < MAX_INVENTORY; i++) {
  1477. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1478. //Logs (A)dmins items [Lupus]
  1479. if(log_config.enable_logs&0x400)
  1480. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1481. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  1482. }
  1483. }
  1484. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1485. return 0;
  1486. }
  1487. /*==========================================
  1488. * Atcommand @lvlup
  1489. *------------------------------------------*/
  1490. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1491. {
  1492. int level=0, i=0, status_point=0;
  1493. nullpo_retr(-1, sd);
  1494. level = atoi(message);
  1495. if (!message || !*message || !level) {
  1496. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1497. return -1;
  1498. }
  1499. if (level > 0) {
  1500. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1501. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1502. return -1;
  1503. } // End Addition
  1504. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1505. level = pc_maxbaselv(sd) - sd->status.base_level;
  1506. for (i = 1; i <= level; i++)
  1507. status_point += (sd->status.base_level + i + 14) / 5;
  1508. if (sd->status.status_point > USHRT_MAX - status_point)
  1509. sd->status.status_point = USHRT_MAX;
  1510. else
  1511. sd->status.status_point += status_point;
  1512. sd->status.base_level += (unsigned int)level;
  1513. status_percent_heal(&sd->bl, 100, 100);
  1514. clif_misceffect(&sd->bl, 0);
  1515. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1516. } else {
  1517. if (sd->status.base_level == 1) {
  1518. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1519. return -1;
  1520. }
  1521. level*=-1;
  1522. if ((unsigned int)level >= sd->status.base_level)
  1523. level = sd->status.base_level-1;
  1524. for (i = 0; i > -level; i--)
  1525. status_point += (sd->status.base_level + i + 14) / 5;
  1526. if (sd->status.status_point < status_point)
  1527. pc_resetstate(sd);
  1528. if (sd->status.status_point < status_point)
  1529. sd->status.status_point = 0;
  1530. else
  1531. sd->status.status_point -= status_point;
  1532. sd->status.base_level -= (unsigned int)level;
  1533. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1534. }
  1535. clif_updatestatus(sd, SP_STATUSPOINT);
  1536. clif_updatestatus(sd, SP_BASELEVEL);
  1537. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1538. status_calc_pc(sd, 0);
  1539. if(sd->status.party_id)
  1540. party_send_levelup(sd);
  1541. return 0;
  1542. }
  1543. /*==========================================
  1544. *
  1545. *------------------------------------------*/
  1546. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1547. {
  1548. int level=0;
  1549. nullpo_retr(-1, sd);
  1550. level = atoi(message);
  1551. if (!message || !*message || !level) {
  1552. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1553. return -1;
  1554. }
  1555. if (level > 0) {
  1556. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1557. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1558. return -1;
  1559. }
  1560. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1561. level = pc_maxjoblv(sd) - sd->status.job_level;
  1562. sd->status.job_level += (unsigned int)level;
  1563. clif_updatestatus(sd, SP_JOBLEVEL);
  1564. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1565. if (sd->status.skill_point > USHRT_MAX - level)
  1566. sd->status.skill_point = USHRT_MAX;
  1567. else
  1568. sd->status.skill_point += level;
  1569. clif_updatestatus(sd, SP_SKILLPOINT);
  1570. status_calc_pc(sd, 0);
  1571. clif_misceffect(&sd->bl, 1);
  1572. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1573. } else {
  1574. if (sd->status.job_level == 1) {
  1575. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1576. return -1;
  1577. }
  1578. level *=-1;
  1579. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1580. level = sd->status.job_level-1;
  1581. sd->status.job_level -= (unsigned int)level;
  1582. clif_updatestatus(sd, SP_JOBLEVEL);
  1583. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1584. if (sd->status.skill_point < level)
  1585. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1586. if (sd->status.skill_point < level)
  1587. sd->status.skill_point = 0;
  1588. else
  1589. sd->status.skill_point -= level;
  1590. clif_updatestatus(sd, SP_SKILLPOINT);
  1591. status_calc_pc(sd, 0);
  1592. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1593. }
  1594. return 0;
  1595. }
  1596. /*==========================================
  1597. * @help
  1598. *------------------------------------------*/
  1599. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1600. {
  1601. char buf[2048], w1[2048], w2[2048];
  1602. int i, gm_level;
  1603. FILE* fp;
  1604. nullpo_retr(-1, sd);
  1605. memset(buf, '\0', sizeof(buf));
  1606. if ((fp = fopen(help_txt, "r")) != NULL) {
  1607. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1608. gm_level = pc_isGM(sd);
  1609. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1610. if (buf[0] == '/' && buf[1] == '/')
  1611. continue;
  1612. for (i = 0; buf[i] != '\0'; i++) {
  1613. if (buf[i] == '\r' || buf[i] == '\n') {
  1614. buf[i] = '\0';
  1615. break;
  1616. }
  1617. }
  1618. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1619. clif_displaymessage(fd, buf);
  1620. else if (gm_level >= atoi(w1))
  1621. clif_displaymessage(fd, w2);
  1622. }
  1623. fclose(fp);
  1624. } else {
  1625. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1626. return -1;
  1627. }
  1628. return 0;
  1629. }
  1630. /*==========================================
  1631. * @help2 - Char commands [Kayla]
  1632. *------------------------------------------*/
  1633. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1634. {
  1635. char buf[2048], w1[2048], w2[2048];
  1636. int i, gm_level;
  1637. FILE* fp;
  1638. nullpo_retr(-1, sd);
  1639. memset(buf, '\0', sizeof(buf));
  1640. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1641. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1642. gm_level = pc_isGM(sd);
  1643. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1644. if (buf[0] == '/' && buf[1] == '/')
  1645. continue;
  1646. for (i = 0; buf[i] != '\0'; i++) {
  1647. if (buf[i] == '\r' || buf[i] == '\n') {
  1648. buf[i] = '\0';
  1649. break;
  1650. }
  1651. }
  1652. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1653. clif_displaymessage(fd, buf);
  1654. else if (gm_level >= atoi(w1))
  1655. clif_displaymessage(fd, w2);
  1656. }
  1657. fclose(fp);
  1658. } else {
  1659. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1660. return -1;
  1661. }
  1662. return 0;
  1663. }
  1664. // helper function, used in foreach calls to stop auto-attack timers
  1665. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1666. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1667. {
  1668. struct unit_data *ud = unit_bl2ud(bl);
  1669. int id = va_arg(ap, int);
  1670. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1671. {
  1672. unit_stop_attack(bl);
  1673. return 1;
  1674. }
  1675. return 0;
  1676. }
  1677. /*==========================================
  1678. *
  1679. *------------------------------------------*/
  1680. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1681. {
  1682. TBL_PC* sd = (TBL_PC*)bl;
  1683. clif_pvpset(sd, 0, 0, 2);
  1684. if (sd->pvp_timer != -1) {
  1685. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1686. sd->pvp_timer = INVALID_TIMER;
  1687. }
  1688. return 0;
  1689. }
  1690. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1691. {
  1692. nullpo_retr(-1, sd);
  1693. if (!map[sd->bl.m].flag.pvp) {
  1694. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1695. return -1;
  1696. }
  1697. map[sd->bl.m].flag.pvp = 0;
  1698. if (!battle_config.pk_mode)
  1699. clif_send0199(sd->bl.m, 0);
  1700. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1701. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1702. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1703. return 0;
  1704. }
  1705. /*==========================================
  1706. *
  1707. *------------------------------------------*/
  1708. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1709. {
  1710. TBL_PC* sd = (TBL_PC*)bl;
  1711. if (sd->pvp_timer == -1) {
  1712. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1713. sd->pvp_rank = 0;
  1714. sd->pvp_lastusers = 0;
  1715. sd->pvp_point = 5;
  1716. sd->pvp_won = 0;
  1717. sd->pvp_lost = 0;
  1718. }
  1719. return 0;
  1720. }
  1721. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1722. {
  1723. nullpo_retr(-1, sd);
  1724. if (map[sd->bl.m].flag.pvp) {
  1725. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1726. return -1;
  1727. }
  1728. map[sd->bl.m].flag.pvp = 1;
  1729. if (!battle_config.pk_mode)
  1730. {// display pvp circle and rank
  1731. clif_send0199(sd->bl.m, 1);
  1732. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1733. }
  1734. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1735. return 0;
  1736. }
  1737. /*==========================================
  1738. *
  1739. *------------------------------------------*/
  1740. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1741. {
  1742. nullpo_retr(-1, sd);
  1743. if (!map[sd->bl.m].flag.gvg) {
  1744. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1745. return -1;
  1746. }
  1747. map[sd->bl.m].flag.gvg = 0;
  1748. clif_send0199(sd->bl.m, 0);
  1749. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1750. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1751. return 0;
  1752. }
  1753. /*==========================================
  1754. *
  1755. *------------------------------------------*/
  1756. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1757. {
  1758. nullpo_retr(-1, sd);
  1759. if (map[sd->bl.m].flag.gvg) {
  1760. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1761. return -1;
  1762. }
  1763. map[sd->bl.m].flag.gvg = 1;
  1764. clif_send0199(sd->bl.m, 3);
  1765. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1766. return 0;
  1767. }
  1768. /*==========================================
  1769. *
  1770. *------------------------------------------*/
  1771. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1772. {
  1773. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1774. nullpo_retr(-1, sd);
  1775. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1776. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1777. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1778. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1779. clif_displaymessage(fd, atcmd_output);
  1780. return -1;
  1781. }
  1782. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1783. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1784. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1785. pc_changelook(sd, LOOK_HAIR, hair_style);
  1786. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1787. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1788. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1789. } else {
  1790. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1791. return -1;
  1792. }
  1793. return 0;
  1794. }
  1795. /*==========================================
  1796. * @dye && @ccolor
  1797. *------------------------------------------*/
  1798. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1799. {
  1800. int cloth_color = 0;
  1801. nullpo_retr(-1, sd);
  1802. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1803. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1804. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1805. clif_displaymessage(fd, atcmd_output);
  1806. return -1;
  1807. }
  1808. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1809. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1810. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1811. } else {
  1812. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1813. return -1;
  1814. }
  1815. return 0;
  1816. }
  1817. /*==========================================
  1818. * @hairstyle && @hstyle
  1819. *------------------------------------------*/
  1820. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1821. {
  1822. int hair_style = 0;
  1823. nullpo_retr(-1, sd);
  1824. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1825. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1826. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1827. clif_displaymessage(fd, atcmd_output);
  1828. return -1;
  1829. }
  1830. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1831. pc_changelook(sd, LOOK_HAIR, hair_style);
  1832. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1833. } else {
  1834. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1835. return -1;
  1836. }
  1837. return 0;
  1838. }
  1839. /*==========================================
  1840. * @haircolor && @hcolor
  1841. *------------------------------------------*/
  1842. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1843. {
  1844. int hair_color = 0;
  1845. nullpo_retr(-1, sd);
  1846. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1847. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1848. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1849. clif_displaymessage(fd, atcmd_output);
  1850. return -1;
  1851. }
  1852. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1853. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1854. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1855. } else {
  1856. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1857. return -1;
  1858. }
  1859. return 0;
  1860. }
  1861. /*==========================================
  1862. * @go [city_number or city_name] - Updated by Harbin
  1863. *------------------------------------------*/
  1864. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1865. {
  1866. int i;
  1867. int town;
  1868. char map_name[MAP_NAME_LENGTH];
  1869. int m;
  1870. const struct {
  1871. char map[MAP_NAME_LENGTH];
  1872. int x, y;
  1873. } data[] = {
  1874. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1875. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1876. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1877. { MAP_PAYON, 162, 233 }, // 3=Payon
  1878. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1879. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1880. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1881. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1882. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1883. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1884. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1885. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1886. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1887. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1888. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1889. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1890. { MAP_JAIL, 23, 61 }, // 16=Prison
  1891. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1892. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1893. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1894. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1895. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1896. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1897. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1898. { MAP_VEINS, 216, 123 }, // 24=Veins
  1899. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1900. };
  1901. nullpo_retr(-1, sd);
  1902. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  1903. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1904. return 0;
  1905. }
  1906. memset(map_name, '\0', sizeof(map_name));
  1907. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1908. // get the number
  1909. town = atoi(message);
  1910. // if no value, display all value
  1911. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1912. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  1913. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  1914. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1915. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1916. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1917. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1918. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1919. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1920. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1921. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  1922. clif_displaymessage(fd, " 24=Veins 25=Moscovia");
  1923. return -1;
  1924. }
  1925. // get possible name of the city
  1926. map_name[MAP_NAME_LENGTH-1] = '\0';
  1927. for (i = 0; map_name[i]; i++)
  1928. map_name[i] = TOLOWER(map_name[i]);
  1929. // try to identify the map name
  1930. if (strncmp(map_name, "prontera", 3) == 0) {
  1931. town = 0;
  1932. } else if (strncmp(map_name, "morocc", 3) == 0) {
  1933. town = 1;
  1934. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1935. town = 2;
  1936. } else if (strncmp(map_name, "payon", 3) == 0 ||
  1937. strncmp(map_name, "paion", 3) == 0) {
  1938. town = 3;
  1939. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1940. town = 4;
  1941. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  1942. strncmp(map_name, "islude", 3) == 0) {
  1943. town = 5;
  1944. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  1945. strcmp(map_name, "al") == 0) {
  1946. town = 6;
  1947. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1948. strcmp(map_name, "christmas") == 0 ||
  1949. strncmp(map_name, "xmas", 3) == 0 ||
  1950. strncmp(map_name, "x-mas", 3) == 0) {
  1951. town = 7;
  1952. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1953. town = 8;
  1954. } else if (strncmp(map_name, "yuno", 3) == 0) {
  1955. town = 9;
  1956. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1957. town = 10;
  1958. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  1959. town = 11;
  1960. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1961. town = 12;
  1962. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1963. town = 13;
  1964. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1965. town = 14;
  1966. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1967. strncmp(map_name, "startpoint", 3) == 0 ||
  1968. strncmp(map_name, "begining", 3) == 0) {
  1969. town = 15;
  1970. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1971. strncmp(map_name, "prison", 3) == 0 ||
  1972. strncmp(map_name, "jails", 3) == 0) {
  1973. town = 16;
  1974. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  1975. strncmp(map_name, "jawai", 3) == 0) {
  1976. town = 17;
  1977. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  1978. strncmp(map_name, "ayotaya", 3) == 0) {
  1979. town = 18;
  1980. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  1981. strncmp(map_name, "ainbroch", 5) == 0) {
  1982. town = 19;
  1983. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1984. town = 20;
  1985. } else if (strncmp(map_name, "einbech", 3) == 0) {
  1986. town = 21;
  1987. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1988. town = 22;
  1989. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1990. town = 23;
  1991. } else if (strncmp(map_name, "veins", 3) == 0) {
  1992. town = 24;
  1993. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1994. town = 25;
  1995. }
  1996. if (town >= 0 && town < ARRAYLENGTH(data))
  1997. {
  1998. m = map_mapname2mapid(data[town].map);
  1999. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2000. clif_displaymessage(fd, msg_txt(247));
  2001. return -1;
  2002. }
  2003. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2004. clif_displaymessage(fd, msg_txt(248));
  2005. return -1;
  2006. }
  2007. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
  2008. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2009. } else {
  2010. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2011. return -1;
  2012. }
  2013. } else { // if you arrive here, you have an error in town variable when reading of names
  2014. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2015. return -1;
  2016. }
  2017. return 0;
  2018. }
  2019. /*==========================================
  2020. *
  2021. *------------------------------------------*/
  2022. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2023. {
  2024. char name[NAME_LENGTH];
  2025. char monster[NAME_LENGTH];
  2026. int mob_id;
  2027. int number = 0;
  2028. int count;
  2029. int i, k, range;
  2030. short mx, my;
  2031. nullpo_retr(-1, sd);
  2032. memset(name, '\0', sizeof(name));
  2033. memset(monster, '\0', sizeof(monster));
  2034. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2035. if (!message || !*message) {
  2036. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2037. return -1;
  2038. }
  2039. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2040. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2041. //All data can be left as it is.
  2042. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2043. //Here, it is possible name was not given and we are using monster for it.
  2044. if (count < 3) //Blank mob's name.
  2045. name[0] = '\0';
  2046. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2047. //All data can be left as it is.
  2048. } else if (sscanf(message, "%23s", monster) > 0) {
  2049. //As before, name may be already filled.
  2050. name[0] = '\0';
  2051. } else {
  2052. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2053. return -1;
  2054. }
  2055. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2056. mob_id = mobdb_checkid(atoi(monster));
  2057. if (mob_id == 0) {
  2058. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2059. return -1;
  2060. }
  2061. if (mob_id == MOBID_EMPERIUM) {
  2062. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2063. return -1;
  2064. }
  2065. if (number <= 0)
  2066. number = 1;
  2067. if (strlen(name) < 1)
  2068. strcpy(name, "--ja--");
  2069. // 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
  2070. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2071. number = battle_config.atc_spawn_quantity_limit;
  2072. if (battle_config.etc_log)
  2073. 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);
  2074. count = 0;
  2075. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2076. for (i = 0; i < number; i++) {
  2077. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2078. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2079. count += (k != 0) ? 1 : 0;
  2080. }
  2081. if (count != 0)
  2082. if (number == count)
  2083. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2084. else {
  2085. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2086. clif_displaymessage(fd, atcmd_output);
  2087. }
  2088. else {
  2089. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2090. return -1;
  2091. }
  2092. return 0;
  2093. }
  2094. // small monster spawning [Valaris]
  2095. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2096. {
  2097. char name[NAME_LENGTH] = "";
  2098. char monster[NAME_LENGTH] = "";
  2099. int mob_id = 0;
  2100. int number = 0;
  2101. int x = 0;
  2102. int y = 0;
  2103. int count;
  2104. int i;
  2105. nullpo_retr(-1, sd);
  2106. if (!message || !*message) {
  2107. clif_displaymessage(fd, "Give a monster name/id please.");
  2108. return -1;
  2109. }
  2110. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2111. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2112. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2113. clif_displaymessage(fd, "Give a monster name/id please.");
  2114. return -1;
  2115. }
  2116. // If monster identifier/name argument is a name
  2117. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2118. mob_id = atoi(monster);
  2119. if (mob_id == 0) {
  2120. clif_displaymessage(fd, msg_txt(40));
  2121. return -1;
  2122. }
  2123. if (mob_id == MOBID_EMPERIUM) {
  2124. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2125. return -1;
  2126. }
  2127. if (mobdb_checkid(mob_id) == 0) {
  2128. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2129. return -1;
  2130. }
  2131. if (number <= 0)
  2132. number = 1;
  2133. if (strlen(name) < 1)
  2134. strcpy(name, "--ja--");
  2135. // 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
  2136. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2137. number = battle_config.atc_spawn_quantity_limit;
  2138. count = 0;
  2139. for (i = 0; i < number; i++) {
  2140. int mx, my;
  2141. if (x <= 0)
  2142. mx = sd->bl.x + (rand() % 11 - 5);
  2143. else
  2144. mx = x;
  2145. if (y <= 0)
  2146. my = sd->bl.y + (rand() % 11 - 5);
  2147. else
  2148. my = y;
  2149. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2150. }
  2151. if (count != 0)
  2152. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2153. else
  2154. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2155. return 0;
  2156. }
  2157. // big monster spawning [Valaris]
  2158. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2159. {
  2160. char name[NAME_LENGTH] = "";
  2161. char monster[NAME_LENGTH] = "";
  2162. int mob_id = 0;
  2163. int number = 0;
  2164. int x = 0;
  2165. int y = 0;
  2166. int count;
  2167. int i;
  2168. nullpo_retr(-1, sd);
  2169. if (!message || !*message) {
  2170. clif_displaymessage(fd, "Give a monster name/id please.");
  2171. return -1;
  2172. }
  2173. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2174. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2175. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2176. clif_displaymessage(fd, "Give a monster name/id please.");
  2177. return -1;
  2178. }
  2179. // If monster identifier/name argument is a name
  2180. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2181. mob_id = atoi(monster);
  2182. if (mob_id == 0) {
  2183. clif_displaymessage(fd, msg_txt(40));
  2184. return -1;
  2185. }
  2186. if (mob_id == MOBID_EMPERIUM) {
  2187. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2188. return -1;
  2189. }
  2190. if (mobdb_checkid(mob_id) == 0) {
  2191. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2192. return -1;
  2193. }
  2194. if (number <= 0)
  2195. number = 1;
  2196. if (strlen(name) < 1)
  2197. strcpy(name, "--ja--");
  2198. // 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
  2199. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2200. number = battle_config.atc_spawn_quantity_limit;
  2201. count = 0;
  2202. for (i = 0; i < number; i++) {
  2203. int mx, my;
  2204. if (x <= 0)
  2205. mx = sd->bl.x + (rand() % 11 - 5);
  2206. else
  2207. mx = x;
  2208. if (y <= 0)
  2209. my = sd->bl.y + (rand() % 11 - 5);
  2210. else
  2211. my = y;
  2212. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2213. }
  2214. if (count != 0)
  2215. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2216. else
  2217. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2218. return 0;
  2219. }
  2220. /*==========================================
  2221. *
  2222. *------------------------------------------*/
  2223. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2224. {
  2225. struct mob_data *md;
  2226. int flag;
  2227. nullpo_retr(0, md=(struct mob_data *)bl);
  2228. flag = va_arg(ap, int);
  2229. if (md->guardian_data)
  2230. return 0; //Do not touch WoE mobs!
  2231. if (flag)
  2232. status_zap(bl,md->status.hp, 0);
  2233. else
  2234. status_kill(bl);
  2235. return 1;
  2236. }
  2237. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2238. {
  2239. int map_id;
  2240. char map_name[MAP_NAME_LENGTH_EXT];
  2241. if (!sd) return;
  2242. memset(map_name, '\0', sizeof(map_name));
  2243. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2244. map_id = sd->bl.m;
  2245. else {
  2246. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2247. map_id = sd->bl.m;
  2248. }
  2249. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2250. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2251. return;
  2252. }
  2253. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2254. {
  2255. atcommand_killmonster_sub(fd, sd, message, 1);
  2256. return 0;
  2257. }
  2258. /*==========================================
  2259. *
  2260. *------------------------------------------*/
  2261. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2262. {
  2263. atcommand_killmonster_sub(fd, sd, message, 0);
  2264. return 0;
  2265. }
  2266. /*==========================================
  2267. *
  2268. *------------------------------------------*/
  2269. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2270. {
  2271. int i,j, position = 0, refine = 0, current_position, final_refine;
  2272. int count;
  2273. nullpo_retr(-1, sd);
  2274. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2275. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2276. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  2277. sprintf(atcmd_output, "%d: Left Accessory", EQI_ACC_L);
  2278. clif_displaymessage(fd, atcmd_output);
  2279. sprintf(atcmd_output, "%d: Right Accessory", EQI_ACC_R);
  2280. clif_displaymessage(fd, atcmd_output);
  2281. sprintf(atcmd_output, "%d: Shoes", EQI_SHOES);
  2282. clif_displaymessage(fd, atcmd_output);
  2283. sprintf(atcmd_output, "%d: Garment", EQI_GARMENT);
  2284. clif_displaymessage(fd, atcmd_output);
  2285. sprintf(atcmd_output, "%d: Lower Headgear", EQI_HEAD_LOW);
  2286. clif_displaymessage(fd, atcmd_output);
  2287. sprintf(atcmd_output, "%d: Mid Headgear", EQI_HEAD_MID);
  2288. clif_displaymessage(fd, atcmd_output);
  2289. sprintf(atcmd_output, "%d: Top Headgear", EQI_HEAD_TOP);
  2290. clif_displaymessage(fd, atcmd_output);
  2291. sprintf(atcmd_output, "%d: Body Armor", EQI_ARMOR);
  2292. clif_displaymessage(fd, atcmd_output);
  2293. sprintf(atcmd_output, "%d: Left Hand", EQI_HAND_L);
  2294. clif_displaymessage(fd, atcmd_output);
  2295. sprintf(atcmd_output, "%d: Right Hand", EQI_HAND_R);
  2296. clif_displaymessage(fd, atcmd_output);
  2297. return -1;
  2298. }
  2299. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2300. count = 0;
  2301. for (j = 0; j < EQI_MAX-1; j++) {
  2302. if ((i = sd->equip_index[j]) < 0)
  2303. continue;
  2304. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2305. continue;
  2306. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2307. continue;
  2308. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2309. continue;
  2310. if(position && !(sd->status.inventory[i].equip & position))
  2311. continue;
  2312. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2313. if (sd->status.inventory[i].refine != final_refine) {
  2314. sd->status.inventory[i].refine = final_refine;
  2315. current_position = sd->status.inventory[i].equip;
  2316. pc_unequipitem(sd, i, 3);
  2317. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2318. clif_delitem(sd, i, 1);
  2319. clif_additem(sd, i, 1, 0);
  2320. pc_equipitem(sd, i, current_position);
  2321. clif_misceffect(&sd->bl, 3);
  2322. count++;
  2323. }
  2324. }
  2325. if (count == 0)
  2326. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2327. else if (count == 1)
  2328. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2329. else {
  2330. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2331. clif_displaymessage(fd, atcmd_output);
  2332. }
  2333. return 0;
  2334. }
  2335. /*==========================================
  2336. *
  2337. *------------------------------------------*/
  2338. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2339. {
  2340. char item_name[100];
  2341. int item_id, attribute = 0, star = 0;
  2342. int flag = 0;
  2343. struct item_data *item_data;
  2344. struct item tmp_item;
  2345. nullpo_retr(-1, sd);
  2346. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2347. memset(item_name, '\0', sizeof(item_name));
  2348. if (!message || !*message || (
  2349. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2350. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2351. )) {
  2352. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2353. return -1;
  2354. }
  2355. item_id = 0;
  2356. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2357. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2358. {
  2359. sprintf(atcmd_output, msg_txt(170)); // The item is not equipable.
  2360. clif_displaymessage(fd, atcmd_output);
  2361. return -1;
  2362. }
  2363. item_id = item_data->nameid;
  2364. if (itemdb_isequip2(item_data)) {
  2365. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2366. attribute = ATTRIBUTE_NORMAL;
  2367. if (star < MIN_STAR || star > MAX_STAR)
  2368. star = 0;
  2369. memset(&tmp_item, 0, sizeof tmp_item);
  2370. tmp_item.nameid = item_id;
  2371. tmp_item.amount = 1;
  2372. tmp_item.identify = 1;
  2373. tmp_item.card[0] = CARD0_FORGE;
  2374. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2375. ((star*5) << 8) + attribute:0;
  2376. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2377. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2378. clif_produceeffect(sd, 0, item_id);
  2379. clif_misceffect(&sd->bl, 3);
  2380. //Logs (A)dmins items [Lupus]
  2381. if(log_config.enable_logs&0x400)
  2382. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  2383. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2384. clif_additem(sd, 0, 0, flag);
  2385. } else {
  2386. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2387. clif_displaymessage(fd, atcmd_output);
  2388. return -1;
  2389. }
  2390. return 0;
  2391. }
  2392. /*==========================================
  2393. *
  2394. *------------------------------------------*/
  2395. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2396. {
  2397. int position = 0;
  2398. nullpo_retr(-1, sd);
  2399. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2400. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2401. {
  2402. int i;
  2403. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2404. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2405. {
  2406. if( sd->status.memo_point[i].map )
  2407. 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);
  2408. else
  2409. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2410. clif_displaymessage(sd->fd, atcmd_output);
  2411. }
  2412. return 0;
  2413. }
  2414. if( position < 0 && position >= MAX_MEMOPOINTS )
  2415. {
  2416. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2417. clif_displaymessage(fd, atcmd_output);
  2418. return -1;
  2419. }
  2420. pc_memo(sd, position);
  2421. return 0;
  2422. }
  2423. /*==========================================
  2424. *
  2425. *------------------------------------------*/
  2426. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2427. {
  2428. int y;
  2429. nullpo_retr(-1, sd);
  2430. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2431. for (y = 2; y >= -2; y--) {
  2432. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2433. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2434. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2435. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2436. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2437. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2438. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2439. clif_displaymessage(fd, atcmd_output);
  2440. }
  2441. return 0;
  2442. }
  2443. /*==========================================
  2444. *
  2445. *------------------------------------------*/
  2446. int atcommand_displaystatus(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2447. {
  2448. int i, type, flag;
  2449. nullpo_retr(-1, sd);
  2450. if (!message || !*message || (i = sscanf(message, "%d %d", &type, &flag)) < 1) {
  2451. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag>).");
  2452. return -1;
  2453. }
  2454. if (i == 1) flag = 1;
  2455. clif_status_change(&sd->bl, type, flag);
  2456. return 0;
  2457. }
  2458. /*==========================================
  2459. * @stpoint (Rewritten by [Yor])
  2460. *------------------------------------------*/
  2461. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2462. {
  2463. int point, new_status_point;
  2464. if (!message || !*message || (point = atoi(message)) == 0) {
  2465. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2466. return -1;
  2467. }
  2468. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  2469. new_status_point = USHRT_MAX;
  2470. else
  2471. if (point < 0 && sd->status.status_point < -point)
  2472. new_status_point = 0;
  2473. else
  2474. new_status_point = sd->status.status_point + point;
  2475. if (new_status_point != (int)sd->status.status_point) {
  2476. sd->status.status_point = (unsigned short)new_status_point;
  2477. clif_updatestatus(sd, SP_STATUSPOINT);
  2478. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2479. } else {
  2480. if (point < 0)
  2481. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2482. else
  2483. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2484. return -1;
  2485. }
  2486. return 0;
  2487. }
  2488. /*==========================================
  2489. * @skpoint (Rewritten by [Yor])
  2490. *------------------------------------------*/
  2491. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2492. {
  2493. int point, new_skill_point;
  2494. nullpo_retr(-1, sd);
  2495. if (!message || !*message || (point = atoi(message)) == 0) {
  2496. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2497. return -1;
  2498. }
  2499. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  2500. new_skill_point = USHRT_MAX;
  2501. else if (point < 0 && sd->status.skill_point < -point)
  2502. new_skill_point = 0;
  2503. else
  2504. new_skill_point = sd->status.skill_point + point;
  2505. if (new_skill_point != (int)sd->status.skill_point) {
  2506. sd->status.skill_point = (unsigned short)new_skill_point;
  2507. clif_updatestatus(sd, SP_SKILLPOINT);
  2508. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2509. } else {
  2510. if (point < 0)
  2511. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2512. else
  2513. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2514. return -1;
  2515. }
  2516. return 0;
  2517. }
  2518. /*==========================================
  2519. * @zeny (Rewritten by [Yor])
  2520. *------------------------------------------*/
  2521. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2522. {
  2523. int zeny, new_zeny;
  2524. nullpo_retr(-1, sd);
  2525. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2526. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2527. return -1;
  2528. }
  2529. new_zeny = sd->status.zeny + zeny;
  2530. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2531. new_zeny = MAX_ZENY;
  2532. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2533. new_zeny = 0;
  2534. if (new_zeny != sd->status.zeny) {
  2535. sd->status.zeny = new_zeny;
  2536. clif_updatestatus(sd, SP_ZENY);
  2537. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2538. } else {
  2539. if (zeny < 0)
  2540. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2541. else
  2542. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2543. return -1;
  2544. }
  2545. return 0;
  2546. }
  2547. /*==========================================
  2548. *
  2549. *------------------------------------------*/
  2550. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2551. {
  2552. int i, value = 0, new_value, max;
  2553. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  2554. short* status[6];
  2555. //we don't use direct initialization because it isn't part of the c standard.
  2556. nullpo_retr(-1, sd);
  2557. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2558. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2559. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2560. clif_displaymessage(fd, atcmd_output);
  2561. return -1;
  2562. }
  2563. for (i = 0; param[i] != NULL; i++)
  2564. if (strcmpi(command, param[i]) == 0)
  2565. break;
  2566. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  2567. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2568. clif_displaymessage(fd, atcmd_output);
  2569. return -1;
  2570. }
  2571. status[0] = &sd->status.str;
  2572. status[1] = &sd->status.agi;
  2573. status[2] = &sd->status.vit;
  2574. status[3] = &sd->status.int_;
  2575. status[4] = &sd->status.dex;
  2576. status[5] = &sd->status.luk;
  2577. max = SHRT_MAX;
  2578. new_value = cap_value(*status[i] + value, 1, max);
  2579. if (new_value != (int)*status[i]) {
  2580. *status[i] = new_value;
  2581. clif_updatestatus(sd, SP_STR + i);
  2582. clif_updatestatus(sd, SP_USTR + i);
  2583. status_calc_pc(sd, 0);
  2584. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2585. } else {
  2586. if (value < 0)
  2587. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2588. else
  2589. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2590. return -1;
  2591. }
  2592. return 0;
  2593. }
  2594. /*==========================================
  2595. * Stat all by fritz (rewritten by [Yor])
  2596. *------------------------------------------*/
  2597. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2598. {
  2599. int index, count, value, max, new_value;
  2600. short* status[6];
  2601. //we don't use direct initialization because it isn't part of the c standard.
  2602. nullpo_retr(-1, sd);
  2603. status[0] = &sd->status.str;
  2604. status[1] = &sd->status.agi;
  2605. status[2] = &sd->status.vit;
  2606. status[3] = &sd->status.int_;
  2607. status[4] = &sd->status.dex;
  2608. status[5] = &sd->status.luk;
  2609. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2610. value = pc_maxparameter(sd);
  2611. max = pc_maxparameter(sd);
  2612. } else {
  2613. max = SHRT_MAX;
  2614. }
  2615. count = 0;
  2616. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2617. if (value > 0 && *status[index] > max - value)
  2618. new_value = max;
  2619. else if (value < 0 && *status[index] <= -value)
  2620. new_value = 1;
  2621. else
  2622. new_value = *status[index] +value;
  2623. if (new_value != (int)*status[index]) {
  2624. *status[index] = new_value;
  2625. clif_updatestatus(sd, SP_STR + index);
  2626. clif_updatestatus(sd, SP_USTR + index);
  2627. count++;
  2628. }
  2629. }
  2630. if (count > 0) { // if at least 1 stat modified
  2631. status_calc_pc(sd, 0);
  2632. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2633. } else {
  2634. if (value < 0)
  2635. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2636. else
  2637. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2638. return -1;
  2639. }
  2640. return 0;
  2641. }
  2642. /*==========================================
  2643. *
  2644. *------------------------------------------*/
  2645. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2646. {
  2647. int level = 0;
  2648. short added_level;
  2649. struct guild *guild_info;
  2650. nullpo_retr(-1, sd);
  2651. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2652. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2653. return -1;
  2654. }
  2655. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2656. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2657. return -1;
  2658. }
  2659. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2660. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2661. // return -1;
  2662. //}
  2663. added_level = (short)level;
  2664. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2665. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2666. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2667. added_level = 1 - guild_info->guild_lv;
  2668. if (added_level != 0) {
  2669. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  2670. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2671. } else {
  2672. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2673. return -1;
  2674. }
  2675. return 0;
  2676. }
  2677. /*==========================================
  2678. *
  2679. *------------------------------------------*/
  2680. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2681. {
  2682. struct item_data *item_data;
  2683. int id, pet_id;
  2684. nullpo_retr(-1, sd);
  2685. if (!message || !*message) {
  2686. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2687. return -1;
  2688. }
  2689. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2690. id = item_data->nameid;
  2691. else
  2692. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2693. ;
  2694. else
  2695. id = atoi(message);
  2696. pet_id = search_petDB_index(id, PET_CLASS);
  2697. if (pet_id < 0)
  2698. pet_id = search_petDB_index(id, PET_EGG);
  2699. if (pet_id >= 0) {
  2700. sd->catch_target_class = pet_db[pet_id].class_;
  2701. intif_create_pet(
  2702. sd->status.account_id, sd->status.char_id,
  2703. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2704. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2705. 100, 0, 1, pet_db[pet_id].jname);
  2706. } else {
  2707. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2708. return -1;
  2709. }
  2710. return 0;
  2711. }
  2712. /*==========================================
  2713. *
  2714. *------------------------------------------*/
  2715. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2716. {
  2717. nullpo_retr(-1, sd);
  2718. if (sd->status.pet_id <= 0)
  2719. clif_sendegg(sd);
  2720. else {
  2721. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2722. return -1;
  2723. }
  2724. return 0;
  2725. }
  2726. /*==========================================
  2727. *
  2728. *------------------------------------------*/
  2729. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2730. {
  2731. int friendly;
  2732. struct pet_data *pd;
  2733. nullpo_retr(-1, sd);
  2734. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2735. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2736. return -1;
  2737. }
  2738. pd = sd->pd;
  2739. if (!pd) {
  2740. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2741. return -1;
  2742. }
  2743. if (friendly < 0 || friendly > 1000)
  2744. {
  2745. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2746. return -1;
  2747. }
  2748. if (friendly == pd->pet.intimate) {
  2749. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2750. return -1;
  2751. }
  2752. pd->pet.intimate = friendly;
  2753. clif_send_petstatus(sd);
  2754. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2755. return 0;
  2756. }
  2757. /*==========================================
  2758. *
  2759. *------------------------------------------*/
  2760. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2761. {
  2762. int hungry;
  2763. struct pet_data *pd;
  2764. nullpo_retr(-1, sd);
  2765. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2766. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2767. return -1;
  2768. }
  2769. pd = sd->pd;
  2770. if (!sd->status.pet_id || !pd) {
  2771. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2772. return -1;
  2773. }
  2774. if (hungry < 0 || hungry > 100) {
  2775. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2776. return -1;
  2777. }
  2778. if (hungry == pd->pet.hungry) {
  2779. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2780. return -1;
  2781. }
  2782. pd->pet.hungry = hungry;
  2783. clif_send_petstatus(sd);
  2784. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2785. return 0;
  2786. }
  2787. /*==========================================
  2788. *
  2789. *------------------------------------------*/
  2790. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2791. {
  2792. struct pet_data *pd;
  2793. nullpo_retr(-1, sd);
  2794. if (!sd->status.pet_id || !sd->pd) {
  2795. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2796. return -1;
  2797. }
  2798. pd = sd->pd;
  2799. if (!pd->pet.rename_flag) {
  2800. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2801. return -1;
  2802. }
  2803. pd->pet.rename_flag = 0;
  2804. intif_save_petdata(sd->status.account_id, &pd->pet);
  2805. clif_send_petstatus(sd);
  2806. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2807. return 0;
  2808. }
  2809. /*==========================================
  2810. *
  2811. *------------------------------------------*/
  2812. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2813. {
  2814. struct map_session_data *pl_sd = NULL;
  2815. nullpo_retr(-1, sd);
  2816. if (!message || !*message) {
  2817. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2818. return -1;
  2819. }
  2820. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2821. {
  2822. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2823. return -1;
  2824. }
  2825. if (pl_sd == sd)
  2826. {
  2827. clif_displaymessage(fd, "You are already where you are...");
  2828. return -1;
  2829. }
  2830. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2831. {
  2832. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2833. return -1;
  2834. }
  2835. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2836. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  2837. return -1;
  2838. }
  2839. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2840. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2841. return -1;
  2842. }
  2843. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  2844. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2845. clif_displaymessage(fd, atcmd_output);
  2846. return 0;
  2847. }
  2848. /*==========================================
  2849. * charblock command (usage: charblock <player_name>)
  2850. * This command do a definitiv ban on a player
  2851. *------------------------------------------*/
  2852. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2853. {
  2854. nullpo_retr(-1, sd);
  2855. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2856. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2857. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2858. return -1;
  2859. }
  2860. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2861. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2862. return 0;
  2863. }
  2864. /*==========================================
  2865. * charban command (usage: charban <time> <player_name>)
  2866. * This command do a limited ban on a player
  2867. * Time is done as follows:
  2868. * Adjustment value (-1, 1, +1, etc...)
  2869. * Modified element:
  2870. * a or y: year
  2871. * m: month
  2872. * j or d: day
  2873. * h: hour
  2874. * mn: minute
  2875. * s: second
  2876. * <example> @ban +1m-2mn1s-6y test_player
  2877. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2878. *------------------------------------------*/
  2879. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2880. {
  2881. char * modif_p;
  2882. int year, month, day, hour, minute, second, value;
  2883. nullpo_retr(-1, sd);
  2884. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2885. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2886. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2887. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2888. return -1;
  2889. }
  2890. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2891. modif_p = atcmd_output;
  2892. year = month = day = hour = minute = second = 0;
  2893. while (modif_p[0] != '\0') {
  2894. value = atoi(modif_p);
  2895. if (value == 0)
  2896. modif_p++;
  2897. else {
  2898. if (modif_p[0] == '-' || modif_p[0] == '+')
  2899. modif_p++;
  2900. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2901. modif_p++;
  2902. if (modif_p[0] == 's') {
  2903. second = value;
  2904. modif_p++;
  2905. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  2906. minute = value;
  2907. modif_p = modif_p + 2;
  2908. } else if (modif_p[0] == 'h') {
  2909. hour = value;
  2910. modif_p++;
  2911. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2912. day = value;
  2913. modif_p++;
  2914. } else if (modif_p[0] == 'm') {
  2915. month = value;
  2916. modif_p++;
  2917. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2918. year = value;
  2919. modif_p++;
  2920. } else if (modif_p[0] != '\0') {
  2921. modif_p++;
  2922. }
  2923. }
  2924. }
  2925. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2926. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2927. return -1;
  2928. }
  2929. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2930. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2931. return 0;
  2932. }
  2933. /*==========================================
  2934. * charunblock command (usage: charunblock <player_name>)
  2935. *------------------------------------------*/
  2936. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2937. {
  2938. nullpo_retr(-1, sd);
  2939. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2940. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2941. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  2942. return -1;
  2943. }
  2944. // send answer to login server via char-server
  2945. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2946. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2947. return 0;
  2948. }
  2949. /*==========================================
  2950. * charunban command (usage: charunban <player_name>)
  2951. *------------------------------------------*/
  2952. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2953. {
  2954. nullpo_retr(-1, sd);
  2955. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2956. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2957. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  2958. return -1;
  2959. }
  2960. // send answer to login server via char-server
  2961. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2962. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2963. return 0;
  2964. }
  2965. /*==========================================
  2966. *
  2967. *------------------------------------------*/
  2968. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2969. {
  2970. nullpo_retr(-1, sd);
  2971. if (night_flag != 1) {
  2972. map_night_timer(night_timer_tid, 0, 0, 1);
  2973. } else {
  2974. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  2975. return -1;
  2976. }
  2977. return 0;
  2978. }
  2979. /*==========================================
  2980. *
  2981. *------------------------------------------*/
  2982. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2983. {
  2984. nullpo_retr(-1, sd);
  2985. if (night_flag != 0) {
  2986. map_day_timer(day_timer_tid, 0, 0, 1);
  2987. } else {
  2988. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  2989. return -1;
  2990. }
  2991. return 0;
  2992. }
  2993. /*==========================================
  2994. *
  2995. *------------------------------------------*/
  2996. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2997. {
  2998. struct map_session_data* pl_sd;
  2999. struct s_mapiterator* iter;
  3000. nullpo_retr(-1, sd);
  3001. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  3002. iter = mapit_getallusers();
  3003. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3004. {
  3005. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3006. {
  3007. status_kill(&pl_sd->bl);
  3008. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3009. }
  3010. }
  3011. mapit_free(iter);
  3012. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3013. return 0;
  3014. }
  3015. /*==========================================
  3016. *
  3017. *------------------------------------------*/
  3018. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3019. {
  3020. struct map_session_data* pl_sd;
  3021. struct s_mapiterator* iter;
  3022. nullpo_retr(-1, sd);
  3023. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  3024. iter = mapit_getallusers();
  3025. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3026. {
  3027. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3028. {
  3029. status_kill(&pl_sd->bl);
  3030. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3031. }
  3032. }
  3033. mapit_free(iter);
  3034. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3035. return 0;
  3036. }
  3037. /*==========================================
  3038. *
  3039. *------------------------------------------*/
  3040. static void atcommand_raise_sub(struct map_session_data* sd)
  3041. {
  3042. if (!status_isdead(&sd->bl))
  3043. return;
  3044. if(!status_revive(&sd->bl, 100, 100))
  3045. return;
  3046. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3047. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3048. }
  3049. /*==========================================
  3050. *
  3051. *------------------------------------------*/
  3052. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3053. {
  3054. struct map_session_data* pl_sd;
  3055. struct s_mapiterator* iter;
  3056. nullpo_retr(-1, sd);
  3057. iter = mapit_getallusers();
  3058. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3059. atcommand_raise_sub(pl_sd);
  3060. mapit_free(iter);
  3061. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3062. return 0;
  3063. }
  3064. /*==========================================
  3065. *
  3066. *------------------------------------------*/
  3067. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3068. {
  3069. struct map_session_data* pl_sd;
  3070. struct s_mapiterator* iter;
  3071. nullpo_retr(-1, sd);
  3072. iter = mapit_getallusers();
  3073. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3074. if (sd->bl.m == pl_sd->bl.m)
  3075. atcommand_raise_sub(pl_sd);
  3076. mapit_free(iter);
  3077. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3078. return 0;
  3079. }
  3080. /*==========================================
  3081. *
  3082. *------------------------------------------*/
  3083. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3084. {
  3085. struct map_session_data *pl_sd;
  3086. nullpo_retr(-1, sd);
  3087. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3088. if (!message || !*message) {
  3089. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3090. return -1;
  3091. }
  3092. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3093. {
  3094. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3095. return -1;
  3096. }
  3097. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3098. {
  3099. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3100. return -1;
  3101. }
  3102. clif_GM_kick(sd, pl_sd);
  3103. return 0;
  3104. }
  3105. /*==========================================
  3106. *
  3107. *------------------------------------------*/
  3108. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3109. {
  3110. struct map_session_data* pl_sd;
  3111. struct s_mapiterator* iter;
  3112. nullpo_retr(-1, sd);
  3113. iter = mapit_getallusers();
  3114. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3115. {
  3116. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3117. if (sd->status.account_id != pl_sd->status.account_id)
  3118. clif_GM_kick(NULL, pl_sd);
  3119. }
  3120. }
  3121. mapit_free(iter);
  3122. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3123. return 0;
  3124. }
  3125. /*==========================================
  3126. *
  3127. *------------------------------------------*/
  3128. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3129. {
  3130. nullpo_retr(-1, sd);
  3131. pc_allskillup(sd); // all skills
  3132. sd->status.skill_point = 0; // 0 skill points
  3133. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3134. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3135. return 0;
  3136. }
  3137. /*==========================================
  3138. *
  3139. *------------------------------------------*/
  3140. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3141. {
  3142. int skill_id;
  3143. nullpo_retr(-1, sd);
  3144. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3145. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3146. return -1;
  3147. }
  3148. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3149. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3150. return -1;
  3151. }
  3152. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3153. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3154. return -1;
  3155. }
  3156. if (pc_checkskill(sd, skill_id) > 0) {
  3157. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3158. return -1;
  3159. }
  3160. pc_skill(sd, skill_id, 1, 0);
  3161. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3162. return 0;
  3163. }
  3164. /*==========================================
  3165. *
  3166. *------------------------------------------*/
  3167. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3168. {
  3169. int skill_id;
  3170. nullpo_retr(-1, sd);
  3171. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3172. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3173. return -1;
  3174. }
  3175. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3176. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3177. return -1;
  3178. }
  3179. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3180. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3181. return -1;
  3182. }
  3183. if (pc_checkskill(sd, skill_id) == 0) {
  3184. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3185. return -1;
  3186. }
  3187. sd->status.skill[skill_id].lv = 0;
  3188. sd->status.skill[skill_id].flag = 0;
  3189. clif_skillinfoblock(sd);
  3190. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3191. return 0;
  3192. }
  3193. /*==========================================
  3194. *
  3195. *------------------------------------------*/
  3196. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3197. {
  3198. int number;
  3199. nullpo_retr(-1, sd);
  3200. if (!message || !*message || (number = atoi(message)) < 0) {
  3201. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  3202. return -1;
  3203. }
  3204. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  3205. if (number > 500)
  3206. number = 500;
  3207. if (number >= 0 && number <= 0x7FFF) {
  3208. if (sd->spiritball != number || number > 499) {
  3209. if (sd->spiritball > 0)
  3210. pc_delspiritball(sd, sd->spiritball, 1);
  3211. sd->spiritball = number;
  3212. clif_spiritball(sd);
  3213. // no message, player can look the difference
  3214. if (number > 1000)
  3215. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  3216. } else {
  3217. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  3218. return -1;
  3219. }
  3220. } else {
  3221. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3222. return -1;
  3223. }
  3224. return 0;
  3225. }
  3226. /*==========================================
  3227. *
  3228. *------------------------------------------*/
  3229. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3230. {
  3231. char party[NAME_LENGTH];
  3232. nullpo_retr(-1, sd);
  3233. memset(party, '\0', sizeof(party));
  3234. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3235. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3236. return -1;
  3237. }
  3238. party_create(sd, party, 0, 0);
  3239. return 0;
  3240. }
  3241. /*==========================================
  3242. *
  3243. *------------------------------------------*/
  3244. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3245. {
  3246. char guild[NAME_LENGTH];
  3247. int prev;
  3248. nullpo_retr(-1, sd);
  3249. memset(guild, '\0', sizeof(guild));
  3250. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3251. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3252. return -1;
  3253. }
  3254. prev = battle_config.guild_emperium_check;
  3255. battle_config.guild_emperium_check = 0;
  3256. guild_create(sd, guild);
  3257. battle_config.guild_emperium_check = prev;
  3258. return 0;
  3259. }
  3260. /*==========================================
  3261. *
  3262. *------------------------------------------*/
  3263. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3264. {
  3265. nullpo_retr(-1, sd);
  3266. if (agit_flag == 1) {
  3267. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3268. return -1;
  3269. }
  3270. agit_flag = 1;
  3271. guild_agit_start();
  3272. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3273. return 0;
  3274. }
  3275. /*==========================================
  3276. *
  3277. *------------------------------------------*/
  3278. int atcommand_agitstart2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3279. {
  3280. nullpo_retr(-1, sd);
  3281. if (agit2_flag == 1) {
  3282. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3283. return -1;
  3284. }
  3285. agit2_flag = 1;
  3286. guild_agit2_start();
  3287. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3288. return 0;
  3289. }
  3290. /*==========================================
  3291. *
  3292. *------------------------------------------*/
  3293. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3294. {
  3295. nullpo_retr(-1, sd);
  3296. if (agit_flag == 0) {
  3297. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3298. return -1;
  3299. }
  3300. agit_flag = 0;
  3301. guild_agit_end();
  3302. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3303. return 0;
  3304. }
  3305. /*==========================================
  3306. *
  3307. *------------------------------------------*/
  3308. int atcommand_agitend2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3309. {
  3310. nullpo_retr(-1, sd);
  3311. if (agit2_flag == 0) {
  3312. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3313. return -1;
  3314. }
  3315. agit2_flag = 0;
  3316. guild_agit2_end();
  3317. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3318. return 0;
  3319. }
  3320. /*==========================================
  3321. * @mapexit - shuts down the map server
  3322. *------------------------------------------*/
  3323. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3324. {
  3325. struct map_session_data* pl_sd;
  3326. struct s_mapiterator* iter;
  3327. nullpo_retr(-1, sd);
  3328. iter = mapit_getallusers();
  3329. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3330. if (sd->status.account_id != pl_sd->status.account_id)
  3331. clif_GM_kick(NULL, pl_sd);
  3332. mapit_free(iter);
  3333. clif_GM_kick(NULL, sd);
  3334. flush_fifos();
  3335. runflag = 0;
  3336. return 0;
  3337. }
  3338. /*==========================================
  3339. * idsearch <part_of_name>: revrited by [Yor]
  3340. *------------------------------------------*/
  3341. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3342. {
  3343. char item_name[100];
  3344. unsigned int i, match;
  3345. struct item_data *item_array[MAX_SEARCH];
  3346. nullpo_retr(-1, sd);
  3347. memset(item_name, '\0', sizeof(item_name));
  3348. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3349. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3350. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3351. return -1;
  3352. }
  3353. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3354. clif_displaymessage(fd, atcmd_output);
  3355. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3356. if (match > MAX_SEARCH) {
  3357. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3358. clif_displaymessage(fd, atcmd_output);
  3359. match = MAX_SEARCH;
  3360. }
  3361. for(i = 0; i < match; i++) {
  3362. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3363. clif_displaymessage(fd, atcmd_output);
  3364. }
  3365. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3366. clif_displaymessage(fd, atcmd_output);
  3367. return 0;
  3368. }
  3369. /*==========================================
  3370. * Recall All Characters Online To Your Location
  3371. *------------------------------------------*/
  3372. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3373. {
  3374. struct map_session_data* pl_sd;
  3375. struct s_mapiterator* iter;
  3376. int count;
  3377. nullpo_retr(-1, sd);
  3378. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3379. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3380. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3381. return -1;
  3382. }
  3383. count = 0;
  3384. iter = mapit_getallusers();
  3385. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3386. {
  3387. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3388. {
  3389. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3390. count++;
  3391. else {
  3392. if (pc_isdead(pl_sd)) { //Wake them up
  3393. pc_setstand(pl_sd);
  3394. pc_setrestartvalue(pl_sd,1);
  3395. }
  3396. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3397. }
  3398. }
  3399. }
  3400. mapit_free(iter);
  3401. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3402. if (count) {
  3403. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3404. clif_displaymessage(fd, atcmd_output);
  3405. }
  3406. return 0;
  3407. }
  3408. /*==========================================
  3409. * Recall online characters of a guild to your location
  3410. *------------------------------------------*/
  3411. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3412. {
  3413. struct map_session_data* pl_sd;
  3414. struct s_mapiterator* iter;
  3415. int count;
  3416. char guild_name[NAME_LENGTH];
  3417. struct guild *g;
  3418. nullpo_retr(-1, sd);
  3419. memset(guild_name, '\0', sizeof(guild_name));
  3420. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3421. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3422. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3423. return -1;
  3424. }
  3425. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3426. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3427. return -1;
  3428. }
  3429. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3430. (g = guild_search(atoi(message))) == NULL)
  3431. {
  3432. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3433. return -1;
  3434. }
  3435. count = 0;
  3436. iter = mapit_getallusers();
  3437. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3438. {
  3439. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3440. {
  3441. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3442. continue; //Skip GMs greater than you.
  3443. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3444. count++;
  3445. else
  3446. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3447. }
  3448. }
  3449. mapit_free(iter);
  3450. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3451. clif_displaymessage(fd, atcmd_output);
  3452. if (count) {
  3453. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3454. clif_displaymessage(fd, atcmd_output);
  3455. }
  3456. return 0;
  3457. }
  3458. /*==========================================
  3459. * Recall online characters of a party to your location
  3460. *------------------------------------------*/
  3461. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3462. {
  3463. struct map_session_data* pl_sd;
  3464. struct s_mapiterator* iter;
  3465. char party_name[NAME_LENGTH];
  3466. struct party_data *p;
  3467. int count;
  3468. nullpo_retr(-1, sd);
  3469. memset(party_name, '\0', sizeof(party_name));
  3470. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3471. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3472. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3473. return -1;
  3474. }
  3475. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3476. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3477. return -1;
  3478. }
  3479. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3480. (p = party_search(atoi(message))) == NULL)
  3481. {
  3482. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3483. return -1;
  3484. }
  3485. count = 0;
  3486. iter = mapit_getallusers();
  3487. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3488. {
  3489. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3490. {
  3491. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3492. continue; //Skip GMs greater than you.
  3493. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3494. count++;
  3495. else
  3496. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3497. }
  3498. }
  3499. mapit_free(iter);
  3500. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3501. clif_displaymessage(fd, atcmd_output);
  3502. if (count) {
  3503. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3504. clif_displaymessage(fd, atcmd_output);
  3505. }
  3506. return 0;
  3507. }
  3508. /*==========================================
  3509. *
  3510. *------------------------------------------*/
  3511. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3512. {
  3513. nullpo_retr(-1, sd);
  3514. itemdb_reload();
  3515. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3516. return 0;
  3517. }
  3518. /*==========================================
  3519. *
  3520. *------------------------------------------*/
  3521. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3522. {
  3523. nullpo_retr(-1, sd);
  3524. mob_reload();
  3525. read_petdb();
  3526. merc_reload();
  3527. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3528. return 0;
  3529. }
  3530. /*==========================================
  3531. *
  3532. *------------------------------------------*/
  3533. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3534. {
  3535. nullpo_retr(-1, sd);
  3536. skill_reload();
  3537. merc_skill_reload();
  3538. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3539. return 0;
  3540. }
  3541. /*==========================================
  3542. * @reloadatcommand - reloads atcommand_athena.conf
  3543. *------------------------------------------*/
  3544. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3545. {
  3546. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  3547. clif_displaymessage(fd, msg_txt(254));
  3548. return 0;
  3549. }
  3550. /*==========================================
  3551. * @reloadbattleconf - reloads battle_athena.conf
  3552. *------------------------------------------*/
  3553. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3554. {
  3555. struct Battle_Config prev_config;
  3556. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3557. battle_config_read(BATTLE_CONF_FILENAME);
  3558. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3559. || prev_config.item_rate_common != battle_config.item_rate_common
  3560. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3561. || prev_config.item_rate_card != battle_config.item_rate_card
  3562. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3563. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3564. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3565. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3566. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3567. || prev_config.item_rate_use != battle_config.item_rate_use
  3568. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3569. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3570. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3571. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3572. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3573. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3574. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3575. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3576. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3577. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3578. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3579. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3580. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3581. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3582. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3583. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3584. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3585. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3586. )
  3587. { //Drop rates changed.
  3588. mob_reload(); //Needed as well so rate changes take effect.
  3589. #ifndef TXT_ONLY
  3590. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3591. #endif
  3592. }
  3593. clif_displaymessage(fd, msg_txt(255));
  3594. return 0;
  3595. }
  3596. /*==========================================
  3597. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3598. *------------------------------------------*/
  3599. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3600. {
  3601. status_readdb();
  3602. clif_displaymessage(fd, msg_txt(256));
  3603. return 0;
  3604. }
  3605. /*==========================================
  3606. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3607. *------------------------------------------*/
  3608. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3609. {
  3610. pc_readdb();
  3611. clif_displaymessage(fd, msg_txt(257));
  3612. return 0;
  3613. }
  3614. /*==========================================
  3615. * @reloadmotd - reloads motd.txt
  3616. *------------------------------------------*/
  3617. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3618. {
  3619. pc_read_motd();
  3620. clif_displaymessage(fd, msg_txt(268));
  3621. return 0;
  3622. }
  3623. /*==========================================
  3624. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3625. *------------------------------------------*/
  3626. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3627. {
  3628. nullpo_retr(-1, sd);
  3629. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3630. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3631. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3632. flush_fifos();
  3633. script_reload();
  3634. npc_reload();
  3635. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3636. return 0;
  3637. }
  3638. /*==========================================
  3639. * @mapinfo <map name> [0-3] by MC_Cameri
  3640. * => Shows information about the map [map name]
  3641. * 0 = no additional information
  3642. * 1 = Show users in that map and their location
  3643. * 2 = Shows NPCs in that map
  3644. * 3 = Shows the shops/chats in that map (not implemented)
  3645. *------------------------------------------*/
  3646. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3647. {
  3648. struct map_session_data* pl_sd;
  3649. struct s_mapiterator* iter;
  3650. struct npc_data *nd = NULL;
  3651. struct chat_data *cd = NULL;
  3652. char direction[12];
  3653. int i, m_id, chat_num, list = 0;
  3654. unsigned short m_index;
  3655. char mapname[24];
  3656. nullpo_retr(-1, sd);
  3657. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3658. memset(mapname, '\0', sizeof(mapname));
  3659. memset(direction, '\0', sizeof(direction));
  3660. sscanf(message, "%d %23[^\n]", &list, mapname);
  3661. if (list < 0 || list > 3) {
  3662. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3663. return -1;
  3664. }
  3665. if (mapname[0] == '\0') {
  3666. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3667. m_id = map_mapindex2mapid(sd->mapindex);
  3668. } else {
  3669. m_id = map_mapname2mapid(mapname);
  3670. }
  3671. if (m_id < 0) {
  3672. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3673. return -1;
  3674. }
  3675. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3676. clif_displaymessage(fd, "------ Map Info ------");
  3677. // count chats (for initial message)
  3678. chat_num = 0;
  3679. iter = mapit_getallusers();
  3680. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3681. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3682. chat_num++;
  3683. mapit_free(iter);
  3684. 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);
  3685. clif_displaymessage(fd, atcmd_output);
  3686. clif_displaymessage(fd, "------ Map Flags ------");
  3687. strcpy(atcmd_output,"PvP Flags: ");
  3688. if (map[m_id].flag.pvp)
  3689. strcat(atcmd_output, "Pvp ON | ");
  3690. if (map[m_id].flag.pvp_noguild)
  3691. strcat(atcmd_output, "NoGuild | ");
  3692. if (map[m_id].flag.pvp_noparty)
  3693. strcat(atcmd_output, "NoParty | ");
  3694. if (map[m_id].flag.pvp_nightmaredrop)
  3695. strcat(atcmd_output, "NightmareDrop | ");
  3696. if (map[m_id].flag.pvp_nocalcrank)
  3697. strcat(atcmd_output, "NoCalcRank | ");
  3698. clif_displaymessage(fd, atcmd_output);
  3699. strcpy(atcmd_output,"GvG Flags: ");
  3700. if (map[m_id].flag.gvg)
  3701. strcat(atcmd_output, "GvG ON | ");
  3702. if (map[m_id].flag.gvg_dungeon)
  3703. strcat(atcmd_output, "GvG Dungeon | ");
  3704. if (map[m_id].flag.gvg_castle)
  3705. strcat(atcmd_output, "GvG Castle | ");
  3706. if (map[m_id].flag.gvg_noparty)
  3707. strcat(atcmd_output, "NoParty | ");
  3708. clif_displaymessage(fd, atcmd_output);
  3709. strcpy(atcmd_output,"Teleport Flags: ");
  3710. if (map[m_id].flag.noteleport)
  3711. strcat(atcmd_output, "NoTeleport | ");
  3712. if (map[m_id].flag.monster_noteleport)
  3713. strcat(atcmd_output, "Monster NoTeleport | ");
  3714. if (map[m_id].flag.nowarp)
  3715. strcat(atcmd_output, "NoWarp | ");
  3716. if (map[m_id].flag.nowarpto)
  3717. strcat(atcmd_output, "NoWarpTo | ");
  3718. if (map[m_id].flag.noreturn)
  3719. strcat(atcmd_output, "NoReturn | ");
  3720. if (map[m_id].flag.nogo)
  3721. strcat(atcmd_output, "NoGo | ");
  3722. if (map[m_id].flag.nomemo)
  3723. strcat(atcmd_output, "NoMemo | ");
  3724. clif_displaymessage(fd, atcmd_output);
  3725. 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");
  3726. clif_displaymessage(fd, atcmd_output);
  3727. if (map[m_id].flag.nosave) {
  3728. if (!map[m_id].save.map)
  3729. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3730. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3731. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3732. else
  3733. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3734. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3735. clif_displaymessage(fd, atcmd_output);
  3736. }
  3737. strcpy(atcmd_output,"Weather Flags: ");
  3738. if (map[m_id].flag.snow)
  3739. strcat(atcmd_output, "Snow | ");
  3740. if (map[m_id].flag.fog)
  3741. strcat(atcmd_output, "Fog | ");
  3742. if (map[m_id].flag.sakura)
  3743. strcat(atcmd_output, "Sakura | ");
  3744. if (map[m_id].flag.clouds)
  3745. strcat(atcmd_output, "Clouds | ");
  3746. if (map[m_id].flag.clouds2)
  3747. strcat(atcmd_output, "Clouds2 | ");
  3748. if (map[m_id].flag.fireworks)
  3749. strcat(atcmd_output, "Fireworks | ");
  3750. if (map[m_id].flag.leaves)
  3751. strcat(atcmd_output, "Leaves | ");
  3752. if (map[m_id].flag.rain)
  3753. strcat(atcmd_output, "Rain | ");
  3754. if (map[m_id].flag.indoors)
  3755. strcat(atcmd_output, "Indoors | ");
  3756. if (map[m_id].flag.nightenabled)
  3757. strcat(atcmd_output, "Displays Night | ");
  3758. clif_displaymessage(fd, atcmd_output);
  3759. strcpy(atcmd_output,"Other Flags: ");
  3760. if (map[m_id].flag.nobranch)
  3761. strcat(atcmd_output, "NoBranch | ");
  3762. if (map[m_id].flag.notrade)
  3763. strcat(atcmd_output, "NoTrade | ");
  3764. if (map[m_id].flag.novending)
  3765. strcat(atcmd_output, "NoVending | ");
  3766. if (map[m_id].flag.nodrop)
  3767. strcat(atcmd_output, "NoDrop | ");
  3768. if (map[m_id].flag.noskill)
  3769. strcat(atcmd_output, "NoSkill | ");
  3770. if (map[m_id].flag.noicewall)
  3771. strcat(atcmd_output, "NoIcewall | ");
  3772. clif_displaymessage(fd, atcmd_output);
  3773. strcpy(atcmd_output,"Other Flags: ");
  3774. if (map[m_id].nocommand)
  3775. strcat(atcmd_output, "NoCommand | ");
  3776. if (map[m_id].flag.nobaseexp)
  3777. strcat(atcmd_output, "NoBaseEXP | ");
  3778. if (map[m_id].flag.nojobexp)
  3779. strcat(atcmd_output, "NoJobEXP | ");
  3780. if (map[m_id].flag.nomobloot)
  3781. strcat(atcmd_output, "NoMobLoot | ");
  3782. if (map[m_id].flag.nomvploot)
  3783. strcat(atcmd_output, "NoMVPLoot | ");
  3784. if (map[m_id].flag.partylock)
  3785. strcat(atcmd_output, "PartyLock | ");
  3786. if (map[m_id].flag.guildlock)
  3787. strcat(atcmd_output, "GuildLock | ");
  3788. clif_displaymessage(fd, atcmd_output);
  3789. switch (list) {
  3790. case 0:
  3791. // Do nothing. It's list 0, no additional display.
  3792. break;
  3793. case 1:
  3794. clif_displaymessage(fd, "----- Players in Map -----");
  3795. iter = mapit_getallusers();
  3796. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3797. {
  3798. if (pl_sd->mapindex == m_index) {
  3799. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3800. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3801. clif_displaymessage(fd, atcmd_output);
  3802. }
  3803. }
  3804. mapit_free(iter);
  3805. break;
  3806. case 2:
  3807. clif_displaymessage(fd, "----- NPCs in Map -----");
  3808. for (i = 0; i < map[m_id].npc_num;)
  3809. {
  3810. nd = map[m_id].npc[i];
  3811. switch(nd->ud.dir) {
  3812. case 0: strcpy(direction, "North"); break;
  3813. case 1: strcpy(direction, "North West"); break;
  3814. case 2: strcpy(direction, "West"); break;
  3815. case 3: strcpy(direction, "South West"); break;
  3816. case 4: strcpy(direction, "South"); break;
  3817. case 5: strcpy(direction, "South East"); break;
  3818. case 6: strcpy(direction, "East"); break;
  3819. case 7: strcpy(direction, "North East"); break;
  3820. case 9: strcpy(direction, "North"); break;
  3821. default: strcpy(direction, "Unknown"); break;
  3822. }
  3823. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3824. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3825. clif_displaymessage(fd, atcmd_output);
  3826. }
  3827. break;
  3828. case 3:
  3829. clif_displaymessage(fd, "----- Chats in Map -----");
  3830. iter = mapit_getallusers();
  3831. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3832. {
  3833. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3834. pl_sd->mapindex == m_index &&
  3835. cd->usersd[0] == pl_sd)
  3836. {
  3837. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  3838. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3839. clif_displaymessage(fd, atcmd_output);
  3840. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3841. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3842. clif_displaymessage(fd, atcmd_output);
  3843. }
  3844. }
  3845. mapit_free(iter);
  3846. break;
  3847. default: // normally impossible to arrive here
  3848. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3849. return -1;
  3850. break;
  3851. }
  3852. return 0;
  3853. }
  3854. /*==========================================
  3855. *
  3856. *------------------------------------------*/
  3857. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3858. {
  3859. nullpo_retr(-1, sd);
  3860. if (!pc_isriding(sd)) { // if actually no peco
  3861. if (!pc_checkskill(sd, KN_RIDING))
  3862. {
  3863. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  3864. return -1;
  3865. }
  3866. if (sd->disguise)
  3867. {
  3868. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  3869. return -1;
  3870. }
  3871. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3872. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  3873. } else { //Dismount
  3874. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3875. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  3876. }
  3877. return 0;
  3878. }
  3879. /*==========================================
  3880. *Spy Commands by Syrus22
  3881. *------------------------------------------*/
  3882. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3883. {
  3884. char guild_name[NAME_LENGTH];
  3885. struct guild *g;
  3886. nullpo_retr(-1, sd);
  3887. memset(guild_name, '\0', sizeof(guild_name));
  3888. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3889. if (!enable_spy)
  3890. {
  3891. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3892. return -1;
  3893. }
  3894. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3895. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3896. return -1;
  3897. }
  3898. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3899. (g = guild_search(atoi(message))) != NULL) {
  3900. if (sd->guildspy == g->guild_id) {
  3901. sd->guildspy = 0;
  3902. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3903. clif_displaymessage(fd, atcmd_output);
  3904. } else {
  3905. sd->guildspy = g->guild_id;
  3906. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3907. clif_displaymessage(fd, atcmd_output);
  3908. }
  3909. } else {
  3910. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  3911. return -1;
  3912. }
  3913. return 0;
  3914. }
  3915. /*==========================================
  3916. *
  3917. *------------------------------------------*/
  3918. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3919. {
  3920. char party_name[NAME_LENGTH];
  3921. struct party_data *p;
  3922. nullpo_retr(-1, sd);
  3923. memset(party_name, '\0', sizeof(party_name));
  3924. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3925. if (!enable_spy)
  3926. {
  3927. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3928. return -1;
  3929. }
  3930. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3931. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3932. return -1;
  3933. }
  3934. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3935. (p = party_search(atoi(message))) != NULL) {
  3936. if (sd->partyspy == p->party.party_id) {
  3937. sd->partyspy = 0;
  3938. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3939. clif_displaymessage(fd, atcmd_output);
  3940. } else {
  3941. sd->partyspy = p->party.party_id;
  3942. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3943. clif_displaymessage(fd, atcmd_output);
  3944. }
  3945. } else {
  3946. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  3947. return -1;
  3948. }
  3949. return 0;
  3950. }
  3951. /*==========================================
  3952. * @repairall [Valaris]
  3953. *------------------------------------------*/
  3954. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3955. {
  3956. int count, i;
  3957. nullpo_retr(-1, sd);
  3958. count = 0;
  3959. for (i = 0; i < MAX_INVENTORY; i++) {
  3960. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3961. sd->status.inventory[i].attribute = 0;
  3962. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3963. count++;
  3964. }
  3965. }
  3966. if (count > 0) {
  3967. clif_misceffect(&sd->bl, 3);
  3968. clif_equiplist(sd);
  3969. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3970. } else {
  3971. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3972. return -1;
  3973. }
  3974. return 0;
  3975. }
  3976. /*==========================================
  3977. * @nuke [Valaris]
  3978. *------------------------------------------*/
  3979. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3980. {
  3981. struct map_session_data *pl_sd;
  3982. nullpo_retr(-1, sd);
  3983. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3984. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3985. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  3986. return -1;
  3987. }
  3988. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3989. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  3990. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3991. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3992. } else {
  3993. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3994. return -1;
  3995. }
  3996. } else {
  3997. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3998. return -1;
  3999. }
  4000. return 0;
  4001. }
  4002. /*==========================================
  4003. * @tonpc
  4004. *------------------------------------------*/
  4005. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4006. {
  4007. char npcname[NAME_LENGTH];
  4008. struct npc_data *nd;
  4009. nullpo_retr(-1, sd);
  4010. memset(npcname, 0, sizeof(npcname));
  4011. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4012. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4013. return -1;
  4014. }
  4015. if ((nd = npc_name2id(npcname)) != NULL) {
  4016. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
  4017. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4018. else
  4019. return -1;
  4020. } else {
  4021. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4022. return -1;
  4023. }
  4024. return 0;
  4025. }
  4026. /*==========================================
  4027. *
  4028. *------------------------------------------*/
  4029. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4030. {
  4031. char NPCname[NAME_LENGTH];
  4032. nullpo_retr(-1, sd);
  4033. memset(NPCname, '\0', sizeof(NPCname));
  4034. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4035. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4036. return -1;
  4037. }
  4038. if (npc_name2id(NPCname) != NULL) {
  4039. npc_enable(NPCname, 1);
  4040. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4041. } else {
  4042. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4043. return -1;
  4044. }
  4045. return 0;
  4046. }
  4047. /*==========================================
  4048. *
  4049. *------------------------------------------*/
  4050. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4051. {
  4052. char NPCname[NAME_LENGTH];
  4053. nullpo_retr(-1, sd);
  4054. memset(NPCname, '\0', sizeof(NPCname));
  4055. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4056. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4057. return -1;
  4058. }
  4059. if (npc_name2id(NPCname) == NULL) {
  4060. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4061. return -1;
  4062. }
  4063. npc_enable(NPCname, 0);
  4064. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4065. return 0;
  4066. }
  4067. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4068. {
  4069. FILE *fp;
  4070. if (!message || !*message) {
  4071. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4072. return -1;
  4073. }
  4074. // check if script file exists
  4075. if ((fp = fopen(message, "r")) == NULL) {
  4076. clif_displaymessage(fd, msg_txt(261));
  4077. return -1;
  4078. }
  4079. fclose(fp);
  4080. // add to list of script sources and run it
  4081. npc_addsrcfile(message);
  4082. npc_parsesrcfile(message);
  4083. npc_read_event_script();
  4084. clif_displaymessage(fd, msg_txt(262));
  4085. return 0;
  4086. }
  4087. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4088. {
  4089. struct npc_data *nd;
  4090. char NPCname[NAME_LENGTH];
  4091. nullpo_retr(-1, sd);
  4092. memset(NPCname, '\0', sizeof(NPCname));
  4093. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4094. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4095. return -1;
  4096. }
  4097. if ((nd = npc_name2id(NPCname)) == NULL) {
  4098. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4099. return -1;
  4100. }
  4101. npc_unload_duplicates(nd);
  4102. npc_unload(nd);
  4103. npc_read_event_script();
  4104. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4105. return 0;
  4106. }
  4107. /*==========================================
  4108. * time in txt for time command (by [Yor])
  4109. *------------------------------------------*/
  4110. char* txt_time(unsigned int duration)
  4111. {
  4112. int days, hours, minutes, seconds;
  4113. char temp[256];
  4114. static char temp1[256];
  4115. memset(temp, '\0', sizeof(temp));
  4116. memset(temp1, '\0', sizeof(temp1));
  4117. days = duration / (60 * 60 * 24);
  4118. duration = duration - (60 * 60 * 24 * days);
  4119. hours = duration / (60 * 60);
  4120. duration = duration - (60 * 60 * hours);
  4121. minutes = duration / 60;
  4122. seconds = duration - (60 * minutes);
  4123. if (days < 2)
  4124. sprintf(temp, msg_txt(219), days); // %d day
  4125. else
  4126. sprintf(temp, msg_txt(220), days); // %d days
  4127. if (hours < 2)
  4128. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4129. else
  4130. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4131. if (minutes < 2)
  4132. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4133. else
  4134. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4135. if (seconds < 2)
  4136. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4137. else
  4138. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4139. return temp1;
  4140. }
  4141. /*==========================================
  4142. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4143. * Calculation management of GM modification (@day/@night GM commands) is done
  4144. *------------------------------------------*/
  4145. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4146. {
  4147. const struct TimerData * timer_data;
  4148. const struct TimerData * timer_data2;
  4149. time_t time_server; // variable for number of seconds (used with time() function)
  4150. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4151. char temp[256];
  4152. nullpo_retr(-1, sd);
  4153. memset(temp, '\0', sizeof(temp));
  4154. time(&time_server); // get time in seconds since 1/1/1970
  4155. datetime = localtime(&time_server); // convert seconds in structure
  4156. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4157. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4158. clif_displaymessage(fd, temp);
  4159. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4160. if (night_flag == 0)
  4161. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4162. else
  4163. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4164. } else if (battle_config.night_duration == 0)
  4165. if (night_flag == 1) { // we start with night
  4166. timer_data = get_timer(day_timer_tid);
  4167. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4168. clif_displaymessage(fd, temp);
  4169. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4170. } else
  4171. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4172. else if (battle_config.day_duration == 0)
  4173. if (night_flag == 0) { // we start with day
  4174. timer_data = get_timer(night_timer_tid);
  4175. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4176. clif_displaymessage(fd, temp);
  4177. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4178. } else
  4179. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4180. else {
  4181. if (night_flag == 0) {
  4182. timer_data = get_timer(night_timer_tid);
  4183. timer_data2 = get_timer(day_timer_tid);
  4184. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4185. clif_displaymessage(fd, temp);
  4186. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4187. 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.
  4188. else
  4189. 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.
  4190. clif_displaymessage(fd, temp);
  4191. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4192. clif_displaymessage(fd, temp);
  4193. } else {
  4194. timer_data = get_timer(day_timer_tid);
  4195. timer_data2 = get_timer(night_timer_tid);
  4196. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4197. clif_displaymessage(fd, temp);
  4198. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4199. 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.
  4200. else
  4201. 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.
  4202. clif_displaymessage(fd, temp);
  4203. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4204. clif_displaymessage(fd, temp);
  4205. }
  4206. }
  4207. return 0;
  4208. }
  4209. //Added by Coltaro
  4210. //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...).
  4211. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4212. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4213. {
  4214. const int factor_year = 518400; //12*30*24*60 = 518400
  4215. const int factor_month = 43200; //30*24*60 = 43200
  4216. const int factor_day = 1440; //24*60 = 1440
  4217. const int factor_hour = 60;
  4218. *year = jailtime/factor_year;
  4219. jailtime -= *year*factor_year;
  4220. *month = jailtime/factor_month;
  4221. jailtime -= *month*factor_month;
  4222. *day = jailtime/factor_day;
  4223. jailtime -= *day*factor_day;
  4224. *hour = jailtime/factor_hour;
  4225. jailtime -= *hour*factor_hour;
  4226. *minute = jailtime;
  4227. *year = *year > 0? *year : 0;
  4228. *month = *month > 0? *month : 0;
  4229. *day = *day > 0? *day : 0;
  4230. *hour = *hour > 0? *hour : 0;
  4231. *minute = *minute > 0? *minute : 0;
  4232. return;
  4233. }
  4234. /*==========================================
  4235. * @jail <char_name> by [Yor]
  4236. * Special warp! No check with nowarp and nowarpto flag
  4237. *------------------------------------------*/
  4238. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4239. {
  4240. struct map_session_data *pl_sd;
  4241. int x, y;
  4242. unsigned short m_index;
  4243. nullpo_retr(-1, sd);
  4244. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4245. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4246. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4247. return -1;
  4248. }
  4249. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4250. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4251. return -1;
  4252. }
  4253. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4254. { // you can jail only lower or same GM
  4255. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4256. return -1;
  4257. }
  4258. if (pl_sd->sc.data[SC_JAILED])
  4259. {
  4260. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4261. return -1;
  4262. }
  4263. switch(rand() % 2) { //Jail Locations
  4264. case 0:
  4265. m_index = mapindex_name2id(MAP_JAIL);
  4266. x = 24;
  4267. y = 75;
  4268. break;
  4269. default:
  4270. m_index = mapindex_name2id(MAP_JAIL);
  4271. x = 49;
  4272. y = 75;
  4273. break;
  4274. }
  4275. //Duration of INT_MAX to specify infinity.
  4276. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4277. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4278. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4279. return 0;
  4280. }
  4281. /*==========================================
  4282. * @unjail/@discharge <char_name> by [Yor]
  4283. * Special warp! No check with nowarp and nowarpto flag
  4284. *------------------------------------------*/
  4285. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4286. {
  4287. struct map_session_data *pl_sd;
  4288. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4289. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4290. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4291. return -1;
  4292. }
  4293. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4294. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4295. return -1;
  4296. }
  4297. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4298. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4299. return -1;
  4300. }
  4301. if (!pl_sd->sc.data[SC_JAILED])
  4302. {
  4303. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4304. return -1;
  4305. }
  4306. //Reset jail time to 1 sec.
  4307. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4308. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4309. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4310. return 0;
  4311. }
  4312. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4313. {
  4314. struct map_session_data *pl_sd = NULL;
  4315. int year, month, day, hour, minute, value;
  4316. char * modif_p;
  4317. int jailtime = 0,x,y;
  4318. short m_index = 0;
  4319. nullpo_retr(-1, sd);
  4320. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4321. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4322. return -1;
  4323. }
  4324. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4325. modif_p = atcmd_output;
  4326. year = month = day = hour = minute = 0;
  4327. while (modif_p[0] != '\0') {
  4328. value = atoi(modif_p);
  4329. if (value == 0)
  4330. modif_p++;
  4331. else {
  4332. if (modif_p[0] == '-' || modif_p[0] == '+')
  4333. modif_p++;
  4334. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4335. modif_p++;
  4336. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4337. minute = value;
  4338. modif_p = modif_p + 2;
  4339. } else if (modif_p[0] == 'h') {
  4340. hour = value;
  4341. modif_p++;
  4342. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4343. day = value;
  4344. modif_p++;
  4345. } else if (modif_p[0] == 'm') {
  4346. month = value;
  4347. modif_p++;
  4348. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4349. year = value;
  4350. modif_p++;
  4351. } else if (modif_p[0] != '\0') {
  4352. modif_p++;
  4353. }
  4354. }
  4355. }
  4356. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4357. clif_displaymessage(fd, "Invalid time for jail command.");
  4358. return -1;
  4359. }
  4360. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4361. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4362. return -1;
  4363. }
  4364. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4365. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4366. return -1;
  4367. }
  4368. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4369. if(jailtime==0) {
  4370. clif_displaymessage(fd, "Invalid time for jail command.");
  4371. return -1;
  4372. }
  4373. //Added by Coltaro
  4374. if(pl_sd->sc.data[SC_JAILED] &&
  4375. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4376. { //Update the player's jail time
  4377. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4378. if (jailtime <= 0) {
  4379. jailtime = 0;
  4380. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4381. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4382. } else {
  4383. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4384. 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
  4385. clif_displaymessage(pl_sd->fd, atcmd_output);
  4386. 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
  4387. clif_displaymessage(fd, atcmd_output);
  4388. }
  4389. } else if (jailtime < 0) {
  4390. clif_displaymessage(fd, "Invalid time for jail command.");
  4391. return -1;
  4392. }
  4393. //Jail locations, add more as you wish.
  4394. switch(rand()%2)
  4395. {
  4396. case 1: //Jail #1
  4397. m_index = mapindex_name2id(MAP_JAIL);
  4398. x = 49; y = 75;
  4399. break;
  4400. default: //Default Jail
  4401. m_index = mapindex_name2id(MAP_JAIL);
  4402. x = 24; y = 75;
  4403. break;
  4404. }
  4405. 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).
  4406. return 0;
  4407. }
  4408. //By Coltaro
  4409. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4410. {
  4411. int year, month, day, hour, minute;
  4412. nullpo_retr(-1, sd);
  4413. if (!sd->sc.data[SC_JAILED]) {
  4414. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4415. return -1;
  4416. }
  4417. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4418. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4419. return 0;
  4420. }
  4421. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4422. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4423. return -1;
  4424. }
  4425. //Get remaining jail time
  4426. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4427. 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
  4428. clif_displaymessage(fd, atcmd_output);
  4429. return 0;
  4430. }
  4431. /*==========================================
  4432. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4433. *------------------------------------------*/
  4434. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4435. {
  4436. int id = 0;
  4437. nullpo_retr(-1, sd);
  4438. if (!message || !*message) {
  4439. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4440. return -1;
  4441. }
  4442. if ((id = atoi(message)) > 0)
  4443. { //Acquired an ID
  4444. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4445. id = 0; //Invalid id for either mobs or npcs.
  4446. } else { //Acquired a Name
  4447. if ((id = mobdb_searchname(message)) == 0)
  4448. {
  4449. struct npc_data* nd = npc_name2id(message);
  4450. if (nd != NULL)
  4451. id = nd->class_;
  4452. }
  4453. }
  4454. if (id == 0)
  4455. {
  4456. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4457. return -1;
  4458. }
  4459. if(pc_isriding(sd))
  4460. {
  4461. //FIXME: wrong message [ultramage]
  4462. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4463. return -1;
  4464. }
  4465. pc_disguise(sd, id);
  4466. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4467. return 0;
  4468. }
  4469. /*==========================================
  4470. * DisguiseAll
  4471. *------------------------------------------*/
  4472. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4473. {
  4474. int mob_id=0;
  4475. struct map_session_data *pl_sd;
  4476. struct s_mapiterator* iter;
  4477. nullpo_retr(-1, sd);
  4478. if (!message || !*message) {
  4479. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4480. return -1;
  4481. }
  4482. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4483. mob_id = atoi(message);
  4484. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4485. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4486. return -1;
  4487. }
  4488. iter = mapit_getallusers();
  4489. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4490. pc_disguise(pl_sd, mob_id);
  4491. mapit_free(iter);
  4492. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4493. return 0;
  4494. }
  4495. /*==========================================
  4496. * @undisguise by [Yor]
  4497. *------------------------------------------*/
  4498. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4499. {
  4500. nullpo_retr(-1, sd);
  4501. if (sd->disguise) {
  4502. pc_disguise(sd, 0);
  4503. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4504. } else {
  4505. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4506. return -1;
  4507. }
  4508. return 0;
  4509. }
  4510. /*==========================================
  4511. * UndisguiseAll
  4512. *------------------------------------------*/
  4513. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4514. {
  4515. struct map_session_data *pl_sd;
  4516. struct s_mapiterator* iter;
  4517. nullpo_retr(-1, sd);
  4518. iter = mapit_getallusers();
  4519. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4520. if( pl_sd->disguise )
  4521. pc_disguise(pl_sd, 0);
  4522. mapit_free(iter);
  4523. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4524. return 0;
  4525. }
  4526. /*==========================================
  4527. * @exp by [Skotlex]
  4528. *------------------------------------------*/
  4529. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4530. {
  4531. char output[200];
  4532. double nextb, nextj;
  4533. nullpo_retr(-1, sd);
  4534. memset(output, '\0', sizeof(output));
  4535. nextb = pc_nextbaseexp(sd);
  4536. if (nextb)
  4537. nextb = sd->status.base_exp*100.0/nextb;
  4538. nextj = pc_nextjobexp(sd);
  4539. if (nextj)
  4540. nextj = sd->status.job_exp*100.0/nextj;
  4541. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4542. clif_displaymessage(fd, output);
  4543. return 0;
  4544. }
  4545. /*==========================================
  4546. * @broadcast by [Valaris]
  4547. *------------------------------------------*/
  4548. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4549. {
  4550. nullpo_retr(-1, sd);
  4551. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4552. if (!message || !*message) {
  4553. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4554. return -1;
  4555. }
  4556. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4557. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  4558. return 0;
  4559. }
  4560. /*==========================================
  4561. * @localbroadcast by [Valaris]
  4562. *------------------------------------------*/
  4563. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4564. {
  4565. nullpo_retr(-1, sd);
  4566. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4567. if (!message || !*message) {
  4568. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4569. return -1;
  4570. }
  4571. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4572. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  4573. return 0;
  4574. }
  4575. /*==========================================
  4576. * @email <actual@email> <new@email> by [Yor]
  4577. *------------------------------------------*/
  4578. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4579. {
  4580. char actual_email[100];
  4581. char new_email[100];
  4582. nullpo_retr(-1, sd);
  4583. memset(actual_email, '\0', sizeof(actual_email));
  4584. memset(new_email, '\0', sizeof(new_email));
  4585. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4586. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4587. return -1;
  4588. }
  4589. if (e_mail_check(actual_email) == 0) {
  4590. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4591. return -1;
  4592. } else if (e_mail_check(new_email) == 0) {
  4593. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4594. return -1;
  4595. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4596. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4597. return -1;
  4598. } else if (strcmpi(actual_email, new_email) == 0) {
  4599. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4600. return -1;
  4601. }
  4602. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4603. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4604. return 0;
  4605. }
  4606. /*==========================================
  4607. *@effect
  4608. *------------------------------------------*/
  4609. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4610. {
  4611. int type = 0, flag = 0;
  4612. nullpo_retr(-1, sd);
  4613. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4614. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4615. return -1;
  4616. }
  4617. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4618. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4619. return 0;
  4620. }
  4621. /*==========================================
  4622. * @killer by MouseJstr
  4623. * enable killing players even when not in pvp
  4624. *------------------------------------------*/
  4625. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4626. {
  4627. nullpo_retr(-1, sd);
  4628. sd->state.killer = !sd->state.killer;
  4629. if(sd->state.killer)
  4630. clif_displaymessage(fd, msg_txt(241));
  4631. else {
  4632. clif_displaymessage(fd, msg_txt(287));
  4633. pc_stop_attack(sd);
  4634. }
  4635. return 0;
  4636. }
  4637. /*==========================================
  4638. * @killable by MouseJstr
  4639. * enable other people killing you
  4640. *------------------------------------------*/
  4641. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4642. {
  4643. nullpo_retr(-1, sd);
  4644. sd->state.killable = !sd->state.killable;
  4645. if(sd->state.killable)
  4646. clif_displaymessage(fd, msg_txt(242));
  4647. else {
  4648. clif_displaymessage(fd, msg_txt(288));
  4649. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4650. }
  4651. return 0;
  4652. }
  4653. /*==========================================
  4654. * @skillon by MouseJstr
  4655. * turn skills on for the map
  4656. *------------------------------------------*/
  4657. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4658. {
  4659. nullpo_retr(-1, sd);
  4660. map[sd->bl.m].flag.noskill = 0;
  4661. clif_displaymessage(fd, msg_txt(244));
  4662. return 0;
  4663. }
  4664. /*==========================================
  4665. * @skilloff by MouseJstr
  4666. * Turn skills off on the map
  4667. *------------------------------------------*/
  4668. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4669. {
  4670. nullpo_retr(-1, sd);
  4671. map[sd->bl.m].flag.noskill = 1;
  4672. clif_displaymessage(fd, msg_txt(243));
  4673. return 0;
  4674. }
  4675. /*==========================================
  4676. * @npcmove by MouseJstr
  4677. * move a npc
  4678. *------------------------------------------*/
  4679. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4680. {
  4681. int x = 0, y = 0, m;
  4682. struct npc_data *nd = 0;
  4683. nullpo_retr(-1, sd);
  4684. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4685. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4686. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4687. return -1;
  4688. }
  4689. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4690. {
  4691. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4692. return -1;
  4693. }
  4694. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4695. {
  4696. clif_displaymessage(fd, "NPC is not on this map.");
  4697. return -1; //Not on a map.
  4698. }
  4699. x = cap_value(x, 0, map[m].xs-1);
  4700. y = cap_value(y, 0, map[m].ys-1);
  4701. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4702. map_moveblock(&nd->bl, x, y, gettick());
  4703. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4704. clif_displaymessage(fd, "NPC moved.");
  4705. return 0;
  4706. }
  4707. /*==========================================
  4708. * @addwarp by MouseJstr
  4709. * Create a new static warp point.
  4710. *------------------------------------------*/
  4711. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4712. {
  4713. char mapname[32];
  4714. int x,y;
  4715. unsigned short m;
  4716. struct npc_data* nd;
  4717. nullpo_retr(-1, sd);
  4718. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4719. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4720. return -1;
  4721. }
  4722. m = mapindex_name2id(mapname);
  4723. if( m == 0 )
  4724. {
  4725. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4726. clif_displaymessage(fd, atcmd_output);
  4727. return -1;
  4728. }
  4729. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4730. if( nd == NULL )
  4731. return -1;
  4732. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4733. clif_displaymessage(fd, atcmd_output);
  4734. return 0;
  4735. }
  4736. /*==========================================
  4737. * @follow by [MouseJstr]
  4738. * Follow a player .. staying no more then 5 spaces away
  4739. *------------------------------------------*/
  4740. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4741. {
  4742. struct map_session_data *pl_sd = NULL;
  4743. nullpo_retr(-1, sd);
  4744. if (!message || !*message) {
  4745. if (sd->followtarget == -1)
  4746. return -1;
  4747. pc_stop_following (sd);
  4748. clif_displaymessage(fd, "Follow mode OFF.");
  4749. return 0;
  4750. }
  4751. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4752. {
  4753. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4754. return -1;
  4755. }
  4756. if (sd->followtarget == pl_sd->bl.id) {
  4757. pc_stop_following (sd);
  4758. clif_displaymessage(fd, "Follow mode OFF.");
  4759. } else {
  4760. pc_follow(sd, pl_sd->bl.id);
  4761. clif_displaymessage(fd, "Follow mode ON.");
  4762. }
  4763. return 0;
  4764. }
  4765. /*==========================================
  4766. * @dropall by [MouseJstr]
  4767. * Drop all your possession on the ground
  4768. *------------------------------------------*/
  4769. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4770. {
  4771. int i;
  4772. nullpo_retr(-1, sd);
  4773. for (i = 0; i < MAX_INVENTORY; i++) {
  4774. if (sd->status.inventory[i].amount) {
  4775. if(sd->status.inventory[i].equip != 0)
  4776. pc_unequipitem(sd, i, 3);
  4777. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4778. }
  4779. }
  4780. return 0;
  4781. }
  4782. /*==========================================
  4783. * @storeall by [MouseJstr]
  4784. * Put everything into storage
  4785. *------------------------------------------*/
  4786. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4787. {
  4788. int i;
  4789. nullpo_retr(-1, sd);
  4790. if (sd->state.storage_flag != 1)
  4791. { //Open storage.
  4792. if( storage_storageopen(sd) == 1 ) {
  4793. clif_displaymessage(fd, "You can't open the storage currently.");
  4794. return -1;
  4795. }
  4796. }
  4797. for (i = 0; i < MAX_INVENTORY; i++) {
  4798. if (sd->status.inventory[i].amount) {
  4799. if(sd->status.inventory[i].equip != 0)
  4800. pc_unequipitem(sd, i, 3);
  4801. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4802. }
  4803. }
  4804. storage_storageclose(sd);
  4805. clif_displaymessage(fd, "It is done");
  4806. return 0;
  4807. }
  4808. /*==========================================
  4809. * @skillid by [MouseJstr]
  4810. * lookup a skill by name
  4811. *------------------------------------------*/
  4812. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4813. {
  4814. int skillen, idx;
  4815. nullpo_retr(-1, sd);
  4816. if (!message || !*message)
  4817. {
  4818. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4819. return -1;
  4820. }
  4821. skillen = strlen(message);
  4822. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4823. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4824. {
  4825. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4826. clif_displaymessage(fd, atcmd_output);
  4827. }
  4828. }
  4829. return 0;
  4830. }
  4831. /*==========================================
  4832. * @useskill by [MouseJstr]
  4833. * A way of using skills without having to find them in the skills menu
  4834. *------------------------------------------*/
  4835. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4836. {
  4837. struct map_session_data *pl_sd = NULL;
  4838. struct block_list *bl;
  4839. int skillnum;
  4840. int skilllv;
  4841. char target[100];
  4842. nullpo_retr(-1, sd);
  4843. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4844. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4845. return -1;
  4846. }
  4847. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4848. {
  4849. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4850. return -1;
  4851. }
  4852. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  4853. {
  4854. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4855. return -1;
  4856. }
  4857. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4858. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4859. bl = &sd->hd->bl;
  4860. else
  4861. bl = &sd->bl;
  4862. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4863. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4864. else
  4865. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4866. return 0;
  4867. }
  4868. /*==========================================
  4869. * @displayskill by [Skotlex]
  4870. * Debug command to locate new skill IDs. It sends the
  4871. * three possible skill-effect packets to the area.
  4872. *------------------------------------------*/
  4873. int atcommand_displayskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4874. {
  4875. struct status_data * status;
  4876. unsigned int tick;
  4877. int skillnum;
  4878. int skilllv = 1;
  4879. nullpo_retr(-1, sd);
  4880. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4881. {
  4882. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4883. return -1;
  4884. }
  4885. status = status_get_status_data(&sd->bl);
  4886. tick = gettick();
  4887. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4888. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4889. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4890. return 0;
  4891. }
  4892. /*==========================================
  4893. * @skilltree by [MouseJstr]
  4894. * prints the skill tree for a player required to get to a skill
  4895. *------------------------------------------*/
  4896. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4897. {
  4898. struct map_session_data *pl_sd = NULL;
  4899. int skillnum;
  4900. int meets, j, c=0;
  4901. char target[NAME_LENGTH], *tbl;
  4902. struct skill_tree_entry *ent;
  4903. nullpo_retr(-1, sd);
  4904. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4905. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4906. return -1;
  4907. }
  4908. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4909. {
  4910. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4911. return -1;
  4912. }
  4913. c = pc_calc_skilltree_normalize_job(pl_sd);
  4914. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4915. tbl = job_name(c);
  4916. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", tbl, pc_checkskill(pl_sd, 1));
  4917. clif_displaymessage(fd, atcmd_output);
  4918. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  4919. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4920. {
  4921. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4922. clif_displaymessage(fd, atcmd_output);
  4923. return 0;
  4924. }
  4925. ent = &skill_tree[c][j];
  4926. meets = 1;
  4927. for(j=0;j<5;j++)
  4928. {
  4929. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4930. {
  4931. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  4932. clif_displaymessage(fd, atcmd_output);
  4933. meets = 0;
  4934. }
  4935. }
  4936. if (meets == 1) {
  4937. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4938. clif_displaymessage(fd, atcmd_output);
  4939. }
  4940. return 0;
  4941. }
  4942. // Hand a ring with partners name on it to this char
  4943. void getring (struct map_session_data* sd)
  4944. {
  4945. int flag, item_id;
  4946. struct item item_tmp;
  4947. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4948. memset(&item_tmp, 0, sizeof(item_tmp));
  4949. item_tmp.nameid = item_id;
  4950. item_tmp.identify = 1;
  4951. item_tmp.card[0] = 255;
  4952. item_tmp.card[2] = sd->status.partner_id;
  4953. item_tmp.card[3] = sd->status.partner_id >> 16;
  4954. //Logs (A)dmins items [Lupus]
  4955. if(log_config.enable_logs&0x400)
  4956. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  4957. if((flag = pc_additem(sd,&item_tmp,1))) {
  4958. clif_additem(sd,0,0,flag);
  4959. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4960. }
  4961. }
  4962. /*==========================================
  4963. * @marry by [MouseJstr], fixed by Lupus
  4964. * Marry two players
  4965. *------------------------------------------*/
  4966. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4967. {
  4968. struct map_session_data *pl_sd1 = NULL;
  4969. struct map_session_data *pl_sd2 = NULL;
  4970. char player1[128], player2[128]; //Length used for return error msgs
  4971. nullpo_retr(-1, sd);
  4972. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  4973. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  4974. return -1;
  4975. }
  4976. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  4977. sprintf(player2, "Cannot find player '%s' online", player1);
  4978. clif_displaymessage(fd, player2);
  4979. return -1;
  4980. }
  4981. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  4982. sprintf(player1, "Cannot find player '%s' online", player2);
  4983. clif_displaymessage(fd, player1);
  4984. return -1;
  4985. }
  4986. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  4987. clif_displaymessage(fd, "They are married.. wish them well");
  4988. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  4989. // Auto-give named rings (Aru)
  4990. getring (pl_sd1);
  4991. getring (pl_sd2);
  4992. return 0;
  4993. }
  4994. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  4995. return -1;
  4996. }
  4997. /*==========================================
  4998. * @divorce by [MouseJstr], fixed by [Lupus]
  4999. * divorce two players
  5000. *------------------------------------------*/
  5001. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5002. {
  5003. struct map_session_data *pl_sd = NULL;
  5004. nullpo_retr(-1, sd);
  5005. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5006. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5007. return -1;
  5008. }
  5009. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5010. {
  5011. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5012. return -1;
  5013. }
  5014. if (pc_divorce(pl_sd) != 0) {
  5015. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5016. clif_displaymessage(fd, atcmd_output);
  5017. return -1;
  5018. }
  5019. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5020. clif_displaymessage(fd, atcmd_output);
  5021. return 0;
  5022. }
  5023. /*==========================================
  5024. * @changelook by [Celest]
  5025. *------------------------------------------*/
  5026. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5027. {
  5028. int i, j = 0, k = 0;
  5029. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5030. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5031. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5032. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5033. return -1;
  5034. } else if (i == 2) {
  5035. if (j < 1) j = 1;
  5036. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5037. j = pos[j - 1];
  5038. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5039. k = j; // swap
  5040. j = LOOK_HEAD_TOP;
  5041. }
  5042. clif_changelook(&sd->bl,j,k);
  5043. return 0;
  5044. }
  5045. /*==========================================
  5046. * @autotrade by durf (changed by Lupus)
  5047. * Turns on/off Autotrade for a specific player
  5048. *------------------------------------------*/
  5049. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5050. {
  5051. nullpo_retr(-1, sd);
  5052. if( sd->vender_id ) //check if player's vending
  5053. {
  5054. if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
  5055. {
  5056. sd->state.autotrade = 1;
  5057. if( battle_config.at_timeout )
  5058. {
  5059. int timeout = atoi(message);
  5060. 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);
  5061. }
  5062. clif_authfail_fd(fd, 15);
  5063. } else
  5064. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5065. }
  5066. else
  5067. clif_displaymessage(fd, msg_txt(549)); // You should be vending to use @Autotrade.
  5068. return 0;
  5069. }
  5070. /*==========================================
  5071. * @changegm by durf (changed by Lupus)
  5072. * Changes Master of your Guild to a specified guild member
  5073. *------------------------------------------*/
  5074. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5075. {
  5076. struct guild *g;
  5077. struct map_session_data *pl_sd;
  5078. nullpo_retr(-1, sd);
  5079. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5080. {
  5081. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5082. return -1;
  5083. }
  5084. if( map[sd->bl.m].flag.guildlock )
  5085. {
  5086. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5087. return -1;
  5088. }
  5089. if (strlen(message)==0)
  5090. {
  5091. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5092. return -1;
  5093. }
  5094. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5095. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5096. return -1;
  5097. }
  5098. guild_gm_change(sd->status.guild_id, pl_sd);
  5099. return 0;
  5100. }
  5101. /*==========================================
  5102. * @changeleader by Skotlex
  5103. * Changes the leader of a party.
  5104. *------------------------------------------*/
  5105. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5106. {
  5107. struct party_data *p;
  5108. struct map_session_data *pl_sd;
  5109. int mi, pl_mi;
  5110. nullpo_retr(-1, sd);
  5111. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5112. { //Need to be a party leader.
  5113. clif_displaymessage(fd, msg_txt(282));
  5114. return -1;
  5115. }
  5116. if( map[sd->bl.m].flag.partylock )
  5117. {
  5118. clif_displaymessage(fd, "You cannot change party leaders on this map.");
  5119. return -1;
  5120. }
  5121. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5122. if (mi == MAX_PARTY)
  5123. return -1; //Shouldn't happen
  5124. if (!p->party.member[mi].leader)
  5125. { //Need to be a party leader.
  5126. clif_displaymessage(fd, msg_txt(282));
  5127. return -1;
  5128. }
  5129. if (strlen(message)==0)
  5130. {
  5131. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5132. return -1;
  5133. }
  5134. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  5135. clif_displaymessage(fd, msg_txt(283));
  5136. return -1;
  5137. }
  5138. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  5139. if (pl_mi == MAX_PARTY)
  5140. return -1; //Shouldn't happen
  5141. //Change leadership.
  5142. p->party.member[mi].leader = 0;
  5143. if (p->data[mi].sd->fd)
  5144. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  5145. p->party.member[pl_mi].leader = 1;
  5146. if (p->data[pl_mi].sd->fd)
  5147. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  5148. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  5149. //Update info.
  5150. clif_party_info(p,NULL);
  5151. return 0;
  5152. }
  5153. /*==========================================
  5154. * @partyoption by Skotlex
  5155. * Used to change the item share setting of a party.
  5156. *------------------------------------------*/
  5157. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5158. {
  5159. struct party_data *p;
  5160. int mi, option;
  5161. char w1[16], w2[16];
  5162. nullpo_retr(-1, sd);
  5163. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5164. {
  5165. clif_displaymessage(fd, msg_txt(282));
  5166. return -1;
  5167. }
  5168. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5169. if (mi == MAX_PARTY)
  5170. return -1; //Shouldn't happen
  5171. if (!p->party.member[mi].leader)
  5172. {
  5173. clif_displaymessage(fd, msg_txt(282));
  5174. return -1;
  5175. }
  5176. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5177. {
  5178. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5179. return -1;
  5180. }
  5181. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5182. //Change item share type.
  5183. if (option != p->party.item)
  5184. party_changeoption(sd, p->party.exp, option);
  5185. else
  5186. clif_displaymessage(fd, msg_txt(286));
  5187. return 0;
  5188. }
  5189. /*==========================================
  5190. * @autoloot by Upa-Kun
  5191. * Turns on/off AutoLoot for a specific player
  5192. *------------------------------------------*/
  5193. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5194. {
  5195. int rate;
  5196. double drate;
  5197. nullpo_retr(-1, sd);
  5198. // autoloot command without value
  5199. if(!message || !*message)
  5200. {
  5201. if (sd->state.autoloot)
  5202. rate = 0;
  5203. else
  5204. rate = 10000;
  5205. } else {
  5206. drate = atof(message);
  5207. rate = (int)(drate*100);
  5208. }
  5209. if (rate < 0) rate = 0;
  5210. if (rate > 10000) rate = 10000;
  5211. sd->state.autoloot = rate;
  5212. if (sd->state.autoloot) {
  5213. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5214. clif_displaymessage(fd, atcmd_output);
  5215. }else
  5216. clif_displaymessage(fd, "Autoloot is now off.");
  5217. return 0;
  5218. }
  5219. /*==========================================
  5220. * @autolootitem
  5221. *------------------------------------------*/
  5222. int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5223. {
  5224. struct item_data *item_data = NULL;
  5225. if (!message || !*message) {
  5226. if (sd->state.autolootid) {
  5227. sd->state.autolootid = 0;
  5228. clif_displaymessage(fd, "Autolootitem have been turned OFF.");
  5229. } else
  5230. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>).");
  5231. return -1;
  5232. }
  5233. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5234. item_data = itemdb_searchname(message);
  5235. if (!item_data) {
  5236. // No items founds in the DB with Id or Name
  5237. clif_displaymessage(fd, "Item not found.");
  5238. return -1;
  5239. }
  5240. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  5241. sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
  5242. item_data->name, item_data->jname, item_data->nameid);
  5243. clif_displaymessage(fd, atcmd_output);
  5244. return 0;
  5245. }
  5246. /*==========================================
  5247. * It is made to rain.
  5248. *------------------------------------------*/
  5249. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5250. {
  5251. nullpo_retr(-1, sd);
  5252. if (map[sd->bl.m].flag.rain) {
  5253. map[sd->bl.m].flag.rain=0;
  5254. clif_weather(sd->bl.m);
  5255. clif_displaymessage(fd, "The rain has stopped.");
  5256. } else {
  5257. map[sd->bl.m].flag.rain=1;
  5258. clif_weather(sd->bl.m);
  5259. clif_displaymessage(fd, "It is made to rain.");
  5260. }
  5261. return 0;
  5262. }
  5263. /*==========================================
  5264. * It is made to snow.
  5265. *------------------------------------------*/
  5266. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5267. {
  5268. nullpo_retr(-1, sd);
  5269. if (map[sd->bl.m].flag.snow) {
  5270. map[sd->bl.m].flag.snow=0;
  5271. clif_weather(sd->bl.m);
  5272. clif_displaymessage(fd, "Snow has stopped falling.");
  5273. } else {
  5274. map[sd->bl.m].flag.snow=1;
  5275. clif_weather(sd->bl.m);
  5276. clif_displaymessage(fd, "It is made to snow.");
  5277. }
  5278. return 0;
  5279. }
  5280. /*==========================================
  5281. * Cherry tree snowstorm is made to fall. (Sakura)
  5282. *------------------------------------------*/
  5283. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5284. {
  5285. nullpo_retr(-1, sd);
  5286. if (map[sd->bl.m].flag.sakura) {
  5287. map[sd->bl.m].flag.sakura=0;
  5288. clif_weather(sd->bl.m);
  5289. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5290. } else {
  5291. map[sd->bl.m].flag.sakura=1;
  5292. clif_weather(sd->bl.m);
  5293. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5294. }
  5295. return 0;
  5296. }
  5297. /*==========================================
  5298. * Clouds appear.
  5299. *------------------------------------------*/
  5300. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5301. {
  5302. nullpo_retr(-1, sd);
  5303. if (map[sd->bl.m].flag.clouds) {
  5304. map[sd->bl.m].flag.clouds=0;
  5305. clif_weather(sd->bl.m);
  5306. clif_displaymessage(fd, "The clouds has disappear.");
  5307. } else {
  5308. map[sd->bl.m].flag.clouds=1;
  5309. clif_weather(sd->bl.m);
  5310. clif_displaymessage(fd, "Clouds appear.");
  5311. }
  5312. return 0;
  5313. }
  5314. /*==========================================
  5315. * Different type of clouds using effect 516
  5316. *------------------------------------------*/
  5317. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5318. {
  5319. nullpo_retr(-1, sd);
  5320. if (map[sd->bl.m].flag.clouds2) {
  5321. map[sd->bl.m].flag.clouds2=0;
  5322. clif_weather(sd->bl.m);
  5323. clif_displaymessage(fd, "The alternative clouds disappear.");
  5324. } else {
  5325. map[sd->bl.m].flag.clouds2=1;
  5326. clif_weather(sd->bl.m);
  5327. clif_displaymessage(fd, "Alternative clouds appear.");
  5328. }
  5329. return 0;
  5330. }
  5331. /*==========================================
  5332. * Fog hangs over.
  5333. *------------------------------------------*/
  5334. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5335. {
  5336. nullpo_retr(-1, sd);
  5337. if (map[sd->bl.m].flag.fog) {
  5338. map[sd->bl.m].flag.fog=0;
  5339. clif_weather(sd->bl.m);
  5340. clif_displaymessage(fd, "The fog has gone.");
  5341. } else {
  5342. map[sd->bl.m].flag.fog=1;
  5343. clif_weather(sd->bl.m);
  5344. clif_displaymessage(fd, "Fog hangs over.");
  5345. }
  5346. return 0;
  5347. }
  5348. /*==========================================
  5349. * Fallen leaves fall.
  5350. *------------------------------------------*/
  5351. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5352. {
  5353. nullpo_retr(-1, sd);
  5354. if (map[sd->bl.m].flag.leaves) {
  5355. map[sd->bl.m].flag.leaves=0;
  5356. clif_weather(sd->bl.m);
  5357. clif_displaymessage(fd, "Leaves no longer fall.");
  5358. } else {
  5359. map[sd->bl.m].flag.leaves=1;
  5360. clif_weather(sd->bl.m);
  5361. clif_displaymessage(fd, "Fallen leaves fall.");
  5362. }
  5363. return 0;
  5364. }
  5365. /*==========================================
  5366. * Fireworks appear.
  5367. *------------------------------------------*/
  5368. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5369. {
  5370. nullpo_retr(-1, sd);
  5371. if (map[sd->bl.m].flag.fireworks) {
  5372. map[sd->bl.m].flag.fireworks=0;
  5373. clif_weather(sd->bl.m);
  5374. clif_displaymessage(fd, "Fireworks are ended.");
  5375. } else {
  5376. map[sd->bl.m].flag.fireworks=1;
  5377. clif_weather(sd->bl.m);
  5378. clif_displaymessage(fd, "Fireworks are launched.");
  5379. }
  5380. return 0;
  5381. }
  5382. /*==========================================
  5383. * Clearing Weather Effects by Dexity
  5384. *------------------------------------------*/
  5385. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5386. {
  5387. nullpo_retr(-1, sd);
  5388. map[sd->bl.m].flag.rain=0;
  5389. map[sd->bl.m].flag.snow=0;
  5390. map[sd->bl.m].flag.sakura=0;
  5391. map[sd->bl.m].flag.clouds=0;
  5392. map[sd->bl.m].flag.clouds2=0;
  5393. map[sd->bl.m].flag.fog=0;
  5394. map[sd->bl.m].flag.fireworks=0;
  5395. map[sd->bl.m].flag.leaves=0;
  5396. clif_weather(sd->bl.m);
  5397. clif_displaymessage(fd, msg_txt(291));
  5398. return 0;
  5399. }
  5400. /*===============================================================
  5401. * Sound Command - plays a sound for everyone around! [Codemaster]
  5402. *---------------------------------------------------------------*/
  5403. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  5404. {
  5405. char sound_file[100];
  5406. memset(sound_file, '\0', sizeof(sound_file));
  5407. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5408. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5409. return -1;
  5410. }
  5411. if(strstr(sound_file, ".wav") == NULL)
  5412. strcat(sound_file, ".wav");
  5413. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5414. return 0;
  5415. }
  5416. /*==========================================
  5417. * MOB Search
  5418. *------------------------------------------*/
  5419. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5420. {
  5421. char mob_name[100];
  5422. int mob_id,map_id = 0;
  5423. int number = 0;
  5424. struct s_mapiterator* it;
  5425. nullpo_retr(-1, sd);
  5426. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5427. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5428. return -1;
  5429. }
  5430. if ((mob_id = atoi(mob_name)) == 0)
  5431. mob_id = mobdb_searchname(mob_name);
  5432. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5433. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5434. clif_displaymessage(fd, atcmd_output);
  5435. return -1;
  5436. }
  5437. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5438. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5439. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5440. map_id = sd->bl.m;
  5441. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5442. clif_displaymessage(fd, atcmd_output);
  5443. it = mapit_geteachmob();
  5444. while( true )
  5445. {
  5446. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5447. if( md == NULL )
  5448. break;// no more mobs
  5449. if( mob_id == -1 || md->class_ == mob_id )
  5450. {
  5451. ++number;
  5452. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5453. clif_displaymessage(fd, atcmd_output);
  5454. }
  5455. }
  5456. mapit_free(it);
  5457. return 0;
  5458. }
  5459. /*==========================================
  5460. * @cleanmap - cleans items on the ground
  5461. *------------------------------------------*/
  5462. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5463. {
  5464. nullpo_retr(0, bl);
  5465. map_clearflooritem(bl->id);
  5466. return 0;
  5467. }
  5468. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5469. {
  5470. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5471. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5472. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5473. BL_ITEM);
  5474. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5475. return 0;
  5476. }
  5477. /*==========================================
  5478. * make a NPC/PET talk
  5479. *------------------------------------------*/
  5480. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5481. {
  5482. char name[NAME_LENGTH],mes[100],temp[100];
  5483. struct npc_data *nd;
  5484. if (sd->sc.count && //no "chatting" while muted.
  5485. (sd->sc.data[SC_BERSERK] ||
  5486. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5487. return -1;
  5488. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5489. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5490. return -1;
  5491. }
  5492. if (!(nd = npc_name2id(name))) {
  5493. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5494. return -1;
  5495. }
  5496. strtok(name, "#"); // discard extra name identifier if present
  5497. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5498. clif_message(&nd->bl, temp);
  5499. return 0;
  5500. }
  5501. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5502. {
  5503. char mes[100],temp[100];
  5504. struct pet_data *pd;
  5505. nullpo_retr(-1, sd);
  5506. if(!sd->status.pet_id || !(pd=sd->pd))
  5507. {
  5508. clif_displaymessage(fd, msg_txt(184));
  5509. return -1;
  5510. }
  5511. if (sd->sc.count && //no "chatting" while muted.
  5512. (sd->sc.data[SC_BERSERK] ||
  5513. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5514. return -1;
  5515. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5516. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5517. return -1;
  5518. }
  5519. if (message[0] == '/')
  5520. {// pet emotion processing
  5521. const char* emo[] = {
  5522. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5523. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5524. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5525. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5526. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5527. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5528. };
  5529. int i;
  5530. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5531. if( i < ARRAYLENGTH(emo) )
  5532. {
  5533. clif_emotion(&pd->bl, i);
  5534. return 0;
  5535. }
  5536. }
  5537. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5538. clif_message(&pd->bl, temp);
  5539. return 0;
  5540. }
  5541. /*==========================================
  5542. * @users - displays the number of players present on each map (percentage)
  5543. *------------------------------------------*/
  5544. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5545. {
  5546. char buf[256];
  5547. DBMap* users_db; // unsigned int mapindex -> int users
  5548. int users_all;
  5549. users_db = uidb_alloc(DB_OPT_BASE);
  5550. users_all = 0;
  5551. // count users on each map
  5552. {
  5553. struct s_mapiterator* iter;
  5554. struct map_session_data* sd;
  5555. iter = mapit_getallusers();
  5556. for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) )
  5557. {
  5558. int users = (int)uidb_get(users_db,sd->mapindex) + 1;
  5559. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  5560. users_all++;
  5561. }
  5562. mapit_free(iter);
  5563. }
  5564. // display results for each map
  5565. {
  5566. DBIterator* iter;
  5567. DBKey index;
  5568. int users;
  5569. iter = users_db->iterator(users_db);
  5570. for( users = (int)iter->first(iter,&index); iter->exists(iter); users = (int)iter->next(iter,&index) )
  5571. {
  5572. sprintf(buf,"%s: %d (%d%%)",mapindex_id2name(index.i),users,users * 100 / users_all);
  5573. clif_displaymessage(sd->fd,buf);
  5574. }
  5575. iter->destroy(iter);
  5576. }
  5577. // display overall count
  5578. sprintf(buf,"all: %d",users_all);
  5579. clif_displaymessage(fd,buf);
  5580. users_db->destroy(users_db,NULL);
  5581. return 0;
  5582. }
  5583. /*==========================================
  5584. *
  5585. *------------------------------------------*/
  5586. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5587. {
  5588. pc_resetstate(sd);
  5589. pc_resetskill(sd,1);
  5590. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5591. clif_displaymessage(fd, atcmd_output);
  5592. return 0;
  5593. }
  5594. /*==========================================
  5595. *
  5596. *------------------------------------------*/
  5597. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5598. {
  5599. char name[NAME_LENGTH];
  5600. int mob_id = 0;
  5601. int duration = 0;
  5602. struct mob_data *md;
  5603. unsigned int tick=gettick();
  5604. nullpo_retr(-1, sd);
  5605. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5606. {
  5607. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5608. return -1;
  5609. }
  5610. if (duration < 1)
  5611. duration =1;
  5612. else if (duration > 60)
  5613. duration =60;
  5614. if ((mob_id = atoi(name)) == 0)
  5615. mob_id = mobdb_searchname(name);
  5616. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5617. {
  5618. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5619. return -1;
  5620. }
  5621. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5622. if(!md)
  5623. return -1;
  5624. md->master_id=sd->bl.id;
  5625. md->special_state.ai=1;
  5626. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5627. clif_misceffect2(&md->bl,344);
  5628. mob_spawn(md);
  5629. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5630. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5631. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5632. return 0;
  5633. }
  5634. /*==========================================
  5635. * @adjcmdlvl by [MouseJstr]
  5636. *
  5637. * Temp adjust the GM level required to use a GM command
  5638. * Useful during beta testing to allow players to use GM commands for short periods of time
  5639. *------------------------------------------*/
  5640. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5641. {
  5642. int newlev, newremotelev;
  5643. char name[100];
  5644. AtCommandInfo* cmd;
  5645. nullpo_retr(-1, sd);
  5646. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  5647. {
  5648. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  5649. return -1;
  5650. }
  5651. cmd = get_atcommandinfo_byname(name);
  5652. if (cmd == NULL)
  5653. {
  5654. clif_displaymessage(fd, "@command not found.");
  5655. return -1;
  5656. }
  5657. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  5658. {
  5659. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5660. return -1;
  5661. }
  5662. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  5663. {
  5664. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5665. return -1;
  5666. }
  5667. else
  5668. {
  5669. cmd->level = newlev;
  5670. cmd->level2 = newremotelev;
  5671. clif_displaymessage(fd, "@command level changed.");
  5672. return 0;
  5673. }
  5674. }
  5675. /*==========================================
  5676. * @adjgmlvl by [MouseJstr]
  5677. * Create a temp GM
  5678. * Useful during beta testing to allow players to use GM commands for short periods of time
  5679. *------------------------------------------*/
  5680. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5681. {
  5682. int newlev;
  5683. char user[NAME_LENGTH];
  5684. struct map_session_data *pl_sd;
  5685. nullpo_retr(-1, sd);
  5686. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5687. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5688. return -1;
  5689. }
  5690. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5691. {
  5692. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5693. return -1;
  5694. }
  5695. pl_sd->gmlevel = newlev;
  5696. return 0;
  5697. }
  5698. /*==========================================
  5699. * @trade by [MouseJstr]
  5700. * Open a trade window with a remote player
  5701. *------------------------------------------*/
  5702. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5703. {
  5704. struct map_session_data *pl_sd = NULL;
  5705. nullpo_retr(-1, sd);
  5706. if (!message || !*message) {
  5707. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5708. return -1;
  5709. }
  5710. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5711. {
  5712. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5713. return -1;
  5714. }
  5715. trade_traderequest(sd, pl_sd);
  5716. return 0;
  5717. }
  5718. /*==========================================
  5719. * @setbattleflag by [MouseJstr]
  5720. * set a battle_config flag without having to reboot
  5721. *------------------------------------------*/
  5722. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5723. {
  5724. char flag[128], value[128];
  5725. nullpo_retr(-1, sd);
  5726. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5727. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5728. return -1;
  5729. }
  5730. if (battle_set_value(flag, value) == 0)
  5731. {
  5732. clif_displaymessage(fd, "unknown battle_config flag");
  5733. return -1;
  5734. }
  5735. clif_displaymessage(fd, "battle_config set as requested");
  5736. return 0;
  5737. }
  5738. /*==========================================
  5739. * @unmute [Valaris]
  5740. *------------------------------------------*/
  5741. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5742. {
  5743. struct map_session_data *pl_sd = NULL;
  5744. nullpo_retr(-1, sd);
  5745. if (!message || !*message) {
  5746. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5747. return -1;
  5748. }
  5749. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5750. {
  5751. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5752. return -1;
  5753. }
  5754. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5755. clif_displaymessage(sd->fd,"Player is not muted");
  5756. return -1;
  5757. }
  5758. pl_sd->status.manner = 0;
  5759. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5760. clif_displaymessage(sd->fd,"Player unmuted");
  5761. return 0;
  5762. }
  5763. /*==========================================
  5764. * @uptime by MC Cameri
  5765. *------------------------------------------*/
  5766. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5767. {
  5768. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5769. minute = 60, days = 0, hours = 0, minutes = 0;
  5770. nullpo_retr(-1, sd);
  5771. seconds = get_uptime();
  5772. days = seconds/day;
  5773. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5774. hours = seconds/hour;
  5775. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5776. minutes = seconds/minute;
  5777. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5778. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5779. clif_displaymessage(fd, atcmd_output);
  5780. return 0;
  5781. }
  5782. /*==========================================
  5783. * @changesex <sex>
  5784. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5785. *------------------------------------------*/
  5786. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5787. {
  5788. nullpo_retr(-1, sd);
  5789. chrif_changesex(sd);
  5790. return 0;
  5791. }
  5792. /*================================================
  5793. * @mute - Mutes a player for a set amount of time
  5794. *------------------------------------------------*/
  5795. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5796. {
  5797. struct map_session_data *pl_sd = NULL;
  5798. int manner;
  5799. nullpo_retr(-1, sd);
  5800. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5801. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5802. return -1;
  5803. }
  5804. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5805. {
  5806. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5807. return -1;
  5808. }
  5809. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5810. {
  5811. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5812. return -1;
  5813. }
  5814. clif_manner_message(sd, 0);
  5815. clif_manner_message(pl_sd, 5);
  5816. if( pl_sd->status.manner < manner ) {
  5817. pl_sd->status.manner -= manner;
  5818. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5819. } else {
  5820. pl_sd->status.manner = 0;
  5821. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5822. }
  5823. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5824. return 0;
  5825. }
  5826. /*==========================================
  5827. * @refresh (like @jumpto <<yourself>>)
  5828. *------------------------------------------*/
  5829. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5830. {
  5831. nullpo_retr(-1, sd);
  5832. clif_refresh(sd);
  5833. return 0;
  5834. }
  5835. /*==========================================
  5836. * @identify
  5837. * => GM's magnifier.
  5838. *------------------------------------------*/
  5839. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5840. {
  5841. int i,num;
  5842. nullpo_retr(-1, sd);
  5843. for(i=num=0;i<MAX_INVENTORY;i++){
  5844. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5845. num++;
  5846. }
  5847. }
  5848. if (num > 0) {
  5849. clif_item_identify_list(sd);
  5850. } else {
  5851. clif_displaymessage(fd,"There are no items to appraise.");
  5852. }
  5853. return 0;
  5854. }
  5855. /*==========================================
  5856. * @gmotd (Global MOTD)
  5857. * by davidsiaw :P
  5858. *------------------------------------------*/
  5859. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5860. {
  5861. char buf[256];
  5862. FILE *fp;
  5863. nullpo_retr(-1, sd);
  5864. if((fp = fopen(motd_txt, "r"))!=NULL){
  5865. while(fgets(buf, sizeof(buf), fp) != NULL)
  5866. {
  5867. int i;
  5868. if (buf[0] == '/' && buf[1] == '/')
  5869. continue;
  5870. for(i=0; buf[i]; i++){
  5871. if(buf[i]=='\r' || buf[i]=='\n'){
  5872. buf[i]=0;
  5873. break;
  5874. }
  5875. }
  5876. intif_GMmessage(buf,strlen(buf)+1,8);
  5877. }
  5878. fclose(fp);
  5879. }
  5880. return 0;
  5881. }
  5882. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5883. {
  5884. int effect = 0;
  5885. nullpo_retr(-1, sd);
  5886. if (!message || !*message)
  5887. return -1;
  5888. if (sscanf(message, "%d", &effect) < 1)
  5889. return -1;
  5890. clif_misceffect(&sd->bl,effect);
  5891. return 0;
  5892. }
  5893. /*==========================================
  5894. * MAIL SYSTEM
  5895. *------------------------------------------*/
  5896. int atcommand_mail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5897. {
  5898. nullpo_retr(0,sd);
  5899. #ifndef TXT_ONLY
  5900. mail_openmail(sd);
  5901. #endif
  5902. return 0;
  5903. }
  5904. /*==========================================
  5905. * Show Monster DB Info v 1.0
  5906. * originally by [Lupus] eAthena
  5907. *------------------------------------------*/
  5908. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5909. {
  5910. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5911. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5912. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5913. char atcmd_output2[200];
  5914. struct item_data *item_data;
  5915. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5916. int count;
  5917. int i, j, k;
  5918. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5919. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5920. if (!message || !*message) {
  5921. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5922. return -1;
  5923. }
  5924. // If monster identifier/name argument is a name
  5925. if ((i = mobdb_checkid(atoi(message))))
  5926. {
  5927. mob_array[0] = mob_db(i);
  5928. count = 1;
  5929. } else
  5930. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5931. if (!count) {
  5932. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5933. return -1;
  5934. }
  5935. if (count > MAX_SEARCH) {
  5936. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5937. clif_displaymessage(fd, atcmd_output);
  5938. count = MAX_SEARCH;
  5939. }
  5940. for (k = 0; k < count; k++) {
  5941. mob = mob_array[k];
  5942. // stats
  5943. if (mob->mexp)
  5944. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5945. else
  5946. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5947. clif_displaymessage(fd, atcmd_output);
  5948. 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);
  5949. clif_displaymessage(fd, atcmd_output);
  5950. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5951. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5952. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5953. clif_displaymessage(fd, atcmd_output);
  5954. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5955. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5956. mob->range2 , mob->range3, msize[mob->status.size],
  5957. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5958. clif_displaymessage(fd, atcmd_output);
  5959. // drops
  5960. clif_displaymessage(fd, " Drops:");
  5961. strcpy(atcmd_output, " ");
  5962. j = 0;
  5963. for (i = 0; i < MAX_MOB_DROP; i++) {
  5964. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  5965. continue;
  5966. if (item_data->slot)
  5967. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5968. else
  5969. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5970. strcat(atcmd_output, atcmd_output2);
  5971. if (++j % 3 == 0) {
  5972. clif_displaymessage(fd, atcmd_output);
  5973. strcpy(atcmd_output, " ");
  5974. }
  5975. }
  5976. if (j == 0)
  5977. clif_displaymessage(fd, "This monster has no drops.");
  5978. else if (j % 3 != 0)
  5979. clif_displaymessage(fd, atcmd_output);
  5980. // mvp
  5981. if (mob->mexp) {
  5982. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  5983. clif_displaymessage(fd, atcmd_output);
  5984. strcpy(atcmd_output, " MVP Items:");
  5985. j = 0;
  5986. for (i = 0; i < 3; i++) {
  5987. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  5988. continue;
  5989. if (mob->mvpitem[i].p > 0) {
  5990. j++;
  5991. if (j == 1)
  5992. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5993. else
  5994. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5995. strcat(atcmd_output, atcmd_output2);
  5996. }
  5997. }
  5998. if (j == 0)
  5999. clif_displaymessage(fd, "This monster has no MVP prizes.");
  6000. else
  6001. clif_displaymessage(fd, atcmd_output);
  6002. }
  6003. }
  6004. return 0;
  6005. }
  6006. /*=========================================
  6007. * @showmobs by KarLaeda
  6008. * => For 5 sec displays the mobs on minimap
  6009. *------------------------------------------*/
  6010. int atshowmobs_timer(int tid, unsigned int tick, int id, intptr data)
  6011. {
  6012. struct map_session_data* sd = map_id2sd(id);
  6013. if( sd == NULL )
  6014. return 0;
  6015. // remove indicator
  6016. clif_viewpoint(sd, 1, 2, 0, 0, (int)data, 0xFFFFFF);
  6017. return 1;
  6018. }
  6019. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6020. {
  6021. char mob_name[100];
  6022. int mob_id,map_id = 0;
  6023. int number = 0;
  6024. struct s_mapiterator* it;
  6025. nullpo_retr(-1, sd);
  6026. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6027. return -1;
  6028. if((mob_id = atoi(mob_name)) == 0)
  6029. mob_id = mobdb_searchname(mob_name);
  6030. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6031. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6032. clif_displaymessage(fd, atcmd_output);
  6033. return 0;
  6034. }
  6035. // Uncomment the following line to show mini-bosses & MVP.
  6036. //#define SHOW_MVP
  6037. #ifndef SHOW_MVP
  6038. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6039. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6040. clif_displaymessage(fd, atcmd_output);
  6041. return 0;
  6042. }
  6043. #endif
  6044. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6045. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6046. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6047. map_id = sd->bl.m;
  6048. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6049. mob_name, mapindex_id2name(sd->mapindex));
  6050. clif_displaymessage(fd, atcmd_output);
  6051. it = mapit_geteachmob();
  6052. while( true )
  6053. {
  6054. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6055. if( md == NULL )
  6056. break;// no more mobs
  6057. if( md->special_state.ai || md->master_id )
  6058. continue;//Hide slaves and player summoned mobs. [Skotlex]
  6059. if( mob_id == -1 || md->class_ == mob_id )
  6060. {
  6061. ++number;
  6062. clif_viewpoint(sd, 1, 1, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6063. add_timer(gettick()+5000, atshowmobs_timer, sd->bl.id, number);
  6064. }
  6065. }
  6066. mapit_free(it);
  6067. return 0;
  6068. }
  6069. /*==========================================
  6070. * homunculus level up [orn]
  6071. *------------------------------------------*/
  6072. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6073. {
  6074. TBL_HOM * hd;
  6075. int level = 0, i = 0;
  6076. nullpo_retr(-1, sd);
  6077. if (!message || !*message) {
  6078. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <+/- # of levels>.");
  6079. return -1;
  6080. }
  6081. if ( !merc_is_hom_active(sd->hd) ) {
  6082. clif_displaymessage(fd, "You do not have a homunculus.");
  6083. return -1;
  6084. }
  6085. level = atoi(message);
  6086. hd = sd->hd;
  6087. for (i = 1; i <= level && hd->exp_next; i++){
  6088. hd->homunculus.exp += hd->exp_next;
  6089. merc_hom_levelup(hd);
  6090. }
  6091. status_calc_homunculus(hd,0);
  6092. status_percent_heal(&hd->bl, 100, 100);
  6093. clif_misceffect2(&hd->bl,568);
  6094. return 0;
  6095. }
  6096. /*==========================================
  6097. * homunculus evolution H [orn]
  6098. *------------------------------------------*/
  6099. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6100. {
  6101. nullpo_retr(-1, sd);
  6102. if ( !merc_is_hom_active(sd->hd) ) {
  6103. clif_displaymessage(fd, "You do not have a homunculus.");
  6104. return -1;
  6105. }
  6106. if ( !merc_hom_evolution(sd->hd) ) {
  6107. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6108. return -1;
  6109. }
  6110. return 0;
  6111. }
  6112. /*==========================================
  6113. * call choosen homunculus [orn]
  6114. *------------------------------------------*/
  6115. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6116. {
  6117. int homunid;
  6118. nullpo_retr(-1, sd);
  6119. if ( merc_is_hom_active(sd->hd) ) {
  6120. clif_displaymessage(fd, msg_txt(450));
  6121. return -1;
  6122. }
  6123. if (!message || !*message) {
  6124. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6125. return -1;
  6126. }
  6127. homunid = atoi(message);
  6128. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6129. {
  6130. clif_displaymessage(fd, "Invalid Homunculus id.");
  6131. return -1;
  6132. }
  6133. merc_create_homunculus_request(sd,homunid);
  6134. return 0;
  6135. }
  6136. /*==========================================
  6137. * modify homunculus intimacy [orn]
  6138. *------------------------------------------*/
  6139. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6140. {
  6141. int friendly = 0;
  6142. nullpo_retr(-1, sd);
  6143. if ( !merc_is_hom_active(sd->hd) ) {
  6144. clif_displaymessage(fd, "You do not have a homunculus.");
  6145. return -1;
  6146. }
  6147. if (!message || !*message) {
  6148. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6149. return -1;
  6150. }
  6151. friendly = atoi(message);
  6152. friendly = cap_value(friendly, 0, 1000);
  6153. sd->hd->homunculus.intimacy = friendly * 100 ;
  6154. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6155. return 0;
  6156. }
  6157. /*==========================================
  6158. * modify homunculus hunger [orn]
  6159. *------------------------------------------*/
  6160. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6161. {
  6162. int hungry = 0;
  6163. nullpo_retr(-1, sd);
  6164. if ( !merc_is_hom_active(sd->hd) ) {
  6165. clif_displaymessage(fd, "You do not have a homunculus.");
  6166. return -1;
  6167. }
  6168. if (!message || !*message) {
  6169. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6170. return -1;
  6171. }
  6172. hungry = atoi(message);
  6173. hungry = cap_value(hungry, 0, 100);
  6174. sd->hd->homunculus.hunger = hungry;
  6175. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6176. return 0;
  6177. }
  6178. /*==========================================
  6179. * make the homunculus speak [orn]
  6180. *------------------------------------------*/
  6181. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6182. {
  6183. char mes[100],temp[100];
  6184. nullpo_retr(-1, sd);
  6185. if (sd->sc.count && //no "chatting" while muted.
  6186. (sd->sc.data[SC_BERSERK] ||
  6187. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6188. return -1;
  6189. if ( !merc_is_hom_active(sd->hd) ) {
  6190. clif_displaymessage(fd, "You do not have a homunculus.");
  6191. return -1;
  6192. }
  6193. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6194. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6195. return -1;
  6196. }
  6197. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6198. clif_message(&sd->hd->bl, temp);
  6199. return 0;
  6200. }
  6201. /*==========================================
  6202. * Show homunculus stats
  6203. *------------------------------------------*/
  6204. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6205. {
  6206. struct homun_data *hd;
  6207. struct status_data *status;
  6208. nullpo_retr(-1, sd);
  6209. if ( !merc_is_hom_active(sd->hd) ) {
  6210. clif_displaymessage(fd, "You do not have a homunculus.");
  6211. return -1;
  6212. }
  6213. hd = sd->hd;
  6214. status = status_get_status_data(&hd->bl);
  6215. clif_displaymessage(fd, "Homunculus stats :");
  6216. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6217. status->hp, status->max_hp, status->sp, status->max_sp);
  6218. clif_displaymessage(fd, atcmd_output);
  6219. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6220. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6221. clif_displaymessage(fd, atcmd_output);
  6222. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6223. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6224. clif_displaymessage(fd, atcmd_output);
  6225. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6226. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6227. status->str, status->agi, status->vit,
  6228. status->int_, status->dex, status->luk);
  6229. clif_displaymessage(fd, atcmd_output);
  6230. return 0;
  6231. }
  6232. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6233. {
  6234. struct homun_data *hd;
  6235. struct s_homunculus_db *db;
  6236. struct s_homunculus *hom;
  6237. int lv, min, max, evo;
  6238. nullpo_retr(-1, sd);
  6239. if ( !merc_is_hom_active(sd->hd) ) {
  6240. clif_displaymessage(fd, "You do not have a homunculus.");
  6241. return -1;
  6242. }
  6243. hd = sd->hd;
  6244. hom = &hd->homunculus;
  6245. db = hd->homunculusDB;
  6246. lv = hom->level;
  6247. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6248. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6249. clif_displaymessage(fd, atcmd_output);
  6250. lv--; //Since the first increase is at level 2.
  6251. evo = (hom->class_ == db->evo_class);
  6252. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6253. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6254. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6255. clif_displaymessage(fd, atcmd_output);
  6256. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6257. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6258. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6259. clif_displaymessage(fd, atcmd_output);
  6260. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6261. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6262. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6263. clif_displaymessage(fd, atcmd_output);
  6264. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6265. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6266. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6267. clif_displaymessage(fd, atcmd_output);
  6268. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6269. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6270. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6271. clif_displaymessage(fd, atcmd_output);
  6272. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6273. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6274. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6275. clif_displaymessage(fd, atcmd_output);
  6276. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6277. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6278. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6279. clif_displaymessage(fd, atcmd_output);
  6280. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6281. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6282. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6283. clif_displaymessage(fd, atcmd_output);
  6284. return 0;
  6285. }
  6286. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6287. {
  6288. TBL_PC* tsd = sd;
  6289. nullpo_retr(-1, sd);
  6290. if ((!message || !*message) && !sd->hd)
  6291. {
  6292. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  6293. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  6294. return -1;
  6295. }
  6296. if (message && *message) {
  6297. tsd = map_nick2sd((char*)message);
  6298. if (!tsd) {
  6299. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6300. return -1;
  6301. }
  6302. if (pc_isGM(tsd) > pc_isGM(sd)) {
  6303. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6304. return -1;
  6305. }
  6306. }
  6307. if(!merc_hom_shuffle(tsd->hd))
  6308. return -1;
  6309. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6310. //Print out the new stats
  6311. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  6312. atcommand_homstats(fd, tsd, command, message);
  6313. return 0;
  6314. }
  6315. /*==========================================
  6316. * Show Items DB Info v 1.0
  6317. * originally by [Lupus] eAthena
  6318. *------------------------------------------*/
  6319. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6320. {
  6321. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  6322. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  6323. struct item_data *item_data, *item_array[MAX_SEARCH];
  6324. int i, count = 1;
  6325. if (!message || !*message) {
  6326. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6327. return -1;
  6328. }
  6329. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6330. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6331. if (!count) {
  6332. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6333. return -1;
  6334. }
  6335. if (count > MAX_SEARCH) {
  6336. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6337. clif_displaymessage(fd, atcmd_output);
  6338. count = MAX_SEARCH;
  6339. }
  6340. for (i = 0; i < count; i++) {
  6341. item_data = item_array[i];
  6342. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6343. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6344. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  6345. (item_data->script==NULL)? "None" : "With script"
  6346. );
  6347. clif_displaymessage(fd, atcmd_output);
  6348. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
  6349. clif_displaymessage(fd, atcmd_output);
  6350. if (item_data->maxchance == 10000)
  6351. strcpy(atcmd_output, " - Available in the shops only");
  6352. else if (item_data->maxchance)
  6353. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6354. else
  6355. strcpy(atcmd_output, " - Monsters don't drop this item");
  6356. clif_displaymessage(fd, atcmd_output);
  6357. }
  6358. return 0;
  6359. }
  6360. /*==========================================
  6361. * Show who drops the item.
  6362. *------------------------------------------*/
  6363. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6364. {
  6365. struct item_data *item_data, *item_array[MAX_SEARCH];
  6366. int i,j, count = 1;
  6367. if (!message || !*message) {
  6368. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6369. return -1;
  6370. }
  6371. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6372. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6373. if (!count) {
  6374. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6375. return -1;
  6376. }
  6377. if (count > MAX_SEARCH) {
  6378. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6379. clif_displaymessage(fd, atcmd_output);
  6380. count = MAX_SEARCH;
  6381. }
  6382. for (i = 0; i < count; i++) {
  6383. item_data = item_array[i];
  6384. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6385. clif_displaymessage(fd, atcmd_output);
  6386. if (item_data->mob[0].chance == 0) {
  6387. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6388. clif_displaymessage(fd, atcmd_output);
  6389. } else {
  6390. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6391. clif_displaymessage(fd, atcmd_output);
  6392. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6393. {
  6394. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6395. clif_displaymessage(fd, atcmd_output);
  6396. }
  6397. }
  6398. }
  6399. return 0;
  6400. }
  6401. int atcommand_whereis(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6402. {
  6403. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6404. int count;
  6405. int i, j, k;
  6406. if (!message || !*message) {
  6407. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6408. return -1;
  6409. }
  6410. // If monster identifier/name argument is a name
  6411. if ((i = mobdb_checkid(atoi(message))))
  6412. {
  6413. mob_array[0] = mob_db(i);
  6414. count = 1;
  6415. } else
  6416. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6417. if (!count) {
  6418. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6419. return -1;
  6420. }
  6421. if (count > MAX_SEARCH) {
  6422. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6423. clif_displaymessage(fd, atcmd_output);
  6424. count = MAX_SEARCH;
  6425. }
  6426. for (k = 0; k < count; k++) {
  6427. mob = mob_array[k];
  6428. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6429. clif_displaymessage(fd, atcmd_output);
  6430. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6431. {
  6432. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6433. if (j < 0) continue;
  6434. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6435. clif_displaymessage(fd, atcmd_output);
  6436. }
  6437. if (i == 0)
  6438. clif_displaymessage(fd, "This monster does not spawn normally.");
  6439. }
  6440. return 0;
  6441. }
  6442. /*==========================================
  6443. * @adopt by [Veider]
  6444. * adopt a novice
  6445. *------------------------------------------*/
  6446. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6447. {
  6448. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6449. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6450. char output[256];
  6451. nullpo_retr(-1, sd);
  6452. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6453. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6454. return -1;
  6455. }
  6456. if (battle_config.etc_log)
  6457. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6458. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6459. sprintf(output, "Cannot find player %s online", player1);
  6460. clif_displaymessage(fd, output);
  6461. return -1;
  6462. }
  6463. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6464. sprintf(output, "Cannot find player %s online", player2);
  6465. clif_displaymessage(fd, output);
  6466. return -1;
  6467. }
  6468. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6469. sprintf(output, "Cannot find player %s online", player3);
  6470. clif_displaymessage(fd, output);
  6471. return -1;
  6472. }
  6473. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6474. return -1;
  6475. }
  6476. clif_displaymessage(fd, "They are family... wish them luck");
  6477. return 0;
  6478. }
  6479. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6480. {
  6481. const char * revision;
  6482. if ((revision = get_svn_revision()) != 0) {
  6483. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6484. clif_displaymessage(fd,atcmd_output);
  6485. } else
  6486. clif_displaymessage(fd,"Cannot determine SVN revision");
  6487. return 0;
  6488. }
  6489. /*==========================================
  6490. * @mutearea by MouseJstr
  6491. *------------------------------------------*/
  6492. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6493. {
  6494. int time, id;
  6495. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6496. if (pl_sd == NULL)
  6497. return 0;
  6498. id = va_arg(ap, int);
  6499. time = va_arg(ap, int);
  6500. if (id != bl->id && !pc_isGM(pl_sd)) {
  6501. pl_sd->status.manner -= time;
  6502. if (pl_sd->status.manner < 0)
  6503. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6504. else if (pl_sd->sc.data[SC_NOCHAT])
  6505. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  6506. }
  6507. return 0;
  6508. }
  6509. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6510. {
  6511. int time;
  6512. nullpo_retr(0, sd);
  6513. if (!message || !*message) {
  6514. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6515. return -1;
  6516. }
  6517. time = atoi(message);
  6518. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6519. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6520. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6521. return 0;
  6522. }
  6523. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6524. {
  6525. char buf[255];
  6526. nullpo_retr(0, sd);
  6527. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  6528. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6529. clif_displaymessage(fd, buf);
  6530. return 0;
  6531. }
  6532. /*==========================================
  6533. * @me by lordalfa
  6534. * => Displays the OUTPUT string on top of the Visible players Heads.
  6535. *------------------------------------------*/
  6536. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6537. {
  6538. char tempmes[200];
  6539. nullpo_retr(-1, sd);
  6540. memset(tempmes, '\0', sizeof(tempmes));
  6541. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6542. if (sd->sc.count && //no "chatting" while muted.
  6543. (sd->sc.data[SC_BERSERK] ||
  6544. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6545. return -1;
  6546. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6547. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6548. return -1;
  6549. }
  6550. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6551. clif_disp_overhead(sd, atcmd_output);
  6552. return 0;
  6553. }
  6554. /*==========================================
  6555. * @size
  6556. * => Resize your character sprite. [Valaris]
  6557. *------------------------------------------*/
  6558. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6559. {
  6560. int size=0;
  6561. nullpo_retr(-1, sd);
  6562. size = atoi(message);
  6563. if(sd->state.size) {
  6564. sd->state.size=0;
  6565. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  6566. }
  6567. if(size==1) {
  6568. sd->state.size=1;
  6569. clif_specialeffect(&sd->bl,420,AREA);
  6570. } else if(size==2) {
  6571. sd->state.size=2;
  6572. clif_specialeffect(&sd->bl,422,AREA);
  6573. }
  6574. return 0;
  6575. }
  6576. /*==========================================
  6577. * @monsterignore
  6578. * => Makes monsters ignore you. [Valaris]
  6579. *------------------------------------------*/
  6580. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6581. {
  6582. nullpo_retr(-1, sd);
  6583. if (!sd->state.monster_ignore) {
  6584. sd->state.monster_ignore = 1;
  6585. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6586. } else {
  6587. sd->state.monster_ignore = 0;
  6588. clif_displaymessage(sd->fd, "Returned to normal state.");
  6589. }
  6590. return 0;
  6591. }
  6592. /*==========================================
  6593. * @fakename
  6594. * => Gives your character a fake name. [Valaris]
  6595. *------------------------------------------*/
  6596. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6597. {
  6598. char name[NAME_LENGTH];
  6599. nullpo_retr(-1, sd);
  6600. if((!message || !*message) && strlen(sd->fakename) > 1) {
  6601. sd->fakename[0]='\0';
  6602. clif_charnameack(0, &sd->bl);
  6603. clif_displaymessage(sd->fd,"Returned to real name.");
  6604. return 0;
  6605. }
  6606. if (!message || !*message || sscanf(message, "%23[^\n]", name) < 1) {
  6607. clif_displaymessage(sd->fd,"You must enter a name.");
  6608. return -1;
  6609. }
  6610. if(strlen(name) < 2) {
  6611. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  6612. return -1;
  6613. }
  6614. memcpy(sd->fakename,name,NAME_LENGTH);
  6615. sd->fakename[NAME_LENGTH-1] = '\0';
  6616. clif_charnameack(0, &sd->bl);
  6617. clif_displaymessage(sd->fd,"Fake name enabled.");
  6618. return 0;
  6619. }
  6620. /*==========================================
  6621. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  6622. * => Shows information about the map flags [map name]
  6623. * Also set flags
  6624. *------------------------------------------*/
  6625. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6626. {
  6627. // WIP
  6628. return 0;
  6629. }
  6630. /*===================================
  6631. * Remove some messages
  6632. *-----------------------------------*/
  6633. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6634. {
  6635. if (sd->state.showexp) {
  6636. sd->state.showexp = 0;
  6637. clif_displaymessage(fd, "Gained exp will not be shown.");
  6638. return 0;
  6639. }
  6640. sd->state.showexp = 1;
  6641. clif_displaymessage(fd, "Gained exp is now shown");
  6642. return 0;
  6643. }
  6644. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6645. {
  6646. if (sd->state.showzeny) {
  6647. sd->state.showzeny = 0;
  6648. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6649. return 0;
  6650. }
  6651. sd->state.showzeny = 1;
  6652. clif_displaymessage(fd, "Gained zeny is now shown");
  6653. return 0;
  6654. }
  6655. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6656. {
  6657. if (sd->state.showdelay) {
  6658. sd->state.showdelay = 0;
  6659. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6660. return 0;
  6661. }
  6662. sd->state.showdelay = 1;
  6663. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6664. return 0;
  6665. }
  6666. /*==========================================
  6667. * Duel organizing functions [LuzZza]
  6668. *
  6669. * @duel [limit|nick] - create a duel
  6670. * @invite <nick> - invite player
  6671. * @accept - accept invitation
  6672. * @reject - reject invitation
  6673. * @leave - leave duel
  6674. *------------------------------------------*/
  6675. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6676. {
  6677. unsigned int did = sd->duel_group;
  6678. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6679. if(did <= 0) {
  6680. // "Duel: @invite without @duel."
  6681. clif_displaymessage(fd, msg_txt(350));
  6682. return 0;
  6683. }
  6684. if(duel_list[did].max_players_limit > 0 &&
  6685. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6686. // "Duel: Limit of players is reached."
  6687. clif_displaymessage(fd, msg_txt(351));
  6688. return 0;
  6689. }
  6690. if(target_sd == NULL) {
  6691. // "Duel: Player not found."
  6692. clif_displaymessage(fd, msg_txt(352));
  6693. return 0;
  6694. }
  6695. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6696. // "Duel: Player already in duel."
  6697. clif_displaymessage(fd, msg_txt(353));
  6698. return 0;
  6699. }
  6700. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6701. {
  6702. sprintf(atcmd_output, msg_txt(364), message);
  6703. clif_displaymessage(fd, atcmd_output);
  6704. return 0;
  6705. }
  6706. duel_invite(did, sd, target_sd);
  6707. // "Duel: Invitation has been sent."
  6708. clif_displaymessage(fd, msg_txt(354));
  6709. return 0;
  6710. }
  6711. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6712. {
  6713. char output[256];
  6714. unsigned int maxpl=0, newduel;
  6715. struct map_session_data *target_sd;
  6716. if(sd->duel_group > 0) {
  6717. duel_showinfo(sd->duel_group, sd);
  6718. return 0;
  6719. }
  6720. if(sd->duel_invite > 0) {
  6721. // "Duel: @duel without @reject."
  6722. clif_displaymessage(fd, msg_txt(355));
  6723. return 0;
  6724. }
  6725. if(!duel_checktime(sd)) {
  6726. // "Duel: You can take part in duel only one time per %d minutes."
  6727. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6728. clif_displaymessage(fd, output);
  6729. return 0;
  6730. }
  6731. if(strlen(message) > 0) {
  6732. if(sscanf(message, "%d", &maxpl) >= 1) {
  6733. if(maxpl < 2 || maxpl > 65535) {
  6734. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6735. return 0;
  6736. }
  6737. duel_create(sd, maxpl);
  6738. } else {
  6739. target_sd = map_nick2sd((char *)message);
  6740. if(target_sd != NULL) {
  6741. if((newduel = duel_create(sd, 2)) != -1) {
  6742. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6743. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6744. return 0;
  6745. }
  6746. duel_invite(newduel, sd, target_sd);
  6747. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6748. }
  6749. } else {
  6750. // "Duel: Player not found."
  6751. clif_displaymessage(fd, msg_txt(352));
  6752. return 0;
  6753. }
  6754. }
  6755. } else
  6756. duel_create(sd, 0);
  6757. return 0;
  6758. }
  6759. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6760. {
  6761. if(sd->duel_group <= 0) {
  6762. // "Duel: @leave without @duel."
  6763. clif_displaymessage(fd, msg_txt(358));
  6764. return 0;
  6765. }
  6766. duel_leave(sd->duel_group, sd);
  6767. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6768. return 0;
  6769. }
  6770. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6771. {
  6772. char output[256];
  6773. if(!duel_checktime(sd)) {
  6774. // "Duel: You can take part in duel only one time per %d minutes."
  6775. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6776. clif_displaymessage(fd, output);
  6777. return 0;
  6778. }
  6779. if(sd->duel_invite <= 0) {
  6780. // "Duel: @accept without invititation."
  6781. clif_displaymessage(fd, msg_txt(360));
  6782. return 0;
  6783. }
  6784. duel_accept(sd->duel_invite, sd);
  6785. // "Duel: Invitation has been accepted."
  6786. clif_displaymessage(fd, msg_txt(361));
  6787. return 0;
  6788. }
  6789. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6790. {
  6791. if(sd->duel_invite <= 0) {
  6792. // "Duel: @reject without invititation."
  6793. clif_displaymessage(fd, msg_txt(362));
  6794. return 0;
  6795. }
  6796. duel_reject(sd->duel_invite, sd);
  6797. // "Duel: Invitation has been rejected."
  6798. clif_displaymessage(fd, msg_txt(363));
  6799. return 0;
  6800. }
  6801. /*===================================
  6802. * Cash Points
  6803. *-----------------------------------*/
  6804. int atcommand_cash(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6805. {
  6806. int value;
  6807. nullpo_retr(-1, sd);
  6808. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6809. clif_displaymessage(fd, "Please, enter an amount.");
  6810. return -1;
  6811. }
  6812. if( !strcmpi(command+1,"cash") )
  6813. {
  6814. if( value > 0 )
  6815. pc_getcash(sd, value, 0);
  6816. else
  6817. pc_paycash(sd, -value, 0);
  6818. }
  6819. else
  6820. { // @points
  6821. if( value > 0 )
  6822. pc_getcash(sd, 0, value);
  6823. else
  6824. pc_paycash(sd, -value, -value);
  6825. }
  6826. return 0;
  6827. }
  6828. /*===================================
  6829. * Away message (@away, @aw) [LuzZza]
  6830. *-----------------------------------*/
  6831. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6832. {
  6833. if(strlen(message) > 0) {
  6834. if(strlen(message) > 128)
  6835. return -1;
  6836. strcpy(sd->away_message, message);
  6837. //"Away automessage has been activated."
  6838. clif_displaymessage(fd, msg_txt(546));
  6839. } else {
  6840. if(strlen(sd->away_message) > 0) {
  6841. sd->away_message[0] = 0;
  6842. //"Away automessage has been disabled."
  6843. clif_displaymessage(fd, msg_txt(547));
  6844. return 0;
  6845. }
  6846. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  6847. clif_displaymessage(fd, msg_txt(548));
  6848. }
  6849. return 0;
  6850. }
  6851. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6852. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6853. {
  6854. int x=0,y=0,flag=0,master=0,i=0;
  6855. struct map_session_data *pl_sd=NULL;
  6856. if (!message || !*message) {
  6857. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6858. return 0;
  6859. }
  6860. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6861. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6862. return 0;
  6863. }
  6864. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  6865. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6866. return 0;
  6867. }
  6868. if (strcmpi(command+1, "clone") == 0)
  6869. flag = 1;
  6870. else if (strcmpi(command+1, "slaveclone") == 0) {
  6871. flag = 2;
  6872. master = sd->bl.id;
  6873. if (battle_config.atc_slave_clone_limit
  6874. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6875. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6876. return 0;
  6877. }
  6878. }
  6879. do {
  6880. x = sd->bl.x + (rand() % 10 - 5);
  6881. y = sd->bl.y + (rand() % 10 - 5);
  6882. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6883. if (i >= 10) {
  6884. x = sd->bl.x;
  6885. y = sd->bl.y;
  6886. }
  6887. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6888. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6889. return 0;
  6890. }
  6891. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6892. return 0;
  6893. }
  6894. /*===================================
  6895. * Main chat [LuzZza]
  6896. * Usage: @main <on|off|message>
  6897. *-----------------------------------*/
  6898. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6899. {
  6900. if(strlen(message) > 0) {
  6901. if(strcmpi(message, "on") == 0) {
  6902. if(!sd->state.mainchat) {
  6903. sd->state.mainchat = 1;
  6904. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6905. } else {
  6906. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6907. }
  6908. } else if(strcmpi(message, "off") == 0) {
  6909. if(sd->state.mainchat) {
  6910. sd->state.mainchat = 0;
  6911. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6912. } else {
  6913. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6914. }
  6915. } else {
  6916. if(!sd->state.mainchat) {
  6917. sd->state.mainchat = 1;
  6918. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6919. }
  6920. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6921. clif_displaymessage(fd, msg_txt(387));
  6922. return -1;
  6923. }
  6924. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  6925. // I use 0xFE000000 color for signalizing that this message is
  6926. // main chat message. 0xFE000000 is invalid color, same using
  6927. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  6928. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  6929. // Chat logging type 'M' / Main Chat
  6930. if( log_config.chat&1 || (log_config.chat&32 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
  6931. log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  6932. }
  6933. } else {
  6934. if(sd->state.mainchat)
  6935. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6936. else
  6937. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6938. }
  6939. return 0;
  6940. }
  6941. /*=====================================
  6942. * Autorejecting Invites/Deals [LuzZza]
  6943. * Usage: @noask
  6944. *-------------------------------------*/
  6945. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6946. {
  6947. if(sd->state.noask) {
  6948. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6949. sd->state.noask = 0;
  6950. } else {
  6951. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6952. sd->state.noask = 1;
  6953. }
  6954. return 0;
  6955. }
  6956. /*=====================================
  6957. * Send a @request message to all GMs of lowest_gm_level.
  6958. * Usage: @request <petition>
  6959. *-------------------------------------*/
  6960. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6961. {
  6962. if (!message || !*message) {
  6963. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6964. return -1;
  6965. }
  6966. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6967. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  6968. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6969. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6970. return 0;
  6971. }
  6972. /*==========================================
  6973. * Feel (SG save map) Reset [HiddenDragon]
  6974. *------------------------------------------*/
  6975. int atcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6976. {
  6977. pc_resetfeel(sd);
  6978. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  6979. return 0;
  6980. }
  6981. /*==========================================
  6982. * AUCTION SYSTEM
  6983. *------------------------------------------*/
  6984. int atcommand_auction(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6985. {
  6986. nullpo_retr(0,sd);
  6987. #ifndef TXT_ONLY
  6988. clif_Auction_openwindow(sd);
  6989. #endif
  6990. return 0;
  6991. }
  6992. /*==========================================
  6993. * Kill Steal Protection
  6994. *------------------------------------------*/
  6995. int atcommand_ksprotection(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6996. {
  6997. nullpo_retr(-1,sd);
  6998. if( sd->state.noks ) {
  6999. sd->state.noks = 0;
  7000. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  7001. }
  7002. else
  7003. {
  7004. if( !message || !*message || !strcmpi(message, "party") )
  7005. { // Default is Party
  7006. sd->state.noks = 2;
  7007. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7008. }
  7009. else if( !strcmpi(message, "self") )
  7010. {
  7011. sd->state.noks = 1;
  7012. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7013. }
  7014. else if( !strcmpi(message, "guild") )
  7015. {
  7016. sd->state.noks = 3;
  7017. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7018. }
  7019. else
  7020. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  7021. }
  7022. clif_displaymessage(fd, atcmd_output);
  7023. return 0;
  7024. }
  7025. /*==========================================
  7026. * Map Kill Steal Protection Setting
  7027. *------------------------------------------*/
  7028. int atcommand_allowks(const int fd, struct map_session_data *sd, const char *command, const char *message)
  7029. {
  7030. nullpo_retr(-1,sd);
  7031. if( map[sd->bl.m].flag.allowks ) {
  7032. map[sd->bl.m].flag.allowks = 0;
  7033. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7034. } else {
  7035. map[sd->bl.m].flag.allowks = 1;
  7036. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7037. }
  7038. clif_displaymessage(fd, atcmd_output);
  7039. return 0;
  7040. }
  7041. int atcommand_resetstat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7042. {
  7043. nullpo_retr(-1, sd);
  7044. pc_resetstate(sd);
  7045. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  7046. clif_displaymessage(fd, atcmd_output);
  7047. return 0;
  7048. }
  7049. int atcommand_resetskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7050. {
  7051. nullpo_retr(-1,sd);
  7052. pc_resetskill(sd,1);
  7053. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  7054. clif_displaymessage(fd, atcmd_output);
  7055. return 0;
  7056. }
  7057. /*==========================================
  7058. * #storagelist <character>: Displays the items list of a player's storage.
  7059. *------------------------------------------*/
  7060. int atcommand_storagelist(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7061. {
  7062. struct item_data *item_data, *item_temp;
  7063. int i, j, count = 0, counter = 0, counter2 = 0;
  7064. char character[NAME_LENGTH], output[200], outputtmp[200];
  7065. nullpo_retr(-1, sd);
  7066. memset(character, '\0', sizeof(character));
  7067. memset(output, '\0', sizeof(output));
  7068. memset(outputtmp, '\0', sizeof(outputtmp));
  7069. for (i = 0; i < MAX_STORAGE; i++)
  7070. {
  7071. struct item* it = &sd->status.storage.items[i];
  7072. if( it->nameid > 0 && (item_data = itemdb_search(it->nameid)) != NULL )
  7073. {
  7074. counter = counter + it->amount;
  7075. count++;
  7076. if (count == 1) {
  7077. sprintf(output, "------ Storage items list of '%s' ------", sd->status.name);
  7078. clif_displaymessage(fd, output);
  7079. }
  7080. if (it->refine)
  7081. sprintf(output, "%d %s %+d (%s %+d, id: %d)", it->amount, item_data->name, it->refine, item_data->jname, it->refine, it->nameid);
  7082. else
  7083. sprintf(output, "%d %s (%s, id: %d)", it->amount, item_data->name, item_data->jname, it->nameid);
  7084. clif_displaymessage(fd, output);
  7085. memset(output, '\0', sizeof(output));
  7086. counter2 = 0;
  7087. for (j = 0; j < item_data->slot; j++) {
  7088. if (it->card[j]) {
  7089. if ((item_temp = itemdb_search(it->card[j])) != NULL) {
  7090. if (output[0] == '\0')
  7091. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  7092. else
  7093. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  7094. strcat(output, outputtmp);
  7095. }
  7096. }
  7097. }
  7098. if (output[0] != '\0') {
  7099. output[strlen(output) - 2] = ')';
  7100. output[strlen(output) - 1] = '\0';
  7101. clif_displaymessage(fd, output);
  7102. }
  7103. }
  7104. }
  7105. if (count == 0)
  7106. clif_displaymessage(fd, "No item found in the storage of this player.");
  7107. else {
  7108. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  7109. clif_displaymessage(fd, output);
  7110. }
  7111. return 0;
  7112. }
  7113. /*==========================================
  7114. * Displays contents of target's cart [HiddenDragon]
  7115. *------------------------------------------*/
  7116. int atcommand_cart_list(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7117. {
  7118. char outputtmp[200];
  7119. char output[200];
  7120. char character[NAME_LENGTH];
  7121. struct item_data *item_data, *item_temp;
  7122. int i, j, count = 0, counter = 0, counter2;
  7123. nullpo_retr(-1, sd);
  7124. memset(character, '\0', sizeof(character));
  7125. memset(output, '\0', sizeof(output));
  7126. memset(outputtmp, '\0', sizeof(outputtmp));
  7127. for (i = 0; i < MAX_CART; i++) {
  7128. if (sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(sd->status.cart[i].nameid)) != NULL) {
  7129. counter = counter + sd->status.cart[i].amount;
  7130. count++;
  7131. if (count == 1) {
  7132. sprintf(output, "------ Cart items list of '%s' ------", sd->status.name);
  7133. clif_displaymessage(fd, output);
  7134. }
  7135. if (sd->status.cart[i].refine)
  7136. sprintf(output, "%d %s %+d (%s %+d, id: %d)", sd->status.cart[i].amount, item_data->name, sd->status.cart[i].refine, item_data->jname, sd->status.cart[i].refine, sd->status.cart[i].nameid);
  7137. else
  7138. sprintf(output, "%d %s (%s, id: %d)", sd->status.cart[i].amount, item_data->name, item_data->jname, sd->status.cart[i].nameid);
  7139. clif_displaymessage(fd, output);
  7140. memset(output, '\0', sizeof(output));
  7141. counter2 = 0;
  7142. for (j = 0; j < item_data->slot; j++) {
  7143. if (sd->status.cart[i].card[j]) {
  7144. if ( (item_temp = itemdb_search(sd->status.cart[i].card[j])) != NULL) {
  7145. if (output[0] == '\0')
  7146. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  7147. else
  7148. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  7149. strcat(output, outputtmp);
  7150. }
  7151. }
  7152. }
  7153. if (output[0] != '\0') {
  7154. output[strlen(output) - 2] = ')';
  7155. output[strlen(output) - 1] = '\0';
  7156. clif_displaymessage(fd, output);
  7157. }
  7158. }
  7159. }
  7160. if (count == 0)
  7161. clif_displaymessage(fd, "No item found in the cart of this player.");
  7162. else {
  7163. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  7164. clif_displaymessage(fd, output);
  7165. }
  7166. return 0;
  7167. }
  7168. int atcommand_itemlist(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7169. {
  7170. struct item_data *item_data, *item_temp;
  7171. int i, j, equip, count, counter, counter2;
  7172. char character[NAME_LENGTH], output[200], equipstr[100], outputtmp[200];
  7173. struct item *i_item; //Current inventory item.
  7174. nullpo_retr(-1, sd);
  7175. memset(character, '\0', sizeof(character));
  7176. memset(output, '\0', sizeof(output));
  7177. memset(equipstr, '\0', sizeof(equipstr));
  7178. memset(outputtmp, '\0', sizeof(outputtmp));
  7179. counter = 0;
  7180. count = 0;
  7181. for (i = 0; i < MAX_INVENTORY; i++) {
  7182. i_item = &sd->status.inventory[i];
  7183. if (sd->status.inventory[i].nameid > 0 && (item_data = itemdb_exists(i_item->nameid)) != NULL) {
  7184. counter = counter + i_item->amount;
  7185. count++;
  7186. if (count == 1) {
  7187. sprintf(output, "------ Items list of '%s' ------", sd->status.name);
  7188. clif_displaymessage(fd, output);
  7189. }
  7190. if ((equip = i_item->equip)) {
  7191. strcpy(equipstr, "| equiped: ");
  7192. if (equip & EQP_GARMENT)
  7193. strcat(equipstr, "robe/gargment, ");
  7194. if (equip & EQP_ACC_L)
  7195. strcat(equipstr, "left accessory, ");
  7196. if (equip & EQP_ARMOR)
  7197. strcat(equipstr, "body/armor, ");
  7198. if ((equip & EQP_ARMS) == EQP_HAND_R)
  7199. strcat(equipstr, "right hand, ");
  7200. if ((equip & EQP_ARMS) == EQP_HAND_L)
  7201. strcat(equipstr, "left hand, ");
  7202. if ((equip & EQP_ARMS) == EQP_ARMS)
  7203. strcat(equipstr, "both hands, ");
  7204. if (equip & EQP_SHOES)
  7205. strcat(equipstr, "feet, ");
  7206. if (equip & EQP_ACC_R)
  7207. strcat(equipstr, "right accessory, ");
  7208. if ((equip & EQP_HELM) == EQP_HEAD_LOW)
  7209. strcat(equipstr, "lower head, ");
  7210. if ((equip & EQP_HELM) == EQP_HEAD_TOP)
  7211. strcat(equipstr, "top head, ");
  7212. if ((equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP))
  7213. strcat(equipstr, "lower/top head, ");
  7214. if ((equip & EQP_HELM) == EQP_HEAD_MID)
  7215. strcat(equipstr, "mid head, ");
  7216. if ((equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID))
  7217. strcat(equipstr, "lower/mid head, ");
  7218. if ((equip & EQP_HELM) == EQP_HELM)
  7219. strcat(equipstr, "lower/mid/top head, ");
  7220. // remove final ', '
  7221. equipstr[strlen(equipstr) - 2] = '\0';
  7222. } else
  7223. memset(equipstr, '\0', sizeof(equipstr));
  7224. if (i_item->refine)
  7225. sprintf(output, "%d %s %+d (%s %+d, id: %d) %s", i_item->amount, item_data->name, i_item->refine, item_data->jname, i_item->refine, i_item->nameid, equipstr);
  7226. else
  7227. sprintf(output, "%d %s (%s, id: %d) %s", i_item->amount, item_data->name, item_data->jname, i_item->nameid, equipstr);
  7228. clif_displaymessage(fd, output);
  7229. memset(output, '\0', sizeof(output));
  7230. counter2 = 0;
  7231. if(i_item->card[0]==CARD0_PET) { //pet eggs
  7232. if (i_item->card[3])
  7233. sprintf(outputtmp, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(i_item->card[1], i_item->card[2]));
  7234. else
  7235. sprintf(outputtmp, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(i_item->card[1], i_item->card[2]));
  7236. strcat(output, outputtmp);
  7237. } else
  7238. if(i_item->card[0]==CARD0_FORGE) { //forged items.
  7239. sprintf(outputtmp, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(i_item->card[2], i_item->card[3]), i_item->card[1]>>8, i_item->card[1]&0x0f);
  7240. } else
  7241. if(i_item->card[0]==CARD0_CREATE) { //created items.
  7242. sprintf(outputtmp, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(i_item->card[2], i_item->card[3]));
  7243. strcat(output, outputtmp);
  7244. } else //Normal slots
  7245. for (j = 0; j < item_data->slot; j++) {
  7246. if (sd->status.inventory[i].card[j]) {
  7247. if ((item_temp = itemdb_exists(i_item->card[j])) != NULL) {
  7248. if (output[0] == '\0')
  7249. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  7250. else
  7251. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  7252. strcat(output, outputtmp);
  7253. }
  7254. }
  7255. }
  7256. if (output[0] != '\0') {
  7257. output[strlen(output) - 2] = ')';
  7258. output[strlen(output) - 1] = '\0';
  7259. clif_displaymessage(fd, output);
  7260. }
  7261. }
  7262. }
  7263. if (count == 0)
  7264. {
  7265. clif_displaymessage(fd, "No item found on this player.");
  7266. return -1;
  7267. }
  7268. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  7269. clif_displaymessage(fd, output);
  7270. return 0;
  7271. }
  7272. int atcommand_stats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7273. {
  7274. char character[NAME_LENGTH];
  7275. char job_jobname[100];
  7276. char output[200];
  7277. int i;
  7278. struct {
  7279. const char* format;
  7280. int value;
  7281. } output_table[] = {
  7282. { "Base Level - %d", 0 },
  7283. { NULL, 0 },
  7284. { "Hp - %d", 0 },
  7285. { "MaxHp - %d", 0 },
  7286. { "Sp - %d", 0 },
  7287. { "MaxSp - %d", 0 },
  7288. { "Str - %3d", 0 },
  7289. { "Agi - %3d", 0 },
  7290. { "Vit - %3d", 0 },
  7291. { "Int - %3d", 0 },
  7292. { "Dex - %3d", 0 },
  7293. { "Luk - %3d", 0 },
  7294. { "Zeny - %d", 0 },
  7295. { "Free SK Points - %d", 0 },
  7296. { "JobChangeLvl - %d", 0 },
  7297. { NULL, 0 }
  7298. };
  7299. memset(character, '\0', sizeof(character));
  7300. memset(job_jobname, '\0', sizeof(job_jobname));
  7301. memset(output, '\0', sizeof(output));
  7302. //direct array initialization with variables is not standard C compliant.
  7303. output_table[0].value = sd->status.base_level;
  7304. output_table[1].format = job_jobname;
  7305. output_table[1].value = sd->status.job_level;
  7306. output_table[2].value = sd->status.hp;
  7307. output_table[3].value = sd->status.max_hp;
  7308. output_table[4].value = sd->status.sp;
  7309. output_table[5].value = sd->status.max_sp;
  7310. output_table[6].value = sd->status.str;
  7311. output_table[7].value = sd->status.agi;
  7312. output_table[8].value = sd->status.vit;
  7313. output_table[9].value = sd->status.int_;
  7314. output_table[10].value = sd->status.dex;
  7315. output_table[11].value = sd->status.luk;
  7316. output_table[12].value = sd->status.zeny;
  7317. output_table[13].value = sd->status.skill_point;
  7318. output_table[14].value = sd->change_level;
  7319. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7320. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7321. clif_displaymessage(fd, output);
  7322. for (i = 0; output_table[i].format != NULL; i++) {
  7323. sprintf(output, output_table[i].format, output_table[i].value);
  7324. clif_displaymessage(fd, output);
  7325. }
  7326. return 0;
  7327. }
  7328. int atcommand_delitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7329. {
  7330. char item_name[100];
  7331. int i, number = 0, item_id, item_position, count;
  7332. struct item_data *item_data;
  7333. char output[200];
  7334. nullpo_retr(-1, sd);
  7335. memset(item_name, '\0', sizeof(item_name));
  7336. memset(output, '\0', sizeof(output));
  7337. if (!message || !*message || (
  7338. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 2 &&
  7339. sscanf(message, "%s %d", item_name, &number) < 2
  7340. ) || number < 1) {
  7341. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <item_name_or_ID> <quantity> <player>).");
  7342. return -1;
  7343. }
  7344. item_id = 0;
  7345. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  7346. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  7347. item_id = item_data->nameid;
  7348. if (item_id > 500) {
  7349. item_position = pc_search_inventory(sd, item_id);
  7350. if (item_position >= 0) {
  7351. count = 0;
  7352. for(i = 0; i < number && item_position >= 0; i++) {
  7353. //Logs (A)dmins items [Lupus]
  7354. if(log_config.enable_logs&0x400)
  7355. log_pick_pc(sd, "A", sd->status.inventory[item_position].nameid, -1, &sd->status.inventory[item_position]);
  7356. pc_delitem(sd, item_position, 1, 0);
  7357. count++;
  7358. item_position = pc_search_inventory(sd, item_id); // for next loop
  7359. }
  7360. sprintf(output, msg_txt(113), count); // %d item(s) removed by a GM.
  7361. clif_displaymessage(sd->fd, output);
  7362. if (number == count)
  7363. sprintf(output, msg_txt(114), count); // %d item(s) removed from the player.
  7364. else
  7365. sprintf(output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  7366. clif_displaymessage(fd, output);
  7367. } else {
  7368. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7369. return -1;
  7370. }
  7371. }
  7372. else
  7373. {
  7374. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7375. return -1;
  7376. }
  7377. return 0;
  7378. }
  7379. /*==========================================
  7380. * atcommand_info[] structure definition
  7381. *------------------------------------------*/
  7382. AtCommandInfo atcommand_info[] = {
  7383. { "rura", 40,40, atcommand_mapmove },
  7384. { "warp", 40,40, atcommand_mapmove },
  7385. { "mapmove", 40,40, atcommand_mapmove }, // + /mm
  7386. { "where", 1,1, atcommand_where },
  7387. { "jumpto", 20,20, atcommand_jumpto }, // + /shift
  7388. { "warpto", 20,20, atcommand_jumpto },
  7389. { "goto", 20,20, atcommand_jumpto },
  7390. { "jump", 40,40, atcommand_jump },
  7391. { "who", 20,20, atcommand_who },
  7392. { "whois", 20,20, atcommand_who },
  7393. { "who2", 20,20, atcommand_who2 },
  7394. { "who3", 20,20, atcommand_who3 },
  7395. { "whomap", 20,20, atcommand_whomap },
  7396. { "whomap2", 20,20, atcommand_whomap2 },
  7397. { "whomap3", 20,20, atcommand_whomap3 },
  7398. { "whogm", 20,20, atcommand_whogm },
  7399. { "save", 40,40, atcommand_save },
  7400. { "return", 40,40, atcommand_load },
  7401. { "load", 40,40, atcommand_load },
  7402. { "speed", 40,40, atcommand_speed },
  7403. { "storage", 1,1, atcommand_storage },
  7404. { "gstorage", 50,50, atcommand_guildstorage },
  7405. { "option", 40,40, atcommand_option },
  7406. { "hide", 40,40, atcommand_hide }, // + /hide
  7407. { "jobchange", 40,40, atcommand_jobchange },
  7408. { "job", 40,40, atcommand_jobchange },
  7409. { "die", 1,1, atcommand_die },
  7410. { "kill", 60,60, atcommand_kill },
  7411. { "alive", 60,60, atcommand_alive },
  7412. { "kami", 40,40, atcommand_kami },
  7413. { "kamib", 40,40, atcommand_kami },
  7414. { "kamic", 40,40, atcommand_kami },
  7415. { "heal", 40,60, atcommand_heal },
  7416. { "item", 60,60, atcommand_item },
  7417. { "item2", 60,60, atcommand_item2 },
  7418. { "itemreset", 40,40, atcommand_itemreset },
  7419. { "blvl", 60,60, atcommand_baselevelup },
  7420. { "lvup", 60,60, atcommand_baselevelup },
  7421. { "blevel", 60,60, atcommand_baselevelup },
  7422. { "baselvl", 60,60, atcommand_baselevelup },
  7423. { "baselvup", 60,60, atcommand_baselevelup },
  7424. { "baselevel", 60,60, atcommand_baselevelup },
  7425. { "baselvlup", 60,60, atcommand_baselevelup },
  7426. { "jlvl", 60,60, atcommand_joblevelup },
  7427. { "jlevel", 60,60, atcommand_joblevelup },
  7428. { "joblvl", 60,60, atcommand_joblevelup },
  7429. { "joblevel", 60,60, atcommand_joblevelup },
  7430. { "joblvup", 60,60, atcommand_joblevelup },
  7431. { "joblvlup", 60,60, atcommand_joblevelup },
  7432. { "h", 20,20, atcommand_help },
  7433. { "help", 20,20, atcommand_help },
  7434. { "h2", 20,20, atcommand_help2 },
  7435. { "help2", 20,20, atcommand_help2 },
  7436. { "pvpoff", 40,40, atcommand_pvpoff },
  7437. { "pvpon", 40,40, atcommand_pvpon },
  7438. { "gvgoff", 40,40, atcommand_gvgoff },
  7439. { "gpvpoff", 40,40, atcommand_gvgoff },
  7440. { "gvgon", 40,40, atcommand_gvgon },
  7441. { "gpvpon", 40,40, atcommand_gvgon },
  7442. { "model", 20,20, atcommand_model },
  7443. { "go", 10,10, atcommand_go },
  7444. { "monster", 50,50, atcommand_monster },
  7445. { "spawn", 50,50, atcommand_monster },
  7446. { "monstersmall", 50,50, atcommand_monstersmall },
  7447. { "monsterbig", 50,50, atcommand_monsterbig },
  7448. { "killmonster", 60,60, atcommand_killmonster },
  7449. { "killmonster2", 40,40, atcommand_killmonster2 },
  7450. { "refine", 60,60, atcommand_refine },
  7451. { "produce", 60,60, atcommand_produce },
  7452. { "memo", 40,40, atcommand_memo },
  7453. { "gat", 99,99, atcommand_gat },
  7454. { "displaystatus", 99,99, atcommand_displaystatus },
  7455. { "stpoint", 60,60, atcommand_statuspoint },
  7456. { "skpoint", 60,60, atcommand_skillpoint },
  7457. { "zeny", 60,60, atcommand_zeny },
  7458. { "str", 60,60, atcommand_param },
  7459. { "agi", 60,60, atcommand_param },
  7460. { "vit", 60,60, atcommand_param },
  7461. { "int", 60,60, atcommand_param },
  7462. { "dex", 60,60, atcommand_param },
  7463. { "luk", 60,60, atcommand_param },
  7464. { "glvl", 60,60, atcommand_guildlevelup },
  7465. { "glevel", 60,60, atcommand_guildlevelup },
  7466. { "guildlvl", 60,60, atcommand_guildlevelup },
  7467. { "guildlvup", 60,60, atcommand_guildlevelup },
  7468. { "guildlevel", 60,60, atcommand_guildlevelup },
  7469. { "guildlvlup", 60,60, atcommand_guildlevelup },
  7470. { "makeegg", 60,60, atcommand_makeegg },
  7471. { "hatch", 60,60, atcommand_hatch },
  7472. { "petfriendly", 40,40, atcommand_petfriendly },
  7473. { "pethungry", 40,40, atcommand_pethungry },
  7474. { "petrename", 1,1, atcommand_petrename },
  7475. { "recall", 60,60, atcommand_recall }, // + /recall
  7476. { "night", 80,80, atcommand_night },
  7477. { "day", 80,80, atcommand_day },
  7478. { "doom", 80,80, atcommand_doom },
  7479. { "doommap", 80,80, atcommand_doommap },
  7480. { "raise", 80,80, atcommand_raise },
  7481. { "raisemap", 80,80, atcommand_raisemap },
  7482. { "kick", 20,20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7483. { "kickall", 99,99, atcommand_kickall },
  7484. { "allskill", 60,60, atcommand_allskill },
  7485. { "allskills", 60,60, atcommand_allskill },
  7486. { "skillall", 60,60, atcommand_allskill },
  7487. { "skillsall", 60,60, atcommand_allskill },
  7488. { "questskill", 40,40, atcommand_questskill },
  7489. { "lostskill", 40,40, atcommand_lostskill },
  7490. { "spiritball", 40,40, atcommand_spiritball },
  7491. { "party", 1,1, atcommand_party },
  7492. { "guild", 50,50, atcommand_guild },
  7493. { "agitstart", 60,60, atcommand_agitstart },
  7494. { "agitend", 60,60, atcommand_agitend },
  7495. { "mapexit", 99,99, atcommand_mapexit },
  7496. { "idsearch", 60,60, atcommand_idsearch },
  7497. { "broadcast", 40,40, atcommand_broadcast }, // + /b and /nb
  7498. { "localbroadcast", 40,40, atcommand_localbroadcast }, // + /lb and /nlb
  7499. { "recallall", 80,80, atcommand_recallall },
  7500. { "reloaditemdb", 99,99, atcommand_reloaditemdb },
  7501. { "reloadmobdb", 99,99, atcommand_reloadmobdb },
  7502. { "reloadskilldb", 99,99, atcommand_reloadskilldb },
  7503. { "reloadscript", 99,99, atcommand_reloadscript },
  7504. { "reloadatcommand", 99,99, atcommand_reloadatcommand },
  7505. { "reloadbattleconf", 99,99, atcommand_reloadbattleconf },
  7506. { "reloadstatusdb", 99,99, atcommand_reloadstatusdb },
  7507. { "reloadpcdb", 99,99, atcommand_reloadpcdb },
  7508. { "reloadmotd", 99,99, atcommand_reloadmotd },
  7509. { "mapinfo", 99,99, atcommand_mapinfo },
  7510. { "dye", 40,40, atcommand_dye },
  7511. { "ccolor", 40,40, atcommand_dye },
  7512. { "hairstyle", 40,40, atcommand_hair_style },
  7513. { "hstyle", 40,40, atcommand_hair_style },
  7514. { "haircolor", 40,40, atcommand_hair_color },
  7515. { "hcolor", 40,40, atcommand_hair_color },
  7516. { "statall", 60,60, atcommand_stat_all },
  7517. { "statsall", 60,60, atcommand_stat_all },
  7518. { "allstats", 60,60, atcommand_stat_all },
  7519. { "allstat", 60,60, atcommand_stat_all },
  7520. { "block", 60,60, atcommand_char_block },
  7521. { "charblock", 60,60, atcommand_char_block },
  7522. { "ban", 60,60, atcommand_char_ban },
  7523. { "banish", 60,60, atcommand_char_ban },
  7524. { "charban", 60,60, atcommand_char_ban },
  7525. { "charbanish", 60,60, atcommand_char_ban },
  7526. { "unblock", 60,60, atcommand_char_unblock },
  7527. { "charunblock", 60,60, atcommand_char_unblock },
  7528. { "unban", 60,60, atcommand_char_unban },
  7529. { "unbanish", 60,60, atcommand_char_unban },
  7530. { "charunban", 60,60, atcommand_char_unban },
  7531. { "charunbanish", 60,60, atcommand_char_unban },
  7532. { "mount", 20,20, atcommand_mount_peco },
  7533. { "mountpeco", 20,20, atcommand_mount_peco },
  7534. { "guildspy", 60,60, atcommand_guildspy },
  7535. { "partyspy", 60,60, atcommand_partyspy },
  7536. { "repairall", 60,60, atcommand_repairall },
  7537. { "guildrecall", 60,60, atcommand_guildrecall },
  7538. { "partyrecall", 60,60, atcommand_partyrecall },
  7539. { "nuke", 60,60, atcommand_nuke },
  7540. { "shownpc", 80,80, atcommand_shownpc },
  7541. { "hidenpc", 80,80, atcommand_hidenpc },
  7542. { "loadnpc", 80,80, atcommand_loadnpc },
  7543. { "unloadnpc", 80,80, atcommand_unloadnpc },
  7544. { "time", 1,1, atcommand_servertime },
  7545. { "date", 1,1, atcommand_servertime },
  7546. { "serverdate", 1,1, atcommand_servertime },
  7547. { "servertime", 1,1, atcommand_servertime },
  7548. { "jail", 60,60, atcommand_jail },
  7549. { "unjail", 60,60, atcommand_unjail },
  7550. { "discharge", 60,60, atcommand_unjail },
  7551. { "jailfor", 60,60, atcommand_jailfor },
  7552. { "jailtime", 1,1, atcommand_jailtime },
  7553. { "disguise", 20,20, atcommand_disguise },
  7554. { "undisguise", 20,20, atcommand_undisguise },
  7555. { "email", 1,1, atcommand_email },
  7556. { "effect", 40,40, atcommand_effect },
  7557. { "follow", 20,20, atcommand_follow },
  7558. { "addwarp", 60,60, atcommand_addwarp },
  7559. { "skillon", 80,80, atcommand_skillon },
  7560. { "skilloff", 80,80, atcommand_skilloff },
  7561. { "killer", 60,60, atcommand_killer },
  7562. { "npcmove", 80,80, atcommand_npcmove },
  7563. { "killable", 40,40, atcommand_killable },
  7564. { "dropall", 40,40, atcommand_dropall },
  7565. { "storeall", 40,40, atcommand_storeall },
  7566. { "skillid", 40,40, atcommand_skillid },
  7567. { "useskill", 40,40, atcommand_useskill },
  7568. { "displayskill", 99,99, atcommand_displayskill },
  7569. { "snow", 99,99, atcommand_snow },
  7570. { "sakura", 99,99, atcommand_sakura },
  7571. { "clouds", 99,99, atcommand_clouds },
  7572. { "clouds2", 99,99, atcommand_clouds2 },
  7573. { "fog", 99,99, atcommand_fog },
  7574. { "fireworks", 99,99, atcommand_fireworks },
  7575. { "leaves", 99,99, atcommand_leaves },
  7576. { "summon", 60,60, atcommand_summon },
  7577. { "adjgmlvl", 99,99, atcommand_adjgmlvl },
  7578. { "adjcmdlvl", 99,99, atcommand_adjcmdlvl },
  7579. { "trade", 60,60, atcommand_trade },
  7580. { "send", 99,99, atcommand_send },
  7581. { "setbattleflag", 99,99, atcommand_setbattleflag },
  7582. { "unmute", 80,80, atcommand_unmute },
  7583. { "clearweather", 99,99, atcommand_clearweather },
  7584. { "uptime", 1,1, atcommand_uptime },
  7585. { "changesex", 60,60, atcommand_changesex },
  7586. { "mute", 80,80, atcommand_mute },
  7587. { "refresh", 1,1, atcommand_refresh },
  7588. { "identify", 40,40, atcommand_identify },
  7589. { "gmotd", 20,20, atcommand_gmotd },
  7590. { "misceffect", 50,50, atcommand_misceffect },
  7591. { "mobsearch", 10,10, atcommand_mobsearch },
  7592. { "cleanmap", 40,40, atcommand_cleanmap },
  7593. { "npctalk", 20,20, atcommand_npctalk },
  7594. { "pettalk", 10,10, atcommand_pettalk },
  7595. { "users", 40,40, atcommand_users },
  7596. { "reset", 40,40, atcommand_reset },
  7597. { "skilltree", 40,40, atcommand_skilltree },
  7598. { "marry", 40,40, atcommand_marry },
  7599. { "divorce", 40,40, atcommand_divorce },
  7600. { "sound", 40,40, atcommand_sound },
  7601. { "undisguiseall", 99,99, atcommand_undisguiseall },
  7602. { "disguiseall", 99,99, atcommand_disguiseall },
  7603. { "changelook", 60,60, atcommand_changelook },
  7604. { "autoloot", 10,10, atcommand_autoloot },
  7605. { "alootid", 10,10, atcommand_autolootitem },
  7606. { "mobinfo", 1,1, atcommand_mobinfo },
  7607. { "monsterinfo", 1,1, atcommand_mobinfo },
  7608. { "mi", 1,1, atcommand_mobinfo },
  7609. { "exp", 1,1, atcommand_exp },
  7610. { "adopt", 40,40, atcommand_adopt },
  7611. { "version", 1,1, atcommand_version },
  7612. { "mutearea", 99,99, atcommand_mutearea },
  7613. { "stfu", 99,99, atcommand_mutearea },
  7614. { "rates", 1,1, atcommand_rates },
  7615. { "iteminfo", 1,1, atcommand_iteminfo },
  7616. { "ii", 1,1, atcommand_iteminfo },
  7617. { "whodrops", 1,1, atcommand_whodrops },
  7618. { "whereis", 10,10, atcommand_whereis },
  7619. { "mapflag", 99,99, atcommand_mapflag },
  7620. { "me", 20,20, atcommand_me },
  7621. { "monsterignore", 99,99, atcommand_monsterignore },
  7622. { "battleignore", 99,99, atcommand_monsterignore },
  7623. { "fakename", 20,20, atcommand_fakename },
  7624. { "size", 20,20, atcommand_size },
  7625. { "showexp", 10,10, atcommand_showexp},
  7626. { "showzeny", 10,10, atcommand_showzeny},
  7627. { "showdelay", 1,1, atcommand_showdelay},
  7628. { "autotrade", 10,10, atcommand_autotrade },
  7629. { "at", 10,10, atcommand_autotrade },
  7630. { "changegm", 10,10, atcommand_changegm },
  7631. { "changeleader", 10,10, atcommand_changeleader },
  7632. { "partyoption", 10,10, atcommand_partyoption},
  7633. { "invite", 1,1, atcommand_invite },
  7634. { "duel", 1,1, atcommand_duel },
  7635. { "leave", 1,1, atcommand_leave },
  7636. { "accept", 1,1, atcommand_accept },
  7637. { "reject", 1,1, atcommand_reject },
  7638. { "away", 1,1, atcommand_away },
  7639. { "aw", 1,1, atcommand_away },
  7640. { "main", 1,1, atcommand_main },
  7641. { "clone", 50,50, atcommand_clone },
  7642. { "slaveclone", 50,50, atcommand_clone },
  7643. { "evilclone", 50,50, atcommand_clone },
  7644. { "tonpc", 40,40, atcommand_tonpc },
  7645. { "commands", 1,1, atcommand_commands },
  7646. { "noask", 1,1, atcommand_noask },
  7647. { "request", 20,20, atcommand_request },
  7648. { "hlvl", 60,60, atcommand_homlevel },
  7649. { "hlevel", 60,60, atcommand_homlevel },
  7650. { "homlvl", 60,60, atcommand_homlevel },
  7651. { "homlvup", 60,60, atcommand_homlevel },
  7652. { "homlevel", 60,60, atcommand_homlevel },
  7653. { "homevolve", 60,60, atcommand_homevolution },
  7654. { "homevolution", 60,60, atcommand_homevolution },
  7655. { "makehomun", 60,60, atcommand_makehomun },
  7656. { "homfriendly", 60,60, atcommand_homfriendly },
  7657. { "homhungry", 60,60, atcommand_homhungry },
  7658. { "homtalk", 10,10, atcommand_homtalk },
  7659. { "hominfo", 1,1, atcommand_hominfo },
  7660. { "homstats", 1,1, atcommand_homstats },
  7661. { "homshuffle", 60,60, atcommand_homshuffle },
  7662. { "showmobs", 10,10, atcommand_showmobs },
  7663. { "feelreset", 10,10, atcommand_feelreset },
  7664. { "auction", 60,60, atcommand_auction },
  7665. { "mail", 1,1, atcommand_mail },
  7666. { "noks", 0,0, atcommand_ksprotection },
  7667. { "allowks", 6,6, atcommand_allowks },
  7668. { "cash", 60,60, atcommand_cash },
  7669. { "points", 60,60, atcommand_cash },
  7670. { "agitstart2", 60,60, atcommand_agitstart2 },
  7671. { "agitend2", 60,60, atcommand_agitend2 },
  7672. { "skreset", 60,60, atcommand_resetskill },
  7673. { "streset", 60,60, atcommand_resetstat },
  7674. { "storagelist", 40,40, atcommand_storagelist },
  7675. { "cartlist", 40,40, atcommand_cart_list },
  7676. { "itemlist", 40,40, atcommand_itemlist },
  7677. { "stats", 40,40, atcommand_stats },
  7678. { "delitem", 60,60, atcommand_delitem },
  7679. };
  7680. /*==========================================
  7681. * Command lookup functions
  7682. *------------------------------------------*/
  7683. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  7684. {
  7685. int i;
  7686. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  7687. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  7688. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7689. }
  7690. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  7691. {
  7692. int i;
  7693. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  7694. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7695. }
  7696. /*==========================================
  7697. * Retrieve the command's required gm level
  7698. *------------------------------------------*/
  7699. int get_atcommand_level(const AtCommandFunc func)
  7700. {
  7701. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  7702. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7703. }
  7704. /// Executes an at-command.
  7705. /// To be called by internal server code (bypasses various restrictions).
  7706. bool is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  7707. {
  7708. AtCommandInfo* info;
  7709. char command[100];
  7710. char args[100];
  7711. char output[200];
  7712. if( !str || !*str )
  7713. return false;
  7714. if( *str != atcommand_symbol && *str != charcommand_symbol ) // check first char
  7715. return false;
  7716. if( sscanf(str, "%99s %99[^\n]", command, args) < 2 )
  7717. args[0] = '\0';
  7718. info = get_atcommandinfo_byname(command);
  7719. if( info == NULL || info->func == NULL || ( *str == atcommand_symbol && gmlvl < info->level ) || ( *str == charcommand_symbol && gmlvl < info->level2 ) )
  7720. {
  7721. if( gmlvl == 0 )
  7722. return false; // will just display as normal text
  7723. else
  7724. {
  7725. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7726. clif_displaymessage(fd, output);
  7727. return true;
  7728. }
  7729. }
  7730. //fd will not equal sd->fd if it's a charcommand. Of course, using a charcommand on yourself would make it = sd->fd as well
  7731. if( log_config.gm && ( info->level >= log_config.gm || info->level2 >= log_config.gm ) && fd == sd->fd)
  7732. log_atcommand(sd, str);
  7733. if( info->func(fd, sd, command, args) != 0 )
  7734. {
  7735. sprintf(output, msg_txt(154), command); // "%s failed."
  7736. clif_displaymessage(fd, output);
  7737. }
  7738. return true;
  7739. }
  7740. /// Executes an at-command.
  7741. /// To be used by player-invoked code (restrictions will be applied).
  7742. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  7743. {
  7744. struct map_session_data* pl_sd;
  7745. char charname[NAME_LENGTH];
  7746. char cmd[100];
  7747. char param[100];
  7748. char output[200];
  7749. char output2[200];
  7750. const char* message2;
  7751. int gmlvl = pc_isGM(sd);
  7752. nullpo_retr(false, sd);
  7753. if( !message || !*message )
  7754. return false; // shouldn't happen
  7755. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7756. return true; // so that it won't display as normal message
  7757. if( battle_config.atc_gmonly != 0 && gmlvl == 0 )
  7758. return false;
  7759. if( map[sd->bl.m].nocommand && gmlvl < map[sd->bl.m].nocommand )
  7760. {
  7761. clif_displaymessage(fd, msg_txt(143)); // "Commands are disabled on this map."
  7762. return false;
  7763. }
  7764. // skip 10/11-langtype's codepage indicator, if detected
  7765. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7766. message += 3;
  7767. if (*message == charcommand_symbol)
  7768. {
  7769. //Fail any #commands without names.
  7770. if( sscanf(message, "%99s %99[^\n]", cmd, param) == 1 ) {
  7771. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7772. clif_displaymessage(fd, output);
  7773. return true;
  7774. }
  7775. //Checks to see if #command has a name or a name + parameters.
  7776. else if (sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", cmd, charname, param) >= 2
  7777. || sscanf(message, "%99s %23s %99[^\n]", cmd, charname, param) >= 2)
  7778. {
  7779. if ( (pl_sd = map_nick2sd(charname)) == NULL )
  7780. {
  7781. sprintf(output, "%s failed. Player %s not found.", cmd, charname);
  7782. clif_displaymessage(fd, output);
  7783. return true;
  7784. }
  7785. else {
  7786. //If it's just a name and no params, send the command with no name. Otherwise, send it with the parameters.
  7787. if (sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", cmd, charname, param) == 2
  7788. || sscanf(message, "%99s %23s %99[^\n]", cmd, charname, param) == 2)
  7789. {
  7790. sprintf(output, "%s", cmd);
  7791. memcpy(output2, output, sizeof(output2));
  7792. message2 = output2;
  7793. //NOTE: fd is passed to is_atcommand_sub instead of pl_sd->fd because we want output sent to the user of the command, not the target.
  7794. return is_atcommand_sub(fd,pl_sd,message2,gmlvl);
  7795. }
  7796. else {
  7797. sprintf(output, "%s %s", cmd, param);
  7798. memcpy(output2, output, sizeof(output2));
  7799. message2 = output2;
  7800. return is_atcommand_sub(fd,pl_sd,message2,gmlvl);
  7801. }
  7802. }
  7803. }
  7804. }
  7805. return is_atcommand_sub(fd,sd,message,gmlvl);
  7806. }
  7807. /*==========================================
  7808. *
  7809. *------------------------------------------*/
  7810. int atcommand_config_read(const char* cfgName)
  7811. {
  7812. char line[1024], w1[1024], w2[1024], w3[1024];
  7813. AtCommandInfo* p;
  7814. FILE* fp;
  7815. if( (fp = fopen(cfgName, "r")) == NULL )
  7816. {
  7817. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  7818. return 1;
  7819. }
  7820. while( fgets(line, sizeof(line), fp) )
  7821. {
  7822. if( line[0] == '/' && line[1] == '/' )
  7823. continue;
  7824. if( (sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3)) != 3 && ( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2
  7825. && strcmpi(w1, "import") != 0 ) && strcmpi(w1, "command_symbol") != 0 && strcmpi(w1, "char_symbol") != 0 )
  7826. continue;
  7827. p = get_atcommandinfo_byname(w1);
  7828. if( p != NULL )
  7829. {
  7830. p->level = atoi(w2);
  7831. p->level = cap_value(p->level, 0, 100);
  7832. if( (sscanf(line, "%1023[^:]:%1023s", w1, w2) == 2) && (sscanf(line, "%1023[^:]:%1023[^,],%1023s", w1, w2, w3)) != 3 )
  7833. {
  7834. ShowWarning("atcommand_conf: setting %s:%d is deprecated! Please see atcommand_athena.conf for the new setting format.\n",w1,atoi(w2));
  7835. ShowWarning("atcommand_conf: defaulting %s charcommand level to %d.\n",w1,atoi(w2));
  7836. p->level2 = atoi(w2);
  7837. }
  7838. else {
  7839. p->level2 = atoi(w3);
  7840. p->level2 = cap_value(p->level2, 0, 100);
  7841. }
  7842. }
  7843. else
  7844. if( strcmpi(w1, "import") == 0 )
  7845. atcommand_config_read(w2);
  7846. else
  7847. if( strcmpi(w1, "command_symbol") == 0 &&
  7848. w2[0] > 31 && // control characters
  7849. w2[0] != '/' && // symbol of standard ragnarok GM commands
  7850. w2[0] != '%' && // symbol of party chat speaking
  7851. w2[0] != '$' && // symbol of guild chat speaking
  7852. w2[0] != '#' ) // remote symbol
  7853. atcommand_symbol = w2[0];
  7854. else
  7855. if( strcmpi(w1, "char_symbol") == 0 &&
  7856. w2[0] > 31 &&
  7857. w2[0] != '/' &&
  7858. w2[0] != '%' &&
  7859. w2[0] != '$' &&
  7860. w2[0] != '@' )
  7861. charcommand_symbol = w2[0];
  7862. else
  7863. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  7864. }
  7865. fclose(fp);
  7866. return 0;
  7867. }
  7868. void do_init_atcommand()
  7869. {
  7870. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  7871. return;
  7872. }
  7873. void do_final_atcommand()
  7874. {
  7875. }
  7876. // commands that need to go _after_ the commands table
  7877. /*==========================================
  7878. * @commands Lists available @ commands to you
  7879. *------------------------------------------*/
  7880. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7881. {
  7882. char line_buff[CHATBOX_SIZE];
  7883. int i, gm_lvl = pc_isGM(sd), count = 0, count2 = 0;
  7884. char* cur = line_buff;
  7885. memset(line_buff,' ',CHATBOX_SIZE);
  7886. line_buff[CHATBOX_SIZE-1] = 0;
  7887. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7888. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  7889. {
  7890. unsigned int slen;
  7891. if( gm_lvl < atcommand_info[i].level )
  7892. continue;
  7893. slen = (unsigned int)strlen(atcommand_info[i].command);
  7894. // flush the text buffer if this command won't fit into it
  7895. if( slen + cur - line_buff >= CHATBOX_SIZE )
  7896. {
  7897. clif_displaymessage(fd,line_buff);
  7898. cur = line_buff;
  7899. memset(line_buff,' ',CHATBOX_SIZE);
  7900. line_buff[CHATBOX_SIZE-1] = 0;
  7901. }
  7902. memcpy(cur,atcommand_info[i].command,slen);
  7903. cur += slen+(10-slen%10);
  7904. count++;
  7905. }
  7906. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  7907. {
  7908. unsigned int slen;
  7909. if( gm_lvl < atcommand_info[i].level2 )
  7910. continue;
  7911. slen = (unsigned int)strlen(atcommand_info[i].command);
  7912. // flush the text buffer if this command won't fit into it
  7913. if( slen + cur - line_buff >= CHATBOX_SIZE )
  7914. {
  7915. clif_displaymessage(fd,line_buff);
  7916. cur = line_buff;
  7917. memset(line_buff,' ',CHATBOX_SIZE);
  7918. line_buff[CHATBOX_SIZE-1] = 0;
  7919. }
  7920. memcpy(cur,atcommand_info[i].command,slen);
  7921. cur += slen+(10-slen%10);
  7922. count2++;
  7923. }
  7924. clif_displaymessage(fd,line_buff);
  7925. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7926. clif_displaymessage(fd, atcmd_output);
  7927. sprintf(atcmd_output, "%d charcommands found.", count2);
  7928. clif_displaymessage(fd, atcmd_output);
  7929. return 0;
  7930. }