atcommand.c 270 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785
  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 "mercenary.h"
  29. #include "party.h"
  30. #include "guild.h"
  31. #include "script.h"
  32. #include "trade.h"
  33. #include "unit.h"
  34. #ifndef TXT_ONLY
  35. #include "mail.h"
  36. #endif
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <math.h>
  41. // extern variables
  42. char atcommand_symbol = '@'; // first char of the commands
  43. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  44. // local declarations
  45. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  46. typedef struct AtCommandInfo
  47. {
  48. const char* command;
  49. int level;
  50. AtCommandFunc func;
  51. } AtCommandInfo;
  52. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  53. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  54. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message);
  55. /*=========================================
  56. * Generic variables
  57. *-----------------------------------------*/
  58. char atcmd_output[200];
  59. char atcmd_player_name[NAME_LENGTH];
  60. char atcmd_temp[100];
  61. // compare function for sorting high to lowest
  62. int hightolow_compare (const void * a, const void * b)
  63. {
  64. return ( *(int*)b - *(int*)a );
  65. }
  66. // compare function for sorting lowest to highest
  67. int lowtohigh_compare (const void * a, const void * b)
  68. {
  69. return ( *(int*)a - *(int*)b );
  70. }
  71. //-----------------------------------------------------------
  72. // Return the message string of the specified number by [Yor]
  73. //-----------------------------------------------------------
  74. char* msg_txt(int msg_number)
  75. {
  76. if (msg_number >= 0 && msg_number < MAX_MSG &&
  77. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  78. return msg_table[msg_number];
  79. return "??";
  80. }
  81. //-----------------------------------------------------------
  82. // Returns Players title (from msg_athena.conf) [Lupus]
  83. //-----------------------------------------------------------
  84. static char* player_title_txt(int level)
  85. {
  86. const char* format;
  87. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  88. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  89. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  90. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  91. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  92. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  93. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  94. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  95. : "";
  96. sprintf(atcmd_temp, format, level);
  97. return atcmd_temp;
  98. }
  99. /*==========================================
  100. * Read Message Data
  101. *------------------------------------------*/
  102. int msg_config_read(const char* cfgName)
  103. {
  104. int msg_number;
  105. char line[1024], w1[1024], w2[1024];
  106. FILE *fp;
  107. static int called = 1;
  108. if ((fp = fopen(cfgName, "r")) == NULL) {
  109. ShowError("Messages file not found: %s\n", cfgName);
  110. return 1;
  111. }
  112. if ((--called) == 0)
  113. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  114. while(fgets(line, sizeof(line), fp))
  115. {
  116. if (line[0] == '/' && line[1] == '/')
  117. continue;
  118. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  119. continue;
  120. if (strcmpi(w1, "import") == 0)
  121. msg_config_read(w2);
  122. else
  123. {
  124. msg_number = atoi(w1);
  125. if (msg_number >= 0 && msg_number < MAX_MSG)
  126. {
  127. if (msg_table[msg_number] != NULL)
  128. aFree(msg_table[msg_number]);
  129. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  130. strcpy(msg_table[msg_number],w2);
  131. }
  132. }
  133. }
  134. fclose(fp);
  135. return 0;
  136. }
  137. /*==========================================
  138. * Cleanup Message Data
  139. *------------------------------------------*/
  140. void do_final_msg(void)
  141. {
  142. int i;
  143. for (i = 0; i < MAX_MSG; i++)
  144. aFree(msg_table[i]);
  145. }
  146. /*==========================================
  147. * @send (used for testing packet sends from the client)
  148. *------------------------------------------*/
  149. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  150. {
  151. int len=0,off,end,type;
  152. long num;
  153. (void)command; // not used
  154. // read message type as hex number (without the 0x)
  155. if(!message || !*message ||
  156. !((sscanf(message, "len %x", &type)==1 && (len=1))
  157. || sscanf(message, "%x", &type)==1) )
  158. {
  159. clif_displaymessage(fd, "Usage:");
  160. clif_displaymessage(fd, " @send len <packet hex number>");
  161. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  162. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  163. return -1;
  164. }
  165. #define PARSE_ERROR(error,p) \
  166. {\
  167. clif_displaymessage(fd, (error));\
  168. sprintf(atcmd_output, ">%s", (p));\
  169. clif_displaymessage(fd, atcmd_output);\
  170. }
  171. //define PARSE_ERROR
  172. #define CHECK_EOS(p) \
  173. if(*(p) == 0){\
  174. clif_displaymessage(fd, "Unexpected end of string");\
  175. return -1;\
  176. }
  177. //define CHECK_EOS
  178. #define SKIP_VALUE(p) \
  179. {\
  180. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  181. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  182. }
  183. //define SKIP_VALUE
  184. #define GET_VALUE(p,num) \
  185. {\
  186. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  187. PARSE_ERROR("Invalid number in:",(p));\
  188. return -1;\
  189. }\
  190. }
  191. //define GET_VALUE
  192. if (type > 0 && type < MAX_PACKET_DB) {
  193. if(len)
  194. {// show packet length
  195. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  196. clif_displaymessage(fd, atcmd_output);
  197. return 0;
  198. }
  199. len=packet_db[sd->packet_ver][type].len;
  200. off=2;
  201. if(len == 0)
  202. {// unknown packet - ERROR
  203. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  204. clif_displaymessage(fd, atcmd_output);
  205. return -1;
  206. } else if(len == -1)
  207. {// dynamic packet
  208. len=SHRT_MAX-4; // maximum length
  209. off=4;
  210. }
  211. WFIFOHEAD(fd, len);
  212. WFIFOW(fd,0)=TOW(type);
  213. // parse packet contents
  214. SKIP_VALUE(message);
  215. while(*message != 0 && off < len){
  216. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  217. {// default (byte)
  218. GET_VALUE(message,num);
  219. WFIFOB(fd,off)=TOB(num);
  220. ++off;
  221. } else if(TOUPPER(*message) == 'B')
  222. {// byte
  223. ++message;
  224. GET_VALUE(message,num);
  225. WFIFOB(fd,off)=TOB(num);
  226. ++off;
  227. } else if(TOUPPER(*message) == 'W')
  228. {// word (2 bytes)
  229. ++message;
  230. GET_VALUE(message,num);
  231. WFIFOW(fd,off)=TOW(num);
  232. off+=2;
  233. } else if(TOUPPER(*message) == 'L')
  234. {// long word (4 bytes)
  235. ++message;
  236. GET_VALUE(message,num);
  237. WFIFOL(fd,off)=TOL(num);
  238. off+=4;
  239. } else if(TOUPPER(*message) == 'S')
  240. {// string - escapes are valid
  241. // get string length - num <= 0 means not fixed length (default)
  242. ++message;
  243. if(*message == '"'){
  244. num=0;
  245. } else {
  246. GET_VALUE(message,num);
  247. while(*message != '"')
  248. {// find start of string
  249. if(*message == 0 || ISSPACE(*message)){
  250. PARSE_ERROR("Not a string:",message);
  251. return -1;
  252. }
  253. ++message;
  254. }
  255. }
  256. // parse string
  257. ++message;
  258. CHECK_EOS(message);
  259. end=(num<=0? 0: min(off+((int)num),len));
  260. for(; *message != '"' && (off < end || end == 0); ++off){
  261. if(*message == '\\'){
  262. ++message;
  263. CHECK_EOS(message);
  264. switch(*message){
  265. case 'a': num=0x07; break; // Bell
  266. case 'b': num=0x08; break; // Backspace
  267. case 't': num=0x09; break; // Horizontal tab
  268. case 'n': num=0x0A; break; // Line feed
  269. case 'v': num=0x0B; break; // Vertical tab
  270. case 'f': num=0x0C; break; // Form feed
  271. case 'r': num=0x0D; break; // Carriage return
  272. case 'e': num=0x1B; break; // Escape
  273. default: num=*message; break;
  274. case 'x': // Hexadecimal
  275. {
  276. ++message;
  277. CHECK_EOS(message);
  278. if(!ISXDIGIT(*message)){
  279. PARSE_ERROR("Not a hexadecimal digit:",message);
  280. return -1;
  281. }
  282. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  283. if(ISXDIGIT(*message)){
  284. ++message;
  285. CHECK_EOS(message);
  286. num<<=8;
  287. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  288. }
  289. WFIFOB(fd,off)=TOB(num);
  290. ++message;
  291. CHECK_EOS(message);
  292. continue;
  293. }
  294. case '0':
  295. case '1':
  296. case '2':
  297. case '3':
  298. case '4':
  299. case '5':
  300. case '6':
  301. case '7': // Octal
  302. {
  303. num=*message-'0'; // 1st octal digit
  304. ++message;
  305. CHECK_EOS(message);
  306. if(ISDIGIT(*message) && *message < '8'){
  307. num<<=3;
  308. num+=*message-'0'; // 2nd octal digit
  309. ++message;
  310. CHECK_EOS(message);
  311. if(ISDIGIT(*message) && *message < '8'){
  312. num<<=3;
  313. num+=*message-'0'; // 3rd octal digit
  314. ++message;
  315. CHECK_EOS(message);
  316. }
  317. }
  318. WFIFOB(fd,off)=TOB(num);
  319. continue;
  320. }
  321. }
  322. } else
  323. num=*message;
  324. WFIFOB(fd,off)=TOB(num);
  325. ++message;
  326. CHECK_EOS(message);
  327. }//for
  328. while(*message != '"')
  329. {// ignore extra characters
  330. ++message;
  331. CHECK_EOS(message);
  332. }
  333. // terminate the string
  334. if(off < end)
  335. {// fill the rest with 0's
  336. memset(WFIFOP(fd,off),0,end-off);
  337. off=end;
  338. }
  339. } else
  340. {// unknown
  341. PARSE_ERROR("Unknown type of value in:",message);
  342. return -1;
  343. }
  344. SKIP_VALUE(message);
  345. }
  346. if(packet_db[sd->packet_ver][type].len == -1)
  347. {// send dynamic packet
  348. WFIFOW(fd,2)=TOW(off);
  349. WFIFOSET(fd,off);
  350. } else
  351. {// send static packet
  352. if(off < len)
  353. memset(WFIFOP(fd,off),0,len-off);
  354. WFIFOSET(fd,len);
  355. }
  356. } else {
  357. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  358. return -1;
  359. }
  360. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  361. clif_displaymessage(fd, atcmd_output);
  362. return 0;
  363. #undef PARSE_ERROR
  364. #undef CHECK_EOS
  365. #undef SKIP_VALUE
  366. #undef GET_VALUE
  367. }
  368. /*==========================================
  369. * @rura, @warp, @mapmove
  370. *------------------------------------------*/
  371. int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  372. {
  373. char map_name[MAP_NAME_LENGTH_EXT];
  374. unsigned short mapindex;
  375. int x = 0, y = 0;
  376. int m = -1;
  377. nullpo_retr(-1, sd);
  378. memset(map_name, '\0', sizeof(map_name));
  379. if (!message || !*message ||
  380. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  381. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  382. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  383. return -1;
  384. }
  385. mapindex = mapindex_name2id(map_name);
  386. if (mapindex)
  387. m = map_mapindex2mapid(mapindex);
  388. if (!mapindex) { // m < 0 means on different server! [Kevin]
  389. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  390. return -1;
  391. }
  392. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  393. { //This is to prevent the pc_setpos call from printing an error.
  394. clif_displaymessage(fd, msg_txt(2));
  395. x = y = 0; //Invalid cell, use random spot.
  396. }
  397. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  398. clif_displaymessage(fd, msg_txt(247));
  399. return -1;
  400. }
  401. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  402. clif_displaymessage(fd, msg_txt(248));
  403. return -1;
  404. }
  405. if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
  406. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  407. return -1;
  408. }
  409. clif_displaymessage(fd, msg_txt(0)); // Warped.
  410. return 0;
  411. }
  412. /*==========================================
  413. * Displays where a character is. Corrected version by Silent. [Skotlex]
  414. *------------------------------------------*/
  415. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  416. {
  417. struct map_session_data* pl_sd;
  418. nullpo_retr(-1, sd);
  419. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  420. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  421. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  422. return -1;
  423. }
  424. pl_sd = map_nick2sd(atcmd_player_name);
  425. if( pl_sd == NULL
  426. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  427. || (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))
  428. ) {
  429. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  430. return -1;
  431. }
  432. 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);
  433. clif_displaymessage(fd, atcmd_output);
  434. return 0;
  435. }
  436. /*==========================================
  437. *
  438. *------------------------------------------*/
  439. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  440. {
  441. struct map_session_data *pl_sd = NULL;
  442. nullpo_retr(-1, sd);
  443. if (!message || !*message) {
  444. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  445. return -1;
  446. }
  447. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  448. {
  449. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  450. return -1;
  451. }
  452. if (pl_sd == sd)
  453. {
  454. clif_displaymessage(fd, "But you are already where you are...");
  455. return -1;
  456. }
  457. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  458. {
  459. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  460. return -1;
  461. }
  462. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  463. {
  464. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  465. return -1;
  466. }
  467. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  468. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  469. clif_displaymessage(fd, atcmd_output);
  470. return 0;
  471. }
  472. /*==========================================
  473. *
  474. *------------------------------------------*/
  475. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  476. {
  477. int x = 0, y = 0;
  478. nullpo_retr(-1, sd);
  479. memset(atcmd_output, '\0', sizeof(atcmd_output));
  480. sscanf(message, "%d %d", &x, &y);
  481. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  482. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  483. return -1;
  484. }
  485. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  486. { //This is to prevent the pc_setpos call from printing an error.
  487. clif_displaymessage(fd, msg_txt(2));
  488. x = y = 0; //Invalid cell, use random spot.
  489. }
  490. pc_setpos(sd, sd->mapindex, x, y, 3);
  491. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  492. clif_displaymessage(fd, atcmd_output);
  493. return 0;
  494. }
  495. /*==========================================
  496. * @who3 = Player name, his location
  497. *------------------------------------------*/
  498. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  499. {
  500. char temp0[100];
  501. struct map_session_data *pl_sd;
  502. struct s_mapiterator* iter;
  503. int j, count;
  504. int pl_GM_level, GM_level;
  505. char match_text[100];
  506. char player_name[NAME_LENGTH];
  507. nullpo_retr(-1, sd);
  508. memset(atcmd_output, '\0', sizeof(atcmd_output));
  509. memset(match_text, '\0', sizeof(match_text));
  510. memset(player_name, '\0', sizeof(player_name));
  511. if (sscanf(message, "%99[^\n]", match_text) < 1)
  512. strcpy(match_text, "");
  513. for (j = 0; match_text[j]; j++)
  514. match_text[j] = TOLOWER(match_text[j]);
  515. count = 0;
  516. GM_level = pc_isGM(sd);
  517. iter = mapit_getallusers();
  518. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  519. {
  520. pl_GM_level = pc_isGM(pl_sd);
  521. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  522. {// you can look only lower or same level
  523. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  524. for (j = 0; player_name[j]; j++)
  525. player_name[j] = TOLOWER(player_name[j]);
  526. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  527. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  528. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  529. } else {
  530. atcmd_output[0]=0;
  531. }
  532. //Player name
  533. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  534. strcat(atcmd_output,temp0);
  535. //Player title, if exists
  536. if (pl_GM_level > 0) {
  537. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  538. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  539. strcat(atcmd_output,temp0);
  540. }
  541. //Players Location: map x y
  542. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  543. strcat(atcmd_output,temp0);
  544. clif_displaymessage(fd, atcmd_output);
  545. count++;
  546. }
  547. }
  548. }
  549. mapit_free(iter);
  550. if (count == 0)
  551. clif_displaymessage(fd, msg_txt(28)); // No player found.
  552. else if (count == 1)
  553. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  554. else {
  555. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  556. clif_displaymessage(fd, atcmd_output);
  557. }
  558. return 0;
  559. }
  560. /*==========================================
  561. * Player name, BLevel, Job,
  562. *------------------------------------------*/
  563. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  564. {
  565. char temp0[100];
  566. struct map_session_data *pl_sd;
  567. struct s_mapiterator* iter;
  568. int j, count;
  569. int pl_GM_level, GM_level;
  570. char match_text[100];
  571. char player_name[NAME_LENGTH];
  572. nullpo_retr(-1, sd);
  573. memset(atcmd_output, '\0', sizeof(atcmd_output));
  574. memset(match_text, '\0', sizeof(match_text));
  575. memset(player_name, '\0', sizeof(player_name));
  576. if (sscanf(message, "%99[^\n]", match_text) < 1)
  577. strcpy(match_text, "");
  578. for (j = 0; match_text[j]; j++)
  579. match_text[j] = TOLOWER(match_text[j]);
  580. count = 0;
  581. GM_level = pc_isGM(sd);
  582. iter = mapit_getallusers();
  583. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  584. {
  585. pl_GM_level = pc_isGM(pl_sd);
  586. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  587. {// you can look only lower or same level
  588. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  589. for (j = 0; player_name[j]; j++)
  590. player_name[j] = TOLOWER(player_name[j]);
  591. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  592. //Players Name
  593. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  594. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  595. //Player title, if exists
  596. if (pl_GM_level > 0) {
  597. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  598. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  599. strcat(atcmd_output,temp0);
  600. }
  601. //Players Base Level / Job name
  602. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  603. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  604. strcat(atcmd_output,temp0);
  605. clif_displaymessage(fd, atcmd_output);
  606. count++;
  607. }
  608. }
  609. }
  610. mapit_free(iter);
  611. if (count == 0)
  612. clif_displaymessage(fd, msg_txt(28)); // No player found.
  613. else if (count == 1)
  614. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  615. else {
  616. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  617. clif_displaymessage(fd, atcmd_output);
  618. }
  619. return 0;
  620. }
  621. /*==========================================
  622. * Player name, Playrs Party / Guild name
  623. *------------------------------------------*/
  624. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  625. {
  626. char temp0[100];
  627. struct map_session_data *pl_sd;
  628. struct s_mapiterator* iter;
  629. int j, count;
  630. int pl_GM_level, GM_level;
  631. char match_text[100];
  632. char player_name[NAME_LENGTH];
  633. struct guild *g;
  634. struct party_data *p;
  635. nullpo_retr(-1, sd);
  636. memset(temp0, '\0', sizeof(temp0));
  637. memset(atcmd_output, '\0', sizeof(atcmd_output));
  638. memset(match_text, '\0', sizeof(match_text));
  639. memset(player_name, '\0', sizeof(player_name));
  640. if (sscanf(message, "%99[^\n]", match_text) < 1)
  641. strcpy(match_text, "");
  642. for (j = 0; match_text[j]; j++)
  643. match_text[j] = TOLOWER(match_text[j]);
  644. count = 0;
  645. GM_level = pc_isGM(sd);
  646. iter = mapit_getallusers();
  647. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  648. {
  649. pl_GM_level = pc_isGM(pl_sd);
  650. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  651. {// you can look only lower or same level
  652. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  653. for (j = 0; player_name[j]; j++)
  654. player_name[j] = TOLOWER(player_name[j]);
  655. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  656. g = guild_search(pl_sd->status.guild_id);
  657. p = party_search(pl_sd->status.party_id);
  658. //Players Name
  659. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  660. //Player title, if exists
  661. if (pl_GM_level > 0) {
  662. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  663. strcat(atcmd_output,temp0);
  664. }
  665. //Players Party if exists
  666. if (p != NULL) {
  667. //sprintf(temp0," | Party: '%s'", p->name);
  668. sprintf(temp0, msg_txt(335), p->party.name);
  669. strcat(atcmd_output,temp0);
  670. }
  671. //Players Guild if exists
  672. if (g != NULL) {
  673. //sprintf(temp0," | Guild: '%s'", g->name);
  674. sprintf(temp0, msg_txt(336), g->name);
  675. strcat(atcmd_output,temp0);
  676. }
  677. clif_displaymessage(fd, atcmd_output);
  678. count++;
  679. }
  680. }
  681. }
  682. mapit_free(iter);
  683. if (count == 0)
  684. clif_displaymessage(fd, msg_txt(28)); // No player found.
  685. else if (count == 1)
  686. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  687. else {
  688. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  689. clif_displaymessage(fd, atcmd_output);
  690. }
  691. return 0;
  692. }
  693. /*==========================================
  694. *
  695. *------------------------------------------*/
  696. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  697. {
  698. struct map_session_data *pl_sd;
  699. struct s_mapiterator* iter;
  700. int count;
  701. int pl_GM_level, GM_level;
  702. int map_id;
  703. char map_name[MAP_NAME_LENGTH_EXT];
  704. memset(atcmd_output, '\0', sizeof(atcmd_output));
  705. memset(map_name, '\0', sizeof(map_name));
  706. if (!message || !*message)
  707. map_id = sd->bl.m;
  708. else {
  709. sscanf(message, "%15s", map_name);
  710. if ((map_id = map_mapname2mapid(map_name)) < 0)
  711. map_id = sd->bl.m;
  712. }
  713. count = 0;
  714. GM_level = pc_isGM(sd);
  715. iter = mapit_getallusers();
  716. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  717. {
  718. pl_GM_level = pc_isGM(pl_sd);
  719. if( pl_sd->bl.m != map_id )
  720. continue;
  721. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  722. continue;
  723. if (pl_GM_level > 0)
  724. 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);
  725. else
  726. 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);
  727. clif_displaymessage(fd, atcmd_output);
  728. count++;
  729. }
  730. mapit_free(iter);
  731. if (count == 0)
  732. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  733. else if (count == 1)
  734. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  735. else {
  736. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  737. }
  738. clif_displaymessage(fd, atcmd_output);
  739. return 0;
  740. }
  741. /*==========================================
  742. *
  743. *------------------------------------------*/
  744. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  745. {
  746. struct map_session_data *pl_sd;
  747. struct s_mapiterator* iter;
  748. int count;
  749. int pl_GM_level, GM_level;
  750. int map_id = 0;
  751. char map_name[MAP_NAME_LENGTH_EXT];
  752. nullpo_retr(-1, sd);
  753. memset(atcmd_output, '\0', sizeof(atcmd_output));
  754. memset(map_name, '\0', sizeof(map_name));
  755. if (!message || !*message)
  756. map_id = sd->bl.m;
  757. else {
  758. sscanf(message, "%15s", map_name);
  759. if ((map_id = map_mapname2mapid(map_name)) < 0)
  760. map_id = sd->bl.m;
  761. }
  762. count = 0;
  763. GM_level = pc_isGM(sd);
  764. iter = mapit_getallusers();
  765. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  766. {
  767. pl_GM_level = pc_isGM(pl_sd);
  768. if( pl_sd->bl.m != map_id )
  769. continue;
  770. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  771. continue;
  772. if (pl_GM_level > 0)
  773. 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);
  774. else
  775. 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);
  776. clif_displaymessage(fd, atcmd_output);
  777. count++;
  778. }
  779. mapit_free(iter);
  780. if (count == 0)
  781. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  782. else if (count == 1)
  783. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  784. else {
  785. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  786. }
  787. clif_displaymessage(fd, atcmd_output);
  788. return 0;
  789. }
  790. /*==========================================
  791. *
  792. *------------------------------------------*/
  793. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  794. {
  795. char temp0[100];
  796. char temp1[100];
  797. struct map_session_data *pl_sd;
  798. struct s_mapiterator* iter;
  799. int count;
  800. int pl_GM_level, GM_level;
  801. int map_id = 0;
  802. char map_name[MAP_NAME_LENGTH_EXT];
  803. struct guild *g;
  804. struct party_data *p;
  805. nullpo_retr(-1, sd);
  806. memset(temp0, '\0', sizeof(temp0));
  807. memset(temp1, '\0', sizeof(temp1));
  808. memset(atcmd_output, '\0', sizeof(atcmd_output));
  809. memset(map_name, '\0', sizeof(map_name));
  810. if (!message || !*message)
  811. map_id = sd->bl.m;
  812. else {
  813. sscanf(message, "%15s", map_name);
  814. if ((map_id = map_mapname2mapid(map_name)) < 0)
  815. map_id = sd->bl.m;
  816. }
  817. count = 0;
  818. GM_level = pc_isGM(sd);
  819. iter = mapit_getallusers();
  820. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  821. {
  822. pl_GM_level = pc_isGM(pl_sd);
  823. if( pl_sd->bl.m != map_id )
  824. continue;
  825. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  826. continue;
  827. g = guild_search(pl_sd->status.guild_id);
  828. if (g == NULL)
  829. sprintf(temp1, "None");
  830. else
  831. sprintf(temp1, "%s", g->name);
  832. p = party_search(pl_sd->status.party_id);
  833. if (p == NULL)
  834. sprintf(temp0, "None");
  835. else
  836. sprintf(temp0, "%s", p->party.name);
  837. if (pl_GM_level > 0)
  838. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  839. else
  840. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  841. clif_displaymessage(fd, atcmd_output);
  842. count++;
  843. }
  844. mapit_free(iter);
  845. if (count == 0)
  846. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  847. else if (count == 1)
  848. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  849. else {
  850. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  851. }
  852. clif_displaymessage(fd, atcmd_output);
  853. return 0;
  854. }
  855. /*==========================================
  856. *
  857. *------------------------------------------*/
  858. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  859. {
  860. struct map_session_data* pl_sd;
  861. struct s_mapiterator* iter;
  862. int j, count;
  863. int pl_GM_level, GM_level;
  864. char match_text[200];
  865. char player_name[NAME_LENGTH];
  866. struct guild *g;
  867. struct party_data *p;
  868. nullpo_retr(-1, sd);
  869. memset(atcmd_output, '\0', sizeof(atcmd_output));
  870. memset(match_text, '\0', sizeof(match_text));
  871. memset(player_name, '\0', sizeof(player_name));
  872. if (sscanf(message, "%199[^\n]", match_text) < 1)
  873. strcpy(match_text, "");
  874. for (j = 0; match_text[j]; j++)
  875. match_text[j] = TOLOWER(match_text[j]);
  876. count = 0;
  877. GM_level = pc_isGM(sd);
  878. iter = mapit_getallusers();
  879. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  880. {
  881. pl_GM_level = pc_isGM(pl_sd);
  882. if (!pl_GM_level)
  883. continue;
  884. if (match_text[0])
  885. {
  886. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  887. for (j = 0; player_name[j]; j++)
  888. player_name[j] = TOLOWER(player_name[j]);
  889. // search with no case sensitive
  890. if (strstr(player_name, match_text) == NULL)
  891. continue;
  892. }
  893. if (pl_GM_level > GM_level) {
  894. if (pl_sd->sc.option & OPTION_INVISIBLE)
  895. continue;
  896. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  897. clif_displaymessage(fd, atcmd_output);
  898. count++;
  899. continue;
  900. }
  901. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  902. pl_sd->status.name, pl_GM_level,
  903. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  904. clif_displaymessage(fd, atcmd_output);
  905. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  906. pl_sd->status.base_level,
  907. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  908. clif_displaymessage(fd, atcmd_output);
  909. p = party_search(pl_sd->status.party_id);
  910. g = guild_search(pl_sd->status.guild_id);
  911. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  912. p?p->party.name:"None", g?g->name:"None");
  913. clif_displaymessage(fd, atcmd_output);
  914. count++;
  915. }
  916. mapit_free(iter);
  917. if (count == 0)
  918. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  919. else if (count == 1)
  920. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  921. else {
  922. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  923. clif_displaymessage(fd, atcmd_output);
  924. }
  925. return 0;
  926. }
  927. /*==========================================
  928. *
  929. *------------------------------------------*/
  930. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  931. {
  932. nullpo_retr(-1, sd);
  933. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  934. if (sd->status.pet_id > 0 && sd->pd)
  935. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  936. chrif_save(sd,0);
  937. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  938. return 0;
  939. }
  940. /*==========================================
  941. *
  942. *------------------------------------------*/
  943. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  944. {
  945. int m;
  946. nullpo_retr(-1, sd);
  947. m = map_mapindex2mapid(sd->status.save_point.map);
  948. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  949. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  950. return -1;
  951. }
  952. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  953. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  954. return -1;
  955. }
  956. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  957. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  958. return 0;
  959. }
  960. /*==========================================
  961. *
  962. *------------------------------------------*/
  963. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  964. {
  965. int speed;
  966. nullpo_retr(-1, sd);
  967. memset(atcmd_output, '\0', sizeof(atcmd_output));
  968. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  969. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  970. clif_displaymessage(fd, atcmd_output);
  971. return -1;
  972. }
  973. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  974. status_calc_bl(&sd->bl, SCB_SPEED);
  975. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  976. return 0;
  977. }
  978. /*==========================================
  979. *
  980. *------------------------------------------*/
  981. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  982. {
  983. nullpo_retr(-1, sd);
  984. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  985. return -1;
  986. if (storage_storageopen(sd) == 1)
  987. { //Already open.
  988. clif_displaymessage(fd, msg_txt(250));
  989. return -1;
  990. }
  991. clif_displaymessage(fd, "Storage opened.");
  992. return 0;
  993. }
  994. /*==========================================
  995. *
  996. *------------------------------------------*/
  997. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  998. {
  999. struct storage_data *stor; //changes from Freya/Yor
  1000. nullpo_retr(-1, sd);
  1001. if (!sd->status.guild_id) {
  1002. clif_displaymessage(fd, msg_txt(252));
  1003. return -1;
  1004. }
  1005. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1006. return -1;
  1007. if (sd->state.storage_flag) {
  1008. clif_displaymessage(fd, msg_txt(251));
  1009. return -1;
  1010. }
  1011. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1012. clif_displaymessage(fd, msg_txt(251));
  1013. return -1;
  1014. }
  1015. storage_guild_storageopen(sd);
  1016. clif_displaymessage(fd, "Guild storage opened.");
  1017. return 0;
  1018. }
  1019. /*==========================================
  1020. *
  1021. *------------------------------------------*/
  1022. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1023. {
  1024. int param1 = 0, param2 = 0, param3 = 0;
  1025. nullpo_retr(-1, sd);
  1026. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1027. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1028. return -1;
  1029. }
  1030. sd->sc.opt1 = param1;
  1031. sd->sc.opt2 = param2;
  1032. pc_setoption(sd, param3);
  1033. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1034. return 0;
  1035. }
  1036. /*==========================================
  1037. *
  1038. *------------------------------------------*/
  1039. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1040. {
  1041. nullpo_retr(-1, sd);
  1042. if (sd->sc.option & OPTION_INVISIBLE) {
  1043. sd->sc.option &= ~OPTION_INVISIBLE;
  1044. if (sd->disguise)
  1045. status_set_viewdata(&sd->bl, sd->disguise);
  1046. else
  1047. status_set_viewdata(&sd->bl, sd->status.class_);
  1048. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1049. } else {
  1050. sd->sc.option |= OPTION_INVISIBLE;
  1051. sd->vd.class_ = INVISIBLE_CLASS;
  1052. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1053. }
  1054. clif_changeoption(&sd->bl);
  1055. return 0;
  1056. }
  1057. /*==========================================
  1058. * Changes a character's class
  1059. *------------------------------------------*/
  1060. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1061. {
  1062. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1063. int job = 0, upper = 0;
  1064. nullpo_retr(-1, sd);
  1065. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1066. {
  1067. int i, found = 0;
  1068. const struct { char name[16]; int id; } jobs[] = {
  1069. { "novice", 0 },
  1070. { "swordsman", 1 },
  1071. { "mage", 2 },
  1072. { "archer", 3 },
  1073. { "acolyte", 4 },
  1074. { "merchant", 5 },
  1075. { "thief", 6 },
  1076. { "knight", 7 },
  1077. { "priest", 8 },
  1078. { "priestess", 8 },
  1079. { "wizard", 9 },
  1080. { "blacksmith", 10 },
  1081. { "hunter", 11 },
  1082. { "assassin", 12 },
  1083. { "crusader", 14 },
  1084. { "monk", 15 },
  1085. { "sage", 16 },
  1086. { "rogue", 17 },
  1087. { "alchemist", 18 },
  1088. { "bard", 19 },
  1089. { "dancer", 20 },
  1090. { "super novice", 23 },
  1091. { "supernovice", 23 },
  1092. { "gunslinger", 24 },
  1093. { "gunner", 24 },
  1094. { "ninja", 25 },
  1095. { "high novice", 4001 },
  1096. { "swordsman high", 4002 },
  1097. { "mage high", 4003 },
  1098. { "archer high", 4004 },
  1099. { "acolyte high", 4005 },
  1100. { "merchant high", 4006 },
  1101. { "thief high", 4007 },
  1102. { "lord knight", 4008 },
  1103. { "high priest", 4009 },
  1104. { "high priestess", 4009 },
  1105. { "high wizard", 4010 },
  1106. { "whitesmith", 4011 },
  1107. { "sniper", 4012 },
  1108. { "assassin cross", 4013 },
  1109. { "paladin", 4015 },
  1110. { "champion", 4016 },
  1111. { "professor", 4017 },
  1112. { "stalker", 4018 },
  1113. { "creator", 4019 },
  1114. { "clown", 4020 },
  1115. { "gypsy", 4021 },
  1116. { "baby novice", 4023 },
  1117. { "baby swordsman", 4024 },
  1118. { "baby mage", 4025 },
  1119. { "baby archer", 4026 },
  1120. { "baby acolyte", 4027 },
  1121. { "baby merchant", 4028 },
  1122. { "baby thief", 4029 },
  1123. { "baby knight", 4030 },
  1124. { "baby priest", 4031 },
  1125. { "baby priestess", 4031 },
  1126. { "baby wizard", 4032 },
  1127. { "baby blacksmith",4033 },
  1128. { "baby hunter", 4034 },
  1129. { "baby assassin", 4035 },
  1130. { "baby crusader", 4037 },
  1131. { "baby monk", 4038 },
  1132. { "baby sage", 4039 },
  1133. { "baby rogue", 4040 },
  1134. { "baby alchemist", 4041 },
  1135. { "baby bard", 4042 },
  1136. { "baby dancer", 4043 },
  1137. { "super baby", 4045 },
  1138. { "taekwon", 4046 },
  1139. { "taekwon boy", 4046 },
  1140. { "taekwon girl", 4046 },
  1141. { "star gladiator", 4047 },
  1142. { "soul linker", 4049 },
  1143. };
  1144. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1145. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1146. job = jobs[i].id;
  1147. upper = 0;
  1148. found = 1;
  1149. break;
  1150. }
  1151. }
  1152. if (!found) {
  1153. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1154. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1155. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1156. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1157. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1158. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1159. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1160. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1161. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1162. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1163. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1164. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1165. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1166. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1167. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1168. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1169. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1170. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1171. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1172. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1173. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1174. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1175. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1176. return -1;
  1177. }
  1178. }
  1179. if (job == 37 ||job == 45)
  1180. return 0;
  1181. if (pcdb_checkid(job))
  1182. {
  1183. if (pc_jobchange(sd, job, upper) == 0)
  1184. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1185. else {
  1186. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  1187. return -1;
  1188. }
  1189. } else {
  1190. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1191. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1192. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1193. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1194. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1195. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1196. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1197. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1198. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1199. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1200. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1201. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1202. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1203. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1204. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1205. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1206. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1207. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1208. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1209. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1210. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1211. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1212. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1213. return -1;
  1214. }
  1215. return 0;
  1216. }
  1217. /*==========================================
  1218. *
  1219. *------------------------------------------*/
  1220. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1221. {
  1222. nullpo_retr(-1, sd);
  1223. clif_specialeffect(&sd->bl,450,SELF);
  1224. status_kill(&sd->bl);
  1225. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1226. return 0;
  1227. }
  1228. /*==========================================
  1229. *
  1230. *------------------------------------------*/
  1231. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1232. {
  1233. struct map_session_data *pl_sd;
  1234. nullpo_retr(-1, sd);
  1235. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1236. if (!message || !*message) {
  1237. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1238. return -1;
  1239. }
  1240. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1241. {
  1242. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1243. return -1;
  1244. }
  1245. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1246. { // you can kill only lower or same level
  1247. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1248. return -1;
  1249. }
  1250. status_kill(&pl_sd->bl);
  1251. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1252. if (fd != pl_sd->fd)
  1253. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1254. return 0;
  1255. }
  1256. /*==========================================
  1257. *
  1258. *------------------------------------------*/
  1259. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1260. {
  1261. nullpo_retr(-1, sd);
  1262. if (!status_revive(&sd->bl, 100, 100))
  1263. {
  1264. clif_displaymessage(fd, "You're not dead.");
  1265. return -1;
  1266. }
  1267. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1268. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1269. return 0;
  1270. }
  1271. /*==========================================
  1272. * +kamic [LuzZza]
  1273. *------------------------------------------*/
  1274. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1275. {
  1276. unsigned long color=0;
  1277. nullpo_retr(-1, sd);
  1278. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1279. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1280. if (!message || !*message) {
  1281. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1282. return -1;
  1283. }
  1284. sscanf(message, "%199[^\n]", atcmd_output);
  1285. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1286. } else {
  1287. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1288. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1289. return -1;
  1290. }
  1291. if(color > 0xFFFFFF) {
  1292. clif_displaymessage(fd, "Invalid color.");
  1293. return -1;
  1294. }
  1295. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  1296. }
  1297. return 0;
  1298. }
  1299. /*==========================================
  1300. *
  1301. *------------------------------------------*/
  1302. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1303. {
  1304. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1305. nullpo_retr(-1, sd);
  1306. sscanf(message, "%d %d", &hp, &sp);
  1307. if (hp == 0 && sp == 0) {
  1308. if (!status_percent_heal(&sd->bl, 100, 100))
  1309. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1310. else
  1311. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1312. return 0;
  1313. }
  1314. if(hp > 0 && sp >= 0) {
  1315. if(!status_heal(&sd->bl, hp, sp, 0))
  1316. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1317. else
  1318. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1319. return 0;
  1320. }
  1321. if(hp < 0 && sp <= 0) {
  1322. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1323. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1324. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1325. return 0;
  1326. }
  1327. //Opposing signs.
  1328. if (hp) {
  1329. if (hp > 0)
  1330. status_heal(&sd->bl, hp, 0, 0);
  1331. else {
  1332. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1333. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1334. }
  1335. }
  1336. if (sp) {
  1337. if (sp > 0)
  1338. status_heal(&sd->bl, 0, sp, 0);
  1339. else
  1340. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1341. }
  1342. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1343. return 0;
  1344. }
  1345. /*==========================================
  1346. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1347. *------------------------------------------*/
  1348. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1349. {
  1350. char item_name[100];
  1351. int number = 0, item_id, flag;
  1352. struct item item_tmp;
  1353. struct item_data *item_data;
  1354. int get_count, i;
  1355. nullpo_retr(-1, sd);
  1356. memset(item_name, '\0', sizeof(item_name));
  1357. if (!message || !*message || (
  1358. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1359. sscanf(message, "%99s %d", item_name, &number) < 1
  1360. )) {
  1361. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1362. return -1;
  1363. }
  1364. if (number <= 0)
  1365. number = 1;
  1366. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1367. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1368. {
  1369. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1370. return -1;
  1371. }
  1372. item_id = item_data->nameid;
  1373. get_count = number;
  1374. //Check if it's stackable.
  1375. if (!itemdb_isstackable2(item_data))
  1376. get_count = 1;
  1377. for (i = 0; i < number; i += get_count) {
  1378. // if not pet egg
  1379. if (!pet_create_egg(sd, item_id)) {
  1380. memset(&item_tmp, 0, sizeof(item_tmp));
  1381. item_tmp.nameid = item_id;
  1382. item_tmp.identify = 1;
  1383. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1384. clif_additem(sd, 0, 0, flag);
  1385. }
  1386. }
  1387. //Logs (A)dmins items [Lupus]
  1388. if(log_config.enable_logs&0x400)
  1389. log_pick_pc(sd, "A", item_id, number, NULL);
  1390. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1391. return 0;
  1392. }
  1393. /*==========================================
  1394. *
  1395. *------------------------------------------*/
  1396. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1397. {
  1398. struct item item_tmp;
  1399. struct item_data *item_data;
  1400. char item_name[100];
  1401. int item_id, number = 0;
  1402. int identify = 0, refine = 0, attr = 0;
  1403. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1404. int flag;
  1405. int loop, get_count, i;
  1406. nullpo_retr(-1, sd);
  1407. memset(item_name, '\0', sizeof(item_name));
  1408. if (!message || !*message || (
  1409. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1410. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1411. )) {
  1412. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1413. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1414. return -1;
  1415. }
  1416. if (number <= 0)
  1417. number = 1;
  1418. item_id = 0;
  1419. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1420. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1421. item_id = item_data->nameid;
  1422. if (item_id > 500) {
  1423. loop = 1;
  1424. get_count = number;
  1425. if (item_data->type == 4 || item_data->type == 5 ||
  1426. item_data->type == 7 || item_data->type == 8) {
  1427. loop = number;
  1428. get_count = 1;
  1429. if (item_data->type == 7) {
  1430. identify = 1;
  1431. refine = 0;
  1432. }
  1433. if (item_data->type == 8)
  1434. refine = 0;
  1435. if (refine > 10)
  1436. refine = 10;
  1437. } else {
  1438. identify = 1;
  1439. refine = attr = 0;
  1440. }
  1441. for (i = 0; i < loop; i++) {
  1442. memset(&item_tmp, 0, sizeof(item_tmp));
  1443. item_tmp.nameid = item_id;
  1444. item_tmp.identify = identify;
  1445. item_tmp.refine = refine;
  1446. item_tmp.attribute = attr;
  1447. item_tmp.card[0] = c1;
  1448. item_tmp.card[1] = c2;
  1449. item_tmp.card[2] = c3;
  1450. item_tmp.card[3] = c4;
  1451. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1452. clif_additem(sd, 0, 0, flag);
  1453. }
  1454. //Logs (A)dmins items [Lupus]
  1455. if(log_config.enable_logs&0x400)
  1456. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  1457. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1458. } else {
  1459. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1460. return -1;
  1461. }
  1462. return 0;
  1463. }
  1464. /*==========================================
  1465. *
  1466. *------------------------------------------*/
  1467. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1468. {
  1469. int i;
  1470. nullpo_retr(-1, sd);
  1471. for (i = 0; i < MAX_INVENTORY; i++) {
  1472. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1473. //Logs (A)dmins items [Lupus]
  1474. if(log_config.enable_logs&0x400)
  1475. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1476. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  1477. }
  1478. }
  1479. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1480. return 0;
  1481. }
  1482. /*==========================================
  1483. * Atcommand @lvlup
  1484. *------------------------------------------*/
  1485. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1486. {
  1487. int level=0, i=0, status_point=0;
  1488. nullpo_retr(-1, sd);
  1489. level = atoi(message);
  1490. if (!message || !*message || !level) {
  1491. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1492. return -1;
  1493. }
  1494. if (level > 0) {
  1495. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1496. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1497. return -1;
  1498. } // End Addition
  1499. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1500. level = pc_maxbaselv(sd) - sd->status.base_level;
  1501. for (i = 1; i <= level; i++)
  1502. status_point += (sd->status.base_level + i + 14) / 5;
  1503. if (sd->status.status_point > USHRT_MAX - status_point)
  1504. sd->status.status_point = USHRT_MAX;
  1505. else
  1506. sd->status.status_point += status_point;
  1507. sd->status.base_level += (unsigned int)level;
  1508. status_percent_heal(&sd->bl, 100, 100);
  1509. clif_misceffect(&sd->bl, 0);
  1510. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1511. } else {
  1512. if (sd->status.base_level == 1) {
  1513. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1514. return -1;
  1515. }
  1516. level*=-1;
  1517. if ((unsigned int)level >= sd->status.base_level)
  1518. level = sd->status.base_level-1;
  1519. for (i = 0; i > -level; i--)
  1520. status_point += (sd->status.base_level + i + 14) / 5;
  1521. if (sd->status.status_point < status_point)
  1522. pc_resetstate(sd);
  1523. if (sd->status.status_point < status_point)
  1524. sd->status.status_point = 0;
  1525. else
  1526. sd->status.status_point -= status_point;
  1527. sd->status.base_level -= (unsigned int)level;
  1528. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1529. }
  1530. clif_updatestatus(sd, SP_STATUSPOINT);
  1531. clif_updatestatus(sd, SP_BASELEVEL);
  1532. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1533. status_calc_pc(sd, 0);
  1534. if(sd->status.party_id)
  1535. party_send_levelup(sd);
  1536. return 0;
  1537. }
  1538. /*==========================================
  1539. *
  1540. *------------------------------------------*/
  1541. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1542. {
  1543. int level=0;
  1544. nullpo_retr(-1, sd);
  1545. level = atoi(message);
  1546. if (!message || !*message || !level) {
  1547. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1548. return -1;
  1549. }
  1550. if (level > 0) {
  1551. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1552. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1553. return -1;
  1554. }
  1555. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1556. level = pc_maxjoblv(sd) - sd->status.job_level;
  1557. sd->status.job_level += (unsigned int)level;
  1558. clif_updatestatus(sd, SP_JOBLEVEL);
  1559. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1560. if (sd->status.skill_point > USHRT_MAX - level)
  1561. sd->status.skill_point = USHRT_MAX;
  1562. else
  1563. sd->status.skill_point += level;
  1564. clif_updatestatus(sd, SP_SKILLPOINT);
  1565. status_calc_pc(sd, 0);
  1566. clif_misceffect(&sd->bl, 1);
  1567. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1568. } else {
  1569. if (sd->status.job_level == 1) {
  1570. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1571. return -1;
  1572. }
  1573. level *=-1;
  1574. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1575. level = sd->status.job_level-1;
  1576. sd->status.job_level -= (unsigned int)level;
  1577. clif_updatestatus(sd, SP_JOBLEVEL);
  1578. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1579. if (sd->status.skill_point < level)
  1580. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1581. if (sd->status.skill_point < level)
  1582. sd->status.skill_point = 0;
  1583. else
  1584. sd->status.skill_point -= level;
  1585. clif_updatestatus(sd, SP_SKILLPOINT);
  1586. status_calc_pc(sd, 0);
  1587. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1588. }
  1589. return 0;
  1590. }
  1591. /*==========================================
  1592. * @help
  1593. *------------------------------------------*/
  1594. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1595. {
  1596. char buf[2048], w1[2048], w2[2048];
  1597. int i, gm_level;
  1598. FILE* fp;
  1599. nullpo_retr(-1, sd);
  1600. memset(buf, '\0', sizeof(buf));
  1601. if ((fp = fopen(help_txt, "r")) != NULL) {
  1602. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1603. gm_level = pc_isGM(sd);
  1604. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1605. if (buf[0] == '/' && buf[1] == '/')
  1606. continue;
  1607. for (i = 0; buf[i] != '\0'; i++) {
  1608. if (buf[i] == '\r' || buf[i] == '\n') {
  1609. buf[i] = '\0';
  1610. break;
  1611. }
  1612. }
  1613. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1614. clif_displaymessage(fd, buf);
  1615. else if (gm_level >= atoi(w1))
  1616. clif_displaymessage(fd, w2);
  1617. }
  1618. fclose(fp);
  1619. } else {
  1620. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1621. return -1;
  1622. }
  1623. return 0;
  1624. }
  1625. /*==========================================
  1626. * @help2 - Char commands [Kayla]
  1627. *------------------------------------------*/
  1628. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1629. {
  1630. char buf[2048], w1[2048], w2[2048];
  1631. int i, gm_level;
  1632. FILE* fp;
  1633. nullpo_retr(-1, sd);
  1634. memset(buf, '\0', sizeof(buf));
  1635. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1636. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1637. gm_level = pc_isGM(sd);
  1638. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1639. if (buf[0] == '/' && buf[1] == '/')
  1640. continue;
  1641. for (i = 0; buf[i] != '\0'; i++) {
  1642. if (buf[i] == '\r' || buf[i] == '\n') {
  1643. buf[i] = '\0';
  1644. break;
  1645. }
  1646. }
  1647. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1648. clif_displaymessage(fd, buf);
  1649. else if (gm_level >= atoi(w1))
  1650. clif_displaymessage(fd, w2);
  1651. }
  1652. fclose(fp);
  1653. } else {
  1654. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1655. return -1;
  1656. }
  1657. return 0;
  1658. }
  1659. // helper function, used in foreach calls to stop auto-attack timers
  1660. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1661. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1662. {
  1663. struct unit_data *ud = unit_bl2ud(bl);
  1664. int id = va_arg(ap, int);
  1665. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1666. {
  1667. unit_stop_attack(bl);
  1668. return 1;
  1669. }
  1670. return 0;
  1671. }
  1672. /*==========================================
  1673. *
  1674. *------------------------------------------*/
  1675. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1676. {
  1677. TBL_PC* sd = (TBL_PC*)bl;
  1678. clif_pvpset(sd, 0, 0, 2);
  1679. if (sd->pvp_timer != -1) {
  1680. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1681. sd->pvp_timer = -1;
  1682. }
  1683. return 0;
  1684. }
  1685. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1686. {
  1687. nullpo_retr(-1, sd);
  1688. if (!map[sd->bl.m].flag.pvp) {
  1689. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1690. return -1;
  1691. }
  1692. map[sd->bl.m].flag.pvp = 0;
  1693. if (!battle_config.pk_mode)
  1694. clif_send0199(sd->bl.m, 0);
  1695. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1696. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1697. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1698. return 0;
  1699. }
  1700. /*==========================================
  1701. *
  1702. *------------------------------------------*/
  1703. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1704. {
  1705. TBL_PC* sd = (TBL_PC*)bl;
  1706. if (sd->pvp_timer == -1) {
  1707. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1708. sd->pvp_rank = 0;
  1709. sd->pvp_lastusers = 0;
  1710. sd->pvp_point = 5;
  1711. sd->pvp_won = 0;
  1712. sd->pvp_lost = 0;
  1713. }
  1714. return 0;
  1715. }
  1716. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1717. {
  1718. nullpo_retr(-1, sd);
  1719. if (map[sd->bl.m].flag.pvp) {
  1720. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1721. return -1;
  1722. }
  1723. map[sd->bl.m].flag.pvp = 1;
  1724. if (!battle_config.pk_mode)
  1725. {// display pvp circle and rank
  1726. clif_send0199(sd->bl.m, 1);
  1727. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1728. }
  1729. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1730. return 0;
  1731. }
  1732. /*==========================================
  1733. *
  1734. *------------------------------------------*/
  1735. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1736. {
  1737. nullpo_retr(-1, sd);
  1738. if (!map[sd->bl.m].flag.gvg) {
  1739. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1740. return -1;
  1741. }
  1742. map[sd->bl.m].flag.gvg = 0;
  1743. clif_send0199(sd->bl.m, 0);
  1744. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1745. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1746. return 0;
  1747. }
  1748. /*==========================================
  1749. *
  1750. *------------------------------------------*/
  1751. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1752. {
  1753. nullpo_retr(-1, sd);
  1754. if (map[sd->bl.m].flag.gvg) {
  1755. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1756. return -1;
  1757. }
  1758. map[sd->bl.m].flag.gvg = 1;
  1759. clif_send0199(sd->bl.m, 3);
  1760. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1761. return 0;
  1762. }
  1763. /*==========================================
  1764. *
  1765. *------------------------------------------*/
  1766. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1767. {
  1768. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1769. nullpo_retr(-1, sd);
  1770. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1771. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1772. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1773. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1774. clif_displaymessage(fd, atcmd_output);
  1775. return -1;
  1776. }
  1777. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1778. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1779. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1780. pc_changelook(sd, LOOK_HAIR, hair_style);
  1781. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1782. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1783. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1784. } else {
  1785. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1786. return -1;
  1787. }
  1788. return 0;
  1789. }
  1790. /*==========================================
  1791. * @dye && @ccolor
  1792. *------------------------------------------*/
  1793. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1794. {
  1795. int cloth_color = 0;
  1796. nullpo_retr(-1, sd);
  1797. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1798. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1799. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1800. clif_displaymessage(fd, atcmd_output);
  1801. return -1;
  1802. }
  1803. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1804. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1805. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1806. } else {
  1807. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1808. return -1;
  1809. }
  1810. return 0;
  1811. }
  1812. /*==========================================
  1813. * @hairstyle && @hstyle
  1814. *------------------------------------------*/
  1815. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1816. {
  1817. int hair_style = 0;
  1818. nullpo_retr(-1, sd);
  1819. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1820. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1821. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1822. clif_displaymessage(fd, atcmd_output);
  1823. return -1;
  1824. }
  1825. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1826. pc_changelook(sd, LOOK_HAIR, hair_style);
  1827. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1828. } else {
  1829. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1830. return -1;
  1831. }
  1832. return 0;
  1833. }
  1834. /*==========================================
  1835. * @haircolor && @hcolor
  1836. *------------------------------------------*/
  1837. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1838. {
  1839. int hair_color = 0;
  1840. nullpo_retr(-1, sd);
  1841. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1842. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1843. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1844. clif_displaymessage(fd, atcmd_output);
  1845. return -1;
  1846. }
  1847. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1848. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1849. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1850. } else {
  1851. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1852. return -1;
  1853. }
  1854. return 0;
  1855. }
  1856. /*==========================================
  1857. * @go [city_number or city_name] - Updated by Harbin
  1858. *------------------------------------------*/
  1859. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1860. {
  1861. int i;
  1862. int town;
  1863. char map_name[MAP_NAME_LENGTH];
  1864. int m;
  1865. const struct {
  1866. char map[MAP_NAME_LENGTH];
  1867. int x, y;
  1868. } data[] = {
  1869. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1870. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1871. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1872. { MAP_PAYON, 162, 233 }, // 3=Payon
  1873. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1874. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1875. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1876. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1877. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1878. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1879. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1880. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1881. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1882. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1883. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1884. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1885. { MAP_JAIL, 23, 61 }, // 16=Prison
  1886. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1887. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1888. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1889. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1890. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1891. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1892. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1893. { MAP_VEINS, 216, 123 }, // 24=Veins
  1894. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1895. };
  1896. nullpo_retr(-1, sd);
  1897. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  1898. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1899. return 0;
  1900. }
  1901. memset(map_name, '\0', sizeof(map_name));
  1902. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1903. // get the number
  1904. town = atoi(message);
  1905. // if no value, display all value
  1906. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1907. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1908. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  1909. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1910. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1911. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1912. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1913. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1914. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1915. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1916. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  1917. clif_displaymessage(fd, " 24=Veins 25=Moscovia");
  1918. return -1;
  1919. }
  1920. // get possible name of the city
  1921. map_name[MAP_NAME_LENGTH-1] = '\0';
  1922. for (i = 0; map_name[i]; i++)
  1923. map_name[i] = TOLOWER(map_name[i]);
  1924. // try to identify the map name
  1925. if (strncmp(map_name, "prontera", 3) == 0) {
  1926. town = 0;
  1927. } else if (strncmp(map_name, "morocc", 3) == 0) {
  1928. town = 1;
  1929. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1930. town = 2;
  1931. } else if (strncmp(map_name, "payon", 3) == 0 ||
  1932. strncmp(map_name, "paion", 3) == 0) {
  1933. town = 3;
  1934. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1935. town = 4;
  1936. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  1937. strncmp(map_name, "islude", 3) == 0) {
  1938. town = 5;
  1939. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  1940. strcmp(map_name, "al") == 0) {
  1941. town = 6;
  1942. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1943. strcmp(map_name, "christmas") == 0 ||
  1944. strncmp(map_name, "xmas", 3) == 0 ||
  1945. strncmp(map_name, "x-mas", 3) == 0) {
  1946. town = 7;
  1947. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1948. town = 8;
  1949. } else if (strncmp(map_name, "yuno", 3) == 0) {
  1950. town = 9;
  1951. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1952. town = 10;
  1953. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  1954. town = 11;
  1955. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1956. town = 12;
  1957. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1958. town = 13;
  1959. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1960. town = 14;
  1961. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1962. strncmp(map_name, "startpoint", 3) == 0 ||
  1963. strncmp(map_name, "begining", 3) == 0) {
  1964. town = 15;
  1965. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1966. strncmp(map_name, "prison", 3) == 0 ||
  1967. strncmp(map_name, "jails", 3) == 0) {
  1968. town = 16;
  1969. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  1970. strncmp(map_name, "jawai", 3) == 0) {
  1971. town = 17;
  1972. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  1973. strncmp(map_name, "ayotaya", 3) == 0) {
  1974. town = 18;
  1975. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  1976. strncmp(map_name, "ainbroch", 5) == 0) {
  1977. town = 19;
  1978. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1979. town = 20;
  1980. } else if (strncmp(map_name, "einbech", 3) == 0) {
  1981. town = 21;
  1982. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1983. town = 22;
  1984. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1985. town = 23;
  1986. } else if (strncmp(map_name, "veins", 3) == 0) {
  1987. town = 24;
  1988. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1989. town = 25;
  1990. }
  1991. if (town >= 0 && town < ARRAYLENGTH(data))
  1992. {
  1993. m = map_mapname2mapid(data[town].map);
  1994. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1995. clif_displaymessage(fd, msg_txt(247));
  1996. return -1;
  1997. }
  1998. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1999. clif_displaymessage(fd, msg_txt(248));
  2000. return -1;
  2001. }
  2002. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
  2003. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2004. } else {
  2005. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2006. return -1;
  2007. }
  2008. } else { // if you arrive here, you have an error in town variable when reading of names
  2009. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2010. return -1;
  2011. }
  2012. return 0;
  2013. }
  2014. /*==========================================
  2015. *
  2016. *------------------------------------------*/
  2017. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2018. {
  2019. char name[NAME_LENGTH];
  2020. char monster[NAME_LENGTH];
  2021. int mob_id;
  2022. int number = 0;
  2023. int count;
  2024. int i, k, range;
  2025. short mx, my;
  2026. nullpo_retr(-1, sd);
  2027. memset(name, '\0', sizeof(name));
  2028. memset(monster, '\0', sizeof(monster));
  2029. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2030. if (!message || !*message) {
  2031. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2032. return -1;
  2033. }
  2034. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2035. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2036. //All data can be left as it is.
  2037. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2038. //Here, it is possible name was not given and we are using monster for it.
  2039. if (count < 3) //Blank mob's name.
  2040. name[0] = '\0';
  2041. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2042. //All data can be left as it is.
  2043. } else if (sscanf(message, "%23s", monster) > 0) {
  2044. //As before, name may be already filled.
  2045. name[0] = '\0';
  2046. } else {
  2047. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2048. return -1;
  2049. }
  2050. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2051. mob_id = mobdb_checkid(atoi(monster));
  2052. if (mob_id == 0) {
  2053. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2054. return -1;
  2055. }
  2056. if (mob_id == MOBID_EMPERIUM) {
  2057. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  2058. return -1;
  2059. }
  2060. if (number <= 0)
  2061. number = 1;
  2062. if (strlen(name) < 1)
  2063. strcpy(name, "--ja--");
  2064. // 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
  2065. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2066. number = battle_config.atc_spawn_quantity_limit;
  2067. if (battle_config.etc_log)
  2068. 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);
  2069. count = 0;
  2070. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2071. for (i = 0; i < number; i++) {
  2072. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2073. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2074. count += (k != 0) ? 1 : 0;
  2075. }
  2076. if (count != 0)
  2077. if (number == count)
  2078. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2079. else {
  2080. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2081. clif_displaymessage(fd, atcmd_output);
  2082. }
  2083. else {
  2084. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2085. return -1;
  2086. }
  2087. return 0;
  2088. }
  2089. // small monster spawning [Valaris]
  2090. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2091. {
  2092. char name[NAME_LENGTH] = "";
  2093. char monster[NAME_LENGTH] = "";
  2094. int mob_id = 0;
  2095. int number = 0;
  2096. int x = 0;
  2097. int y = 0;
  2098. int count;
  2099. int i;
  2100. nullpo_retr(-1, sd);
  2101. if (!message || !*message) {
  2102. clif_displaymessage(fd, "Give a monster name/id please.");
  2103. return -1;
  2104. }
  2105. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2106. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2107. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2108. clif_displaymessage(fd, "Give a monster name/id please.");
  2109. return -1;
  2110. }
  2111. // If monster identifier/name argument is a name
  2112. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2113. mob_id = atoi(monster);
  2114. if (mob_id == 0) {
  2115. clif_displaymessage(fd, msg_txt(40));
  2116. return -1;
  2117. }
  2118. if (mob_id == MOBID_EMPERIUM) {
  2119. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2120. return -1;
  2121. }
  2122. if (mobdb_checkid(mob_id) == 0) {
  2123. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2124. return -1;
  2125. }
  2126. if (number <= 0)
  2127. number = 1;
  2128. if (strlen(name) < 1)
  2129. strcpy(name, "--ja--");
  2130. // 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
  2131. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2132. number = battle_config.atc_spawn_quantity_limit;
  2133. count = 0;
  2134. for (i = 0; i < number; i++) {
  2135. int mx, my;
  2136. if (x <= 0)
  2137. mx = sd->bl.x + (rand() % 11 - 5);
  2138. else
  2139. mx = x;
  2140. if (y <= 0)
  2141. my = sd->bl.y + (rand() % 11 - 5);
  2142. else
  2143. my = y;
  2144. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2145. }
  2146. if (count != 0)
  2147. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2148. else
  2149. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2150. return 0;
  2151. }
  2152. // big monster spawning [Valaris]
  2153. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2154. {
  2155. char name[NAME_LENGTH] = "";
  2156. char monster[NAME_LENGTH] = "";
  2157. int mob_id = 0;
  2158. int number = 0;
  2159. int x = 0;
  2160. int y = 0;
  2161. int count;
  2162. int i;
  2163. nullpo_retr(-1, sd);
  2164. if (!message || !*message) {
  2165. clif_displaymessage(fd, "Give a monster name/id please.");
  2166. return -1;
  2167. }
  2168. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2169. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2170. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2171. clif_displaymessage(fd, "Give a monster name/id please.");
  2172. return -1;
  2173. }
  2174. // If monster identifier/name argument is a name
  2175. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2176. mob_id = atoi(monster);
  2177. if (mob_id == 0) {
  2178. clif_displaymessage(fd, msg_txt(40));
  2179. return -1;
  2180. }
  2181. if (mob_id == MOBID_EMPERIUM) {
  2182. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2183. return -1;
  2184. }
  2185. if (mobdb_checkid(mob_id) == 0) {
  2186. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2187. return -1;
  2188. }
  2189. if (number <= 0)
  2190. number = 1;
  2191. if (strlen(name) < 1)
  2192. strcpy(name, "--ja--");
  2193. // 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
  2194. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2195. number = battle_config.atc_spawn_quantity_limit;
  2196. count = 0;
  2197. for (i = 0; i < number; i++) {
  2198. int mx, my;
  2199. if (x <= 0)
  2200. mx = sd->bl.x + (rand() % 11 - 5);
  2201. else
  2202. mx = x;
  2203. if (y <= 0)
  2204. my = sd->bl.y + (rand() % 11 - 5);
  2205. else
  2206. my = y;
  2207. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2208. }
  2209. if (count != 0)
  2210. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2211. else
  2212. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2213. return 0;
  2214. }
  2215. /*==========================================
  2216. *
  2217. *------------------------------------------*/
  2218. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2219. {
  2220. struct mob_data *md;
  2221. int flag;
  2222. nullpo_retr(0, ap);
  2223. nullpo_retr(0, md=(struct mob_data *)bl);
  2224. flag = va_arg(ap, int);
  2225. if (md->guardian_data)
  2226. return 0; //Do not touch WoE mobs!
  2227. if (flag)
  2228. status_zap(bl,md->status.hp, 0);
  2229. else
  2230. status_kill(bl);
  2231. return 1;
  2232. }
  2233. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2234. {
  2235. int map_id;
  2236. char map_name[MAP_NAME_LENGTH_EXT];
  2237. if (!sd) return;
  2238. memset(map_name, '\0', sizeof(map_name));
  2239. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2240. map_id = sd->bl.m;
  2241. else {
  2242. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2243. map_id = sd->bl.m;
  2244. }
  2245. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2246. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2247. return;
  2248. }
  2249. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2250. {
  2251. atcommand_killmonster_sub(fd, sd, message, 1);
  2252. return 0;
  2253. }
  2254. /*==========================================
  2255. *
  2256. *------------------------------------------*/
  2257. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2258. {
  2259. atcommand_killmonster_sub(fd, sd, message, 0);
  2260. return 0;
  2261. }
  2262. /*==========================================
  2263. *
  2264. *------------------------------------------*/
  2265. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2266. {
  2267. int i,j, position = 0, refine = 0, current_position, final_refine;
  2268. int count;
  2269. nullpo_retr(-1, sd);
  2270. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2271. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2272. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  2273. sprintf(atcmd_output, "%d: Left Accessory", EQI_ACC_L);
  2274. clif_displaymessage(fd, atcmd_output);
  2275. sprintf(atcmd_output, "%d: Right Accessory", EQI_ACC_R);
  2276. clif_displaymessage(fd, atcmd_output);
  2277. sprintf(atcmd_output, "%d: Shoes", EQI_SHOES);
  2278. clif_displaymessage(fd, atcmd_output);
  2279. sprintf(atcmd_output, "%d: Garment", EQI_GARMENT);
  2280. clif_displaymessage(fd, atcmd_output);
  2281. sprintf(atcmd_output, "%d: Lower Headgear", EQI_HEAD_LOW);
  2282. clif_displaymessage(fd, atcmd_output);
  2283. sprintf(atcmd_output, "%d: Mid Headgear", EQI_HEAD_MID);
  2284. clif_displaymessage(fd, atcmd_output);
  2285. sprintf(atcmd_output, "%d: Top Headgear", EQI_HEAD_TOP);
  2286. clif_displaymessage(fd, atcmd_output);
  2287. sprintf(atcmd_output, "%d: Body Armor", EQI_ARMOR);
  2288. clif_displaymessage(fd, atcmd_output);
  2289. sprintf(atcmd_output, "%d: Left Hand", EQI_HAND_L);
  2290. clif_displaymessage(fd, atcmd_output);
  2291. sprintf(atcmd_output, "%d: Right Hand", EQI_HAND_R);
  2292. clif_displaymessage(fd, atcmd_output);
  2293. return -1;
  2294. }
  2295. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2296. count = 0;
  2297. for (j = 0; j < EQI_MAX-1; j++) {
  2298. if ((i = sd->equip_index[j]) < 0)
  2299. continue;
  2300. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2301. continue;
  2302. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2303. continue;
  2304. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2305. continue;
  2306. if(position && !(sd->status.inventory[i].equip & position))
  2307. continue;
  2308. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2309. if (sd->status.inventory[i].refine != final_refine) {
  2310. sd->status.inventory[i].refine = final_refine;
  2311. current_position = sd->status.inventory[i].equip;
  2312. pc_unequipitem(sd, i, 3);
  2313. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2314. clif_delitem(sd, i, 1);
  2315. clif_additem(sd, i, 1, 0);
  2316. pc_equipitem(sd, i, current_position);
  2317. clif_misceffect(&sd->bl, 3);
  2318. count++;
  2319. }
  2320. }
  2321. if (count == 0)
  2322. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  2323. else if (count == 1)
  2324. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  2325. else {
  2326. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  2327. clif_displaymessage(fd, atcmd_output);
  2328. }
  2329. return 0;
  2330. }
  2331. /*==========================================
  2332. *
  2333. *------------------------------------------*/
  2334. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2335. {
  2336. char item_name[100];
  2337. int item_id, attribute = 0, star = 0;
  2338. int flag = 0;
  2339. struct item_data *item_data;
  2340. struct item tmp_item;
  2341. nullpo_retr(-1, sd);
  2342. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2343. memset(item_name, '\0', sizeof(item_name));
  2344. if (!message || !*message || (
  2345. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2346. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2347. )) {
  2348. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2349. return -1;
  2350. }
  2351. item_id = 0;
  2352. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2353. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2354. {
  2355. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  2356. clif_displaymessage(fd, atcmd_output);
  2357. return -1;
  2358. }
  2359. item_id = item_data->nameid;
  2360. if (itemdb_isequip2(item_data)) {
  2361. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2362. attribute = ATTRIBUTE_NORMAL;
  2363. if (star < MIN_STAR || star > MAX_STAR)
  2364. star = 0;
  2365. memset(&tmp_item, 0, sizeof tmp_item);
  2366. tmp_item.nameid = item_id;
  2367. tmp_item.amount = 1;
  2368. tmp_item.identify = 1;
  2369. tmp_item.card[0] = CARD0_FORGE;
  2370. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2371. ((star*5) << 8) + attribute:0;
  2372. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2373. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2374. clif_produceeffect(sd, 0, item_id);
  2375. clif_misceffect(&sd->bl, 3);
  2376. //Logs (A)dmins items [Lupus]
  2377. if(log_config.enable_logs&0x400)
  2378. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  2379. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2380. clif_additem(sd, 0, 0, flag);
  2381. } else {
  2382. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  2383. clif_displaymessage(fd, atcmd_output);
  2384. return -1;
  2385. }
  2386. return 0;
  2387. }
  2388. /*==========================================
  2389. *
  2390. *------------------------------------------*/
  2391. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2392. {
  2393. int position = 0;
  2394. nullpo_retr(-1, sd);
  2395. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2396. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2397. {
  2398. int i;
  2399. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2400. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2401. {
  2402. if( sd->status.memo_point[i].map )
  2403. 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);
  2404. else
  2405. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2406. clif_displaymessage(sd->fd, atcmd_output);
  2407. }
  2408. return 0;
  2409. }
  2410. if( position < 0 && position >= MAX_MEMOPOINTS )
  2411. {
  2412. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2413. clif_displaymessage(fd, atcmd_output);
  2414. return -1;
  2415. }
  2416. pc_memo(sd, position);
  2417. return 0;
  2418. }
  2419. /*==========================================
  2420. *
  2421. *------------------------------------------*/
  2422. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2423. {
  2424. int y;
  2425. nullpo_retr(-1, sd);
  2426. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2427. for (y = 2; y >= -2; y--) {
  2428. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2429. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2430. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2431. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2432. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2433. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2434. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2435. clif_displaymessage(fd, atcmd_output);
  2436. }
  2437. return 0;
  2438. }
  2439. /*==========================================
  2440. *
  2441. *------------------------------------------*/
  2442. int atcommand_displaystatus(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2443. {
  2444. int i, type, flag;
  2445. nullpo_retr(-1, sd);
  2446. if (!message || !*message || (i = sscanf(message, "%d %d", &type, &flag)) < 1) {
  2447. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag>).");
  2448. return -1;
  2449. }
  2450. if (i == 1) flag = 1;
  2451. clif_status_change(&sd->bl, type, flag);
  2452. return 0;
  2453. }
  2454. /*==========================================
  2455. * @stpoint (Rewritten by [Yor])
  2456. *------------------------------------------*/
  2457. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2458. {
  2459. int point, new_status_point;
  2460. if (!message || !*message || (point = atoi(message)) == 0) {
  2461. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2462. return -1;
  2463. }
  2464. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  2465. new_status_point = USHRT_MAX;
  2466. else
  2467. if (point < 0 && sd->status.status_point < -point)
  2468. new_status_point = 0;
  2469. else
  2470. new_status_point = sd->status.status_point + point;
  2471. if (new_status_point != (int)sd->status.status_point) {
  2472. sd->status.status_point = (unsigned short)new_status_point;
  2473. clif_updatestatus(sd, SP_STATUSPOINT);
  2474. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  2475. } else {
  2476. if (point < 0)
  2477. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2478. else
  2479. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2480. return -1;
  2481. }
  2482. return 0;
  2483. }
  2484. /*==========================================
  2485. * @skpoint (Rewritten by [Yor])
  2486. *------------------------------------------*/
  2487. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2488. {
  2489. int point, new_skill_point;
  2490. nullpo_retr(-1, sd);
  2491. if (!message || !*message || (point = atoi(message)) == 0) {
  2492. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2493. return -1;
  2494. }
  2495. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  2496. new_skill_point = USHRT_MAX;
  2497. else if (point < 0 && sd->status.skill_point < -point)
  2498. new_skill_point = 0;
  2499. else
  2500. new_skill_point = sd->status.skill_point + point;
  2501. if (new_skill_point != (int)sd->status.skill_point) {
  2502. sd->status.skill_point = (unsigned short)new_skill_point;
  2503. clif_updatestatus(sd, SP_SKILLPOINT);
  2504. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  2505. } else {
  2506. if (point < 0)
  2507. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2508. else
  2509. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2510. return -1;
  2511. }
  2512. return 0;
  2513. }
  2514. /*==========================================
  2515. * @zeny (Rewritten by [Yor])
  2516. *------------------------------------------*/
  2517. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2518. {
  2519. int zeny, new_zeny;
  2520. nullpo_retr(-1, sd);
  2521. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2522. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2523. return -1;
  2524. }
  2525. new_zeny = sd->status.zeny + zeny;
  2526. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2527. new_zeny = MAX_ZENY;
  2528. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2529. new_zeny = 0;
  2530. if (new_zeny != sd->status.zeny) {
  2531. sd->status.zeny = new_zeny;
  2532. clif_updatestatus(sd, SP_ZENY);
  2533. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  2534. } else {
  2535. if (zeny < 0)
  2536. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2537. else
  2538. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2539. return -1;
  2540. }
  2541. return 0;
  2542. }
  2543. /*==========================================
  2544. *
  2545. *------------------------------------------*/
  2546. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2547. {
  2548. int i, value = 0, new_value, max;
  2549. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  2550. short* status[6];
  2551. //we don't use direct initialization because it isn't part of the c standard.
  2552. nullpo_retr(-1, sd);
  2553. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2554. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2555. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2556. clif_displaymessage(fd, atcmd_output);
  2557. return -1;
  2558. }
  2559. for (i = 0; param[i] != NULL; i++)
  2560. if (strcmpi(command, param[i]) == 0)
  2561. break;
  2562. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  2563. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2564. clif_displaymessage(fd, atcmd_output);
  2565. return -1;
  2566. }
  2567. status[0] = &sd->status.str;
  2568. status[1] = &sd->status.agi;
  2569. status[2] = &sd->status.vit;
  2570. status[3] = &sd->status.int_;
  2571. status[4] = &sd->status.dex;
  2572. status[5] = &sd->status.luk;
  2573. max = SHRT_MAX;
  2574. new_value = cap_value(*status[i] + value, 1, max);
  2575. if (new_value != (int)*status[i]) {
  2576. *status[i] = new_value;
  2577. clif_updatestatus(sd, SP_STR + i);
  2578. clif_updatestatus(sd, SP_USTR + i);
  2579. status_calc_pc(sd, 0);
  2580. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2581. } else {
  2582. if (value < 0)
  2583. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2584. else
  2585. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2586. return -1;
  2587. }
  2588. return 0;
  2589. }
  2590. /*==========================================
  2591. * Stat all by fritz (rewritten by [Yor])
  2592. *------------------------------------------*/
  2593. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2594. {
  2595. int index, count, value, max, new_value;
  2596. short* status[6];
  2597. //we don't use direct initialization because it isn't part of the c standard.
  2598. nullpo_retr(-1, sd);
  2599. status[0] = &sd->status.str;
  2600. status[1] = &sd->status.agi;
  2601. status[2] = &sd->status.vit;
  2602. status[3] = &sd->status.int_;
  2603. status[4] = &sd->status.dex;
  2604. status[5] = &sd->status.luk;
  2605. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2606. value = pc_maxparameter(sd);
  2607. max = pc_maxparameter(sd);
  2608. } else {
  2609. max = SHRT_MAX;
  2610. }
  2611. count = 0;
  2612. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2613. if (value > 0 && *status[index] > max - value)
  2614. new_value = max;
  2615. else if (value < 0 && *status[index] <= -value)
  2616. new_value = 1;
  2617. else
  2618. new_value = *status[index] +value;
  2619. if (new_value != (int)*status[index]) {
  2620. *status[index] = new_value;
  2621. clif_updatestatus(sd, SP_STR + index);
  2622. clif_updatestatus(sd, SP_USTR + index);
  2623. count++;
  2624. }
  2625. }
  2626. if (count > 0) { // if at least 1 stat modified
  2627. status_calc_pc(sd, 0);
  2628. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2629. } else {
  2630. if (value < 0)
  2631. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  2632. else
  2633. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  2634. return -1;
  2635. }
  2636. return 0;
  2637. }
  2638. /*==========================================
  2639. *
  2640. *------------------------------------------*/
  2641. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2642. {
  2643. int level = 0;
  2644. short added_level;
  2645. struct guild *guild_info;
  2646. nullpo_retr(-1, sd);
  2647. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2648. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2649. return -1;
  2650. }
  2651. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2652. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2653. return -1;
  2654. }
  2655. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2656. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2657. // return -1;
  2658. //}
  2659. added_level = (short)level;
  2660. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2661. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2662. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2663. added_level = 1 - guild_info->guild_lv;
  2664. if (added_level != 0) {
  2665. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  2666. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2667. } else {
  2668. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2669. return -1;
  2670. }
  2671. return 0;
  2672. }
  2673. /*==========================================
  2674. *
  2675. *------------------------------------------*/
  2676. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2677. {
  2678. struct item_data *item_data;
  2679. int id, pet_id;
  2680. nullpo_retr(-1, sd);
  2681. if (!message || !*message) {
  2682. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2683. return -1;
  2684. }
  2685. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2686. id = item_data->nameid;
  2687. else
  2688. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2689. ;
  2690. else
  2691. id = atoi(message);
  2692. pet_id = search_petDB_index(id, PET_CLASS);
  2693. if (pet_id < 0)
  2694. pet_id = search_petDB_index(id, PET_EGG);
  2695. if (pet_id >= 0) {
  2696. sd->catch_target_class = pet_db[pet_id].class_;
  2697. intif_create_pet(
  2698. sd->status.account_id, sd->status.char_id,
  2699. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2700. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2701. 100, 0, 1, pet_db[pet_id].jname);
  2702. } else {
  2703. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2704. return -1;
  2705. }
  2706. return 0;
  2707. }
  2708. /*==========================================
  2709. *
  2710. *------------------------------------------*/
  2711. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2712. {
  2713. nullpo_retr(-1, sd);
  2714. if (sd->status.pet_id <= 0)
  2715. clif_sendegg(sd);
  2716. else {
  2717. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2718. return -1;
  2719. }
  2720. return 0;
  2721. }
  2722. /*==========================================
  2723. *
  2724. *------------------------------------------*/
  2725. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2726. {
  2727. int friendly;
  2728. struct pet_data *pd;
  2729. nullpo_retr(-1, sd);
  2730. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2731. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2732. return -1;
  2733. }
  2734. pd = sd->pd;
  2735. if (!pd) {
  2736. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2737. return -1;
  2738. }
  2739. if (friendly < 0 || friendly > 1000)
  2740. {
  2741. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2742. return -1;
  2743. }
  2744. if (friendly == pd->pet.intimate) {
  2745. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  2746. return -1;
  2747. }
  2748. pd->pet.intimate = friendly;
  2749. clif_send_petstatus(sd);
  2750. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  2751. return 0;
  2752. }
  2753. /*==========================================
  2754. *
  2755. *------------------------------------------*/
  2756. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2757. {
  2758. int hungry;
  2759. struct pet_data *pd;
  2760. nullpo_retr(-1, sd);
  2761. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2762. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2763. return -1;
  2764. }
  2765. pd = sd->pd;
  2766. if (!sd->status.pet_id || !pd) {
  2767. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2768. return -1;
  2769. }
  2770. if (hungry < 0 || hungry > 100) {
  2771. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2772. return -1;
  2773. }
  2774. if (hungry == pd->pet.hungry) {
  2775. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  2776. return -1;
  2777. }
  2778. pd->pet.hungry = hungry;
  2779. clif_send_petstatus(sd);
  2780. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  2781. return 0;
  2782. }
  2783. /*==========================================
  2784. *
  2785. *------------------------------------------*/
  2786. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2787. {
  2788. struct pet_data *pd;
  2789. nullpo_retr(-1, sd);
  2790. if (!sd->status.pet_id || !sd->pd) {
  2791. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2792. return -1;
  2793. }
  2794. pd = sd->pd;
  2795. if (!pd->pet.rename_flag) {
  2796. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2797. return -1;
  2798. }
  2799. pd->pet.rename_flag = 0;
  2800. intif_save_petdata(sd->status.account_id, &pd->pet);
  2801. clif_send_petstatus(sd);
  2802. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2803. return 0;
  2804. }
  2805. /*==========================================
  2806. *
  2807. *------------------------------------------*/
  2808. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2809. {
  2810. struct map_session_data *pl_sd = NULL;
  2811. nullpo_retr(-1, sd);
  2812. if (!message || !*message) {
  2813. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2814. return -1;
  2815. }
  2816. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2817. {
  2818. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2819. return -1;
  2820. }
  2821. if (pl_sd == sd)
  2822. {
  2823. clif_displaymessage(fd, "You are already where you are...");
  2824. return -1;
  2825. }
  2826. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2827. {
  2828. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2829. return -1;
  2830. }
  2831. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2832. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  2833. return -1;
  2834. }
  2835. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2836. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2837. return -1;
  2838. }
  2839. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  2840. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2841. clif_displaymessage(fd, atcmd_output);
  2842. return 0;
  2843. }
  2844. /*==========================================
  2845. * charblock command (usage: charblock <player_name>)
  2846. * This command do a definitiv ban on a player
  2847. *------------------------------------------*/
  2848. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2849. {
  2850. nullpo_retr(-1, sd);
  2851. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2852. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2853. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2854. return -1;
  2855. }
  2856. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2857. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2858. return 0;
  2859. }
  2860. /*==========================================
  2861. * charban command (usage: charban <time> <player_name>)
  2862. * This command do a limited ban on a player
  2863. * Time is done as follows:
  2864. * Adjustment value (-1, 1, +1, etc...)
  2865. * Modified element:
  2866. * a or y: year
  2867. * m: month
  2868. * j or d: day
  2869. * h: hour
  2870. * mn: minute
  2871. * s: second
  2872. * <example> @ban +1m-2mn1s-6y test_player
  2873. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2874. *------------------------------------------*/
  2875. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2876. {
  2877. char * modif_p;
  2878. int year, month, day, hour, minute, second, value;
  2879. nullpo_retr(-1, sd);
  2880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2881. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2882. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2883. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2884. return -1;
  2885. }
  2886. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2887. modif_p = atcmd_output;
  2888. year = month = day = hour = minute = second = 0;
  2889. while (modif_p[0] != '\0') {
  2890. value = atoi(modif_p);
  2891. if (value == 0)
  2892. modif_p++;
  2893. else {
  2894. if (modif_p[0] == '-' || modif_p[0] == '+')
  2895. modif_p++;
  2896. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2897. modif_p++;
  2898. if (modif_p[0] == 's') {
  2899. second = value;
  2900. modif_p++;
  2901. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  2902. minute = value;
  2903. modif_p = modif_p + 2;
  2904. } else if (modif_p[0] == 'h') {
  2905. hour = value;
  2906. modif_p++;
  2907. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2908. day = value;
  2909. modif_p++;
  2910. } else if (modif_p[0] == 'm') {
  2911. month = value;
  2912. modif_p++;
  2913. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2914. year = value;
  2915. modif_p++;
  2916. } else if (modif_p[0] != '\0') {
  2917. modif_p++;
  2918. }
  2919. }
  2920. }
  2921. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2922. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2923. return -1;
  2924. }
  2925. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2926. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2927. return 0;
  2928. }
  2929. /*==========================================
  2930. * charunblock command (usage: charunblock <player_name>)
  2931. *------------------------------------------*/
  2932. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2933. {
  2934. nullpo_retr(-1, sd);
  2935. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2936. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2937. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  2938. return -1;
  2939. }
  2940. // send answer to login server via char-server
  2941. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2942. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2943. return 0;
  2944. }
  2945. /*==========================================
  2946. * charunban command (usage: charunban <player_name>)
  2947. *------------------------------------------*/
  2948. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2949. {
  2950. nullpo_retr(-1, sd);
  2951. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2952. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2953. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  2954. return -1;
  2955. }
  2956. // send answer to login server via char-server
  2957. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2958. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2959. return 0;
  2960. }
  2961. /*==========================================
  2962. *
  2963. *------------------------------------------*/
  2964. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2965. {
  2966. nullpo_retr(-1, sd);
  2967. if (night_flag != 1) {
  2968. map_night_timer(night_timer_tid, 0, 0, 1);
  2969. } else {
  2970. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  2971. return -1;
  2972. }
  2973. return 0;
  2974. }
  2975. /*==========================================
  2976. *
  2977. *------------------------------------------*/
  2978. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2979. {
  2980. nullpo_retr(-1, sd);
  2981. if (night_flag != 0) {
  2982. map_day_timer(day_timer_tid, 0, 0, 1);
  2983. } else {
  2984. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  2985. return -1;
  2986. }
  2987. return 0;
  2988. }
  2989. /*==========================================
  2990. *
  2991. *------------------------------------------*/
  2992. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2993. {
  2994. struct map_session_data* pl_sd;
  2995. struct s_mapiterator* iter;
  2996. nullpo_retr(-1, sd);
  2997. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  2998. iter = mapit_getallusers();
  2999. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3000. {
  3001. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3002. {
  3003. status_kill(&pl_sd->bl);
  3004. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3005. }
  3006. }
  3007. mapit_free(iter);
  3008. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3009. return 0;
  3010. }
  3011. /*==========================================
  3012. *
  3013. *------------------------------------------*/
  3014. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3015. {
  3016. struct map_session_data* pl_sd;
  3017. struct s_mapiterator* iter;
  3018. nullpo_retr(-1, sd);
  3019. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  3020. iter = mapit_getallusers();
  3021. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3022. {
  3023. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3024. {
  3025. status_kill(&pl_sd->bl);
  3026. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3027. }
  3028. }
  3029. mapit_free(iter);
  3030. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3031. return 0;
  3032. }
  3033. /*==========================================
  3034. *
  3035. *------------------------------------------*/
  3036. static void atcommand_raise_sub(struct map_session_data* sd)
  3037. {
  3038. if (!status_isdead(&sd->bl))
  3039. return;
  3040. if(!status_revive(&sd->bl, 100, 100))
  3041. return;
  3042. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3043. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3044. }
  3045. /*==========================================
  3046. *
  3047. *------------------------------------------*/
  3048. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3049. {
  3050. struct map_session_data* pl_sd;
  3051. struct s_mapiterator* iter;
  3052. nullpo_retr(-1, sd);
  3053. iter = mapit_getallusers();
  3054. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3055. atcommand_raise_sub(pl_sd);
  3056. mapit_free(iter);
  3057. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3058. return 0;
  3059. }
  3060. /*==========================================
  3061. *
  3062. *------------------------------------------*/
  3063. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3064. {
  3065. struct map_session_data* pl_sd;
  3066. struct s_mapiterator* iter;
  3067. nullpo_retr(-1, sd);
  3068. iter = mapit_getallusers();
  3069. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3070. if (sd->bl.m == pl_sd->bl.m)
  3071. atcommand_raise_sub(pl_sd);
  3072. mapit_free(iter);
  3073. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3074. return 0;
  3075. }
  3076. /*==========================================
  3077. *
  3078. *------------------------------------------*/
  3079. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3080. {
  3081. struct map_session_data *pl_sd;
  3082. nullpo_retr(-1, sd);
  3083. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3084. if (!message || !*message) {
  3085. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3086. return -1;
  3087. }
  3088. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3089. {
  3090. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3091. return -1;
  3092. }
  3093. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3094. {
  3095. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3096. return -1;
  3097. }
  3098. clif_GM_kick(sd, pl_sd);
  3099. return 0;
  3100. }
  3101. /*==========================================
  3102. *
  3103. *------------------------------------------*/
  3104. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3105. {
  3106. struct map_session_data* pl_sd;
  3107. struct s_mapiterator* iter;
  3108. nullpo_retr(-1, sd);
  3109. iter = mapit_getallusers();
  3110. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3111. {
  3112. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3113. if (sd->status.account_id != pl_sd->status.account_id)
  3114. clif_GM_kick(NULL, pl_sd);
  3115. }
  3116. }
  3117. mapit_free(iter);
  3118. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3119. return 0;
  3120. }
  3121. /*==========================================
  3122. *
  3123. *------------------------------------------*/
  3124. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3125. {
  3126. nullpo_retr(-1, sd);
  3127. pc_allskillup(sd); // all skills
  3128. sd->status.skill_point = 0; // 0 skill points
  3129. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3130. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  3131. return 0;
  3132. }
  3133. /*==========================================
  3134. *
  3135. *------------------------------------------*/
  3136. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3137. {
  3138. int skill_id;
  3139. nullpo_retr(-1, sd);
  3140. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3141. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3142. return -1;
  3143. }
  3144. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3145. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3146. return -1;
  3147. }
  3148. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3149. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3150. return -1;
  3151. }
  3152. if (pc_checkskill(sd, skill_id) > 0) {
  3153. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3154. return -1;
  3155. }
  3156. pc_skill(sd, skill_id, 1, 0);
  3157. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3158. return 0;
  3159. }
  3160. /*==========================================
  3161. *
  3162. *------------------------------------------*/
  3163. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3164. {
  3165. int skill_id;
  3166. nullpo_retr(-1, sd);
  3167. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3168. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3169. return -1;
  3170. }
  3171. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3172. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3173. return -1;
  3174. }
  3175. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3176. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3177. return -1;
  3178. }
  3179. if (pc_checkskill(sd, skill_id) == 0) {
  3180. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3181. return -1;
  3182. }
  3183. sd->status.skill[skill_id].lv = 0;
  3184. sd->status.skill[skill_id].flag = 0;
  3185. clif_skillinfoblock(sd);
  3186. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3187. return 0;
  3188. }
  3189. /*==========================================
  3190. *
  3191. *------------------------------------------*/
  3192. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3193. {
  3194. int number;
  3195. nullpo_retr(-1, sd);
  3196. if (!message || !*message || (number = atoi(message)) < 0) {
  3197. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  3198. return -1;
  3199. }
  3200. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  3201. if (number > 500)
  3202. number = 500;
  3203. if (number >= 0 && number <= 0x7FFF) {
  3204. if (sd->spiritball != number || number > 499) {
  3205. if (sd->spiritball > 0)
  3206. pc_delspiritball(sd, sd->spiritball, 1);
  3207. sd->spiritball = number;
  3208. clif_spiritball(sd);
  3209. // no message, player can look the difference
  3210. if (number > 1000)
  3211. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  3212. } else {
  3213. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  3214. return -1;
  3215. }
  3216. } else {
  3217. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3218. return -1;
  3219. }
  3220. return 0;
  3221. }
  3222. /*==========================================
  3223. *
  3224. *------------------------------------------*/
  3225. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3226. {
  3227. char party[NAME_LENGTH];
  3228. nullpo_retr(-1, sd);
  3229. memset(party, '\0', sizeof(party));
  3230. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3231. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3232. return -1;
  3233. }
  3234. party_create(sd, party, 0, 0);
  3235. return 0;
  3236. }
  3237. /*==========================================
  3238. *
  3239. *------------------------------------------*/
  3240. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3241. {
  3242. char guild[NAME_LENGTH];
  3243. int prev;
  3244. nullpo_retr(-1, sd);
  3245. memset(guild, '\0', sizeof(guild));
  3246. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3247. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3248. return -1;
  3249. }
  3250. prev = battle_config.guild_emperium_check;
  3251. battle_config.guild_emperium_check = 0;
  3252. guild_create(sd, guild);
  3253. battle_config.guild_emperium_check = prev;
  3254. return 0;
  3255. }
  3256. /*==========================================
  3257. *
  3258. *------------------------------------------*/
  3259. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3260. {
  3261. nullpo_retr(-1, sd);
  3262. if (agit_flag == 1) {
  3263. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  3264. return -1;
  3265. }
  3266. agit_flag = 1;
  3267. guild_agit_start();
  3268. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  3269. return 0;
  3270. }
  3271. /*==========================================
  3272. *
  3273. *------------------------------------------*/
  3274. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3275. {
  3276. nullpo_retr(-1, sd);
  3277. if (agit_flag == 0) {
  3278. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  3279. return -1;
  3280. }
  3281. agit_flag = 0;
  3282. guild_agit_end();
  3283. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  3284. return 0;
  3285. }
  3286. /*==========================================
  3287. * @mapexit - shuts down the map server
  3288. *------------------------------------------*/
  3289. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3290. {
  3291. struct map_session_data* pl_sd;
  3292. struct s_mapiterator* iter;
  3293. nullpo_retr(-1, sd);
  3294. iter = mapit_getallusers();
  3295. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3296. if (sd->status.account_id != pl_sd->status.account_id)
  3297. clif_GM_kick(NULL, pl_sd);
  3298. mapit_free(iter);
  3299. clif_GM_kick(NULL, sd);
  3300. flush_fifos();
  3301. runflag = 0;
  3302. return 0;
  3303. }
  3304. /*==========================================
  3305. * idsearch <part_of_name>: revrited by [Yor]
  3306. *------------------------------------------*/
  3307. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3308. {
  3309. char item_name[100];
  3310. unsigned int i, match;
  3311. struct item_data *item_array[MAX_SEARCH];
  3312. nullpo_retr(-1, sd);
  3313. memset(item_name, '\0', sizeof(item_name));
  3314. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3315. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3316. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3317. return -1;
  3318. }
  3319. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3320. clif_displaymessage(fd, atcmd_output);
  3321. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3322. if (match > MAX_SEARCH) {
  3323. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3324. clif_displaymessage(fd, atcmd_output);
  3325. match = MAX_SEARCH;
  3326. }
  3327. for(i = 0; i < match; i++) {
  3328. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3329. clif_displaymessage(fd, atcmd_output);
  3330. }
  3331. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3332. clif_displaymessage(fd, atcmd_output);
  3333. return 0;
  3334. }
  3335. /*==========================================
  3336. * Recall All Characters Online To Your Location
  3337. *------------------------------------------*/
  3338. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3339. {
  3340. struct map_session_data* pl_sd;
  3341. struct s_mapiterator* iter;
  3342. int count;
  3343. nullpo_retr(-1, sd);
  3344. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3345. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3346. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3347. return -1;
  3348. }
  3349. count = 0;
  3350. iter = mapit_getallusers();
  3351. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3352. {
  3353. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3354. {
  3355. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3356. count++;
  3357. else {
  3358. if (pc_isdead(pl_sd)) { //Wake them up
  3359. pc_setstand(pl_sd);
  3360. pc_setrestartvalue(pl_sd,1);
  3361. }
  3362. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3363. }
  3364. }
  3365. }
  3366. mapit_free(iter);
  3367. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3368. if (count) {
  3369. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3370. clif_displaymessage(fd, atcmd_output);
  3371. }
  3372. return 0;
  3373. }
  3374. /*==========================================
  3375. * Recall online characters of a guild to your location
  3376. *------------------------------------------*/
  3377. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3378. {
  3379. struct map_session_data* pl_sd;
  3380. struct s_mapiterator* iter;
  3381. int count;
  3382. char guild_name[NAME_LENGTH];
  3383. struct guild *g;
  3384. nullpo_retr(-1, sd);
  3385. memset(guild_name, '\0', sizeof(guild_name));
  3386. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3387. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3388. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3389. return -1;
  3390. }
  3391. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3392. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3393. return -1;
  3394. }
  3395. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3396. (g = guild_search(atoi(message))) == NULL)
  3397. {
  3398. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3399. return -1;
  3400. }
  3401. count = 0;
  3402. iter = mapit_getallusers();
  3403. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3404. {
  3405. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3406. {
  3407. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3408. continue; //Skip GMs greater than you.
  3409. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3410. count++;
  3411. else
  3412. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3413. }
  3414. }
  3415. mapit_free(iter);
  3416. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  3417. clif_displaymessage(fd, atcmd_output);
  3418. if (count) {
  3419. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3420. clif_displaymessage(fd, atcmd_output);
  3421. }
  3422. return 0;
  3423. }
  3424. /*==========================================
  3425. * Recall online characters of a party to your location
  3426. *------------------------------------------*/
  3427. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3428. {
  3429. struct map_session_data* pl_sd;
  3430. struct s_mapiterator* iter;
  3431. char party_name[NAME_LENGTH];
  3432. struct party_data *p;
  3433. int count;
  3434. nullpo_retr(-1, sd);
  3435. memset(party_name, '\0', sizeof(party_name));
  3436. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3437. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3438. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3439. return -1;
  3440. }
  3441. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3442. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3443. return -1;
  3444. }
  3445. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3446. (p = party_search(atoi(message))) == NULL)
  3447. {
  3448. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3449. return -1;
  3450. }
  3451. count = 0;
  3452. iter = mapit_getallusers();
  3453. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3454. {
  3455. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3456. {
  3457. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3458. continue; //Skip GMs greater than you.
  3459. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3460. count++;
  3461. else
  3462. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3463. }
  3464. }
  3465. mapit_free(iter);
  3466. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  3467. clif_displaymessage(fd, atcmd_output);
  3468. if (count) {
  3469. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3470. clif_displaymessage(fd, atcmd_output);
  3471. }
  3472. return 0;
  3473. }
  3474. /*==========================================
  3475. *
  3476. *------------------------------------------*/
  3477. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3478. {
  3479. nullpo_retr(-1, sd);
  3480. itemdb_reload();
  3481. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  3482. return 0;
  3483. }
  3484. /*==========================================
  3485. *
  3486. *------------------------------------------*/
  3487. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3488. {
  3489. nullpo_retr(-1, sd);
  3490. mob_reload();
  3491. read_petdb();
  3492. merc_reload();
  3493. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  3494. return 0;
  3495. }
  3496. /*==========================================
  3497. *
  3498. *------------------------------------------*/
  3499. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3500. {
  3501. nullpo_retr(-1, sd);
  3502. skill_reload();
  3503. merc_skill_reload();
  3504. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  3505. return 0;
  3506. }
  3507. /*==========================================
  3508. * @reloadatcommand - reloads atcommand_athena.conf
  3509. *------------------------------------------*/
  3510. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3511. {
  3512. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  3513. clif_displaymessage(fd, msg_txt(254));
  3514. return 0;
  3515. }
  3516. /*==========================================
  3517. * @reloadbattleconf - reloads battle_athena.conf
  3518. *------------------------------------------*/
  3519. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3520. {
  3521. struct Battle_Config prev_config;
  3522. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3523. battle_config_read(BATTLE_CONF_FILENAME);
  3524. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3525. || prev_config.item_rate_common != battle_config.item_rate_common
  3526. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3527. || prev_config.item_rate_card != battle_config.item_rate_card
  3528. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3529. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3530. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3531. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3532. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3533. || prev_config.item_rate_use != battle_config.item_rate_use
  3534. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3535. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3536. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3537. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3538. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3539. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3540. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3541. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3542. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3543. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3544. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3545. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3546. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3547. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3548. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3549. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3550. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3551. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3552. )
  3553. { //Drop rates changed.
  3554. mob_reload(); //Needed as well so rate changes take effect.
  3555. #ifndef TXT_ONLY
  3556. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3557. #endif
  3558. }
  3559. clif_displaymessage(fd, msg_txt(255));
  3560. return 0;
  3561. }
  3562. /*==========================================
  3563. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3564. *------------------------------------------*/
  3565. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3566. {
  3567. status_readdb();
  3568. clif_displaymessage(fd, msg_txt(256));
  3569. return 0;
  3570. }
  3571. /*==========================================
  3572. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3573. *------------------------------------------*/
  3574. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3575. {
  3576. pc_readdb();
  3577. clif_displaymessage(fd, msg_txt(257));
  3578. return 0;
  3579. }
  3580. /*==========================================
  3581. * @reloadmotd - reloads motd.txt
  3582. *------------------------------------------*/
  3583. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3584. {
  3585. pc_read_motd();
  3586. clif_displaymessage(fd, msg_txt(268));
  3587. return 0;
  3588. }
  3589. /*==========================================
  3590. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3591. *------------------------------------------*/
  3592. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3593. {
  3594. nullpo_retr(-1, sd);
  3595. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3596. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3597. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3598. flush_fifos();
  3599. script_reload();
  3600. npc_reload();
  3601. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  3602. return 0;
  3603. }
  3604. /*==========================================
  3605. * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database)
  3606. *------------------------------------------*/
  3607. int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3608. {
  3609. nullpo_retr(-1, sd);
  3610. chrif_reloadGMdb();
  3611. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  3612. return 0;
  3613. }
  3614. /*==========================================
  3615. * @mapinfo <map name> [0-3] by MC_Cameri
  3616. * => Shows information about the map [map name]
  3617. * 0 = no additional information
  3618. * 1 = Show users in that map and their location
  3619. * 2 = Shows NPCs in that map
  3620. * 3 = Shows the shops/chats in that map (not implemented)
  3621. *------------------------------------------*/
  3622. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3623. {
  3624. struct map_session_data* pl_sd;
  3625. struct s_mapiterator* iter;
  3626. struct npc_data *nd = NULL;
  3627. struct chat_data *cd = NULL;
  3628. char direction[12];
  3629. int i, m_id, chat_num, list = 0;
  3630. unsigned short m_index;
  3631. char mapname[24];
  3632. nullpo_retr(-1, sd);
  3633. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3634. memset(mapname, '\0', sizeof(mapname));
  3635. memset(direction, '\0', sizeof(direction));
  3636. sscanf(message, "%d %23[^\n]", &list, mapname);
  3637. if (list < 0 || list > 3) {
  3638. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3639. return -1;
  3640. }
  3641. if (mapname[0] == '\0') {
  3642. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3643. m_id = map_mapindex2mapid(sd->mapindex);
  3644. } else {
  3645. m_id = map_mapname2mapid(mapname);
  3646. }
  3647. if (m_id < 0) {
  3648. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3649. return -1;
  3650. }
  3651. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3652. clif_displaymessage(fd, "------ Map Info ------");
  3653. // count chats (for initial message)
  3654. chat_num = 0;
  3655. iter = mapit_getallusers();
  3656. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3657. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3658. chat_num++;
  3659. mapit_free(iter);
  3660. 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);
  3661. clif_displaymessage(fd, atcmd_output);
  3662. clif_displaymessage(fd, "------ Map Flags ------");
  3663. strcpy(atcmd_output,"PvP Flags: ");
  3664. if (map[m_id].flag.pvp)
  3665. strcat(atcmd_output, "Pvp ON | ");
  3666. if (map[m_id].flag.pvp_noguild)
  3667. strcat(atcmd_output, "NoGuild | ");
  3668. if (map[m_id].flag.pvp_noparty)
  3669. strcat(atcmd_output, "NoParty | ");
  3670. if (map[m_id].flag.pvp_nightmaredrop)
  3671. strcat(atcmd_output, "NightmareDrop | ");
  3672. if (map[m_id].flag.pvp_nocalcrank)
  3673. strcat(atcmd_output, "NoCalcRank | ");
  3674. clif_displaymessage(fd, atcmd_output);
  3675. strcpy(atcmd_output,"GvG Flags: ");
  3676. if (map[m_id].flag.gvg)
  3677. strcat(atcmd_output, "GvG ON | ");
  3678. if (map[m_id].flag.gvg_dungeon)
  3679. strcat(atcmd_output, "GvG Dungeon | ");
  3680. if (map[m_id].flag.gvg_castle)
  3681. strcat(atcmd_output, "GvG Castle | ");
  3682. if (map[m_id].flag.gvg_noparty)
  3683. strcat(atcmd_output, "NoParty | ");
  3684. clif_displaymessage(fd, atcmd_output);
  3685. strcpy(atcmd_output,"Teleport Flags: ");
  3686. if (map[m_id].flag.noteleport)
  3687. strcat(atcmd_output, "NoTeleport | ");
  3688. if (map[m_id].flag.monster_noteleport)
  3689. strcat(atcmd_output, "Monster NoTeleport | ");
  3690. if (map[m_id].flag.nowarp)
  3691. strcat(atcmd_output, "NoWarp | ");
  3692. if (map[m_id].flag.nowarpto)
  3693. strcat(atcmd_output, "NoWarpTo | ");
  3694. if (map[m_id].flag.noreturn)
  3695. strcat(atcmd_output, "NoReturn | ");
  3696. if (map[m_id].flag.nogo)
  3697. strcat(atcmd_output, "NoGo | ");
  3698. if (map[m_id].flag.nomemo)
  3699. strcat(atcmd_output, "NoMemo | ");
  3700. clif_displaymessage(fd, atcmd_output);
  3701. 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");
  3702. clif_displaymessage(fd, atcmd_output);
  3703. if (map[m_id].flag.nosave) {
  3704. if (!map[m_id].save.map)
  3705. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3706. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3707. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3708. else
  3709. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3710. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3711. clif_displaymessage(fd, atcmd_output);
  3712. }
  3713. strcpy(atcmd_output,"Weather Flags: ");
  3714. if (map[m_id].flag.snow)
  3715. strcat(atcmd_output, "Snow | ");
  3716. if (map[m_id].flag.fog)
  3717. strcat(atcmd_output, "Fog | ");
  3718. if (map[m_id].flag.sakura)
  3719. strcat(atcmd_output, "Sakura | ");
  3720. if (map[m_id].flag.clouds)
  3721. strcat(atcmd_output, "Clouds | ");
  3722. if (map[m_id].flag.clouds2)
  3723. strcat(atcmd_output, "Clouds2 | ");
  3724. if (map[m_id].flag.fireworks)
  3725. strcat(atcmd_output, "Fireworks | ");
  3726. if (map[m_id].flag.leaves)
  3727. strcat(atcmd_output, "Leaves | ");
  3728. if (map[m_id].flag.rain)
  3729. strcat(atcmd_output, "Rain | ");
  3730. if (map[m_id].flag.indoors)
  3731. strcat(atcmd_output, "Indoors | ");
  3732. if (map[m_id].flag.nightenabled)
  3733. strcat(atcmd_output, "Displays Night | ");
  3734. clif_displaymessage(fd, atcmd_output);
  3735. strcpy(atcmd_output,"Other Flags: ");
  3736. if (map[m_id].flag.nobranch)
  3737. strcat(atcmd_output, "NoBranch | ");
  3738. if (map[m_id].flag.notrade)
  3739. strcat(atcmd_output, "NoTrade | ");
  3740. if (map[m_id].flag.novending)
  3741. strcat(atcmd_output, "NoVending | ");
  3742. if (map[m_id].flag.nodrop)
  3743. strcat(atcmd_output, "NoDrop | ");
  3744. if (map[m_id].flag.noskill)
  3745. strcat(atcmd_output, "NoSkill | ");
  3746. if (map[m_id].flag.noicewall)
  3747. strcat(atcmd_output, "NoIcewall | ");
  3748. clif_displaymessage(fd, atcmd_output);
  3749. strcpy(atcmd_output,"Other Flags: ");
  3750. if (map[m_id].nocommand)
  3751. strcat(atcmd_output, "NoCommand | ");
  3752. if (map[m_id].flag.nobaseexp)
  3753. strcat(atcmd_output, "NoBaseEXP | ");
  3754. if (map[m_id].flag.nojobexp)
  3755. strcat(atcmd_output, "NoJobEXP | ");
  3756. if (map[m_id].flag.nomobloot)
  3757. strcat(atcmd_output, "NoMobLoot | ");
  3758. if (map[m_id].flag.nomvploot)
  3759. strcat(atcmd_output, "NoMVPLoot | ");
  3760. if (map[m_id].flag.partylock)
  3761. strcat(atcmd_output, "PartyLock | ");
  3762. if (map[m_id].flag.guildlock)
  3763. strcat(atcmd_output, "GuildLock | ");
  3764. clif_displaymessage(fd, atcmd_output);
  3765. switch (list) {
  3766. case 0:
  3767. // Do nothing. It's list 0, no additional display.
  3768. break;
  3769. case 1:
  3770. clif_displaymessage(fd, "----- Players in Map -----");
  3771. iter = mapit_getallusers();
  3772. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3773. {
  3774. if (pl_sd->mapindex == m_index) {
  3775. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3776. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3777. clif_displaymessage(fd, atcmd_output);
  3778. }
  3779. }
  3780. mapit_free(iter);
  3781. break;
  3782. case 2:
  3783. clif_displaymessage(fd, "----- NPCs in Map -----");
  3784. for (i = 0; i < map[m_id].npc_num;)
  3785. {
  3786. nd = map[m_id].npc[i];
  3787. switch(nd->ud.dir) {
  3788. case 0: strcpy(direction, "North"); break;
  3789. case 1: strcpy(direction, "North West"); break;
  3790. case 2: strcpy(direction, "West"); break;
  3791. case 3: strcpy(direction, "South West"); break;
  3792. case 4: strcpy(direction, "South"); break;
  3793. case 5: strcpy(direction, "South East"); break;
  3794. case 6: strcpy(direction, "East"); break;
  3795. case 7: strcpy(direction, "North East"); break;
  3796. case 9: strcpy(direction, "North"); break;
  3797. default: strcpy(direction, "Unknown"); break;
  3798. }
  3799. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3800. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3801. clif_displaymessage(fd, atcmd_output);
  3802. }
  3803. break;
  3804. case 3:
  3805. clif_displaymessage(fd, "----- Chats in Map -----");
  3806. iter = mapit_getallusers();
  3807. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3808. {
  3809. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3810. pl_sd->mapindex == m_index &&
  3811. cd->usersd[0] == pl_sd)
  3812. {
  3813. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  3814. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3815. clif_displaymessage(fd, atcmd_output);
  3816. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3817. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3818. clif_displaymessage(fd, atcmd_output);
  3819. }
  3820. }
  3821. mapit_free(iter);
  3822. break;
  3823. default: // normally impossible to arrive here
  3824. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3825. return -1;
  3826. break;
  3827. }
  3828. return 0;
  3829. }
  3830. /*==========================================
  3831. *
  3832. *------------------------------------------*/
  3833. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3834. {
  3835. nullpo_retr(-1, sd);
  3836. if (!pc_isriding(sd)) { // if actually no peco
  3837. if (!pc_checkskill(sd, KN_RIDING))
  3838. {
  3839. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  3840. return -1;
  3841. }
  3842. if (sd->disguise)
  3843. {
  3844. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco while in disguise.
  3845. return -1;
  3846. }
  3847. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3848. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  3849. } else { //Dismount
  3850. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3851. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  3852. }
  3853. return 0;
  3854. }
  3855. /*==========================================
  3856. *Spy Commands by Syrus22
  3857. *------------------------------------------*/
  3858. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3859. {
  3860. char guild_name[NAME_LENGTH];
  3861. struct guild *g;
  3862. nullpo_retr(-1, sd);
  3863. memset(guild_name, '\0', sizeof(guild_name));
  3864. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3865. if (!enable_spy)
  3866. {
  3867. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3868. return -1;
  3869. }
  3870. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3871. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3872. return -1;
  3873. }
  3874. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3875. (g = guild_search(atoi(message))) != NULL) {
  3876. if (sd->guildspy == g->guild_id) {
  3877. sd->guildspy = 0;
  3878. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3879. clif_displaymessage(fd, atcmd_output);
  3880. } else {
  3881. sd->guildspy = g->guild_id;
  3882. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3883. clif_displaymessage(fd, atcmd_output);
  3884. }
  3885. } else {
  3886. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3887. return -1;
  3888. }
  3889. return 0;
  3890. }
  3891. /*==========================================
  3892. *
  3893. *------------------------------------------*/
  3894. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3895. {
  3896. char party_name[NAME_LENGTH];
  3897. struct party_data *p;
  3898. nullpo_retr(-1, sd);
  3899. memset(party_name, '\0', sizeof(party_name));
  3900. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3901. if (!enable_spy)
  3902. {
  3903. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3904. return -1;
  3905. }
  3906. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3907. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3908. return -1;
  3909. }
  3910. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3911. (p = party_search(atoi(message))) != NULL) {
  3912. if (sd->partyspy == p->party.party_id) {
  3913. sd->partyspy = 0;
  3914. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3915. clif_displaymessage(fd, atcmd_output);
  3916. } else {
  3917. sd->partyspy = p->party.party_id;
  3918. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3919. clif_displaymessage(fd, atcmd_output);
  3920. }
  3921. } else {
  3922. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3923. return -1;
  3924. }
  3925. return 0;
  3926. }
  3927. /*==========================================
  3928. * @repairall [Valaris]
  3929. *------------------------------------------*/
  3930. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3931. {
  3932. int count, i;
  3933. nullpo_retr(-1, sd);
  3934. count = 0;
  3935. for (i = 0; i < MAX_INVENTORY; i++) {
  3936. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3937. sd->status.inventory[i].attribute = 0;
  3938. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3939. count++;
  3940. }
  3941. }
  3942. if (count > 0) {
  3943. clif_misceffect(&sd->bl, 3);
  3944. clif_equiplist(sd);
  3945. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3946. } else {
  3947. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3948. return -1;
  3949. }
  3950. return 0;
  3951. }
  3952. /*==========================================
  3953. * @nuke [Valaris]
  3954. *------------------------------------------*/
  3955. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3956. {
  3957. struct map_session_data *pl_sd;
  3958. nullpo_retr(-1, sd);
  3959. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3960. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3961. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  3962. return -1;
  3963. }
  3964. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3965. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  3966. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3967. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3968. } else {
  3969. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3970. return -1;
  3971. }
  3972. } else {
  3973. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3974. return -1;
  3975. }
  3976. return 0;
  3977. }
  3978. /*==========================================
  3979. * @tonpc
  3980. *------------------------------------------*/
  3981. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3982. {
  3983. char npcname[NAME_LENGTH];
  3984. struct npc_data *nd;
  3985. nullpo_retr(-1, sd);
  3986. memset(npcname, 0, sizeof(npcname));
  3987. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3988. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  3989. return -1;
  3990. }
  3991. if ((nd = npc_name2id(npcname)) != NULL) {
  3992. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
  3993. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3994. else
  3995. return -1;
  3996. } else {
  3997. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3998. return -1;
  3999. }
  4000. return 0;
  4001. }
  4002. /*==========================================
  4003. *
  4004. *------------------------------------------*/
  4005. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4006. {
  4007. char NPCname[NAME_LENGTH];
  4008. nullpo_retr(-1, sd);
  4009. memset(NPCname, '\0', sizeof(NPCname));
  4010. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4011. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4012. return -1;
  4013. }
  4014. if (npc_name2id(NPCname) != NULL) {
  4015. npc_enable(NPCname, 1);
  4016. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4017. } else {
  4018. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4019. return -1;
  4020. }
  4021. return 0;
  4022. }
  4023. /*==========================================
  4024. *
  4025. *------------------------------------------*/
  4026. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4027. {
  4028. char NPCname[NAME_LENGTH];
  4029. nullpo_retr(-1, sd);
  4030. memset(NPCname, '\0', sizeof(NPCname));
  4031. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4032. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4033. return -1;
  4034. }
  4035. if (npc_name2id(NPCname) == NULL) {
  4036. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4037. return -1;
  4038. }
  4039. npc_enable(NPCname, 0);
  4040. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4041. return 0;
  4042. }
  4043. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4044. {
  4045. FILE *fp;
  4046. if (!message || !*message) {
  4047. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4048. return -1;
  4049. }
  4050. // check if script file exists
  4051. if ((fp = fopen(message, "r")) == NULL) {
  4052. clif_displaymessage(fd, msg_txt(261));
  4053. return -1;
  4054. }
  4055. fclose(fp);
  4056. // add to list of script sources and run it
  4057. npc_addsrcfile(message);
  4058. npc_parsesrcfile(message);
  4059. npc_read_event_script();
  4060. clif_displaymessage(fd, msg_txt(262));
  4061. return 0;
  4062. }
  4063. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4064. {
  4065. struct npc_data *nd;
  4066. char NPCname[NAME_LENGTH];
  4067. nullpo_retr(-1, sd);
  4068. memset(NPCname, '\0', sizeof(NPCname));
  4069. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4070. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4071. return -1;
  4072. }
  4073. if ((nd = npc_name2id(NPCname)) == NULL) {
  4074. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4075. return -1;
  4076. }
  4077. npc_unload_duplicates(nd);
  4078. npc_unload(nd);
  4079. npc_read_event_script();
  4080. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4081. return 0;
  4082. }
  4083. /*==========================================
  4084. * time in txt for time command (by [Yor])
  4085. *------------------------------------------*/
  4086. char* txt_time(unsigned int duration)
  4087. {
  4088. int days, hours, minutes, seconds;
  4089. char temp[256];
  4090. static char temp1[256];
  4091. memset(temp, '\0', sizeof(temp));
  4092. memset(temp1, '\0', sizeof(temp1));
  4093. days = duration / (60 * 60 * 24);
  4094. duration = duration - (60 * 60 * 24 * days);
  4095. hours = duration / (60 * 60);
  4096. duration = duration - (60 * 60 * hours);
  4097. minutes = duration / 60;
  4098. seconds = duration - (60 * minutes);
  4099. if (days < 2)
  4100. sprintf(temp, msg_txt(219), days); // %d day
  4101. else
  4102. sprintf(temp, msg_txt(220), days); // %d days
  4103. if (hours < 2)
  4104. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4105. else
  4106. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4107. if (minutes < 2)
  4108. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4109. else
  4110. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4111. if (seconds < 2)
  4112. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4113. else
  4114. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4115. return temp1;
  4116. }
  4117. /*==========================================
  4118. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4119. * Calculation management of GM modification (@day/@night GM commands) is done
  4120. *------------------------------------------*/
  4121. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4122. {
  4123. const struct TimerData * timer_data;
  4124. const struct TimerData * timer_data2;
  4125. time_t time_server; // variable for number of seconds (used with time() function)
  4126. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4127. char temp[256];
  4128. nullpo_retr(-1, sd);
  4129. memset(temp, '\0', sizeof(temp));
  4130. time(&time_server); // get time in seconds since 1/1/1970
  4131. datetime = localtime(&time_server); // convert seconds in structure
  4132. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4133. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4134. clif_displaymessage(fd, temp);
  4135. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4136. if (night_flag == 0)
  4137. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4138. else
  4139. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4140. } else if (battle_config.night_duration == 0)
  4141. if (night_flag == 1) { // we start with night
  4142. timer_data = get_timer(day_timer_tid);
  4143. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4144. clif_displaymessage(fd, temp);
  4145. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4146. } else
  4147. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4148. else if (battle_config.day_duration == 0)
  4149. if (night_flag == 0) { // we start with day
  4150. timer_data = get_timer(night_timer_tid);
  4151. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4152. clif_displaymessage(fd, temp);
  4153. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4154. } else
  4155. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4156. else {
  4157. if (night_flag == 0) {
  4158. timer_data = get_timer(night_timer_tid);
  4159. timer_data2 = get_timer(day_timer_tid);
  4160. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4161. clif_displaymessage(fd, temp);
  4162. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4163. 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.
  4164. else
  4165. 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.
  4166. clif_displaymessage(fd, temp);
  4167. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4168. clif_displaymessage(fd, temp);
  4169. } else {
  4170. timer_data = get_timer(day_timer_tid);
  4171. timer_data2 = get_timer(night_timer_tid);
  4172. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4173. clif_displaymessage(fd, temp);
  4174. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4175. 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.
  4176. else
  4177. 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.
  4178. clif_displaymessage(fd, temp);
  4179. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4180. clif_displaymessage(fd, temp);
  4181. }
  4182. }
  4183. return 0;
  4184. }
  4185. //Added by Coltaro
  4186. //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...).
  4187. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4188. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4189. {
  4190. const int factor_year = 518400; //12*30*24*60 = 518400
  4191. const int factor_month = 43200; //30*24*60 = 43200
  4192. const int factor_day = 1440; //24*60 = 1440
  4193. const int factor_hour = 60;
  4194. *year = jailtime/factor_year;
  4195. jailtime -= *year*factor_year;
  4196. *month = jailtime/factor_month;
  4197. jailtime -= *month*factor_month;
  4198. *day = jailtime/factor_day;
  4199. jailtime -= *day*factor_day;
  4200. *hour = jailtime/factor_hour;
  4201. jailtime -= *hour*factor_hour;
  4202. *minute = jailtime;
  4203. *year = *year > 0? *year : 0;
  4204. *month = *month > 0? *month : 0;
  4205. *day = *day > 0? *day : 0;
  4206. *hour = *hour > 0? *hour : 0;
  4207. *minute = *minute > 0? *minute : 0;
  4208. return;
  4209. }
  4210. /*==========================================
  4211. * @jail <char_name> by [Yor]
  4212. * Special warp! No check with nowarp and nowarpto flag
  4213. *------------------------------------------*/
  4214. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4215. {
  4216. struct map_session_data *pl_sd;
  4217. int x, y;
  4218. unsigned short m_index;
  4219. nullpo_retr(-1, sd);
  4220. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4221. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4222. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4223. return -1;
  4224. }
  4225. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4226. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4227. return -1;
  4228. }
  4229. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4230. { // you can jail only lower or same GM
  4231. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4232. return -1;
  4233. }
  4234. if (pl_sd->sc.data[SC_JAILED])
  4235. {
  4236. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4237. return -1;
  4238. }
  4239. switch(rand() % 2) { //Jail Locations
  4240. case 0:
  4241. m_index = mapindex_name2id(MAP_JAIL);
  4242. x = 24;
  4243. y = 75;
  4244. break;
  4245. default:
  4246. m_index = mapindex_name2id(MAP_JAIL);
  4247. x = 49;
  4248. y = 75;
  4249. break;
  4250. }
  4251. //Duration of INT_MAX to specify infinity.
  4252. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4253. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4254. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4255. return 0;
  4256. }
  4257. /*==========================================
  4258. * @unjail/@discharge <char_name> by [Yor]
  4259. * Special warp! No check with nowarp and nowarpto flag
  4260. *------------------------------------------*/
  4261. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4262. {
  4263. struct map_session_data *pl_sd;
  4264. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4265. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4266. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4267. return -1;
  4268. }
  4269. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4270. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4271. return -1;
  4272. }
  4273. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4274. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4275. return -1;
  4276. }
  4277. if (!pl_sd->sc.data[SC_JAILED])
  4278. {
  4279. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4280. return -1;
  4281. }
  4282. //Reset jail time to 1 sec.
  4283. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4284. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4285. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4286. return 0;
  4287. }
  4288. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4289. {
  4290. struct map_session_data *pl_sd = NULL;
  4291. int year, month, day, hour, minute, value;
  4292. char * modif_p;
  4293. int jailtime = 0,x,y;
  4294. short m_index = 0;
  4295. nullpo_retr(-1, sd);
  4296. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4297. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4298. return -1;
  4299. }
  4300. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4301. modif_p = atcmd_output;
  4302. year = month = day = hour = minute = 0;
  4303. while (modif_p[0] != '\0') {
  4304. value = atoi(modif_p);
  4305. if (value == 0)
  4306. modif_p++;
  4307. else {
  4308. if (modif_p[0] == '-' || modif_p[0] == '+')
  4309. modif_p++;
  4310. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4311. modif_p++;
  4312. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4313. minute = value;
  4314. modif_p = modif_p + 2;
  4315. } else if (modif_p[0] == 'h') {
  4316. hour = value;
  4317. modif_p++;
  4318. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4319. day = value;
  4320. modif_p++;
  4321. } else if (modif_p[0] == 'm') {
  4322. month = value;
  4323. modif_p++;
  4324. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4325. year = value;
  4326. modif_p++;
  4327. } else if (modif_p[0] != '\0') {
  4328. modif_p++;
  4329. }
  4330. }
  4331. }
  4332. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4333. clif_displaymessage(fd, "Invalid time for jail command.");
  4334. return -1;
  4335. }
  4336. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4337. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4338. return -1;
  4339. }
  4340. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4341. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4342. return -1;
  4343. }
  4344. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4345. if(jailtime==0) {
  4346. clif_displaymessage(fd, "Invalid time for jail command.");
  4347. return -1;
  4348. }
  4349. //Added by Coltaro
  4350. if(pl_sd->sc.data[SC_JAILED] &&
  4351. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4352. { //Update the player's jail time
  4353. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4354. if (jailtime <= 0) {
  4355. jailtime = 0;
  4356. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4357. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4358. } else {
  4359. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4360. 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
  4361. clif_displaymessage(pl_sd->fd, atcmd_output);
  4362. 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
  4363. clif_displaymessage(fd, atcmd_output);
  4364. }
  4365. } else if (jailtime < 0) {
  4366. clif_displaymessage(fd, "Invalid time for jail command.");
  4367. return -1;
  4368. }
  4369. //Jail locations, add more as you wish.
  4370. switch(rand()%2)
  4371. {
  4372. case 1: //Jail #1
  4373. m_index = mapindex_name2id(MAP_JAIL);
  4374. x = 49; y = 75;
  4375. break;
  4376. default: //Default Jail
  4377. m_index = mapindex_name2id(MAP_JAIL);
  4378. x = 24; y = 75;
  4379. break;
  4380. }
  4381. 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).
  4382. return 0;
  4383. }
  4384. //By Coltaro
  4385. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4386. {
  4387. int year, month, day, hour, minute;
  4388. nullpo_retr(-1, sd);
  4389. if (!sd->sc.data[SC_JAILED]) {
  4390. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4391. return -1;
  4392. }
  4393. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4394. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4395. return 0;
  4396. }
  4397. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4398. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4399. return -1;
  4400. }
  4401. //Get remaining jail time
  4402. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4403. 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
  4404. clif_displaymessage(fd, atcmd_output);
  4405. return 0;
  4406. }
  4407. /*==========================================
  4408. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4409. *------------------------------------------*/
  4410. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4411. {
  4412. int id = 0;
  4413. nullpo_retr(-1, sd);
  4414. if (!message || !*message) {
  4415. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4416. return -1;
  4417. }
  4418. if ((id = atoi(message)) > 0)
  4419. { //Acquired an ID
  4420. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4421. id = 0; //Invalid id for either mobs or npcs.
  4422. } else { //Acquired a Name
  4423. if ((id = mobdb_searchname(message)) == 0)
  4424. {
  4425. struct npc_data* nd = npc_name2id(message);
  4426. if (nd != NULL)
  4427. id = nd->class_;
  4428. }
  4429. }
  4430. if (id == 0)
  4431. {
  4432. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4433. return -1;
  4434. }
  4435. if(pc_isriding(sd))
  4436. {
  4437. //FIXME: wrong message [ultramage]
  4438. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4439. return -1;
  4440. }
  4441. pc_disguise(sd, id);
  4442. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4443. return 0;
  4444. }
  4445. /*==========================================
  4446. * DisguiseAll
  4447. *------------------------------------------*/
  4448. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4449. {
  4450. int mob_id=0;
  4451. struct map_session_data *pl_sd;
  4452. struct s_mapiterator* iter;
  4453. nullpo_retr(-1, sd);
  4454. if (!message || !*message) {
  4455. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4456. return -1;
  4457. }
  4458. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4459. mob_id = atoi(message);
  4460. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4461. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4462. return -1;
  4463. }
  4464. iter = mapit_getallusers();
  4465. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4466. pc_disguise(pl_sd, mob_id);
  4467. mapit_free(iter);
  4468. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4469. return 0;
  4470. }
  4471. /*==========================================
  4472. * @undisguise by [Yor]
  4473. *------------------------------------------*/
  4474. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4475. {
  4476. nullpo_retr(-1, sd);
  4477. if (sd->disguise) {
  4478. pc_disguise(sd, 0);
  4479. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4480. } else {
  4481. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4482. return -1;
  4483. }
  4484. return 0;
  4485. }
  4486. /*==========================================
  4487. * UndisguiseAll
  4488. *------------------------------------------*/
  4489. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4490. {
  4491. struct map_session_data *pl_sd;
  4492. struct s_mapiterator* iter;
  4493. nullpo_retr(-1, sd);
  4494. iter = mapit_getallusers();
  4495. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4496. if( pl_sd->disguise )
  4497. pc_disguise(pl_sd, 0);
  4498. mapit_free(iter);
  4499. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4500. return 0;
  4501. }
  4502. /*==========================================
  4503. * @exp by [Skotlex]
  4504. *------------------------------------------*/
  4505. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4506. {
  4507. char output[200];
  4508. double nextb, nextj;
  4509. nullpo_retr(-1, sd);
  4510. memset(output, '\0', sizeof(output));
  4511. nextb = pc_nextbaseexp(sd);
  4512. if (nextb)
  4513. nextb = sd->status.base_exp*100.0/nextb;
  4514. nextj = pc_nextjobexp(sd);
  4515. if (nextj)
  4516. nextj = sd->status.job_exp*100.0/nextj;
  4517. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4518. clif_displaymessage(fd, output);
  4519. return 0;
  4520. }
  4521. /*==========================================
  4522. * @broadcast by [Valaris]
  4523. *------------------------------------------*/
  4524. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4525. {
  4526. nullpo_retr(-1, sd);
  4527. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4528. if (!message || !*message) {
  4529. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4530. return -1;
  4531. }
  4532. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4533. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  4534. return 0;
  4535. }
  4536. /*==========================================
  4537. * @localbroadcast by [Valaris]
  4538. *------------------------------------------*/
  4539. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4540. {
  4541. nullpo_retr(-1, sd);
  4542. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4543. if (!message || !*message) {
  4544. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4545. return -1;
  4546. }
  4547. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4548. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  4549. return 0;
  4550. }
  4551. /*==========================================
  4552. * @email <actual@email> <new@email> by [Yor]
  4553. *------------------------------------------*/
  4554. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4555. {
  4556. char actual_email[100];
  4557. char new_email[100];
  4558. nullpo_retr(-1, sd);
  4559. memset(actual_email, '\0', sizeof(actual_email));
  4560. memset(new_email, '\0', sizeof(new_email));
  4561. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4562. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4563. return -1;
  4564. }
  4565. if (e_mail_check(actual_email) == 0) {
  4566. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4567. return -1;
  4568. } else if (e_mail_check(new_email) == 0) {
  4569. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4570. return -1;
  4571. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4572. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4573. return -1;
  4574. } else if (strcmpi(actual_email, new_email) == 0) {
  4575. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4576. return -1;
  4577. }
  4578. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4579. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4580. return 0;
  4581. }
  4582. /*==========================================
  4583. *@effect
  4584. *------------------------------------------*/
  4585. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4586. {
  4587. int type = 0, flag = 0;
  4588. nullpo_retr(-1, sd);
  4589. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4590. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4591. return -1;
  4592. }
  4593. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4594. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4595. return 0;
  4596. }
  4597. /*==========================================
  4598. * @killer by MouseJstr
  4599. * enable killing players even when not in pvp
  4600. *------------------------------------------*/
  4601. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4602. {
  4603. nullpo_retr(-1, sd);
  4604. sd->state.killer = !sd->state.killer;
  4605. if(sd->state.killer)
  4606. clif_displaymessage(fd, msg_txt(241));
  4607. else {
  4608. clif_displaymessage(fd, msg_txt(287));
  4609. pc_stop_attack(sd);
  4610. }
  4611. return 0;
  4612. }
  4613. /*==========================================
  4614. * @killable by MouseJstr
  4615. * enable other people killing you
  4616. *------------------------------------------*/
  4617. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4618. {
  4619. nullpo_retr(-1, sd);
  4620. sd->state.killable = !sd->state.killable;
  4621. if(sd->state.killable)
  4622. clif_displaymessage(fd, msg_txt(242));
  4623. else {
  4624. clif_displaymessage(fd, msg_txt(288));
  4625. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4626. }
  4627. return 0;
  4628. }
  4629. /*==========================================
  4630. * @skillon by MouseJstr
  4631. * turn skills on for the map
  4632. *------------------------------------------*/
  4633. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4634. {
  4635. nullpo_retr(-1, sd);
  4636. map[sd->bl.m].flag.noskill = 0;
  4637. clif_displaymessage(fd, msg_txt(244));
  4638. return 0;
  4639. }
  4640. /*==========================================
  4641. * @skilloff by MouseJstr
  4642. * Turn skills off on the map
  4643. *------------------------------------------*/
  4644. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4645. {
  4646. nullpo_retr(-1, sd);
  4647. map[sd->bl.m].flag.noskill = 1;
  4648. clif_displaymessage(fd, msg_txt(243));
  4649. return 0;
  4650. }
  4651. /*==========================================
  4652. * @npcmove by MouseJstr
  4653. * move a npc
  4654. *------------------------------------------*/
  4655. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4656. {
  4657. int x = 0, y = 0, m;
  4658. struct npc_data *nd = 0;
  4659. nullpo_retr(-1, sd);
  4660. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4661. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4662. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4663. return -1;
  4664. }
  4665. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4666. {
  4667. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4668. return -1;
  4669. }
  4670. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4671. {
  4672. clif_displaymessage(fd, "NPC is not on this map.");
  4673. return -1; //Not on a map.
  4674. }
  4675. x = cap_value(x, 0, map[m].xs-1);
  4676. y = cap_value(y, 0, map[m].ys-1);
  4677. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4678. map_moveblock(&nd->bl, x, y, gettick());
  4679. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4680. clif_displaymessage(fd, "NPC moved.");
  4681. return 0;
  4682. }
  4683. /*==========================================
  4684. * @addwarp by MouseJstr
  4685. * Create a new static warp point.
  4686. *------------------------------------------*/
  4687. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4688. {
  4689. char mapname[32];
  4690. int x,y;
  4691. unsigned short m;
  4692. struct npc_data* nd;
  4693. nullpo_retr(-1, sd);
  4694. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4695. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4696. return -1;
  4697. }
  4698. m = mapindex_name2id(mapname);
  4699. if( m == 0 )
  4700. {
  4701. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4702. clif_displaymessage(fd, atcmd_output);
  4703. return -1;
  4704. }
  4705. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4706. if( nd == NULL )
  4707. return -1;
  4708. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4709. clif_displaymessage(fd, atcmd_output);
  4710. return 0;
  4711. }
  4712. /*==========================================
  4713. * @follow by [MouseJstr]
  4714. * Follow a player .. staying no more then 5 spaces away
  4715. *------------------------------------------*/
  4716. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4717. {
  4718. struct map_session_data *pl_sd = NULL;
  4719. nullpo_retr(-1, sd);
  4720. if (!message || !*message) {
  4721. if (sd->followtarget == -1)
  4722. return -1;
  4723. pc_stop_following (sd);
  4724. clif_displaymessage(fd, "Follow mode OFF.");
  4725. return 0;
  4726. }
  4727. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4728. {
  4729. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4730. return -1;
  4731. }
  4732. if (sd->followtarget == pl_sd->bl.id) {
  4733. pc_stop_following (sd);
  4734. clif_displaymessage(fd, "Follow mode OFF.");
  4735. } else {
  4736. pc_follow(sd, pl_sd->bl.id);
  4737. clif_displaymessage(fd, "Follow mode ON.");
  4738. }
  4739. return 0;
  4740. }
  4741. /*==========================================
  4742. * @dropall by [MouseJstr]
  4743. * Drop all your possession on the ground
  4744. *------------------------------------------*/
  4745. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4746. {
  4747. int i;
  4748. nullpo_retr(-1, sd);
  4749. for (i = 0; i < MAX_INVENTORY; i++) {
  4750. if (sd->status.inventory[i].amount) {
  4751. if(sd->status.inventory[i].equip != 0)
  4752. pc_unequipitem(sd, i, 3);
  4753. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4754. }
  4755. }
  4756. return 0;
  4757. }
  4758. /*==========================================
  4759. * @storeall by [MouseJstr]
  4760. * Put everything into storage
  4761. *------------------------------------------*/
  4762. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4763. {
  4764. int i;
  4765. nullpo_retr(-1, sd);
  4766. if (sd->state.storage_flag != 1)
  4767. { //Open storage.
  4768. switch (storage_storageopen(sd)) {
  4769. case 2: //Try again
  4770. clif_displaymessage(fd, "run this command again..");
  4771. return 0;
  4772. case 1: //Failure
  4773. clif_displaymessage(fd, "You can't open the storage currently.");
  4774. return -1;
  4775. }
  4776. }
  4777. for (i = 0; i < MAX_INVENTORY; i++) {
  4778. if (sd->status.inventory[i].amount) {
  4779. if(sd->status.inventory[i].equip != 0)
  4780. pc_unequipitem(sd, i, 3);
  4781. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4782. }
  4783. }
  4784. storage_storageclose(sd);
  4785. clif_displaymessage(fd, "It is done");
  4786. return 0;
  4787. }
  4788. /*==========================================
  4789. * @skillid by [MouseJstr]
  4790. * lookup a skill by name
  4791. *------------------------------------------*/
  4792. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4793. {
  4794. int skillen, idx;
  4795. nullpo_retr(-1, sd);
  4796. if (!message || !*message)
  4797. {
  4798. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4799. return -1;
  4800. }
  4801. skillen = strlen(message);
  4802. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4803. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4804. {
  4805. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4806. clif_displaymessage(fd, atcmd_output);
  4807. }
  4808. }
  4809. return 0;
  4810. }
  4811. /*==========================================
  4812. * @useskill by [MouseJstr]
  4813. * A way of using skills without having to find them in the skills menu
  4814. *------------------------------------------*/
  4815. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4816. {
  4817. struct map_session_data *pl_sd = NULL;
  4818. struct block_list *bl;
  4819. int skillnum;
  4820. int skilllv;
  4821. char target[100];
  4822. nullpo_retr(-1, sd);
  4823. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4824. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4825. return -1;
  4826. }
  4827. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4828. {
  4829. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4830. return -1;
  4831. }
  4832. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  4833. {
  4834. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4835. return -1;
  4836. }
  4837. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4838. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4839. bl = &sd->hd->bl;
  4840. else
  4841. bl = &sd->bl;
  4842. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4843. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4844. else
  4845. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4846. return 0;
  4847. }
  4848. /*==========================================
  4849. * @displayskill by [Skotlex]
  4850. * Debug command to locate new skill IDs. It sends the
  4851. * three possible skill-effect packets to the area.
  4852. *------------------------------------------*/
  4853. int atcommand_displayskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4854. {
  4855. struct status_data * status;
  4856. unsigned int tick;
  4857. int skillnum;
  4858. int skilllv = 1;
  4859. nullpo_retr(-1, sd);
  4860. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4861. {
  4862. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4863. return -1;
  4864. }
  4865. status = status_get_status_data(&sd->bl);
  4866. tick = gettick();
  4867. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4868. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4869. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4870. return 0;
  4871. }
  4872. /*==========================================
  4873. * @skilltree by [MouseJstr]
  4874. * prints the skill tree for a player required to get to a skill
  4875. *------------------------------------------*/
  4876. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4877. {
  4878. struct map_session_data *pl_sd = NULL;
  4879. int skillnum;
  4880. int meets, j, c=0;
  4881. char target[NAME_LENGTH], *tbl;
  4882. struct skill_tree_entry *ent;
  4883. nullpo_retr(-1, sd);
  4884. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4885. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4886. return -1;
  4887. }
  4888. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4889. {
  4890. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4891. return -1;
  4892. }
  4893. c = pc_calc_skilltree_normalize_job(pl_sd);
  4894. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4895. tbl = job_name(c);
  4896. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", tbl, pc_checkskill(pl_sd, 1));
  4897. clif_displaymessage(fd, atcmd_output);
  4898. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  4899. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4900. {
  4901. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4902. clif_displaymessage(fd, atcmd_output);
  4903. return 0;
  4904. }
  4905. ent = &skill_tree[c][j];
  4906. meets = 1;
  4907. for(j=0;j<5;j++)
  4908. {
  4909. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4910. {
  4911. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  4912. clif_displaymessage(fd, atcmd_output);
  4913. meets = 0;
  4914. }
  4915. }
  4916. if (meets == 1) {
  4917. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4918. clif_displaymessage(fd, atcmd_output);
  4919. }
  4920. return 0;
  4921. }
  4922. // Hand a ring with partners name on it to this char
  4923. void getring (struct map_session_data* sd)
  4924. {
  4925. int flag, item_id;
  4926. struct item item_tmp;
  4927. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4928. memset(&item_tmp, 0, sizeof(item_tmp));
  4929. item_tmp.nameid = item_id;
  4930. item_tmp.identify = 1;
  4931. item_tmp.card[0] = 255;
  4932. item_tmp.card[2] = sd->status.partner_id;
  4933. item_tmp.card[3] = sd->status.partner_id >> 16;
  4934. //Logs (A)dmins items [Lupus]
  4935. if(log_config.enable_logs&0x400)
  4936. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  4937. if((flag = pc_additem(sd,&item_tmp,1))) {
  4938. clif_additem(sd,0,0,flag);
  4939. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4940. }
  4941. }
  4942. /*==========================================
  4943. * @marry by [MouseJstr], fixed by Lupus
  4944. * Marry two players
  4945. *------------------------------------------*/
  4946. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4947. {
  4948. struct map_session_data *pl_sd1 = NULL;
  4949. struct map_session_data *pl_sd2 = NULL;
  4950. char player1[128], player2[128]; //Length used for return error msgs
  4951. nullpo_retr(-1, sd);
  4952. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  4953. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  4954. return -1;
  4955. }
  4956. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  4957. sprintf(player2, "Cannot find player '%s' online", player1);
  4958. clif_displaymessage(fd, player2);
  4959. return -1;
  4960. }
  4961. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  4962. sprintf(player1, "Cannot find player '%s' online", player2);
  4963. clif_displaymessage(fd, player1);
  4964. return -1;
  4965. }
  4966. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  4967. clif_displaymessage(fd, "They are married.. wish them well");
  4968. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  4969. // Auto-give named rings (Aru)
  4970. getring (pl_sd1);
  4971. getring (pl_sd2);
  4972. return 0;
  4973. }
  4974. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  4975. return -1;
  4976. }
  4977. /*==========================================
  4978. * @divorce by [MouseJstr], fixed by [Lupus]
  4979. * divorce two players
  4980. *------------------------------------------*/
  4981. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4982. {
  4983. struct map_session_data *pl_sd = NULL;
  4984. nullpo_retr(-1, sd);
  4985. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  4986. clif_displaymessage(fd, "Usage: @divorce <player>.");
  4987. return -1;
  4988. }
  4989. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  4990. {
  4991. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4992. return -1;
  4993. }
  4994. if (pc_divorce(pl_sd) != 0) {
  4995. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  4996. clif_displaymessage(fd, atcmd_output);
  4997. return -1;
  4998. }
  4999. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5000. clif_displaymessage(fd, atcmd_output);
  5001. return 0;
  5002. }
  5003. /*==========================================
  5004. * @changelook by [Celest]
  5005. *------------------------------------------*/
  5006. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5007. {
  5008. int i, j = 0, k = 0;
  5009. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5010. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5011. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5012. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5013. return -1;
  5014. } else if (i == 2) {
  5015. if (j < 1) j = 1;
  5016. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5017. j = pos[j - 1];
  5018. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5019. k = j; // swap
  5020. j = LOOK_HEAD_TOP;
  5021. }
  5022. clif_changelook(&sd->bl,j,k);
  5023. return 0;
  5024. }
  5025. /*==========================================
  5026. * @autotrade by durf (changed by Lupus)
  5027. * Turns on/off Autotrade for a specific player
  5028. *------------------------------------------*/
  5029. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5030. {
  5031. nullpo_retr(-1, sd);
  5032. if( sd->vender_id ) //check if player's vending
  5033. {
  5034. if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
  5035. {
  5036. sd->state.autotrade = 1;
  5037. if( battle_config.at_timeout )
  5038. {
  5039. int timeout = atoi(message);
  5040. 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);
  5041. }
  5042. clif_authfail_fd(fd, 15);
  5043. } else
  5044. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5045. }
  5046. else
  5047. clif_displaymessage(fd, msg_txt(549)); // You should be vending to use @Autotrade.
  5048. return 0;
  5049. }
  5050. /*==========================================
  5051. * @changegm by durf (changed by Lupus)
  5052. * Changes Master of your Guild to a specified guild member
  5053. *------------------------------------------*/
  5054. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5055. {
  5056. struct guild *g;
  5057. struct map_session_data *pl_sd;
  5058. nullpo_retr(-1, sd);
  5059. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5060. {
  5061. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5062. return -1;
  5063. }
  5064. if( map[sd->bl.m].flag.guildlock )
  5065. {
  5066. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5067. return -1;
  5068. }
  5069. if (strlen(message)==0)
  5070. {
  5071. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5072. return -1;
  5073. }
  5074. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5075. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5076. return -1;
  5077. }
  5078. guild_gm_change(sd->status.guild_id, pl_sd);
  5079. return 0;
  5080. }
  5081. /*==========================================
  5082. * @changeleader by Skotlex
  5083. * Changes the leader of a party.
  5084. *------------------------------------------*/
  5085. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5086. {
  5087. struct party_data *p;
  5088. struct map_session_data *pl_sd;
  5089. int mi, pl_mi;
  5090. nullpo_retr(-1, sd);
  5091. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5092. { //Need to be a party leader.
  5093. clif_displaymessage(fd, msg_txt(282));
  5094. return -1;
  5095. }
  5096. if( map[sd->bl.m].flag.partylock )
  5097. {
  5098. clif_displaymessage(fd, "You cannot change party leaders on this map.");
  5099. return -1;
  5100. }
  5101. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5102. if (mi == MAX_PARTY)
  5103. return -1; //Shouldn't happen
  5104. if (!p->party.member[mi].leader)
  5105. { //Need to be a party leader.
  5106. clif_displaymessage(fd, msg_txt(282));
  5107. return -1;
  5108. }
  5109. if (strlen(message)==0)
  5110. {
  5111. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5112. return -1;
  5113. }
  5114. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  5115. clif_displaymessage(fd, msg_txt(283));
  5116. return -1;
  5117. }
  5118. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  5119. if (pl_mi == MAX_PARTY)
  5120. return -1; //Shouldn't happen
  5121. //Change leadership.
  5122. p->party.member[mi].leader = 0;
  5123. if (p->data[mi].sd->fd)
  5124. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  5125. p->party.member[pl_mi].leader = 1;
  5126. if (p->data[pl_mi].sd->fd)
  5127. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  5128. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  5129. //Update info.
  5130. clif_party_info(p,NULL);
  5131. return 0;
  5132. }
  5133. /*==========================================
  5134. * @partyoption by Skotlex
  5135. * Used to change the item share setting of a party.
  5136. *------------------------------------------*/
  5137. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5138. {
  5139. struct party_data *p;
  5140. int mi, option;
  5141. char w1[16], w2[16];
  5142. nullpo_retr(-1, sd);
  5143. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5144. {
  5145. clif_displaymessage(fd, msg_txt(282));
  5146. return -1;
  5147. }
  5148. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5149. if (mi == MAX_PARTY)
  5150. return -1; //Shouldn't happen
  5151. if (!p->party.member[mi].leader)
  5152. {
  5153. clif_displaymessage(fd, msg_txt(282));
  5154. return -1;
  5155. }
  5156. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5157. {
  5158. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5159. return -1;
  5160. }
  5161. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5162. //Change item share type.
  5163. if (option != p->party.item)
  5164. party_changeoption(sd, p->party.exp, option);
  5165. else
  5166. clif_displaymessage(fd, msg_txt(286));
  5167. return 0;
  5168. }
  5169. /*==========================================
  5170. * @autoloot by Upa-Kun
  5171. * Turns on/off AutoLoot for a specific player
  5172. *------------------------------------------*/
  5173. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5174. {
  5175. int rate;
  5176. double drate;
  5177. nullpo_retr(-1, sd);
  5178. // autoloot command without value
  5179. if(!message || !*message)
  5180. {
  5181. if (sd->state.autoloot)
  5182. rate = 0;
  5183. else
  5184. rate = 10000;
  5185. } else {
  5186. drate = atof(message);
  5187. rate = (int)(drate*100);
  5188. }
  5189. if (rate < 0) rate = 0;
  5190. if (rate > 10000) rate = 10000;
  5191. sd->state.autoloot = rate;
  5192. if (sd->state.autoloot) {
  5193. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5194. clif_displaymessage(fd, atcmd_output);
  5195. }else
  5196. clif_displaymessage(fd, "Autoloot is now off.");
  5197. if (sd->state.autoloot && sd->state.autolootid) {
  5198. // Autolootitem should be turned off
  5199. sd->state.autolootid = 0;
  5200. clif_displaymessage(fd, "Autolootitem is now off.");
  5201. }
  5202. return 0;
  5203. }
  5204. /*==========================================
  5205. * @autolootitem
  5206. *------------------------------------------*/
  5207. int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5208. {
  5209. struct item_data *item_data = NULL;
  5210. if (!message || !*message) {
  5211. if (sd->state.autolootid) {
  5212. sd->state.autolootid = 0;
  5213. clif_displaymessage(fd, "Autolootitem have been turned OFF.");
  5214. } else
  5215. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>).");
  5216. return -1;
  5217. }
  5218. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5219. item_data = itemdb_searchname(message);
  5220. if (!item_data) {
  5221. // No items founds in the DB with Id or Name
  5222. clif_displaymessage(fd, "Item not found.");
  5223. return -1;
  5224. }
  5225. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  5226. sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
  5227. item_data->name, item_data->jname, item_data->nameid);
  5228. clif_displaymessage(fd, atcmd_output);
  5229. if (sd->state.autolootid && sd->state.autoloot) {
  5230. // Autoloot should be turned off
  5231. sd->state.autoloot = 0;
  5232. clif_displaymessage(fd, "Autoloot is now off (cannot be actitaved together).");
  5233. }
  5234. return 0;
  5235. }
  5236. /*==========================================
  5237. * It is made to rain.
  5238. *------------------------------------------*/
  5239. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5240. {
  5241. nullpo_retr(-1, sd);
  5242. if (map[sd->bl.m].flag.rain) {
  5243. map[sd->bl.m].flag.rain=0;
  5244. clif_weather(sd->bl.m);
  5245. clif_displaymessage(fd, "The rain has stopped.");
  5246. } else {
  5247. map[sd->bl.m].flag.rain=1;
  5248. clif_weather(sd->bl.m);
  5249. clif_displaymessage(fd, "It is made to rain.");
  5250. }
  5251. return 0;
  5252. }
  5253. /*==========================================
  5254. * It is made to snow.
  5255. *------------------------------------------*/
  5256. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5257. {
  5258. nullpo_retr(-1, sd);
  5259. if (map[sd->bl.m].flag.snow) {
  5260. map[sd->bl.m].flag.snow=0;
  5261. clif_weather(sd->bl.m);
  5262. clif_displaymessage(fd, "Snow has stopped falling.");
  5263. } else {
  5264. map[sd->bl.m].flag.snow=1;
  5265. clif_weather(sd->bl.m);
  5266. clif_displaymessage(fd, "It is made to snow.");
  5267. }
  5268. return 0;
  5269. }
  5270. /*==========================================
  5271. * Cherry tree snowstorm is made to fall. (Sakura)
  5272. *------------------------------------------*/
  5273. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5274. {
  5275. nullpo_retr(-1, sd);
  5276. if (map[sd->bl.m].flag.sakura) {
  5277. map[sd->bl.m].flag.sakura=0;
  5278. clif_weather(sd->bl.m);
  5279. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5280. } else {
  5281. map[sd->bl.m].flag.sakura=1;
  5282. clif_weather(sd->bl.m);
  5283. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5284. }
  5285. return 0;
  5286. }
  5287. /*==========================================
  5288. * Clouds appear.
  5289. *------------------------------------------*/
  5290. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5291. {
  5292. nullpo_retr(-1, sd);
  5293. if (map[sd->bl.m].flag.clouds) {
  5294. map[sd->bl.m].flag.clouds=0;
  5295. clif_weather(sd->bl.m);
  5296. clif_displaymessage(fd, "The clouds has disappear.");
  5297. } else {
  5298. map[sd->bl.m].flag.clouds=1;
  5299. clif_weather(sd->bl.m);
  5300. clif_displaymessage(fd, "Clouds appear.");
  5301. }
  5302. return 0;
  5303. }
  5304. /*==========================================
  5305. * Different type of clouds using effect 516
  5306. *------------------------------------------*/
  5307. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5308. {
  5309. nullpo_retr(-1, sd);
  5310. if (map[sd->bl.m].flag.clouds2) {
  5311. map[sd->bl.m].flag.clouds2=0;
  5312. clif_weather(sd->bl.m);
  5313. clif_displaymessage(fd, "The alternative clouds disappear.");
  5314. } else {
  5315. map[sd->bl.m].flag.clouds2=1;
  5316. clif_weather(sd->bl.m);
  5317. clif_displaymessage(fd, "Alternative clouds appear.");
  5318. }
  5319. return 0;
  5320. }
  5321. /*==========================================
  5322. * Fog hangs over.
  5323. *------------------------------------------*/
  5324. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5325. {
  5326. nullpo_retr(-1, sd);
  5327. if (map[sd->bl.m].flag.fog) {
  5328. map[sd->bl.m].flag.fog=0;
  5329. clif_weather(sd->bl.m);
  5330. clif_displaymessage(fd, "The fog has gone.");
  5331. } else {
  5332. map[sd->bl.m].flag.fog=1;
  5333. clif_weather(sd->bl.m);
  5334. clif_displaymessage(fd, "Fog hangs over.");
  5335. }
  5336. return 0;
  5337. }
  5338. /*==========================================
  5339. * Fallen leaves fall.
  5340. *------------------------------------------*/
  5341. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5342. {
  5343. nullpo_retr(-1, sd);
  5344. if (map[sd->bl.m].flag.leaves) {
  5345. map[sd->bl.m].flag.leaves=0;
  5346. clif_weather(sd->bl.m);
  5347. clif_displaymessage(fd, "Leaves no longer fall.");
  5348. } else {
  5349. map[sd->bl.m].flag.leaves=1;
  5350. clif_weather(sd->bl.m);
  5351. clif_displaymessage(fd, "Fallen leaves fall.");
  5352. }
  5353. return 0;
  5354. }
  5355. /*==========================================
  5356. * Fireworks appear.
  5357. *------------------------------------------*/
  5358. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5359. {
  5360. nullpo_retr(-1, sd);
  5361. if (map[sd->bl.m].flag.fireworks) {
  5362. map[sd->bl.m].flag.fireworks=0;
  5363. clif_weather(sd->bl.m);
  5364. clif_displaymessage(fd, "Fireworks are ended.");
  5365. } else {
  5366. map[sd->bl.m].flag.fireworks=1;
  5367. clif_weather(sd->bl.m);
  5368. clif_displaymessage(fd, "Fireworks are launched.");
  5369. }
  5370. return 0;
  5371. }
  5372. /*==========================================
  5373. * Clearing Weather Effects by Dexity
  5374. *------------------------------------------*/
  5375. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5376. {
  5377. nullpo_retr(-1, sd);
  5378. map[sd->bl.m].flag.rain=0;
  5379. map[sd->bl.m].flag.snow=0;
  5380. map[sd->bl.m].flag.sakura=0;
  5381. map[sd->bl.m].flag.clouds=0;
  5382. map[sd->bl.m].flag.clouds2=0;
  5383. map[sd->bl.m].flag.fog=0;
  5384. map[sd->bl.m].flag.fireworks=0;
  5385. map[sd->bl.m].flag.leaves=0;
  5386. clif_weather(sd->bl.m);
  5387. clif_displaymessage(fd, msg_txt(291));
  5388. return 0;
  5389. }
  5390. /*===============================================================
  5391. * Sound Command - plays a sound for everyone around! [Codemaster]
  5392. *---------------------------------------------------------------*/
  5393. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  5394. {
  5395. char sound_file[100];
  5396. memset(sound_file, '\0', sizeof(sound_file));
  5397. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5398. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5399. return -1;
  5400. }
  5401. if(strstr(sound_file, ".wav") == NULL)
  5402. strcat(sound_file, ".wav");
  5403. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5404. return 0;
  5405. }
  5406. /*==========================================
  5407. * MOB Search
  5408. *------------------------------------------*/
  5409. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  5410. {
  5411. int mob_id,fd;
  5412. static int number=0;
  5413. struct mob_data *md;
  5414. nullpo_retr(0, bl);
  5415. if(!ap){
  5416. number=0;
  5417. return 0;
  5418. }
  5419. mob_id = va_arg(ap,int);
  5420. fd = va_arg(ap,int);
  5421. md = (struct mob_data *)bl;
  5422. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  5423. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  5424. ++number,bl->x, bl->y,md->name);
  5425. clif_displaymessage(fd, atcmd_output);
  5426. }
  5427. return 0;
  5428. }
  5429. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5430. {
  5431. char mob_name[100];
  5432. int mob_id,map_id = 0;
  5433. nullpo_retr(-1, sd);
  5434. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5435. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5436. return -1;
  5437. }
  5438. if ((mob_id = atoi(mob_name)) == 0)
  5439. mob_id = mobdb_searchname(mob_name);
  5440. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5441. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5442. clif_displaymessage(fd, atcmd_output);
  5443. return -1;
  5444. }
  5445. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5446. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5447. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5448. map_id = sd->bl.m;
  5449. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5450. clif_displaymessage(fd, atcmd_output);
  5451. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  5452. atmobsearch_sub(&sd->bl,0); // reset the counter
  5453. return 0;
  5454. }
  5455. /*==========================================
  5456. * @cleanmap - cleans items on the ground
  5457. *------------------------------------------*/
  5458. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5459. {
  5460. nullpo_retr(0, bl);
  5461. map_clearflooritem(bl->id);
  5462. return 0;
  5463. }
  5464. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5465. {
  5466. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5467. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5468. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5469. BL_ITEM);
  5470. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5471. return 0;
  5472. }
  5473. /*==========================================
  5474. * make a NPC/PET talk
  5475. *------------------------------------------*/
  5476. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5477. {
  5478. char name[NAME_LENGTH],mes[100],temp[100];
  5479. struct npc_data *nd;
  5480. if (sd->sc.count && //no "chatting" while muted.
  5481. (sd->sc.data[SC_BERSERK] ||
  5482. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5483. return -1;
  5484. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5485. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5486. return -1;
  5487. }
  5488. if (!(nd = npc_name2id(name))) {
  5489. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5490. return -1;
  5491. }
  5492. strtok(name, "#"); // discard extra name identifier if present
  5493. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5494. clif_message(&nd->bl, temp);
  5495. return 0;
  5496. }
  5497. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5498. {
  5499. char mes[100],temp[100];
  5500. struct pet_data *pd;
  5501. nullpo_retr(-1, sd);
  5502. if(!sd->status.pet_id || !(pd=sd->pd))
  5503. {
  5504. clif_displaymessage(fd, msg_txt(184));
  5505. return -1;
  5506. }
  5507. if (sd->sc.count && //no "chatting" while muted.
  5508. (sd->sc.data[SC_BERSERK] ||
  5509. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5510. return -1;
  5511. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5512. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5513. return -1;
  5514. }
  5515. if (message[0] == '/')
  5516. {// pet emotion processing
  5517. const char* emo[] = {
  5518. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5519. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5520. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5521. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5522. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5523. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5524. };
  5525. int i;
  5526. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5527. if( i < ARRAYLENGTH(emo) )
  5528. {
  5529. clif_emotion(&pd->bl, i);
  5530. return 0;
  5531. }
  5532. }
  5533. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5534. clif_message(&pd->bl, temp);
  5535. return 0;
  5536. }
  5537. /*==========================================
  5538. * @users - displays the number of players present on each map (percentage)
  5539. *------------------------------------------*/
  5540. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5541. {
  5542. char buf[256];
  5543. DBMap* users_db; // unsigned int mapindex -> int users
  5544. int users_all;
  5545. users_db = uidb_alloc(DB_OPT_BASE);
  5546. users_all = 0;
  5547. // count users on each map
  5548. {
  5549. struct s_mapiterator* iter;
  5550. struct map_session_data* sd;
  5551. iter = mapit_getallusers();
  5552. for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) )
  5553. {
  5554. int users = (int)uidb_get(users_db,sd->mapindex) + 1;
  5555. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  5556. users_all++;
  5557. }
  5558. mapit_free(iter);
  5559. }
  5560. // display results for each map
  5561. {
  5562. DBIterator* iter;
  5563. DBKey index;
  5564. int users;
  5565. iter = users_db->iterator(users_db);
  5566. for( users = (int)iter->first(iter,&index); iter->exists(iter); users = (int)iter->next(iter,&index) )
  5567. {
  5568. sprintf(buf,"%s: %d (%d%%)",mapindex_id2name(index.i),users,users * 100 / users_all);
  5569. clif_displaymessage(sd->fd,buf);
  5570. }
  5571. iter->destroy(iter);
  5572. }
  5573. // display overall count
  5574. sprintf(buf,"all: %d",users_all);
  5575. clif_displaymessage(fd,buf);
  5576. users_db->destroy(users_db,NULL);
  5577. return 0;
  5578. }
  5579. /*==========================================
  5580. *
  5581. *------------------------------------------*/
  5582. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5583. {
  5584. pc_resetstate(sd);
  5585. pc_resetskill(sd,1);
  5586. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5587. clif_displaymessage(fd, atcmd_output);
  5588. return 0;
  5589. }
  5590. /*==========================================
  5591. *
  5592. *------------------------------------------*/
  5593. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5594. {
  5595. char name[NAME_LENGTH];
  5596. int mob_id = 0;
  5597. int duration = 0;
  5598. struct mob_data *md;
  5599. unsigned int tick=gettick();
  5600. nullpo_retr(-1, sd);
  5601. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5602. {
  5603. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5604. return -1;
  5605. }
  5606. if (duration < 1)
  5607. duration =1;
  5608. else if (duration > 60)
  5609. duration =60;
  5610. if ((mob_id = atoi(name)) == 0)
  5611. mob_id = mobdb_searchname(name);
  5612. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5613. {
  5614. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5615. return -1;
  5616. }
  5617. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5618. if(!md)
  5619. return -1;
  5620. md->master_id=sd->bl.id;
  5621. md->special_state.ai=1;
  5622. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5623. clif_misceffect2(&md->bl,344);
  5624. mob_spawn(md);
  5625. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5626. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5627. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5628. return 0;
  5629. }
  5630. /*==========================================
  5631. * @adjcmdlvl by [MouseJstr]
  5632. *
  5633. * Temp adjust the GM level required to use a GM command
  5634. * Useful during beta testing to allow players to use GM commands for short periods of time
  5635. *------------------------------------------*/
  5636. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5637. {
  5638. int newlev;
  5639. char name[100];
  5640. AtCommandInfo* cmd;
  5641. nullpo_retr(-1, sd);
  5642. if (!message || !*message || sscanf(message, "%d %99s", &newlev, name) != 2)
  5643. {
  5644. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  5645. return -1;
  5646. }
  5647. cmd = get_atcommandinfo_byname(name);
  5648. if (cmd == NULL)
  5649. {
  5650. clif_displaymessage(fd, "@command not found.");
  5651. return -1;
  5652. }
  5653. else if (newlev > pc_isGM(sd))
  5654. {
  5655. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5656. return -1;
  5657. }
  5658. else if (cmd->level > pc_isGM(sd))
  5659. {
  5660. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5661. return -1;
  5662. }
  5663. else
  5664. {
  5665. cmd->level = newlev;
  5666. clif_displaymessage(fd, "@command level changed.");
  5667. return 0;
  5668. }
  5669. }
  5670. /*==========================================
  5671. * @adjgmlvl by [MouseJstr]
  5672. * Create a temp GM
  5673. * Useful during beta testing to allow players to use GM commands for short periods of time
  5674. *------------------------------------------*/
  5675. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5676. {
  5677. int newlev;
  5678. char user[NAME_LENGTH];
  5679. struct map_session_data *pl_sd;
  5680. nullpo_retr(-1, sd);
  5681. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5682. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5683. return -1;
  5684. }
  5685. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5686. {
  5687. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5688. return -1;
  5689. }
  5690. pc_set_gm_level(pl_sd->status.account_id, newlev);
  5691. return 0;
  5692. }
  5693. /*==========================================
  5694. * @trade by [MouseJstr]
  5695. * Open a trade window with a remote player
  5696. *------------------------------------------*/
  5697. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5698. {
  5699. struct map_session_data *pl_sd = NULL;
  5700. nullpo_retr(-1, sd);
  5701. if (!message || !*message) {
  5702. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5703. return -1;
  5704. }
  5705. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5706. {
  5707. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5708. return -1;
  5709. }
  5710. trade_traderequest(sd, pl_sd);
  5711. return 0;
  5712. }
  5713. /*==========================================
  5714. * @setbattleflag by [MouseJstr]
  5715. * set a battle_config flag without having to reboot
  5716. *------------------------------------------*/
  5717. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5718. {
  5719. char flag[128], value[128];
  5720. nullpo_retr(-1, sd);
  5721. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5722. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5723. return -1;
  5724. }
  5725. if (battle_set_value(flag, value) == 0)
  5726. {
  5727. clif_displaymessage(fd, "unknown battle_config flag");
  5728. return -1;
  5729. }
  5730. clif_displaymessage(fd, "battle_config set as requested");
  5731. return 0;
  5732. }
  5733. /*==========================================
  5734. * @unmute [Valaris]
  5735. *------------------------------------------*/
  5736. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5737. {
  5738. struct map_session_data *pl_sd = NULL;
  5739. nullpo_retr(-1, sd);
  5740. if (!message || !*message) {
  5741. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5742. return -1;
  5743. }
  5744. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5745. {
  5746. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5747. return -1;
  5748. }
  5749. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5750. clif_displaymessage(sd->fd,"Player is not muted");
  5751. return -1;
  5752. }
  5753. pl_sd->status.manner = 0;
  5754. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5755. clif_displaymessage(sd->fd,"Player unmuted");
  5756. return 0;
  5757. }
  5758. /*==========================================
  5759. * @uptime by MC Cameri
  5760. *------------------------------------------*/
  5761. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5762. {
  5763. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5764. minute = 60, days = 0, hours = 0, minutes = 0;
  5765. nullpo_retr(-1, sd);
  5766. seconds = get_uptime();
  5767. days = seconds/day;
  5768. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5769. hours = seconds/hour;
  5770. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5771. minutes = seconds/minute;
  5772. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5773. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5774. clif_displaymessage(fd, atcmd_output);
  5775. return 0;
  5776. }
  5777. /*==========================================
  5778. * @changesex <sex>
  5779. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5780. *------------------------------------------*/
  5781. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5782. {
  5783. nullpo_retr(-1, sd);
  5784. chrif_changesex(sd);
  5785. return 0;
  5786. }
  5787. /*================================================
  5788. * @mute - Mutes a player for a set amount of time
  5789. *------------------------------------------------*/
  5790. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5791. {
  5792. struct map_session_data *pl_sd = NULL;
  5793. int manner;
  5794. nullpo_retr(-1, sd);
  5795. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5796. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5797. return -1;
  5798. }
  5799. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5800. {
  5801. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5802. return -1;
  5803. }
  5804. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5805. {
  5806. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5807. return -1;
  5808. }
  5809. clif_manner_message(sd, 0);
  5810. clif_manner_message(pl_sd, 5);
  5811. if( pl_sd->status.manner < manner ) {
  5812. pl_sd->status.manner -= manner;
  5813. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5814. } else {
  5815. pl_sd->status.manner = 0;
  5816. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5817. }
  5818. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5819. return 0;
  5820. }
  5821. /*==========================================
  5822. * @refresh (like @jumpto <<yourself>>)
  5823. *------------------------------------------*/
  5824. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5825. {
  5826. nullpo_retr(-1, sd);
  5827. clif_refresh(sd);
  5828. return 0;
  5829. }
  5830. /*==========================================
  5831. * @identify
  5832. * => GM's magnifier.
  5833. *------------------------------------------*/
  5834. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5835. {
  5836. int i,num;
  5837. nullpo_retr(-1, sd);
  5838. for(i=num=0;i<MAX_INVENTORY;i++){
  5839. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5840. num++;
  5841. }
  5842. }
  5843. if (num > 0) {
  5844. clif_item_identify_list(sd);
  5845. } else {
  5846. clif_displaymessage(fd,"There are no items to appraise.");
  5847. }
  5848. return 0;
  5849. }
  5850. /*==========================================
  5851. * @gmotd (Global MOTD)
  5852. * by davidsiaw :P
  5853. *------------------------------------------*/
  5854. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5855. {
  5856. char buf[256];
  5857. FILE *fp;
  5858. nullpo_retr(-1, sd);
  5859. if((fp = fopen(motd_txt, "r"))!=NULL){
  5860. while(fgets(buf, sizeof(buf), fp) != NULL)
  5861. {
  5862. int i;
  5863. if (buf[0] == '/' && buf[1] == '/')
  5864. continue;
  5865. for(i=0; buf[i]; i++){
  5866. if(buf[i]=='\r' || buf[i]=='\n'){
  5867. buf[i]=0;
  5868. break;
  5869. }
  5870. }
  5871. intif_GMmessage(buf,strlen(buf)+1,8);
  5872. }
  5873. fclose(fp);
  5874. }
  5875. return 0;
  5876. }
  5877. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5878. {
  5879. int effect = 0;
  5880. nullpo_retr(-1, sd);
  5881. if (!message || !*message)
  5882. return -1;
  5883. if (sscanf(message, "%d", &effect) < 1)
  5884. return -1;
  5885. clif_misceffect(&sd->bl,effect);
  5886. return 0;
  5887. }
  5888. /*==========================================
  5889. * MAIL SYSTEM
  5890. *------------------------------------------*/
  5891. int atcommand_mail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5892. {
  5893. nullpo_retr(0,sd);
  5894. #ifndef TXT_ONLY
  5895. mail_openmail(sd);
  5896. #endif
  5897. return 0;
  5898. }
  5899. /*==========================================
  5900. * Show Monster DB Info v 1.0
  5901. * originally by [Lupus] eAthena
  5902. *------------------------------------------*/
  5903. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5904. {
  5905. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5906. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5907. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5908. char atcmd_output2[200];
  5909. struct item_data *item_data;
  5910. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5911. int count;
  5912. int i, j, k;
  5913. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5914. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5915. if (!message || !*message) {
  5916. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5917. return -1;
  5918. }
  5919. // If monster identifier/name argument is a name
  5920. if ((i = mobdb_checkid(atoi(message))))
  5921. {
  5922. mob_array[0] = mob_db(i);
  5923. count = 1;
  5924. } else
  5925. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5926. if (!count) {
  5927. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5928. return -1;
  5929. }
  5930. if (count > MAX_SEARCH) {
  5931. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5932. clif_displaymessage(fd, atcmd_output);
  5933. count = MAX_SEARCH;
  5934. }
  5935. for (k = 0; k < count; k++) {
  5936. mob = mob_array[k];
  5937. // stats
  5938. if (mob->mexp)
  5939. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5940. else
  5941. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5942. clif_displaymessage(fd, atcmd_output);
  5943. 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);
  5944. clif_displaymessage(fd, atcmd_output);
  5945. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5946. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5947. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5948. clif_displaymessage(fd, atcmd_output);
  5949. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5950. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5951. mob->range2 , mob->range3, msize[mob->status.size],
  5952. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5953. clif_displaymessage(fd, atcmd_output);
  5954. // drops
  5955. clif_displaymessage(fd, " Drops:");
  5956. strcpy(atcmd_output, " ");
  5957. j = 0;
  5958. for (i = 0; i < MAX_MOB_DROP; i++) {
  5959. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  5960. continue;
  5961. if (item_data->slot)
  5962. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5963. else
  5964. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5965. strcat(atcmd_output, atcmd_output2);
  5966. if (++j % 3 == 0) {
  5967. clif_displaymessage(fd, atcmd_output);
  5968. strcpy(atcmd_output, " ");
  5969. }
  5970. }
  5971. if (j == 0)
  5972. clif_displaymessage(fd, "This monster has no drops.");
  5973. else if (j % 3 != 0)
  5974. clif_displaymessage(fd, atcmd_output);
  5975. // mvp
  5976. if (mob->mexp) {
  5977. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  5978. clif_displaymessage(fd, atcmd_output);
  5979. strcpy(atcmd_output, " MVP Items:");
  5980. j = 0;
  5981. for (i = 0; i < 3; i++) {
  5982. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  5983. continue;
  5984. if (mob->mvpitem[i].p > 0) {
  5985. j++;
  5986. if (j == 1)
  5987. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5988. else
  5989. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5990. strcat(atcmd_output, atcmd_output2);
  5991. }
  5992. }
  5993. if (j == 0)
  5994. clif_displaymessage(fd, "This monster has no MVP prizes.");
  5995. else
  5996. clif_displaymessage(fd, atcmd_output);
  5997. }
  5998. }
  5999. return 0;
  6000. }
  6001. /*=========================================
  6002. * @showmobs by KarLaeda
  6003. * => For 5 sec displays the mobs on minimap
  6004. *------------------------------------------*/
  6005. int atshowmobs_timer(int tid, unsigned int tick, int id, intptr data)
  6006. {
  6007. struct map_session_data* sd = map_id2sd(id);
  6008. if( sd == NULL )
  6009. return 0;
  6010. // remove indicator
  6011. clif_viewpoint(sd, 1, 2, 0, 0, (int)data, 0xFFFFFF);
  6012. return 1;
  6013. }
  6014. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  6015. {
  6016. int mob_id;
  6017. struct map_session_data* sd;
  6018. static int number=0;
  6019. struct mob_data *md;
  6020. if(!ap){
  6021. number=0;
  6022. return 0;
  6023. }
  6024. mob_id = va_arg(ap,int);
  6025. sd = va_arg(ap,struct map_session_data*);
  6026. md = (struct mob_data *)bl;
  6027. if(md->special_state.ai || md->master_id)
  6028. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  6029. if(mob_id==-1 || md->class_==mob_id){
  6030. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  6031. add_timer(gettick()+5000, atshowmobs_timer, sd->bl.id, number);
  6032. }
  6033. return 0;
  6034. }
  6035. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6036. {
  6037. char mob_name[100];
  6038. int mob_id,map_id = 0;
  6039. nullpo_retr(-1, sd);
  6040. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6041. return -1;
  6042. if((mob_id = atoi(mob_name)) == 0)
  6043. mob_id = mobdb_searchname(mob_name);
  6044. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6045. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6046. clif_displaymessage(fd, atcmd_output);
  6047. return 0;
  6048. }
  6049. // Uncomment the following line to show mini-bosses & MVP.
  6050. //#define SHOW_MVP
  6051. #ifndef SHOW_MVP
  6052. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6053. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6054. clif_displaymessage(fd, atcmd_output);
  6055. return 0;
  6056. }
  6057. #endif
  6058. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6059. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6060. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6061. map_id = sd->bl.m;
  6062. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6063. mob_name, mapindex_id2name(sd->mapindex));
  6064. clif_displaymessage(fd, atcmd_output);
  6065. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, sd);
  6066. atshowmobs_sub(&sd->bl,0);
  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. * Barricade Build
  6668. *------------------------------------------*/
  6669. int atcommand_barricade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6670. {
  6671. int x = 0, y = 0, size = 1, killable = 0, shootable = 0, dir = 0;
  6672. char event[50];
  6673. short result;
  6674. if( !message || !*message || (sscanf(message, "%d %d %d %d %d %d %50s", &x, &y, &size, &dir, &killable, &shootable, event) < 7) )
  6675. {
  6676. clif_displaymessage(fd, "usage @barricade <x> <y> <size> <dir> <killable> <shootable> <event>");
  6677. return -1;
  6678. }
  6679. if( x == -1 ) x = sd->bl.x;
  6680. if( y == -1 ) y = sd->bl.y;
  6681. result = mob_barricade_build(sd->bl.m, x, y, "--ja--", size, dir, (bool)killable, false, (bool)shootable, false, event);
  6682. switch( result )
  6683. {
  6684. case 0: clif_displaymessage(fd, "Barricade build."); return 0; break;
  6685. case 1: clif_displaymessage(fd, "Barricade fail. Invalid Size"); break;
  6686. case 2: clif_displaymessage(fd, "Barricade fail. Invalid Event"); break;
  6687. case 3: clif_displaymessage(fd, "Barricade fail. Event already exists"); break;
  6688. case 4: clif_displaymessage(fd, "Barricade fail. Wall problem."); break;
  6689. }
  6690. return -1;
  6691. }
  6692. int atcommand_barricade_destroy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6693. {
  6694. mob_barricade_destroy(sd->bl.m, message);
  6695. return 0;
  6696. }
  6697. /*==========================================
  6698. * Duel organizing functions [LuzZza]
  6699. *
  6700. * @duel [limit|nick] - create a duel
  6701. * @invite <nick> - invite player
  6702. * @accept - accept invitation
  6703. * @reject - reject invitation
  6704. * @leave - leave duel
  6705. *------------------------------------------*/
  6706. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6707. {
  6708. unsigned int did = sd->duel_group;
  6709. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6710. if(did <= 0) {
  6711. // "Duel: @invite without @duel."
  6712. clif_displaymessage(fd, msg_txt(350));
  6713. return 0;
  6714. }
  6715. if(duel_list[did].max_players_limit > 0 &&
  6716. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6717. // "Duel: Limit of players is reached."
  6718. clif_displaymessage(fd, msg_txt(351));
  6719. return 0;
  6720. }
  6721. if(target_sd == NULL) {
  6722. // "Duel: Player not found."
  6723. clif_displaymessage(fd, msg_txt(352));
  6724. return 0;
  6725. }
  6726. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6727. // "Duel: Player already in duel."
  6728. clif_displaymessage(fd, msg_txt(353));
  6729. return 0;
  6730. }
  6731. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6732. {
  6733. sprintf(atcmd_output, msg_txt(364), message);
  6734. clif_displaymessage(fd, atcmd_output);
  6735. return 0;
  6736. }
  6737. duel_invite(did, sd, target_sd);
  6738. // "Duel: Invitation has been sent."
  6739. clif_displaymessage(fd, msg_txt(354));
  6740. return 0;
  6741. }
  6742. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6743. {
  6744. char output[256];
  6745. unsigned int maxpl=0, newduel;
  6746. struct map_session_data *target_sd;
  6747. if(sd->duel_group > 0) {
  6748. duel_showinfo(sd->duel_group, sd);
  6749. return 0;
  6750. }
  6751. if(sd->duel_invite > 0) {
  6752. // "Duel: @duel without @reject."
  6753. clif_displaymessage(fd, msg_txt(355));
  6754. return 0;
  6755. }
  6756. if(!duel_checktime(sd)) {
  6757. // "Duel: You can take part in duel only one time per %d minutes."
  6758. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6759. clif_displaymessage(fd, output);
  6760. return 0;
  6761. }
  6762. if(strlen(message) > 0) {
  6763. if(sscanf(message, "%d", &maxpl) >= 1) {
  6764. if(maxpl < 2 || maxpl > 65535) {
  6765. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6766. return 0;
  6767. }
  6768. duel_create(sd, maxpl);
  6769. } else {
  6770. target_sd = map_nick2sd((char *)message);
  6771. if(target_sd != NULL) {
  6772. if((newduel = duel_create(sd, 2)) != -1) {
  6773. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6774. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6775. return 0;
  6776. }
  6777. duel_invite(newduel, sd, target_sd);
  6778. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6779. }
  6780. } else {
  6781. // "Duel: Player not found."
  6782. clif_displaymessage(fd, msg_txt(352));
  6783. return 0;
  6784. }
  6785. }
  6786. } else
  6787. duel_create(sd, 0);
  6788. return 0;
  6789. }
  6790. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6791. {
  6792. if(sd->duel_group <= 0) {
  6793. // "Duel: @leave without @duel."
  6794. clif_displaymessage(fd, msg_txt(358));
  6795. return 0;
  6796. }
  6797. duel_leave(sd->duel_group, sd);
  6798. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6799. return 0;
  6800. }
  6801. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6802. {
  6803. char output[256];
  6804. if(!duel_checktime(sd)) {
  6805. // "Duel: You can take part in duel only one time per %d minutes."
  6806. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6807. clif_displaymessage(fd, output);
  6808. return 0;
  6809. }
  6810. if(sd->duel_invite <= 0) {
  6811. // "Duel: @accept without invititation."
  6812. clif_displaymessage(fd, msg_txt(360));
  6813. return 0;
  6814. }
  6815. duel_accept(sd->duel_invite, sd);
  6816. // "Duel: Invitation has been accepted."
  6817. clif_displaymessage(fd, msg_txt(361));
  6818. return 0;
  6819. }
  6820. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6821. {
  6822. if(sd->duel_invite <= 0) {
  6823. // "Duel: @reject without invititation."
  6824. clif_displaymessage(fd, msg_txt(362));
  6825. return 0;
  6826. }
  6827. duel_reject(sd->duel_invite, sd);
  6828. // "Duel: Invitation has been rejected."
  6829. clif_displaymessage(fd, msg_txt(363));
  6830. return 0;
  6831. }
  6832. /*===================================
  6833. * Cash Points
  6834. *-----------------------------------*/
  6835. int atcommand_cash(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6836. {
  6837. int value;
  6838. nullpo_retr(-1, sd);
  6839. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6840. clif_displaymessage(fd, "Please, enter an amount.");
  6841. return -1;
  6842. }
  6843. if( !strcmpi(command+1,"cash") )
  6844. {
  6845. if( value > 0 )
  6846. pc_getcash(sd, value, 0);
  6847. else
  6848. pc_paycash(sd, value, 0);
  6849. }
  6850. else
  6851. { // @points
  6852. if( value > 0 )
  6853. pc_getcash(sd, 0, value);
  6854. else
  6855. pc_paycash(sd, value, value);
  6856. }
  6857. return 0;
  6858. }
  6859. /*===================================
  6860. * Away message (@away, @aw) [LuzZza]
  6861. *-----------------------------------*/
  6862. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6863. {
  6864. if(strlen(message) > 0) {
  6865. if(strlen(message) > 128)
  6866. return -1;
  6867. strcpy(sd->away_message, message);
  6868. //"Away automessage has been activated."
  6869. clif_displaymessage(fd, msg_txt(546));
  6870. } else {
  6871. if(strlen(sd->away_message) > 0) {
  6872. sd->away_message[0] = 0;
  6873. //"Away automessage has been disabled."
  6874. clif_displaymessage(fd, msg_txt(547));
  6875. return 0;
  6876. }
  6877. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  6878. clif_displaymessage(fd, msg_txt(548));
  6879. }
  6880. return 0;
  6881. }
  6882. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6883. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6884. {
  6885. int x=0,y=0,flag=0,master=0,i=0;
  6886. struct map_session_data *pl_sd=NULL;
  6887. if (!message || !*message) {
  6888. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6889. return 0;
  6890. }
  6891. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6892. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6893. return 0;
  6894. }
  6895. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  6896. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6897. return 0;
  6898. }
  6899. if (strcmpi(command+1, "clone") == 0)
  6900. flag = 1;
  6901. else if (strcmpi(command+1, "slaveclone") == 0) {
  6902. flag = 2;
  6903. master = sd->bl.id;
  6904. if (battle_config.atc_slave_clone_limit
  6905. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6906. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6907. return 0;
  6908. }
  6909. }
  6910. do {
  6911. x = sd->bl.x + (rand() % 10 - 5);
  6912. y = sd->bl.y + (rand() % 10 - 5);
  6913. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6914. if (i >= 10) {
  6915. x = sd->bl.x;
  6916. y = sd->bl.y;
  6917. }
  6918. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6919. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6920. return 0;
  6921. }
  6922. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6923. return 0;
  6924. }
  6925. /*===================================
  6926. * Main chat [LuzZza]
  6927. * Usage: @main <on|off|message>
  6928. *-----------------------------------*/
  6929. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6930. {
  6931. if(strlen(message) > 0) {
  6932. if(strcmpi(message, "on") == 0) {
  6933. if(!sd->state.mainchat) {
  6934. sd->state.mainchat = 1;
  6935. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6936. } else {
  6937. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6938. }
  6939. } else if(strcmpi(message, "off") == 0) {
  6940. if(sd->state.mainchat) {
  6941. sd->state.mainchat = 0;
  6942. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6943. } else {
  6944. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6945. }
  6946. } else {
  6947. if(!sd->state.mainchat) {
  6948. sd->state.mainchat = 1;
  6949. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6950. }
  6951. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6952. clif_displaymessage(fd, msg_txt(387));
  6953. return -1;
  6954. }
  6955. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  6956. // I use 0xFE000000 color for signalizing that this message is
  6957. // main chat message. 0xFE000000 is invalid color, same using
  6958. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  6959. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  6960. // Chat logging type 'M' / Main Chat
  6961. if( log_config.chat&1 || (log_config.chat&32 && !(agit_flag && log_config.chat&64)) )
  6962. log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  6963. }
  6964. } else {
  6965. if(sd->state.mainchat)
  6966. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6967. else
  6968. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6969. }
  6970. return 0;
  6971. }
  6972. /*=====================================
  6973. * Autorejecting Invites/Deals [LuzZza]
  6974. * Usage: @noask
  6975. *-------------------------------------*/
  6976. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6977. {
  6978. if(sd->state.noask) {
  6979. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6980. sd->state.noask = 0;
  6981. } else {
  6982. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6983. sd->state.noask = 1;
  6984. }
  6985. return 0;
  6986. }
  6987. /*=====================================
  6988. * Send a @request message to all GMs of lowest_gm_level.
  6989. * Usage: @request <petition>
  6990. *-------------------------------------*/
  6991. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6992. {
  6993. if (!message || !*message) {
  6994. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6995. return -1;
  6996. }
  6997. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6998. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  6999. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7000. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  7001. return 0;
  7002. }
  7003. /*==========================================
  7004. * Feel (SG save map) Reset [HiddenDragon]
  7005. *------------------------------------------*/
  7006. int atcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7007. {
  7008. pc_resetfeel(sd);
  7009. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  7010. return 0;
  7011. }
  7012. /*==========================================
  7013. * AUCTION SYSTEM
  7014. *------------------------------------------*/
  7015. int atcommand_auction(const int fd, struct map_session_data *sd, const char *command, const char *message)
  7016. {
  7017. nullpo_retr(0,sd);
  7018. #ifndef TXT_ONLY
  7019. clif_Auction_openwindow(sd);
  7020. #endif
  7021. return 0;
  7022. }
  7023. /*==========================================
  7024. * Kill Steal Protection
  7025. *------------------------------------------*/
  7026. int atcommand_ksprotection(const int fd, struct map_session_data *sd, const char *command, const char *message)
  7027. {
  7028. nullpo_retr(-1,sd);
  7029. if( sd->state.noks ) {
  7030. sd->state.noks = 0;
  7031. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  7032. }
  7033. else
  7034. {
  7035. if( !message || !*message || !strcmpi(message, "party") )
  7036. { // Default is Party
  7037. sd->state.noks = 2;
  7038. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7039. }
  7040. else if( !strcmpi(message, "self") )
  7041. {
  7042. sd->state.noks = 1;
  7043. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7044. }
  7045. else if( !strcmpi(message, "guild") )
  7046. {
  7047. sd->state.noks = 3;
  7048. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7049. }
  7050. }
  7051. clif_displaymessage(fd, atcmd_output);
  7052. return 0;
  7053. }
  7054. /*==========================================
  7055. * Map Kill Steal Protection Setting
  7056. *------------------------------------------*/
  7057. int atcommand_allowks(const int fd, struct map_session_data *sd, const char *command, const char *message)
  7058. {
  7059. nullpo_retr(-1,sd);
  7060. if( map[sd->bl.m].flag.allowks ) {
  7061. map[sd->bl.m].flag.allowks = 0;
  7062. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7063. } else {
  7064. map[sd->bl.m].flag.allowks = 1;
  7065. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7066. }
  7067. clif_displaymessage(fd, atcmd_output);
  7068. return 0;
  7069. }
  7070. /*==========================================
  7071. * atcommand_info[] structure definition
  7072. *------------------------------------------*/
  7073. AtCommandInfo atcommand_info[] = {
  7074. { "rura", 40, atcommand_mapmove },
  7075. { "warp", 40, atcommand_mapmove },
  7076. { "mapmove", 40, atcommand_mapmove }, // + /mm
  7077. { "where", 1, atcommand_where },
  7078. { "jumpto", 20, atcommand_jumpto }, // + /shift
  7079. { "warpto", 20, atcommand_jumpto },
  7080. { "goto", 20, atcommand_jumpto },
  7081. { "jump", 40, atcommand_jump },
  7082. { "who", 20, atcommand_who },
  7083. { "whois", 20, atcommand_who },
  7084. { "who2", 20, atcommand_who2 },
  7085. { "who3", 20, atcommand_who3 },
  7086. { "whomap", 20, atcommand_whomap },
  7087. { "whomap2", 20, atcommand_whomap2 },
  7088. { "whomap3", 20, atcommand_whomap3 },
  7089. { "whogm", 20, atcommand_whogm },
  7090. { "save", 40, atcommand_save },
  7091. { "return", 40, atcommand_load },
  7092. { "load", 40, atcommand_load },
  7093. { "speed", 40, atcommand_speed },
  7094. { "storage", 1, atcommand_storage },
  7095. { "gstorage", 50, atcommand_guildstorage },
  7096. { "option", 40, atcommand_option },
  7097. { "hide", 40, atcommand_hide }, // + /hide
  7098. { "jobchange", 40, atcommand_jobchange },
  7099. { "job", 40, atcommand_jobchange },
  7100. { "die", 1, atcommand_die },
  7101. { "kill", 60, atcommand_kill },
  7102. { "alive", 60, atcommand_alive },
  7103. { "kami", 40, atcommand_kami },
  7104. { "kamib", 40, atcommand_kami },
  7105. { "kamic", 40, atcommand_kami },
  7106. { "heal", 40, atcommand_heal },
  7107. { "item", 60, atcommand_item },
  7108. { "item2", 60, atcommand_item2 },
  7109. { "itemreset", 40, atcommand_itemreset },
  7110. { "blvl", 60, atcommand_baselevelup },
  7111. { "lvup", 60, atcommand_baselevelup },
  7112. { "blevel", 60, atcommand_baselevelup },
  7113. { "baselvl", 60, atcommand_baselevelup },
  7114. { "baselvup", 60, atcommand_baselevelup },
  7115. { "baselevel", 60, atcommand_baselevelup },
  7116. { "baselvlup", 60, atcommand_baselevelup },
  7117. { "jlvl", 60, atcommand_joblevelup },
  7118. { "jlevel", 60, atcommand_joblevelup },
  7119. { "joblvl", 60, atcommand_joblevelup },
  7120. { "joblevel", 60, atcommand_joblevelup },
  7121. { "joblvup", 60, atcommand_joblevelup },
  7122. { "joblvlup", 60, atcommand_joblevelup },
  7123. { "h", 20, atcommand_help },
  7124. { "help", 20, atcommand_help },
  7125. { "h2", 20, atcommand_help2 },
  7126. { "help2", 20, atcommand_help2 },
  7127. { "pvpoff", 40, atcommand_pvpoff },
  7128. { "pvpon", 40, atcommand_pvpon },
  7129. { "gvgoff", 40, atcommand_gvgoff },
  7130. { "gpvpoff", 40, atcommand_gvgoff },
  7131. { "gvgon", 40, atcommand_gvgon },
  7132. { "gpvpon", 40, atcommand_gvgon },
  7133. { "model", 20, atcommand_model },
  7134. { "go", 10, atcommand_go },
  7135. { "monster", 50, atcommand_monster },
  7136. { "spawn", 50, atcommand_monster },
  7137. { "monstersmall", 50, atcommand_monstersmall },
  7138. { "monsterbig", 50, atcommand_monsterbig },
  7139. { "killmonster", 60, atcommand_killmonster },
  7140. { "killmonster2", 40, atcommand_killmonster2 },
  7141. { "refine", 60, atcommand_refine },
  7142. { "produce", 60, atcommand_produce },
  7143. { "memo", 40, atcommand_memo },
  7144. { "gat", 99, atcommand_gat },
  7145. { "displaystatus", 99, atcommand_displaystatus },
  7146. { "stpoint", 60, atcommand_statuspoint },
  7147. { "skpoint", 60, atcommand_skillpoint },
  7148. { "zeny", 60, atcommand_zeny },
  7149. { "str", 60, atcommand_param },
  7150. { "agi", 60, atcommand_param },
  7151. { "vit", 60, atcommand_param },
  7152. { "int", 60, atcommand_param },
  7153. { "dex", 60, atcommand_param },
  7154. { "luk", 60, atcommand_param },
  7155. { "glvl", 60, atcommand_guildlevelup },
  7156. { "glevel", 60, atcommand_guildlevelup },
  7157. { "guildlvl", 60, atcommand_guildlevelup },
  7158. { "guildlvup", 60, atcommand_guildlevelup },
  7159. { "guildlevel", 60, atcommand_guildlevelup },
  7160. { "guildlvlup", 60, atcommand_guildlevelup },
  7161. { "makeegg", 60, atcommand_makeegg },
  7162. { "hatch", 60, atcommand_hatch },
  7163. { "petfriendly", 40, atcommand_petfriendly },
  7164. { "pethungry", 40, atcommand_pethungry },
  7165. { "petrename", 1, atcommand_petrename },
  7166. { "recall", 60, atcommand_recall }, // + /recall
  7167. { "night", 80, atcommand_night },
  7168. { "day", 80, atcommand_day },
  7169. { "doom", 80, atcommand_doom },
  7170. { "doommap", 80, atcommand_doommap },
  7171. { "raise", 80, atcommand_raise },
  7172. { "raisemap", 80, atcommand_raisemap },
  7173. { "kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7174. { "kickall", 99, atcommand_kickall },
  7175. { "allskill", 60, atcommand_allskill },
  7176. { "allskills", 60, atcommand_allskill },
  7177. { "skillall", 60, atcommand_allskill },
  7178. { "skillsall", 60, atcommand_allskill },
  7179. { "questskill", 40, atcommand_questskill },
  7180. { "lostskill", 40, atcommand_lostskill },
  7181. { "spiritball", 40, atcommand_spiritball },
  7182. { "party", 1, atcommand_party },
  7183. { "guild", 50, atcommand_guild },
  7184. { "agitstart", 60, atcommand_agitstart },
  7185. { "agitend", 60, atcommand_agitend },
  7186. { "mapexit", 99, atcommand_mapexit },
  7187. { "idsearch", 60, atcommand_idsearch },
  7188. { "broadcast", 40, atcommand_broadcast }, // + /b and /nb
  7189. { "localbroadcast", 40, atcommand_localbroadcast }, // + /lb and /nlb
  7190. { "recallall", 80, atcommand_recallall },
  7191. { "reloaditemdb", 99, atcommand_reloaditemdb },
  7192. { "reloadmobdb", 99, atcommand_reloadmobdb },
  7193. { "reloadskilldb", 99, atcommand_reloadskilldb },
  7194. { "reloadscript", 99, atcommand_reloadscript },
  7195. { "reloadgmdb", 99, atcommand_reloadgmdb },
  7196. { "reloadatcommand", 99, atcommand_reloadatcommand },
  7197. { "reloadbattleconf", 99, atcommand_reloadbattleconf },
  7198. { "reloadstatusdb", 99, atcommand_reloadstatusdb },
  7199. { "reloadpcdb", 99, atcommand_reloadpcdb },
  7200. { "reloadmotd", 99, atcommand_reloadmotd },
  7201. { "mapinfo", 99, atcommand_mapinfo },
  7202. { "dye", 40, atcommand_dye },
  7203. { "ccolor", 40, atcommand_dye },
  7204. { "hairstyle", 40, atcommand_hair_style },
  7205. { "hstyle", 40, atcommand_hair_style },
  7206. { "haircolor", 40, atcommand_hair_color },
  7207. { "hcolor", 40, atcommand_hair_color },
  7208. { "statall", 60, atcommand_stat_all },
  7209. { "statsall", 60, atcommand_stat_all },
  7210. { "allstats", 60, atcommand_stat_all },
  7211. { "allstat", 60, atcommand_stat_all },
  7212. { "block", 60, atcommand_char_block },
  7213. { "charblock", 60, atcommand_char_block },
  7214. { "ban", 60, atcommand_char_ban },
  7215. { "banish", 60, atcommand_char_ban },
  7216. { "charban", 60, atcommand_char_ban },
  7217. { "charbanish", 60, atcommand_char_ban },
  7218. { "unblock", 60, atcommand_char_unblock },
  7219. { "charunblock", 60, atcommand_char_unblock },
  7220. { "unban", 60, atcommand_char_unban },
  7221. { "unbanish", 60, atcommand_char_unban },
  7222. { "charunban", 60, atcommand_char_unban },
  7223. { "charunbanish", 60, atcommand_char_unban },
  7224. { "mount", 20, atcommand_mount_peco },
  7225. { "mountpeco", 20, atcommand_mount_peco },
  7226. { "guildspy", 60, atcommand_guildspy },
  7227. { "partyspy", 60, atcommand_partyspy },
  7228. { "repairall", 60, atcommand_repairall },
  7229. { "guildrecall", 60, atcommand_guildrecall },
  7230. { "partyrecall", 60, atcommand_partyrecall },
  7231. { "nuke", 60, atcommand_nuke },
  7232. { "shownpc", 80, atcommand_shownpc },
  7233. { "hidenpc", 80, atcommand_hidenpc },
  7234. { "loadnpc", 80, atcommand_loadnpc },
  7235. { "unloadnpc", 80, atcommand_unloadnpc },
  7236. { "time", 1, atcommand_servertime },
  7237. { "date", 1, atcommand_servertime },
  7238. { "serverdate", 1, atcommand_servertime },
  7239. { "servertime", 1, atcommand_servertime },
  7240. { "jail", 60, atcommand_jail },
  7241. { "unjail", 60, atcommand_unjail },
  7242. { "discharge", 60, atcommand_unjail },
  7243. { "jailfor", 60, atcommand_jailfor },
  7244. { "jailtime", 1, atcommand_jailtime },
  7245. { "disguise", 20, atcommand_disguise },
  7246. { "undisguise", 20, atcommand_undisguise },
  7247. { "email", 1, atcommand_email },
  7248. { "effect", 40, atcommand_effect },
  7249. { "follow", 20, atcommand_follow },
  7250. { "addwarp", 60, atcommand_addwarp },
  7251. { "skillon", 80, atcommand_skillon },
  7252. { "skilloff", 80, atcommand_skilloff },
  7253. { "killer", 60, atcommand_killer },
  7254. { "npcmove", 80, atcommand_npcmove },
  7255. { "killable", 40, atcommand_killable },
  7256. { "dropall", 40, atcommand_dropall },
  7257. { "storeall", 40, atcommand_storeall },
  7258. { "skillid", 40, atcommand_skillid },
  7259. { "useskill", 40, atcommand_useskill },
  7260. { "displayskill", 99, atcommand_displayskill },
  7261. { "snow", 99, atcommand_snow },
  7262. { "sakura", 99, atcommand_sakura },
  7263. { "clouds", 99, atcommand_clouds },
  7264. { "clouds2", 99, atcommand_clouds2 },
  7265. { "fog", 99, atcommand_fog },
  7266. { "fireworks", 99, atcommand_fireworks },
  7267. { "leaves", 99, atcommand_leaves },
  7268. { "summon", 60, atcommand_summon },
  7269. { "adjgmlvl", 99, atcommand_adjgmlvl },
  7270. { "adjcmdlvl", 99, atcommand_adjcmdlvl },
  7271. { "trade", 60, atcommand_trade },
  7272. { "send", 99, atcommand_send },
  7273. { "setbattleflag", 99, atcommand_setbattleflag },
  7274. { "unmute", 80, atcommand_unmute },
  7275. { "clearweather", 99, atcommand_clearweather },
  7276. { "uptime", 1, atcommand_uptime },
  7277. { "changesex", 60, atcommand_changesex },
  7278. { "mute", 80, atcommand_mute },
  7279. { "refresh", 1, atcommand_refresh },
  7280. { "identify", 40, atcommand_identify },
  7281. { "gmotd", 20, atcommand_gmotd },
  7282. { "misceffect", 50, atcommand_misceffect },
  7283. { "mobsearch", 10, atcommand_mobsearch },
  7284. { "cleanmap", 40, atcommand_cleanmap },
  7285. { "npctalk", 20, atcommand_npctalk },
  7286. { "pettalk", 10, atcommand_pettalk },
  7287. { "users", 40, atcommand_users },
  7288. { "reset", 40, atcommand_reset },
  7289. { "skilltree", 40, atcommand_skilltree },
  7290. { "marry", 40, atcommand_marry },
  7291. { "divorce", 40, atcommand_divorce },
  7292. { "sound", 40, atcommand_sound },
  7293. { "undisguiseall", 99, atcommand_undisguiseall },
  7294. { "disguiseall", 99, atcommand_disguiseall },
  7295. { "changelook", 60, atcommand_changelook },
  7296. { "autoloot", 10, atcommand_autoloot },
  7297. { "alootid", 10, atcommand_autolootitem },
  7298. { "mobinfo", 1, atcommand_mobinfo },
  7299. { "monsterinfo", 1, atcommand_mobinfo },
  7300. { "mi", 1, atcommand_mobinfo },
  7301. { "exp", 1, atcommand_exp },
  7302. { "adopt", 40, atcommand_adopt },
  7303. { "version", 1, atcommand_version },
  7304. { "mutearea", 99, atcommand_mutearea },
  7305. { "stfu", 99, atcommand_mutearea },
  7306. { "rates", 1, atcommand_rates },
  7307. { "iteminfo", 1, atcommand_iteminfo },
  7308. { "ii", 1, atcommand_iteminfo },
  7309. { "whodrops", 1, atcommand_whodrops },
  7310. { "whereis", 10, atcommand_whereis },
  7311. { "mapflag", 99, atcommand_mapflag },
  7312. { "me", 20, atcommand_me },
  7313. { "monsterignore", 99, atcommand_monsterignore },
  7314. { "battleignore", 99, atcommand_monsterignore },
  7315. { "fakename", 20, atcommand_fakename },
  7316. { "size", 20, atcommand_size },
  7317. { "showexp", 10, atcommand_showexp},
  7318. { "showzeny", 10, atcommand_showzeny},
  7319. { "showdelay", 1, atcommand_showdelay},
  7320. { "autotrade", 10, atcommand_autotrade },
  7321. { "at", 10, atcommand_autotrade },
  7322. { "changegm", 10, atcommand_changegm },
  7323. { "changeleader", 10, atcommand_changeleader },
  7324. { "partyoption", 10, atcommand_partyoption},
  7325. { "invite", 1, atcommand_invite },
  7326. { "duel", 1, atcommand_duel },
  7327. { "leave", 1, atcommand_leave },
  7328. { "accept", 1, atcommand_accept },
  7329. { "reject", 1, atcommand_reject },
  7330. { "away", 1, atcommand_away },
  7331. { "aw", 1, atcommand_away },
  7332. { "main", 1, atcommand_main },
  7333. { "clone", 50, atcommand_clone },
  7334. { "slaveclone", 50, atcommand_clone },
  7335. { "evilclone", 50, atcommand_clone },
  7336. { "tonpc", 40, atcommand_tonpc },
  7337. { "commands", 1, atcommand_commands },
  7338. { "noask", 1, atcommand_noask },
  7339. { "request", 20, atcommand_request },
  7340. { "hlvl", 60, atcommand_homlevel },
  7341. { "hlevel", 60, atcommand_homlevel },
  7342. { "homlvl", 60, atcommand_homlevel },
  7343. { "homlvup", 60, atcommand_homlevel },
  7344. { "homlevel", 60, atcommand_homlevel },
  7345. { "homevolve", 60, atcommand_homevolution },
  7346. { "homevolution", 60, atcommand_homevolution },
  7347. { "makehomun", 60, atcommand_makehomun },
  7348. { "homfriendly", 60, atcommand_homfriendly },
  7349. { "homhungry", 60, atcommand_homhungry },
  7350. { "homtalk", 10, atcommand_homtalk },
  7351. { "hominfo", 1, atcommand_hominfo },
  7352. { "homstats", 1, atcommand_homstats },
  7353. { "homshuffle", 60, atcommand_homshuffle },
  7354. { "showmobs", 10, atcommand_showmobs },
  7355. { "feelreset", 10, atcommand_feelreset },
  7356. { "auction", 60, atcommand_auction },
  7357. { "mail", 1, atcommand_mail },
  7358. { "noks", 0, atcommand_ksprotection },
  7359. { "allowks", 6, atcommand_allowks },
  7360. { "cash", 60, atcommand_cash },
  7361. { "points", 60, atcommand_cash },
  7362. { "barricade", 60, atcommand_barricade },
  7363. { "killbarricade", 60, atcommand_barricade_destroy },
  7364. };
  7365. /*==========================================
  7366. * Command lookup functions
  7367. *------------------------------------------*/
  7368. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  7369. {
  7370. int i;
  7371. if( *name == atcommand_symbol ) name++; // for backwards compatibility
  7372. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  7373. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7374. }
  7375. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  7376. {
  7377. int i;
  7378. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  7379. return ( i < ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7380. }
  7381. /*==========================================
  7382. * Retrieve the command's required gm level
  7383. *------------------------------------------*/
  7384. int get_atcommand_level(const AtCommandFunc func)
  7385. {
  7386. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  7387. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7388. }
  7389. /// Executes an at-command.
  7390. /// To be called by internal server code (bypasses various restrictions).
  7391. bool is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  7392. {
  7393. AtCommandInfo* info;
  7394. char command[100];
  7395. char args[100];
  7396. char output[200];
  7397. if( !str || !*str )
  7398. return false;
  7399. if( *str != atcommand_symbol ) // check first char
  7400. return false;
  7401. if( sscanf(str, "%99s %99[^\n]", command, args) < 2 )
  7402. args[0] = '\0';
  7403. info = get_atcommandinfo_byname(command);
  7404. if( info == NULL || info->func == NULL || gmlvl < info->level )
  7405. {
  7406. if( gmlvl == 0 )
  7407. return false; // will just display as normal text
  7408. else
  7409. {
  7410. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7411. clif_displaymessage(fd, output);
  7412. return true;
  7413. }
  7414. }
  7415. if( log_config.gm && info->level >= log_config.gm )
  7416. log_atcommand(sd, str);
  7417. if( info->func(fd, sd, command, args) != 0 )
  7418. {
  7419. sprintf(output, msg_txt(154), command); // "%s failed."
  7420. clif_displaymessage(fd, output);
  7421. }
  7422. return true;
  7423. }
  7424. /// Executes an at-command.
  7425. /// To be used by player-invoked code (restrictions will be applied).
  7426. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  7427. {
  7428. int gmlvl = pc_isGM(sd);
  7429. nullpo_retr(false, sd);
  7430. if( !message || !*message )
  7431. return false; // shouldn't happen
  7432. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7433. return true; // so that it won't display as normal message
  7434. if( battle_config.atc_gmonly != 0 && gmlvl == 0 )
  7435. return false;
  7436. if( map[sd->bl.m].nocommand && gmlvl < map[sd->bl.m].nocommand )
  7437. {
  7438. clif_displaymessage(fd, msg_txt(143)); // "Commands are disabled on this map."
  7439. return false;
  7440. }
  7441. // skip 10/11-langtype's codepage indicator, if detected
  7442. if( message[0] == '|' && strlen(message) >= 4 && message[3] == atcommand_symbol )
  7443. message += 3;
  7444. return is_atcommand_sub(fd,sd,message,gmlvl);
  7445. }
  7446. /*==========================================
  7447. *
  7448. *------------------------------------------*/
  7449. int atcommand_config_read(const char* cfgName)
  7450. {
  7451. char line[1024], w1[1024], w2[1024];
  7452. AtCommandInfo* p;
  7453. FILE* fp;
  7454. if( (fp = fopen(cfgName, "r")) == NULL )
  7455. {
  7456. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  7457. return 1;
  7458. }
  7459. while( fgets(line, sizeof(line), fp) )
  7460. {
  7461. if( line[0] == '/' && line[1] == '/' )
  7462. continue;
  7463. if( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2 )
  7464. continue;
  7465. p = get_atcommandinfo_byname(w1);
  7466. if( p != NULL )
  7467. {
  7468. p->level = atoi(w2);
  7469. p->level = cap_value(p->level, 0, 100);
  7470. }
  7471. else
  7472. if( strcmpi(w1, "import") == 0 )
  7473. atcommand_config_read(w2);
  7474. else
  7475. if( strcmpi(w1, "command_symbol") == 0 &&
  7476. w2[0] > 31 && // control characters
  7477. w2[0] != '/' && // symbol of standard ragnarok GM commands
  7478. w2[0] != '%' && // symbol of party chat speaking
  7479. w2[0] != '$' && // symbol of guild chat speaking
  7480. w2[0] != '#' ) // symbol of charcommand
  7481. atcommand_symbol = w2[0];
  7482. else
  7483. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  7484. }
  7485. fclose(fp);
  7486. return 0;
  7487. }
  7488. void do_init_atcommand()
  7489. {
  7490. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  7491. return;
  7492. }
  7493. void do_final_atcommand()
  7494. {
  7495. }
  7496. // commands that need to go _after_ the commands table
  7497. /*==========================================
  7498. * @commands Lists available @ commands to you
  7499. *------------------------------------------*/
  7500. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7501. {
  7502. char line_buff[CHATBOX_SIZE];
  7503. int i, gm_lvl = pc_isGM(sd), count = 0;
  7504. char* cur = line_buff;
  7505. memset(line_buff,' ',CHATBOX_SIZE);
  7506. line_buff[CHATBOX_SIZE-1] = 0;
  7507. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7508. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  7509. {
  7510. unsigned int slen;
  7511. if( gm_lvl < atcommand_info[i].level )
  7512. continue;
  7513. slen = (unsigned int)strlen(atcommand_info[i].command);
  7514. // flush the text buffer if this command won't fit into it
  7515. if( ((CHATBOX_SIZE-1+(int)line_buff)-(int)cur) < (int)slen )
  7516. {
  7517. clif_displaymessage(fd,line_buff);
  7518. cur = line_buff;
  7519. memset(line_buff,' ',CHATBOX_SIZE);
  7520. line_buff[CHATBOX_SIZE-1] = 0;
  7521. }
  7522. memcpy(cur,atcommand_info[i].command,slen);
  7523. cur += slen+(10-slen%10);
  7524. count++;
  7525. }
  7526. clif_displaymessage(fd,line_buff);
  7527. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7528. clif_displaymessage(fd, atcmd_output);
  7529. return 0;
  7530. }