atcommand.c 242 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047
  1. // $Id: atcommand.c 148 2004-09-30 14:05:37Z MouseJstr $
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <math.h>
  7. #include "../common/socket.h"
  8. #include "../common/timer.h"
  9. #include "../common/nullpo.h"
  10. #include "log.h"
  11. #include "clif.h"
  12. #include "chrif.h"
  13. #include "intif.h"
  14. #include "itemdb.h"
  15. #include "map.h"
  16. #include "pc.h"
  17. #include "skill.h"
  18. #include "mob.h"
  19. #include "pet.h"
  20. #include "battle.h"
  21. #include "party.h"
  22. #include "guild.h"
  23. #include "atcommand.h"
  24. #include "script.h"
  25. #include "npc.h"
  26. #include "trade.h"
  27. #include "core.h"
  28. #ifndef TXT_ONLY
  29. #include "mail.h"
  30. #endif
  31. #define STATE_BLIND 0x10
  32. static char command_symbol = '@'; // first char of the commands (by [Yor])
  33. char msg_table[1000][256]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  34. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  35. ACMD_FUNC(broadcast);
  36. ACMD_FUNC(localbroadcast);
  37. ACMD_FUNC(rurap);
  38. ACMD_FUNC(rura);
  39. ACMD_FUNC(where);
  40. ACMD_FUNC(jumpto);
  41. ACMD_FUNC(jump);
  42. ACMD_FUNC(who);
  43. ACMD_FUNC(who2);
  44. ACMD_FUNC(who3);
  45. ACMD_FUNC(whomap);
  46. ACMD_FUNC(whomap2);
  47. ACMD_FUNC(whomap3);
  48. ACMD_FUNC(whogm); // by Yor
  49. ACMD_FUNC(whozeny); // [Valaris]
  50. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  51. ACMD_FUNC(save);
  52. ACMD_FUNC(load);
  53. ACMD_FUNC(speed);
  54. ACMD_FUNC(storage);
  55. ACMD_FUNC(guildstorage);
  56. ACMD_FUNC(option);
  57. ACMD_FUNC(hide);
  58. ACMD_FUNC(jobchange);
  59. ACMD_FUNC(die);
  60. ACMD_FUNC(kill);
  61. ACMD_FUNC(alive);
  62. ACMD_FUNC(kami);
  63. ACMD_FUNC(heal);
  64. ACMD_FUNC(item);
  65. ACMD_FUNC(item2);
  66. ACMD_FUNC(itemreset);
  67. ACMD_FUNC(itemcheck);
  68. ACMD_FUNC(baselevelup);
  69. ACMD_FUNC(joblevelup);
  70. ACMD_FUNC(help);
  71. ACMD_FUNC(gm);
  72. ACMD_FUNC(pvpoff);
  73. ACMD_FUNC(pvpon);
  74. ACMD_FUNC(gvgoff);
  75. ACMD_FUNC(gvgon);
  76. ACMD_FUNC(model);
  77. ACMD_FUNC(go);
  78. ACMD_FUNC(monster);
  79. ACMD_FUNC(monstersmall);
  80. ACMD_FUNC(monsterbig);
  81. ACMD_FUNC(spawn);
  82. ACMD_FUNC(killmonster);
  83. ACMD_FUNC(killmonster2);
  84. ACMD_FUNC(refine);
  85. ACMD_FUNC(produce);
  86. ACMD_FUNC(memo);
  87. ACMD_FUNC(gat);
  88. ACMD_FUNC(packet);
  89. ACMD_FUNC(statuspoint);
  90. ACMD_FUNC(skillpoint);
  91. ACMD_FUNC(zeny);
  92. ACMD_FUNC(param);
  93. ACMD_FUNC(guildlevelup);
  94. ACMD_FUNC(makeegg);
  95. ACMD_FUNC(hatch);
  96. ACMD_FUNC(petfriendly);
  97. ACMD_FUNC(pethungry);
  98. ACMD_FUNC(petrename);
  99. ACMD_FUNC(recall);
  100. ACMD_FUNC(recallall);
  101. ACMD_FUNC(revive);
  102. ACMD_FUNC(character_stats_all);
  103. ACMD_FUNC(character_save);
  104. ACMD_FUNC(night);
  105. ACMD_FUNC(day);
  106. ACMD_FUNC(doom);
  107. ACMD_FUNC(doommap);
  108. ACMD_FUNC(raise);
  109. ACMD_FUNC(raisemap);
  110. ACMD_FUNC(character_baselevel);
  111. ACMD_FUNC(character_joblevel);
  112. ACMD_FUNC(kick);
  113. ACMD_FUNC(kickall);
  114. ACMD_FUNC(allskill);
  115. ACMD_FUNC(questskill);
  116. ACMD_FUNC(charquestskill);
  117. ACMD_FUNC(lostskill);
  118. ACMD_FUNC(charlostskill);
  119. ACMD_FUNC(spiritball);
  120. ACMD_FUNC(party);
  121. ACMD_FUNC(guild);
  122. ACMD_FUNC(charskreset);
  123. ACMD_FUNC(charstreset);
  124. ACMD_FUNC(charreset);
  125. ACMD_FUNC(charstpoint);
  126. ACMD_FUNC(charmodel);
  127. ACMD_FUNC(charskpoint);
  128. ACMD_FUNC(charzeny);
  129. ACMD_FUNC(agitstart);
  130. ACMD_FUNC(agitend);
  131. ACMD_FUNC(reloaditemdb);
  132. ACMD_FUNC(reloadmobdb);
  133. ACMD_FUNC(reloadskilldb);
  134. #ifndef TXT_ONLY
  135. ACMD_FUNC(rehash);// by Fr3DBr
  136. #else /* TXT_ONLY */
  137. ACMD_FUNC(reloadscript);
  138. #endif /* TXT_ONLY */
  139. ACMD_FUNC(reloadgmdb); // by Yor
  140. ACMD_FUNC(mapexit);
  141. ACMD_FUNC(idsearch);
  142. ACMD_FUNC(mapinfo);
  143. ACMD_FUNC(dye); //** by fritz
  144. ACMD_FUNC(hair_style); //** by fritz
  145. ACMD_FUNC(hair_color); //** by fritz
  146. ACMD_FUNC(stat_all); //** by fritz
  147. ACMD_FUNC(char_change_sex); // by Yor
  148. ACMD_FUNC(char_block); // by Yor
  149. ACMD_FUNC(char_ban); // by Yor
  150. ACMD_FUNC(char_unblock); // by Yor
  151. ACMD_FUNC(char_unban); // by Yor
  152. ACMD_FUNC(mount_peco); // by Valaris
  153. ACMD_FUNC(char_mount_peco); // by Yor
  154. ACMD_FUNC(guildspy); // [Syrus22]
  155. ACMD_FUNC(partyspy); // [Syrus22]
  156. ACMD_FUNC(repairall); // [Valaris]
  157. ACMD_FUNC(guildrecall); // by Yor
  158. ACMD_FUNC(partyrecall); // by Yor
  159. //ACMD_FUNC(nuke); // [Valaris]
  160. ACMD_FUNC(enablenpc);
  161. ACMD_FUNC(disablenpc);
  162. ACMD_FUNC(servertime); // by Yor
  163. ACMD_FUNC(chardelitem); // by Yor
  164. ACMD_FUNC(jail); // by Yor
  165. ACMD_FUNC(unjail); // by Yor
  166. ACMD_FUNC(disguise); // [Valaris]
  167. ACMD_FUNC(undisguise); // by Yor
  168. ACMD_FUNC(chardisguise); // Kalaspuff
  169. ACMD_FUNC(charundisguise); // Kalaspuff
  170. ACMD_FUNC(email); // by Yor
  171. ACMD_FUNC(effect);//by Apple
  172. ACMD_FUNC(character_cart_list); // by Yor
  173. ACMD_FUNC(addwarp); // by MouseJstr
  174. ACMD_FUNC(follow); // by MouseJstr
  175. ACMD_FUNC(skillon); // by MouseJstr
  176. ACMD_FUNC(skilloff); // by MouseJstr
  177. ACMD_FUNC(killer); // by MouseJstr
  178. ACMD_FUNC(npcmove); // by MouseJstr
  179. ACMD_FUNC(killable); // by MouseJstr
  180. ACMD_FUNC(charkillable); // by MouseJstr
  181. ACMD_FUNC(dropall); // by MouseJstr
  182. ACMD_FUNC(chardropall); // by MouseJstr
  183. ACMD_FUNC(storeall); // by MouseJstr
  184. ACMD_FUNC(charstoreall); // by MouseJstr
  185. ACMD_FUNC(skillid); // by MouseJstr
  186. ACMD_FUNC(useskill); // by MouseJstr
  187. ACMD_FUNC(summon);
  188. ACMD_FUNC(rain);
  189. ACMD_FUNC(snow);
  190. ACMD_FUNC(sakura);
  191. ACMD_FUNC(fog);
  192. ACMD_FUNC(leaves);
  193. ACMD_FUNC(adjgmlvl); // by MouseJstr
  194. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  195. ACMD_FUNC(trade); // by MouseJstr
  196. ACMD_FUNC(send); // by davidsiaw
  197. ACMD_FUNC(setbattleflag); // by MouseJstr
  198. ACMD_FUNC(unmute); // [Valaris]
  199. ACMD_FUNC(clearweather); // Dexity
  200. ACMD_FUNC(uptime); // by MC Cameri
  201. ACMD_FUNC(changesex); // by MC Cameri
  202. ACMD_FUNC(mute); // celest
  203. ACMD_FUNC(refresh); // by MC Cameri
  204. ACMD_FUNC(petid); // by MC Cameri
  205. ACMD_FUNC(identify); // by MC Cameri
  206. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  207. ACMD_FUNC(misceffect); // by MC Cameri
  208. #ifndef TXT_ONLY
  209. ACMD_FUNC(checkmail); // [Valaris]
  210. ACMD_FUNC(listmail); // [Valaris]
  211. ACMD_FUNC(listnewmail); // [Valaris]
  212. ACMD_FUNC(readmail); // [Valaris]
  213. ACMD_FUNC(sendmail); // [Valaris]
  214. ACMD_FUNC(sendprioritymail); // [Valaris]
  215. ACMD_FUNC(deletemail); // [Valaris]
  216. ACMD_FUNC(sound); // [Valaris]
  217. ACMD_FUNC(refreshonline); // [Valaris]
  218. #endif /* TXT_ONLY */
  219. ACMD_FUNC(skilltree); // by MouseJstr
  220. ACMD_FUNC(marry); // by MouseJstr
  221. ACMD_FUNC(divorce); // by MouseJstr
  222. ACMD_FUNC(rings); // by MouseJstr
  223. ACMD_FUNC(grind); // by MouseJstr
  224. /*==========================================
  225. *AtCommandInfo atcommand_info[]構造体の定義
  226. *------------------------------------------
  227. */
  228. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  229. // to set default level, read atcommand_athena.conf first please.
  230. static AtCommandInfo atcommand_info[] = {
  231. { AtCommand_RuraP, "@rura+", 60, atcommand_rurap },
  232. { AtCommand_RuraP, "@charwarp", 60, atcommand_rurap },
  233. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  234. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  235. { AtCommand_Where, "@where", 1, atcommand_where },
  236. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  237. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  238. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  239. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  240. { AtCommand_Who, "@who", 20, atcommand_who },
  241. { AtCommand_Who, "@whois", 20, atcommand_who },
  242. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  243. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  244. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  245. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  246. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  247. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  248. { AtCommand_Save, "@save", 40, atcommand_save },
  249. { AtCommand_Load, "@return", 40, atcommand_load },
  250. { AtCommand_Load, "@load", 40, atcommand_load },
  251. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  252. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  253. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  254. { AtCommand_Option, "@option", 40, atcommand_option },
  255. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  256. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  257. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  258. { AtCommand_Die, "@die", 1, atcommand_die },
  259. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  260. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  261. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  262. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  263. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  264. { AtCommand_Item, "@item", 60, atcommand_item },
  265. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  266. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  267. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  268. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  269. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  270. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  271. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  272. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  273. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  274. { AtCommand_H, "@h", 20, atcommand_help },
  275. { AtCommand_Help, "@help", 20, atcommand_help },
  276. { AtCommand_GM, "@gm", 100, atcommand_gm },
  277. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  278. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  279. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  280. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  281. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  282. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  283. { AtCommand_Model, "@model", 20, atcommand_model },
  284. { AtCommand_Go, "@go", 10, atcommand_go },
  285. { AtCommand_Spawn, "@monster", 50, atcommand_spawn },
  286. { AtCommand_Spawn, "@spawn", 50, atcommand_spawn },
  287. // { AtCommand_Spawn, "@summon", 50, atcommand_spawn },
  288. { AtCommand_Monster, "@monster2", 50, atcommand_monster },
  289. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  290. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  291. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  292. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  293. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  294. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  295. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  296. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  297. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  298. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  299. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  300. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  301. { AtCommand_Strength, "@str", 60, atcommand_param },
  302. { AtCommand_Agility, "@agi", 60, atcommand_param },
  303. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  304. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  305. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  306. { AtCommand_Luck, "@luk", 60, atcommand_param },
  307. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  308. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  309. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  310. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  311. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  312. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  313. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  314. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  315. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  316. { AtCommand_Night, "@night", 80, atcommand_night },
  317. { AtCommand_Day, "@day", 80, atcommand_day },
  318. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  319. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  320. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  321. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  322. { AtCommand_CharacterBaseLevel, "@charbaselvl", 60, atcommand_character_baselevel },
  323. { AtCommand_CharacterJobLevel, "@charjlvl", 60, atcommand_character_joblevel },
  324. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  325. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  326. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  327. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  328. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  329. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  330. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  331. { AtCommand_CharQuestSkill, "@charquestskill", 60, atcommand_charquestskill },
  332. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  333. { AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill },
  334. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  335. { AtCommand_Party, "@party", 1, atcommand_party },
  336. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  337. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  338. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  339. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  340. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  341. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  342. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  343. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  344. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  345. { AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset },
  346. { AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset },
  347. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  348. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  349. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  350. #ifndef TXT_ONLY
  351. { AtCommand_Rehash, "@rehash", 99, atcommand_rehash }, // admin command
  352. #else /* TXT_ONLY */
  353. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  354. #endif /* TXT_ONLY */
  355. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  356. { AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel },
  357. { AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint },
  358. { AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint },
  359. { AtCommand_CharZeny, "@charzeny", 60, atcommand_charzeny },
  360. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  361. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  362. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  363. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  364. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  365. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  366. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  367. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  368. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  369. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  370. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  371. { AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex }, // by Yor
  372. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  373. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  374. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  375. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  376. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  377. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  378. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  379. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  380. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  381. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  382. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  383. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  384. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  385. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  386. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  387. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  388. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  389. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  390. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  391. // { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  392. { AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc }, // []
  393. { AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // []
  394. { AtCommand_ServerTime, "@time", 0, atcommand_servertime }, // by Yor
  395. { AtCommand_ServerTime, "@date", 0, atcommand_servertime }, // by Yor
  396. { AtCommand_ServerTime, "@server_date", 0, atcommand_servertime }, // by Yor
  397. { AtCommand_ServerTime, "@serverdate", 0, atcommand_servertime }, // by Yor
  398. { AtCommand_ServerTime, "@server_time", 0, atcommand_servertime }, // by Yor
  399. { AtCommand_ServerTime, "@servertime", 0, atcommand_servertime }, // by Yor
  400. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  401. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  402. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  403. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  404. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  405. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  406. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  407. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  408. { AtCommand_EMail, "@email", 0, atcommand_email }, // by Yor
  409. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  410. // { AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list }, // by Yor, now #itemlist
  411. // { AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list }, // by Yor, now #storagelist
  412. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  413. { AtCommand_Follow, "@follow", 10, atcommand_follow }, // by MouseJstr
  414. { AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp }, // by MouseJstr
  415. { AtCommand_SkillOn, "@skillon", 20, atcommand_skillon }, // by MouseJstr
  416. { AtCommand_SkillOff, "@skilloff", 20, atcommand_skilloff }, // by MouseJstr
  417. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  418. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  419. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  420. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  421. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  422. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  423. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  424. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  425. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  426. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  427. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  428. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  429. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  430. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  431. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  432. /*
  433. { AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle },
  434. { AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance },
  435. { AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect },
  436. */
  437. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  438. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  439. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  440. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  441. { AtCommand_Send, "@send", 60, atcommand_send },
  442. { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag },
  443. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  444. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  445. { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri
  446. { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri
  447. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  448. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  449. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  450. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy",40, atcommand_happyhappyjoyjoy }, // [Valaris]
  451. { AtCommand_Refresh, "@refresh", 0, atcommand_refresh }, // by MC Cameri
  452. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  453. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  454. { AtCommand_Gmotd, "@gmotd", 0, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  455. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  456. #ifndef TXT_ONLY // sql-only commands
  457. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  458. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  459. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  460. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  461. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  462. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  463. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  464. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  465. #endif /* TXT_ONLY */
  466. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  467. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  468. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  469. { AtCommand_Rings, "@rings", 40, atcommand_rings }, // [MouseJstr]
  470. { AtCommand_Grind, "@grind", 40, atcommand_grind }, // [MouseJstr]
  471. // add new commands before this line
  472. { AtCommand_Unknown, NULL, 1, NULL }
  473. };
  474. /*====================================================
  475. * This function return the name of the job (by [Yor])
  476. *----------------------------------------------------
  477. */
  478. char * job_name(int class) {
  479. switch (class) {
  480. case 0: return "Novice";
  481. case 1: return "Swordsman";
  482. case 2: return "Mage";
  483. case 3: return "Archer";
  484. case 4: return "Acolyte";
  485. case 5: return "Merchant";
  486. case 6: return "Thief";
  487. case 7: return "Knight";
  488. case 8: return "Priest";
  489. case 9: return "Wizard";
  490. case 10: return "Blacksmith";
  491. case 11: return "Hunter";
  492. case 12: return "Assassin";
  493. case 13: return "Knight 2";
  494. case 14: return "Crusader";
  495. case 15: return "Monk";
  496. case 16: return "Sage";
  497. case 17: return "Rogue";
  498. case 18: return "Alchemist";
  499. case 19: return "Bard";
  500. case 20: return "Dancer";
  501. case 21: return "Crusader 2";
  502. case 22: return "Wedding";
  503. case 23: return "Super Novice";
  504. case 4001: return "Novice High";
  505. case 4002: return "Swordsman High";
  506. case 4003: return "Mage High";
  507. case 4004: return "Archer High";
  508. case 4005: return "Acolyte High";
  509. case 4006: return "Merchant High";
  510. case 4007: return "Thief High";
  511. case 4008: return "Lord Knight";
  512. case 4009: return "High Priest";
  513. case 4010: return "High Wizard";
  514. case 4011: return "Whitesmith";
  515. case 4012: return "Sniper";
  516. case 4013: return "Assassin Cross";
  517. case 4014: return "Peko Knight";
  518. case 4015: return "Paladin";
  519. case 4016: return "Champion";
  520. case 4017: return "Professor";
  521. case 4018: return "Stalker";
  522. case 4019: return "Creator";
  523. case 4020: return "Clown";
  524. case 4021: return "Gypsy";
  525. case 4022: return "Peko Paladin";
  526. case 4023: return "Baby Novice";
  527. case 4024: return "Baby Swordsman";
  528. case 4025: return "Baby Mage";
  529. case 4026: return "Baby Archer";
  530. case 4027: return "Baby Acolyte";
  531. case 4028: return "Baby Merchant";
  532. case 4029: return "Baby Thief";
  533. case 4030: return "Baby Knight";
  534. case 4031: return "Baby Priest";
  535. case 4032: return "Baby Wizard";
  536. case 4033: return "Baby Blacksmith";
  537. case 4034: return "Baby Hunter";
  538. case 4035: return "Baby Assassin";
  539. case 4036: return "Baby Peco Knight";
  540. case 4037: return "Baby Crusader";
  541. case 4038: return "Baby Monk";
  542. case 4039: return "Baby Sage";
  543. case 4040: return "Baby Rogue";
  544. case 4041: return "Baby Alchemist";
  545. case 4042: return "Baby Bard";
  546. case 4043: return "Baby Dancer";
  547. case 4044: return "Baby Peco Crusader";
  548. case 4045: return "Super Baby";
  549. }
  550. return "Unknown Job";
  551. }
  552. /*==========================================
  553. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  554. *------------------------------------------
  555. */
  556. char *estr_lower(char *str)
  557. {
  558. int i;
  559. for (i=0; str[i]; i++)
  560. if ((str[i] >= 65) && (str[i] <= 90))
  561. str[i] += 32;
  562. return str;
  563. }
  564. // compare function for sorting high to lowest
  565. int hightolow_compare (const void * a, const void * b)
  566. {
  567. return ( *(int*)b - *(int*)a );
  568. }
  569. // compare function for sorting lowest to highest
  570. int lowtohigh_compare (const void * a, const void * b)
  571. {
  572. return ( *(int*)a - *(int*)b );
  573. }
  574. //-----------------------------------------------------------
  575. // Return the message string of the specified number by [Yor]
  576. //-----------------------------------------------------------
  577. char * msg_txt(int msg_number) {
  578. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])) &&
  579. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  580. return msg_table[msg_number];
  581. return "??";
  582. }
  583. //------------------------------------------------------------
  584. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  585. //------------------------------------------------------------
  586. int e_mail_check(unsigned char *email) {
  587. char ch;
  588. unsigned char* last_arobas;
  589. // athena limits
  590. if (strlen(email) < 3 || strlen(email) > 39)
  591. return 0;
  592. // part of RFC limits (official reference of e-mail description)
  593. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  594. return 0;
  595. if (email[strlen(email)-1] == '.')
  596. return 0;
  597. last_arobas = strrchr(email, '@');
  598. if (strstr(last_arobas, "@.") != NULL ||
  599. strstr(last_arobas, "..") != NULL)
  600. return 0;
  601. for(ch = 1; ch < 32; ch++) {
  602. if (strchr(last_arobas, ch) != NULL) {
  603. return 0;
  604. break;
  605. }
  606. }
  607. if (strchr(last_arobas, ' ') != NULL ||
  608. strchr(last_arobas, ';') != NULL)
  609. return 0;
  610. // all correct
  611. return 1;
  612. }
  613. /*==========================================
  614. * get_atcommand_level @コマンドの必要レベルを取得
  615. *------------------------------------------
  616. */
  617. int get_atcommand_level(const AtCommandType type) {
  618. int i;
  619. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  620. if (atcommand_info[i].type == type)
  621. return atcommand_info[i].level;
  622. return 100; // 100: command can not be used
  623. }
  624. /*==========================================
  625. *is_atcommand @コマンドに存在するかどうか確認する
  626. *------------------------------------------
  627. */
  628. AtCommandType
  629. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  630. const char* str = message;
  631. int s_flag = 0;
  632. AtCommandInfo info;
  633. AtCommandType type;
  634. nullpo_retr(AtCommand_None, sd);
  635. if (!battle_config.allow_atcommand_when_mute &&
  636. sd->sc_count && sd->sc_data[SC_NOCHAT].timer != -1) {
  637. return AtCommand_Unknown;
  638. }
  639. if (!message || !*message)
  640. return AtCommand_None;
  641. memset(&info, 0, sizeof(info));
  642. str += strlen(sd->status.name);
  643. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  644. if (*str == ':')
  645. s_flag = 1;
  646. str++;
  647. }
  648. if (!*str)
  649. return AtCommand_None;
  650. type = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  651. if (type != AtCommand_None) {
  652. char command[100];
  653. char output[200];
  654. const char* p = str;
  655. memset(command, '\0', sizeof(command));
  656. memset(output, '\0', sizeof(output));
  657. while (*p && !isspace(*p))
  658. p++;
  659. if (p - str >= sizeof(command)) // too long
  660. return AtCommand_Unknown;
  661. strncpy(command, str, p - str);
  662. while (isspace(*p))
  663. p++;
  664. if (type == AtCommand_Unknown || info.proc == NULL) {
  665. sprintf(output, msg_table[153], command); // %s is Unknown Command.
  666. clif_displaymessage(fd, output);
  667. } else {
  668. if (info.proc(fd, sd, command, p) != 0) {
  669. // Command can not be executed
  670. sprintf(output, msg_table[154], command); // %s failed.
  671. clif_displaymessage(fd, output);
  672. }
  673. }
  674. // ToDo: Fix Logs :)
  675. //if((log_config.gm) && (info.level >= log_config.gm))
  676. // log_atcommand(sd, message);
  677. return info.type;
  678. }
  679. return AtCommand_None;
  680. }
  681. /*==========================================
  682. *
  683. *------------------------------------------
  684. */
  685. AtCommandType atcommand(const int level, const char* message, struct AtCommandInfo* info) {
  686. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  687. if (!info)
  688. return AtCommand_None;
  689. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  690. return AtCommand_None;
  691. if (!p || !*p) {
  692. fprintf(stderr, "at command message is empty\n");
  693. return AtCommand_None;
  694. }
  695. if (*p == command_symbol) { // check first char.
  696. char command[101];
  697. int i = 0;
  698. memset(info, 0, sizeof(AtCommandInfo));
  699. sscanf(p, "%100s", command);
  700. command[sizeof(command)-1] = '\0';
  701. while (atcommand_info[i].type != AtCommand_Unknown) {
  702. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  703. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  704. break;
  705. }
  706. i++;
  707. }
  708. if (atcommand_info[i].type == AtCommand_Unknown) {
  709. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  710. if (level == 0)
  711. return AtCommand_None;
  712. else
  713. return AtCommand_Unknown;
  714. }
  715. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  716. } else {
  717. return AtCommand_None;
  718. }
  719. return info->type;
  720. }
  721. /*==========================================
  722. *
  723. *------------------------------------------
  724. */
  725. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  726. int flag = va_arg(ap, int);
  727. nullpo_retr(0, bl);
  728. if (flag)
  729. mob_damage(NULL, (struct mob_data *)bl, ((struct mob_data *)bl)->hp, 2);
  730. else
  731. mob_delete((struct mob_data *)bl);
  732. return 0;
  733. }
  734. #ifndef TXT_ONLY
  735. static int atkillnpc_sub(struct block_list *bl, va_list ap)
  736. {
  737. int flag = va_arg(ap,int);
  738. nullpo_retr(0, bl);
  739. npc_delete((struct npc_data *)bl);
  740. flag = 0;
  741. return 0;
  742. }
  743. void rehash( const int fd, struct map_session_data* sd )
  744. {
  745. int map_id = 0;
  746. int LOADED_MAPS = map_num;
  747. for (map_id = 0; map_id < LOADED_MAPS;map_id++) {
  748. if (map_id > LOADED_MAPS)
  749. break;
  750. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, 0);
  751. map_foreachinarea(atkillnpc_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_NPC, 0);
  752. }
  753. }
  754. #endif /* not TXT_ONLY */
  755. /*==========================================
  756. * Read Message Data
  757. *------------------------------------------
  758. */
  759. int msg_config_read(const char *cfgName) {
  760. int msg_number;
  761. char line[1024], w1[1024], w2[1024];
  762. FILE *fp;
  763. if ((fp = fopen(cfgName, "r")) == NULL) {
  764. printf("Messages file not found: %s\n", cfgName);
  765. return 1;
  766. }
  767. while(fgets(line, sizeof(line)-1, fp)) {
  768. if (line[0] == '/' && line[1] == '/')
  769. continue;
  770. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  771. if (strcmpi(w1, "import") == 0) {
  772. msg_config_read(w2);
  773. } else {
  774. msg_number = atoi(w1);
  775. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])))
  776. strcpy(msg_table[msg_number], w2);
  777. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  778. }
  779. }
  780. }
  781. fclose(fp);
  782. return 0;
  783. }
  784. /*==========================================
  785. *
  786. *------------------------------------------
  787. */
  788. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  789. int i;
  790. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  791. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  792. return &atcommand_info[i];
  793. return NULL;
  794. }
  795. /*==========================================
  796. *
  797. *------------------------------------------
  798. */
  799. int atcommand_config_read(const char *cfgName) {
  800. char line[1024], w1[1024], w2[1024];
  801. AtCommandInfo* p;
  802. FILE* fp;
  803. if ((fp = fopen(cfgName, "r")) == NULL) {
  804. printf("At commands configuration file not found: %s\n", cfgName);
  805. return 1;
  806. }
  807. while (fgets(line, sizeof(line)-1, fp)) {
  808. if (line[0] == '/' && line[1] == '/')
  809. continue;
  810. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  811. continue;
  812. p = get_atcommandinfo_byname(w1);
  813. if (p != NULL) {
  814. p->level = atoi(w2);
  815. if (p->level > 100)
  816. p->level = 100;
  817. else if (p->level < 0)
  818. p->level = 0;
  819. }
  820. if (strcmpi(w1, "import") == 0)
  821. atcommand_config_read(w2);
  822. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  823. w2[0] != '/' && // symbol of standard ragnarok GM commands
  824. w2[0] != '%' && // symbol of party chat speaking
  825. w2[0] != '#') // symbol of charcommand
  826. command_symbol = w2[0];
  827. }
  828. fclose(fp);
  829. return 0;
  830. }
  831. /*==========================================
  832. // @ command processing functions
  833. *------------------------------------------
  834. */
  835. /*==========================================
  836. * @send (used for testing packet sends from the client)
  837. *------------------------------------------
  838. */
  839. int atcommand_send(
  840. const int fd, struct map_session_data* sd,
  841. const char* command, const char* message)
  842. {
  843. int a = atoi(message);
  844. if (a)
  845. {
  846. unsigned char buf[1024];
  847. switch(a)
  848. {
  849. case 1:
  850. WBUFW(buf,0)=0x18d;
  851. case 2:
  852. WBUFW(buf,0)=0x18e;
  853. case 3:
  854. WBUFW(buf,0)=0x18f;
  855. case 4:
  856. WBUFW(buf,0)=0x190;
  857. }
  858. }
  859. return 0;
  860. }
  861. /*==========================================
  862. * @rura+
  863. *------------------------------------------
  864. */
  865. int atcommand_rurap(
  866. const int fd, struct map_session_data* sd,
  867. const char* command, const char* message)
  868. {
  869. char map_name[100];
  870. char character[100];
  871. int x = 0, y = 0;
  872. struct map_session_data *pl_sd;
  873. int m;
  874. nullpo_retr(-1, sd);
  875. memset(map_name, '\0', sizeof(map_name));
  876. memset(character, '\0', sizeof(character));
  877. if (!message || !*message || sscanf(message, "%99s %d %d %99[^\n]", map_name, &x, &y, character) < 4) {
  878. clif_displaymessage(fd, "Usage: @charwarp/@rura+ <mapname> <x> <y> <char name>");
  879. return -1;
  880. }
  881. if (x <= 0)
  882. x = rand() % 399 + 1;
  883. if (y <= 0)
  884. y = rand() % 399 + 1;
  885. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  886. strcat(map_name, ".gat");
  887. if ((pl_sd = map_nick2sd(character)) != NULL) {
  888. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can rura+ only lower or same GM level
  889. if (x > 0 && x < 400 && y > 0 && y < 400) {
  890. m = map_mapname2mapid(map_name);
  891. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  892. clif_displaymessage(fd, "You are not authorised to warp someone to this map.");
  893. return -1;
  894. }
  895. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  896. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  897. return -1;
  898. }
  899. if (pc_setpos(pl_sd, map_name, x, y, 3) == 0) {
  900. clif_displaymessage(pl_sd->fd, msg_table[0]); // Warped.
  901. clif_displaymessage(fd, msg_table[15]); // Player warped (message sends to player too).
  902. } else {
  903. clif_displaymessage(fd, msg_table[1]); // Map not found.
  904. return -1;
  905. }
  906. } else {
  907. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  908. return -1;
  909. }
  910. } else {
  911. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  912. return -1;
  913. }
  914. } else {
  915. clif_displaymessage(fd, msg_table[3]); // Character not found.
  916. return -1;
  917. }
  918. return 0;
  919. }
  920. // @rura
  921. /*==========================================
  922. *
  923. *------------------------------------------
  924. */
  925. int atcommand_rura(
  926. const int fd, struct map_session_data* sd,
  927. const char* command, const char* message)
  928. {
  929. char map_name[100];
  930. int x = 0, y = 0;
  931. int m;
  932. nullpo_retr(-1, sd);
  933. memset(map_name, '\0', sizeof(map_name));
  934. if (!message || !*message || sscanf(message, "%99s %d %d", map_name, &x, &y) < 1) {
  935. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  936. return -1;
  937. }
  938. if (x <= 0)
  939. x = rand() % 399 + 1;
  940. if (y <= 0)
  941. y = rand() % 399 + 1;
  942. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  943. strcat(map_name, ".gat");
  944. if (x > 0 && x < 400 && y > 0 && y < 400) {
  945. m = map_mapname2mapid(map_name);
  946. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  947. clif_displaymessage(fd, "You are not authorised to warp you to this map.");
  948. return -1;
  949. }
  950. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  951. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  952. return -1;
  953. }
  954. if (pc_setpos(sd, map_name, x, y, 3) == 0)
  955. clif_displaymessage(fd, msg_table[0]); // Warped.
  956. else {
  957. clif_displaymessage(fd, msg_table[1]); // Map not found.
  958. return -1;
  959. }
  960. } else {
  961. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  962. return -1;
  963. }
  964. return 0;
  965. }
  966. /*==========================================
  967. *
  968. *------------------------------------------
  969. */
  970. int atcommand_where(
  971. const int fd, struct map_session_data* sd,
  972. const char* command, const char* message)
  973. {
  974. char character[100];
  975. char output[200];
  976. struct map_session_data *pl_sd = NULL;
  977. nullpo_retr(-1, sd);
  978. if (!message || !*message)
  979. return -1;
  980. memset(character, '\0', sizeof character);
  981. if (sscanf(message, "%99[^\n]", character) < 1)
  982. return -1;
  983. if(strncmp(sd->status.name,character,24)==0)
  984. return -1;
  985. if ((pl_sd = map_nick2sd(character)) == NULL) {
  986. snprintf(output, sizeof output, "%s %d %d",
  987. sd->mapname, sd->bl.x, sd->bl.y);
  988. clif_displaymessage(fd, output);
  989. return -1;
  990. }
  991. snprintf(output, sizeof output, "%s %s %d %d",
  992. character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  993. clif_displaymessage(fd, output);
  994. return 0;
  995. }
  996. /*==========================================
  997. *
  998. *------------------------------------------
  999. */
  1000. int atcommand_jumpto(
  1001. const int fd, struct map_session_data* sd,
  1002. const char* command, const char* message)
  1003. {
  1004. char character[100];
  1005. char output[200];
  1006. struct map_session_data *pl_sd = NULL;
  1007. nullpo_retr(-1, sd);
  1008. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1009. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1010. return -1;
  1011. }
  1012. memset(character, '\0', sizeof character);
  1013. if (sscanf(message, "%99[^\n]", character) < 1)
  1014. return -1;
  1015. if(strncmp(sd->status.name,character,24)==0) //Yourself mate? Tsk tsk tsk.
  1016. return -1;
  1017. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1018. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1019. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  1020. return -1;
  1021. }
  1022. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1023. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1024. return -1;
  1025. }
  1026. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  1027. sprintf(output, msg_table[4], character); // Jump to %s
  1028. clif_displaymessage(fd, output);
  1029. } else {
  1030. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1031. return -1;
  1032. }
  1033. return 0;
  1034. }
  1035. /*==========================================
  1036. *
  1037. *------------------------------------------
  1038. */
  1039. int atcommand_jump(
  1040. const int fd, struct map_session_data* sd,
  1041. const char* command, const char* message)
  1042. {
  1043. char output[200];
  1044. int x = 0, y = 0;
  1045. nullpo_retr(-1, sd);
  1046. memset(output, '\0', sizeof(output));
  1047. sscanf(message, "%d %d", &x, &y);
  1048. if (x <= 0)
  1049. x = rand() % 399 + 1;
  1050. if (y <= 0)
  1051. y = rand() % 399 + 1;
  1052. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1053. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1054. clif_displaymessage(fd, "You are not authorised to warp you to your actual map.");
  1055. return -1;
  1056. }
  1057. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1058. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1059. return -1;
  1060. }
  1061. pc_setpos(sd, sd->mapname, x, y, 3);
  1062. sprintf(output, msg_table[5], x, y); // Jump to %d %d
  1063. clif_displaymessage(fd, output);
  1064. } else {
  1065. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1066. return -1;
  1067. }
  1068. return 0;
  1069. }
  1070. /*==========================================
  1071. *
  1072. *------------------------------------------
  1073. */
  1074. int atcommand_who(
  1075. const int fd, struct map_session_data* sd,
  1076. const char* command, const char* message)
  1077. {
  1078. char output[200];
  1079. struct map_session_data *pl_sd;
  1080. int i, j, count;
  1081. int pl_GM_level, GM_level;
  1082. char match_text[100];
  1083. char player_name[24];
  1084. nullpo_retr(-1, sd);
  1085. memset(output, '\0', sizeof(output));
  1086. memset(match_text, '\0', sizeof(match_text));
  1087. memset(player_name, '\0', sizeof(player_name));
  1088. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1089. strcpy(match_text, "");
  1090. for (j = 0; match_text[j]; j++)
  1091. match_text[j] = tolower(match_text[j]);
  1092. count = 0;
  1093. GM_level = pc_isGM(sd);
  1094. for (i = 0; i < fd_max; i++) {
  1095. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1096. pl_GM_level = pc_isGM(pl_sd);
  1097. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1098. memcpy(player_name, pl_sd->status.name, 24);
  1099. for (j = 0; player_name[j]; j++)
  1100. player_name[j] = tolower(player_name[j]);
  1101. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1102. if (pl_GM_level > 0)
  1103. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1104. else
  1105. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1106. clif_displaymessage(fd, output);
  1107. count++;
  1108. }
  1109. }
  1110. }
  1111. }
  1112. if (count == 0)
  1113. clif_displaymessage(fd, msg_table[28]); // No player found.
  1114. else if (count == 1)
  1115. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1116. else {
  1117. sprintf(output, msg_table[30], count); // %d players found.
  1118. clif_displaymessage(fd, output);
  1119. }
  1120. return 0;
  1121. }
  1122. /*==========================================
  1123. *
  1124. *------------------------------------------
  1125. */
  1126. int atcommand_who2(
  1127. const int fd, struct map_session_data* sd,
  1128. const char* command, const char* message)
  1129. {
  1130. char output[200];
  1131. struct map_session_data *pl_sd;
  1132. int i, j, count;
  1133. int pl_GM_level, GM_level;
  1134. char match_text[100];
  1135. char player_name[24];
  1136. nullpo_retr(-1, sd);
  1137. memset(output, '\0', sizeof(output));
  1138. memset(match_text, '\0', sizeof(match_text));
  1139. memset(player_name, '\0', sizeof(player_name));
  1140. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1141. strcpy(match_text, "");
  1142. for (j = 0; match_text[j]; j++)
  1143. match_text[j] = tolower(match_text[j]);
  1144. count = 0;
  1145. GM_level = pc_isGM(sd);
  1146. for (i = 0; i < fd_max; i++) {
  1147. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1148. pl_GM_level = pc_isGM(pl_sd);
  1149. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1150. memcpy(player_name, pl_sd->status.name, 24);
  1151. for (j = 0; player_name[j]; j++)
  1152. player_name[j] = tolower(player_name[j]);
  1153. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1154. if (pl_GM_level > 0)
  1155. sprintf(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);
  1156. else
  1157. sprintf(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);
  1158. clif_displaymessage(fd, output);
  1159. count++;
  1160. }
  1161. }
  1162. }
  1163. }
  1164. if (count == 0)
  1165. clif_displaymessage(fd, msg_table[28]); // No player found.
  1166. else if (count == 1)
  1167. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1168. else {
  1169. sprintf(output, msg_table[30], count); // %d players found.
  1170. clif_displaymessage(fd, output);
  1171. }
  1172. return 0;
  1173. }
  1174. /*==========================================
  1175. *
  1176. *------------------------------------------
  1177. */
  1178. int atcommand_who3(
  1179. const int fd, struct map_session_data* sd,
  1180. const char* command, const char* message)
  1181. {
  1182. char temp0[100];
  1183. char temp1[100];
  1184. char output[200];
  1185. struct map_session_data *pl_sd;
  1186. int i, j, count;
  1187. int pl_GM_level, GM_level;
  1188. char match_text[100];
  1189. char player_name[24];
  1190. struct guild *g;
  1191. struct party *p;
  1192. nullpo_retr(-1, sd);
  1193. memset(temp0, '\0', sizeof(temp0));
  1194. memset(temp1, '\0', sizeof(temp1));
  1195. memset(output, '\0', sizeof(output));
  1196. memset(match_text, '\0', sizeof(match_text));
  1197. memset(player_name, '\0', sizeof(player_name));
  1198. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1199. strcpy(match_text, "");
  1200. for (j = 0; match_text[j]; j++)
  1201. match_text[j] = tolower(match_text[j]);
  1202. count = 0;
  1203. GM_level = pc_isGM(sd);
  1204. for (i = 0; i < fd_max; i++) {
  1205. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1206. pl_GM_level = pc_isGM(pl_sd);
  1207. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1208. memcpy(player_name, pl_sd->status.name, 24);
  1209. for (j = 0; player_name[j]; j++)
  1210. player_name[j] = tolower(player_name[j]);
  1211. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1212. g = guild_search(pl_sd->status.guild_id);
  1213. if (g == NULL)
  1214. sprintf(temp1, "None");
  1215. else
  1216. sprintf(temp1, "%s", g->name);
  1217. p = party_search(pl_sd->status.party_id);
  1218. if (p == NULL)
  1219. sprintf(temp0, "None");
  1220. else
  1221. sprintf(temp0, "%s", p->name);
  1222. if (pl_GM_level > 0)
  1223. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1224. else
  1225. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1226. clif_displaymessage(fd, output);
  1227. count++;
  1228. }
  1229. }
  1230. }
  1231. }
  1232. if (count == 0)
  1233. clif_displaymessage(fd, msg_table[28]); // No player found.
  1234. else if (count == 1)
  1235. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1236. else {
  1237. sprintf(output, msg_table[30], count); // %d players found.
  1238. clif_displaymessage(fd, output);
  1239. }
  1240. return 0;
  1241. }
  1242. /*==========================================
  1243. *
  1244. *------------------------------------------
  1245. */
  1246. int atcommand_whomap(
  1247. const int fd, struct map_session_data* sd,
  1248. const char* command, const char* message)
  1249. {
  1250. char output[200];
  1251. struct map_session_data *pl_sd;
  1252. int i, count;
  1253. int pl_GM_level, GM_level;
  1254. int map_id;
  1255. char map_name[100];
  1256. memset(output, '\0', sizeof(output));
  1257. memset(map_name, '\0', sizeof(map_name));
  1258. if (!message || !*message)
  1259. map_id = sd->bl.m;
  1260. else {
  1261. sscanf(message, "%99s", map_name);
  1262. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1263. strcat(map_name, ".gat");
  1264. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1265. map_id = sd->bl.m;
  1266. }
  1267. count = 0;
  1268. GM_level = pc_isGM(sd);
  1269. for (i = 0; i < fd_max; i++) {
  1270. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1271. pl_GM_level = pc_isGM(pl_sd);
  1272. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1273. if (pl_sd->bl.m == map_id) {
  1274. if (pl_GM_level > 0)
  1275. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1276. else
  1277. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1278. clif_displaymessage(fd, output);
  1279. count++;
  1280. }
  1281. }
  1282. }
  1283. }
  1284. if (count == 0)
  1285. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1286. else if (count == 1)
  1287. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1288. else {
  1289. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1290. }
  1291. clif_displaymessage(fd, output);
  1292. return 0;
  1293. }
  1294. /*==========================================
  1295. *
  1296. *------------------------------------------
  1297. */
  1298. int atcommand_whomap2(
  1299. const int fd, struct map_session_data* sd,
  1300. const char* command, const char* message)
  1301. {
  1302. char output[200];
  1303. struct map_session_data *pl_sd;
  1304. int i, count;
  1305. int pl_GM_level, GM_level;
  1306. int map_id = 0;
  1307. char map_name[100];
  1308. nullpo_retr(-1, sd);
  1309. memset(output, '\0', sizeof(output));
  1310. memset(map_name, '\0', sizeof(map_name));
  1311. if (!message || !*message)
  1312. map_id = sd->bl.m;
  1313. else {
  1314. sscanf(message, "%99s", map_name);
  1315. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1316. strcat(map_name, ".gat");
  1317. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1318. map_id = sd->bl.m;
  1319. }
  1320. count = 0;
  1321. GM_level = pc_isGM(sd);
  1322. for (i = 0; i < fd_max; i++) {
  1323. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1324. pl_GM_level = pc_isGM(pl_sd);
  1325. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1326. if (pl_sd->bl.m == map_id) {
  1327. if (pl_GM_level > 0)
  1328. sprintf(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);
  1329. else
  1330. sprintf(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);
  1331. clif_displaymessage(fd, output);
  1332. count++;
  1333. }
  1334. }
  1335. }
  1336. }
  1337. if (count == 0)
  1338. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1339. else if (count == 1)
  1340. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1341. else {
  1342. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1343. }
  1344. clif_displaymessage(fd, output);
  1345. return 0;
  1346. }
  1347. /*==========================================
  1348. *
  1349. *------------------------------------------
  1350. */
  1351. int atcommand_whomap3(
  1352. const int fd, struct map_session_data* sd,
  1353. const char* command, const char* message)
  1354. {
  1355. char temp0[100];
  1356. char temp1[100];
  1357. char output[200];
  1358. struct map_session_data *pl_sd;
  1359. int i, count;
  1360. int pl_GM_level, GM_level;
  1361. int map_id = 0;
  1362. char map_name[100];
  1363. struct guild *g;
  1364. struct party *p;
  1365. nullpo_retr(-1, sd);
  1366. memset(temp0, '\0', sizeof(temp0));
  1367. memset(temp1, '\0', sizeof(temp1));
  1368. memset(output, '\0', sizeof(output));
  1369. memset(map_name, '\0', sizeof(map_name));
  1370. if (!message || !*message)
  1371. map_id = sd->bl.m;
  1372. else {
  1373. sscanf(message, "%99s", map_name);
  1374. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1375. strcat(map_name, ".gat");
  1376. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1377. map_id = sd->bl.m;
  1378. }
  1379. count = 0;
  1380. GM_level = pc_isGM(sd);
  1381. for (i = 0; i < fd_max; i++) {
  1382. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1383. pl_GM_level = pc_isGM(pl_sd);
  1384. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1385. if (pl_sd->bl.m == map_id) {
  1386. g = guild_search(pl_sd->status.guild_id);
  1387. if (g == NULL)
  1388. sprintf(temp1, "None");
  1389. else
  1390. sprintf(temp1, "%s", g->name);
  1391. p = party_search(pl_sd->status.party_id);
  1392. if (p == NULL)
  1393. sprintf(temp0, "None");
  1394. else
  1395. sprintf(temp0, "%s", p->name);
  1396. if (pl_GM_level > 0)
  1397. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1398. else
  1399. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1400. clif_displaymessage(fd, output);
  1401. count++;
  1402. }
  1403. }
  1404. }
  1405. }
  1406. if (count == 0)
  1407. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1408. else if (count == 1)
  1409. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1410. else {
  1411. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1412. }
  1413. clif_displaymessage(fd, output);
  1414. return 0;
  1415. }
  1416. /*==========================================
  1417. *
  1418. *------------------------------------------
  1419. */
  1420. int atcommand_whogm(
  1421. const int fd, struct map_session_data* sd,
  1422. const char* command, const char* message)
  1423. {
  1424. char temp0[100];
  1425. char temp1[100];
  1426. char output[200];
  1427. struct map_session_data *pl_sd;
  1428. int i, j, count;
  1429. int pl_GM_level, GM_level;
  1430. char match_text[100];
  1431. char player_name[24];
  1432. struct guild *g;
  1433. struct party *p;
  1434. nullpo_retr(-1, sd);
  1435. memset(temp0, '\0', sizeof(temp0));
  1436. memset(temp1, '\0', sizeof(temp1));
  1437. memset(output, '\0', sizeof(output));
  1438. memset(match_text, '\0', sizeof(match_text));
  1439. memset(player_name, '\0', sizeof(player_name));
  1440. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1441. strcpy(match_text, "");
  1442. for (j = 0; match_text[j]; j++)
  1443. match_text[j] = tolower(match_text[j]);
  1444. count = 0;
  1445. GM_level = pc_isGM(sd);
  1446. for (i = 0; i < fd_max; i++) {
  1447. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1448. pl_GM_level = pc_isGM(pl_sd);
  1449. if (pl_GM_level > 0) {
  1450. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1451. memcpy(player_name, pl_sd->status.name, 24);
  1452. for (j = 0; player_name[j]; j++)
  1453. player_name[j] = tolower(player_name[j]);
  1454. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1455. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1456. clif_displaymessage(fd, output);
  1457. sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level);
  1458. clif_displaymessage(fd, output);
  1459. g = guild_search(pl_sd->status.guild_id);
  1460. if (g == NULL)
  1461. sprintf(temp1, "None");
  1462. else
  1463. sprintf(temp1, "%s", g->name);
  1464. p = party_search(pl_sd->status.party_id);
  1465. if (p == NULL)
  1466. sprintf(temp0, "None");
  1467. else
  1468. sprintf(temp0, "%s", p->name);
  1469. sprintf(output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1470. clif_displaymessage(fd, output);
  1471. count++;
  1472. }
  1473. }
  1474. }
  1475. }
  1476. }
  1477. if (count == 0)
  1478. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1479. else if (count == 1)
  1480. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1481. else {
  1482. sprintf(output, msg_table[152], count); // %d GMs found.
  1483. clif_displaymessage(fd, output);
  1484. }
  1485. return 0;
  1486. }
  1487. int atcommand_whozeny(
  1488. const int fd, struct map_session_data* sd,
  1489. const char* command, const char* message)
  1490. {
  1491. char output[200];
  1492. struct map_session_data *pl_sd;
  1493. int i, j, count,c;
  1494. char match_text[100];
  1495. char player_name[24];
  1496. int zeny[clif_countusers()];
  1497. int counted[clif_countusers()];
  1498. nullpo_retr(-1, sd);
  1499. memset(output, '\0', sizeof(output));
  1500. memset(match_text, '\0', sizeof(match_text));
  1501. memset(player_name, '\0', sizeof(player_name));
  1502. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1503. strcpy(match_text, "");
  1504. for (j = 0; match_text[j]; j++)
  1505. match_text[j] = tolower(match_text[j]);
  1506. count = 0;
  1507. for (i = 0; i < fd_max; i++) {
  1508. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1509. memcpy(player_name, pl_sd->status.name, 24);
  1510. for (j = 0; player_name[j]; j++)
  1511. player_name[j] = tolower(player_name[j]);
  1512. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1513. zeny[count]=pl_sd->status.zeny;
  1514. counted[i]=0;
  1515. count++;
  1516. }
  1517. }
  1518. }
  1519. qsort(zeny, count, sizeof(int), hightolow_compare);
  1520. for (c = 0; c < count && c < 50; c++) {
  1521. if(!zeny[c])
  1522. continue;
  1523. for (i = 0; i < fd_max; i++) {
  1524. if(!zeny[c])
  1525. continue;
  1526. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && zeny[c] && counted[i]==0) {
  1527. if(pl_sd->status.zeny==zeny[c]) {
  1528. sprintf(output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1529. clif_displaymessage(fd, output);
  1530. zeny[c]=0;
  1531. counted[i]=1;
  1532. }
  1533. }
  1534. }
  1535. }
  1536. if (count == 0)
  1537. clif_displaymessage(fd, msg_table[28]); // No player found.
  1538. else if (count == 1)
  1539. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1540. else {
  1541. sprintf(output, msg_table[30], count); // %d players found.
  1542. clif_displaymessage(fd, output);
  1543. }
  1544. return 0;
  1545. }
  1546. // cause random emote on all online players [Valaris]
  1547. int atcommand_happyhappyjoyjoy(
  1548. const int fd, struct map_session_data* sd,
  1549. const char* command, const char* message)
  1550. {
  1551. struct map_session_data *pl_sd;
  1552. int i,e;
  1553. nullpo_retr(-1, sd);
  1554. for (i = 0; i < fd_max; i++) {
  1555. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1556. e=rand()%40;
  1557. if(e==34)
  1558. e = 0;
  1559. clif_emotion(&pl_sd->bl,e);
  1560. }
  1561. }
  1562. return 0;
  1563. }
  1564. /*==========================================
  1565. *
  1566. *------------------------------------------
  1567. */
  1568. int atcommand_save(
  1569. const int fd, struct map_session_data* sd,
  1570. const char* command, const char* message)
  1571. {
  1572. nullpo_retr(-1, sd);
  1573. pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y);
  1574. if (sd->status.pet_id > 0 && sd->pd)
  1575. intif_save_petdata(sd->status.account_id, &sd->pet);
  1576. pc_makesavestatus(sd);
  1577. chrif_save(sd);
  1578. storage_storage_save(sd);
  1579. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1580. return 0;
  1581. }
  1582. /*==========================================
  1583. *
  1584. *------------------------------------------
  1585. */
  1586. int atcommand_load(
  1587. const int fd, struct map_session_data* sd,
  1588. const char* command, const char* message)
  1589. {
  1590. int m;
  1591. nullpo_retr(-1, sd);
  1592. m = map_mapname2mapid(sd->status.save_point.map);
  1593. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1594. clif_displaymessage(fd, "You are not authorised to warp you to your save map.");
  1595. return -1;
  1596. }
  1597. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1598. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1599. return -1;
  1600. }
  1601. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1602. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1603. return 0;
  1604. }
  1605. /*==========================================
  1606. *
  1607. *------------------------------------------
  1608. */
  1609. int atcommand_speed(
  1610. const int fd, struct map_session_data* sd,
  1611. const char* command, const char* message)
  1612. {
  1613. char output[200];
  1614. int speed;
  1615. nullpo_retr(-1, sd);
  1616. memset(output, '\0', sizeof(output));
  1617. if (!message || !*message) {
  1618. sprintf(output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1619. clif_displaymessage(fd, output);
  1620. return -1;
  1621. }
  1622. speed = atoi(message);
  1623. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1624. sd->speed = speed;
  1625. //sd->walktimer = x;
  1626. //この文を追加 by れ�
  1627. clif_updatestatus(sd, SP_SPEED);
  1628. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1629. } else {
  1630. sprintf(output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1631. clif_displaymessage(fd, output);
  1632. return -1;
  1633. }
  1634. return 0;
  1635. }
  1636. /*==========================================
  1637. *
  1638. *------------------------------------------
  1639. */
  1640. int atcommand_storage(
  1641. const int fd, struct map_session_data* sd,
  1642. const char* command, const char* message)
  1643. {
  1644. nullpo_retr(-1, sd);
  1645. storage_storageopen(sd);
  1646. return 0;
  1647. }
  1648. /*==========================================
  1649. *
  1650. *------------------------------------------
  1651. */
  1652. int atcommand_guildstorage(
  1653. const int fd, struct map_session_data* sd,
  1654. const char* command, const char* message)
  1655. {
  1656. nullpo_retr(-1, sd);
  1657. if (sd->status.guild_id > 0)
  1658. storage_guild_storageopen(sd);
  1659. return 0;
  1660. }
  1661. /*==========================================
  1662. *
  1663. *------------------------------------------
  1664. */
  1665. int atcommand_option(
  1666. const int fd, struct map_session_data* sd,
  1667. const char* command, const char* message)
  1668. {
  1669. int param1 = 0, param2 = 0, param3 = 0;
  1670. nullpo_retr(-1, sd);
  1671. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1672. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1673. return -1;
  1674. }
  1675. sd->opt1 = param1;
  1676. sd->opt2 = param2;
  1677. if (!(sd->status.option & CART_MASK) && param3 & CART_MASK) {
  1678. clif_cart_itemlist(sd);
  1679. clif_cart_equiplist(sd);
  1680. clif_updatestatus(sd, SP_CARTINFO);
  1681. }
  1682. sd->status.option = param3;
  1683. // fix pecopeco display
  1684. if (sd->status.class == 13 || sd->status.class == 21 || sd->status.class == 4014 || sd->status.class == 4022) {
  1685. if (!pc_isriding(sd)) { // sd have the new value...
  1686. if (sd->status.class == 13)
  1687. sd->status.class = sd->view_class = 7;
  1688. else if (sd->status.class == 21)
  1689. sd->status.class = sd->view_class = 14;
  1690. else if (sd->status.class == 4014)
  1691. sd->status.class = sd->view_class = 4008;
  1692. else if (sd->status.class == 4022)
  1693. sd->status.class = sd->view_class = 4015;
  1694. }
  1695. } else {
  1696. if (pc_isriding(sd)) { // sd have the new value...
  1697. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  1698. sd->status.option &= ~0x0020;
  1699. } else {
  1700. if (sd->status.class == 7)
  1701. sd->status.class = sd->view_class = 13;
  1702. else if (sd->status.class == 14)
  1703. sd->status.class = sd->view_class = 21;
  1704. else if (sd->status.class == 4008)
  1705. sd->status.class = sd->view_class = 4014;
  1706. else if (sd->status.class == 4015)
  1707. sd->status.class = sd->view_class = 4022;
  1708. else
  1709. sd->status.option &= ~0x0020;
  1710. }
  1711. }
  1712. }
  1713. clif_changeoption(&sd->bl);
  1714. pc_calcstatus(sd, 0);
  1715. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1716. return 0;
  1717. }
  1718. /*==========================================
  1719. *
  1720. *------------------------------------------
  1721. */
  1722. int atcommand_hide(
  1723. const int fd, struct map_session_data* sd,
  1724. const char* command, const char* message)
  1725. {
  1726. nullpo_retr(-1, sd);
  1727. if (sd->status.option & OPTION_HIDE) {
  1728. sd->status.option &= ~OPTION_HIDE;
  1729. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1730. } else {
  1731. sd->status.option |= OPTION_HIDE;
  1732. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1733. }
  1734. clif_changeoption(&sd->bl);
  1735. return 0;
  1736. }
  1737. /*==========================================
  1738. * 転職する upperを指定すると転生や養子にもなれる
  1739. *------------------------------------------
  1740. */
  1741. int atcommand_jobchange(
  1742. const int fd, struct map_session_data* sd,
  1743. const char* command, const char* message)
  1744. {
  1745. int job = 0, upper = -1;
  1746. nullpo_retr(-1, sd);
  1747. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1748. int i, found = 0;
  1749. const struct { char name[16]; int id; } jobs[] = {
  1750. { "novice", 0 },
  1751. { "swordsman", 1 },
  1752. { "mage", 2 },
  1753. { "archer", 3 },
  1754. { "acolyte", 4 },
  1755. { "merchant", 5 },
  1756. { "thief", 6 },
  1757. { "knight", 7 },
  1758. { "priest", 8 },
  1759. { "priestess", 8 },
  1760. { "wizard", 9 },
  1761. { "blacksmith", 10 },
  1762. { "hunter", 11 },
  1763. { "assassin", 12 },
  1764. { "crusader", 14 },
  1765. { "monk", 15 },
  1766. { "sage", 16 },
  1767. { "rogue", 17 },
  1768. { "alchemist", 18 },
  1769. { "bard", 19 },
  1770. { "dancer", 20 },
  1771. { "super novice", 23 },
  1772. { "supernovice", 23 },
  1773. { "high novice", 4001 },
  1774. { "swordsman high", 4002 },
  1775. { "mage high", 4003 },
  1776. { "archer high", 4004 },
  1777. { "acolyte high", 4005 },
  1778. { "merchant high", 4006 },
  1779. { "thief high", 4007 },
  1780. { "lord knight", 4008 },
  1781. { "high priest", 4009 },
  1782. { "high priestess", 4009 },
  1783. { "high wizard", 4010 },
  1784. { "whitesmith", 4011 },
  1785. { "sniper", 4012 },
  1786. { "assassin cross", 4013 },
  1787. { "paladin", 4015 },
  1788. { "champion", 4016 },
  1789. { "professor", 4017 },
  1790. { "stalker", 4018 },
  1791. { "creator", 4019 },
  1792. { "clown", 4020 },
  1793. { "gypsy", 4021 },
  1794. { "baby novice", 4023 },
  1795. { "baby swordsman", 4024 },
  1796. { "baby mage", 4025 },
  1797. { "baby archer", 4026 },
  1798. { "baby acolyte", 4027 },
  1799. { "baby merchant", 4028 },
  1800. { "baby thief", 4029 },
  1801. { "baby knight", 4030 },
  1802. { "baby priest", 4031 },
  1803. { "baby priestess", 4031 },
  1804. { "baby wizard", 4032 },
  1805. { "baby blacksmith",4033 },
  1806. { "baby hunter", 4034 },
  1807. { "baby assassin", 4035 },
  1808. { "baby crusader", 4037 },
  1809. { "baby monk", 4038 },
  1810. { "baby sage", 4039 },
  1811. { "baby rogue", 4040 },
  1812. { "baby alchemist", 4041 },
  1813. { "baby bard", 4042 },
  1814. { "baby dancer", 4043 },
  1815. { "super baby", 4045 },
  1816. };
  1817. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  1818. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1819. job = jobs[i].id;
  1820. upper = 0;
  1821. found = 1;
  1822. break;
  1823. }
  1824. }
  1825. if (!found) {
  1826. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  1827. return -1;
  1828. }
  1829. }
  1830. if (job == 37 ||job == 45)
  1831. return 0;
  1832. if ((job >= 0 && job < MAX_PC_CLASS)) {
  1833. int j;
  1834. // fix pecopeco display
  1835. if ((job != 13 && job != 21 && job != 4014 && job != 4022)) {
  1836. if (pc_isriding(sd)) {
  1837. if (sd->status.class == 13)
  1838. sd->status.class = sd->view_class = 7;
  1839. if (sd->status.class == 21)
  1840. sd->status.class = sd->view_class = 14;
  1841. if (sd->status.class == 4014)
  1842. sd->status.class = sd->view_class = 4008;
  1843. if (sd->status.class == 4022)
  1844. sd->status.class = sd->view_class = 4015;
  1845. sd->status.option &= ~0x0020;
  1846. clif_changeoption(&sd->bl);
  1847. pc_calcstatus(sd, 0);
  1848. }
  1849. } else {
  1850. if (!pc_isriding(sd)) {
  1851. if (job == 13)
  1852. job = 7;
  1853. if (job == 21)
  1854. job = 14;
  1855. if (job == 4014)
  1856. job = 4008;
  1857. if (job == 4022)
  1858. job = 4015;
  1859. }
  1860. }
  1861. for (j=0; j < MAX_INVENTORY; j++) {
  1862. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  1863. pc_unequipitem(sd, j, 3);
  1864. }
  1865. if (pc_jobchange(sd, job, upper) == 0)
  1866. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  1867. else {
  1868. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  1869. return -1;
  1870. }
  1871. } else {
  1872. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  1873. return -1;
  1874. }
  1875. return 0;
  1876. }
  1877. /*==========================================
  1878. *
  1879. *------------------------------------------
  1880. */
  1881. int atcommand_die(
  1882. const int fd, struct map_session_data* sd,
  1883. const char* command, const char* message)
  1884. {
  1885. nullpo_retr(-1, sd);
  1886. clif_specialeffect(&sd->bl,450,1);
  1887. pc_damage(NULL, sd, sd->status.hp + 1);
  1888. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  1889. return 0;
  1890. }
  1891. /*==========================================
  1892. *
  1893. *------------------------------------------
  1894. */
  1895. int atcommand_kill(
  1896. const int fd, struct map_session_data* sd,
  1897. const char* command, const char* message)
  1898. {
  1899. char character[100];
  1900. struct map_session_data *pl_sd;
  1901. nullpo_retr(-1, sd);
  1902. memset(character, '\0', sizeof(character));
  1903. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1904. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  1905. return -1;
  1906. }
  1907. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1908. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  1909. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  1910. clif_displaymessage(fd, msg_table[14]); // Character killed.
  1911. } else {
  1912. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1913. return -1;
  1914. }
  1915. } else {
  1916. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1917. return -1;
  1918. }
  1919. return 0;
  1920. }
  1921. /*==========================================
  1922. *
  1923. *------------------------------------------
  1924. */
  1925. int atcommand_alive(
  1926. const int fd, struct map_session_data* sd,
  1927. const char* command, const char* message)
  1928. {
  1929. nullpo_retr(-1, sd);
  1930. if (pc_isdead(sd)) {
  1931. sd->status.hp = sd->status.max_hp;
  1932. sd->status.sp = sd->status.max_sp;
  1933. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1934. pc_setstand(sd);
  1935. if (battle_config.pc_invincible_time > 0)
  1936. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  1937. clif_updatestatus(sd, SP_HP);
  1938. clif_updatestatus(sd, SP_SP);
  1939. clif_resurrection(&sd->bl, 1);
  1940. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  1941. return 0;
  1942. }
  1943. return -1;
  1944. }
  1945. /*==========================================
  1946. *
  1947. *------------------------------------------
  1948. */
  1949. int atcommand_kami(
  1950. const int fd, struct map_session_data* sd,
  1951. const char* command, const char* message)
  1952. {
  1953. char output[200];
  1954. nullpo_retr(-1, sd);
  1955. memset(output, '\0', sizeof(output));
  1956. if (!message || !*message) {
  1957. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1958. return -1;
  1959. }
  1960. sscanf(message, "%199[^\n]", output);
  1961. intif_GMmessage(output, strlen(output) + 1, (*(command + 5) == 'b') ? 0x10 : 0);
  1962. return 0;
  1963. }
  1964. /*==========================================
  1965. *
  1966. *------------------------------------------
  1967. */
  1968. int atcommand_heal(
  1969. const int fd, struct map_session_data* sd,
  1970. const char* command, const char* message)
  1971. {
  1972. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1973. nullpo_retr(-1, sd);
  1974. sscanf(message, "%d %d", &hp, &sp);
  1975. if (hp == 0 && sp == 0) {
  1976. hp = sd->status.max_hp - sd->status.hp;
  1977. sp = sd->status.max_sp - sd->status.sp;
  1978. } else {
  1979. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  1980. hp = sd->status.max_hp - sd->status.hp;
  1981. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  1982. hp = 1 - sd->status.hp;
  1983. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  1984. sp = sd->status.max_sp - sd->status.sp;
  1985. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  1986. sp = 1 - sd->status.sp;
  1987. }
  1988. if (hp > 0) // display like heal
  1989. clif_heal(fd, SP_HP, hp);
  1990. else if (hp < 0) // display like damage
  1991. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1992. if (sp > 0) // no display when we lost SP
  1993. clif_heal(fd, SP_SP, sp);
  1994. if (hp != 0 || sp != 0) {
  1995. pc_heal(sd, hp, sp);
  1996. if (hp >= 0 && sp >= 0)
  1997. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  1998. else
  1999. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2000. } else {
  2001. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2002. return -1;
  2003. }
  2004. return 0;
  2005. }
  2006. /*==========================================
  2007. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2008. *------------------------------------------
  2009. */
  2010. int atcommand_item(
  2011. const int fd, struct map_session_data* sd,
  2012. const char* command, const char* message)
  2013. {
  2014. char item_name[100];
  2015. int number = 0, item_id, flag;
  2016. struct item item_tmp;
  2017. struct item_data *item_data;
  2018. int get_count, i, pet_id;
  2019. nullpo_retr(-1, sd);
  2020. memset(item_name, '\0', sizeof(item_name));
  2021. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2022. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2023. return -1;
  2024. }
  2025. if (number <= 0)
  2026. number = 1;
  2027. item_id = 0;
  2028. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2029. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2030. item_id = item_data->nameid;
  2031. if (item_id >= 500) {
  2032. get_count = number;
  2033. // check pet egg
  2034. pet_id = search_petDB_index(item_id, PET_EGG);
  2035. if (item_data->type == 4 || item_data->type == 5 ||
  2036. item_data->type == 7 || item_data->type == 8) {
  2037. get_count = 1;
  2038. }
  2039. for (i = 0; i < number; i += get_count) {
  2040. // if pet egg
  2041. if (pet_id >= 0) {
  2042. sd->catch_target_class = pet_db[pet_id].class;
  2043. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2044. pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
  2045. pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
  2046. 100, 0, 1, pet_db[pet_id].jname);
  2047. // if not pet egg
  2048. } else {
  2049. memset(&item_tmp, 0, sizeof(item_tmp));
  2050. item_tmp.nameid = item_id;
  2051. item_tmp.identify = 1;
  2052. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2053. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2054. }
  2055. }
  2056. clif_displaymessage(fd, msg_table[18]); // Item created.
  2057. } else {
  2058. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2059. return -1;
  2060. }
  2061. return 0;
  2062. }
  2063. /*==========================================
  2064. *
  2065. *------------------------------------------
  2066. */
  2067. int atcommand_item2(
  2068. const int fd, struct map_session_data* sd,
  2069. const char* command, const char* message)
  2070. {
  2071. struct item item_tmp;
  2072. struct item_data *item_data;
  2073. char item_name[100];
  2074. int item_id, number = 0;
  2075. int identify = 0, refine = 0, attr = 0;
  2076. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2077. int flag;
  2078. int loop, get_count, i;
  2079. nullpo_retr(-1, sd);
  2080. memset(item_name, '\0', sizeof(item_name));
  2081. if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
  2082. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2083. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2084. return -1;
  2085. }
  2086. if (number <= 0)
  2087. number = 1;
  2088. item_id = 0;
  2089. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2090. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2091. item_id = item_data->nameid;
  2092. if (item_id > 500) {
  2093. loop = 1;
  2094. get_count = number;
  2095. if (item_data->type == 4 || item_data->type == 5 ||
  2096. item_data->type == 7 || item_data->type == 8) {
  2097. loop = number;
  2098. get_count = 1;
  2099. if (item_data->type == 7) {
  2100. identify = 1;
  2101. refine = 0;
  2102. }
  2103. if (item_data->type == 8)
  2104. refine = 0;
  2105. if (refine > 10)
  2106. refine = 10;
  2107. } else {
  2108. identify = 1;
  2109. refine = attr = 0;
  2110. }
  2111. for (i = 0; i < loop; i++) {
  2112. memset(&item_tmp, 0, sizeof(item_tmp));
  2113. item_tmp.nameid = item_id;
  2114. item_tmp.identify = identify;
  2115. item_tmp.refine = refine;
  2116. item_tmp.attribute = attr;
  2117. item_tmp.card[0] = c1;
  2118. item_tmp.card[1] = c2;
  2119. item_tmp.card[2] = c3;
  2120. item_tmp.card[3] = c4;
  2121. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2122. clif_additem(sd, 0, 0, flag);
  2123. }
  2124. clif_displaymessage(fd, msg_table[18]); // Item created.
  2125. } else {
  2126. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2127. return -1;
  2128. }
  2129. return 0;
  2130. }
  2131. /*==========================================
  2132. *
  2133. *------------------------------------------
  2134. */
  2135. int atcommand_itemreset(
  2136. const int fd, struct map_session_data* sd,
  2137. const char* command, const char* message)
  2138. {
  2139. int i;
  2140. nullpo_retr(-1, sd);
  2141. for (i = 0; i < MAX_INVENTORY; i++) {
  2142. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0)
  2143. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2144. }
  2145. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2146. return 0;
  2147. }
  2148. /*==========================================
  2149. *
  2150. *------------------------------------------
  2151. */
  2152. int atcommand_itemcheck(
  2153. const int fd, struct map_session_data* sd,
  2154. const char* command, const char* message)
  2155. {
  2156. nullpo_retr(-1, sd);
  2157. pc_checkitem(sd);
  2158. return 0;
  2159. }
  2160. /*==========================================
  2161. *
  2162. *------------------------------------------
  2163. */
  2164. int atcommand_baselevelup(
  2165. const int fd, struct map_session_data* sd,
  2166. const char* command, const char* message)
  2167. {
  2168. int level, i;
  2169. nullpo_retr(-1, sd);
  2170. if (!message || !*message || (level = atoi(message)) == 0) {
  2171. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2172. return -1;
  2173. }
  2174. if (level > 0) {
  2175. if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  2176. clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher.
  2177. return -1;
  2178. } // End Addition
  2179. if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
  2180. level = battle_config.maximum_level - sd->status.base_level;
  2181. for (i = 1; i <= level; i++)
  2182. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2183. sd->status.base_level += level;
  2184. clif_updatestatus(sd, SP_BASELEVEL);
  2185. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2186. clif_updatestatus(sd, SP_STATUSPOINT);
  2187. pc_calcstatus(sd, 0);
  2188. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2189. clif_misceffect(&sd->bl, 0);
  2190. clif_displaymessage(fd, msg_table[21]); // Base level raised.
  2191. } else {
  2192. if (sd->status.base_level == 1) {
  2193. clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower.
  2194. return -1;
  2195. }
  2196. if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow
  2197. level = 1 - sd->status.base_level;
  2198. if (sd->status.status_point > 0) {
  2199. for (i = 0; i > level; i--)
  2200. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2201. if (sd->status.status_point < 0)
  2202. sd->status.status_point = 0;
  2203. clif_updatestatus(sd, SP_STATUSPOINT);
  2204. } // to add: remove status points from stats
  2205. sd->status.base_level += level;
  2206. clif_updatestatus(sd, SP_BASELEVEL);
  2207. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2208. pc_calcstatus(sd, 0);
  2209. clif_displaymessage(fd, msg_table[22]); // Base level lowered.
  2210. }
  2211. return 0;
  2212. }
  2213. /*==========================================
  2214. *
  2215. *------------------------------------------
  2216. */
  2217. int atcommand_joblevelup(
  2218. const int fd, struct map_session_data* sd,
  2219. const char* command, const char* message)
  2220. {
  2221. int up_level = 50, level;
  2222. struct pc_base_job s_class;
  2223. nullpo_retr(-1, sd);
  2224. s_class = pc_calc_base_job(sd->status.class);
  2225. if (!message || !*message || (level = atoi(message)) == 0) {
  2226. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2227. return -1;
  2228. }
  2229. if (s_class.job == 0)
  2230. up_level -= 40;
  2231. // super novices can go up to 99 [celest]
  2232. else if (s_class.job == 23)
  2233. up_level += 49;
  2234. else if (sd->status.class > 4007 && sd->status.class < 4023)
  2235. up_level += 20;
  2236. if (level > 0) {
  2237. if (sd->status.job_level == up_level) {
  2238. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2239. return -1;
  2240. }
  2241. if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow
  2242. level = up_level - sd->status.job_level;
  2243. sd->status.job_level += level;
  2244. clif_updatestatus(sd, SP_JOBLEVEL);
  2245. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2246. sd->status.skill_point += level;
  2247. clif_updatestatus(sd, SP_SKILLPOINT);
  2248. pc_calcstatus(sd, 0);
  2249. clif_misceffect(&sd->bl, 1);
  2250. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2251. } else {
  2252. if (sd->status.job_level == 1) {
  2253. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2254. return -1;
  2255. }
  2256. if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow
  2257. level = 1 - sd->status.job_level;
  2258. sd->status.job_level += level;
  2259. clif_updatestatus(sd, SP_JOBLEVEL);
  2260. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2261. if (sd->status.skill_point > 0) {
  2262. sd->status.skill_point += level;
  2263. if (sd->status.skill_point < 0)
  2264. sd->status.skill_point = 0;
  2265. clif_updatestatus(sd, SP_SKILLPOINT);
  2266. } // to add: remove status points from skills
  2267. pc_calcstatus(sd, 0);
  2268. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2269. }
  2270. return 0;
  2271. }
  2272. /*==========================================
  2273. *
  2274. *------------------------------------------
  2275. */
  2276. int atcommand_help(
  2277. const int fd, struct map_session_data* sd,
  2278. const char* command, const char* message)
  2279. {
  2280. char buf[2048], w1[2048], w2[2048];
  2281. int i, gm_level;
  2282. FILE* fp;
  2283. nullpo_retr(-1, sd);
  2284. memset(buf, '\0', sizeof(buf));
  2285. if ((fp = fopen(help_txt, "r")) != NULL) {
  2286. clif_displaymessage(fd, msg_table[26]); // Help commands:
  2287. gm_level = pc_isGM(sd);
  2288. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2289. if (buf[0] == '/' && buf[1] == '/')
  2290. continue;
  2291. for (i = 0; buf[i] != '\0'; i++) {
  2292. if (buf[i] == '\r' || buf[i] == '\n') {
  2293. buf[i] = '\0';
  2294. break;
  2295. }
  2296. }
  2297. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2298. clif_displaymessage(fd, buf);
  2299. else if (gm_level >= atoi(w1))
  2300. clif_displaymessage(fd, w2);
  2301. }
  2302. fclose(fp);
  2303. } else {
  2304. clif_displaymessage(fd, msg_table[27]); // File help.txt not found.
  2305. return -1;
  2306. }
  2307. return 0;
  2308. }
  2309. /*==========================================
  2310. *
  2311. *------------------------------------------
  2312. */
  2313. int atcommand_gm(
  2314. const int fd, struct map_session_data* sd,
  2315. const char* command, const char* message)
  2316. {
  2317. char password[100];
  2318. nullpo_retr(-1, sd);
  2319. memset(password, '\0', sizeof(password));
  2320. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2321. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2322. return -1;
  2323. }
  2324. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  2325. clif_displaymessage(fd, msg_table[50]); // You already have some GM powers.
  2326. return -1;
  2327. } else
  2328. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2329. return 0;
  2330. }
  2331. /*==========================================
  2332. *
  2333. *------------------------------------------
  2334. */
  2335. int atcommand_pvpoff(
  2336. const int fd, struct map_session_data* sd,
  2337. const char* command, const char* message)
  2338. {
  2339. struct map_session_data *pl_sd;
  2340. int i;
  2341. nullpo_retr(-1, sd);
  2342. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2343. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2344. return -1;
  2345. }
  2346. if (map[sd->bl.m].flag.pvp) {
  2347. map[sd->bl.m].flag.pvp = 0;
  2348. clif_send0199(sd->bl.m, 0);
  2349. for (i = 0; i < fd_max; i++) { //人数分ループ
  2350. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2351. if (sd->bl.m == pl_sd->bl.m) {
  2352. clif_pvpset(pl_sd, 0, 0, 2);
  2353. if (pl_sd->pvp_timer != -1) {
  2354. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2355. pl_sd->pvp_timer = -1;
  2356. }
  2357. }
  2358. }
  2359. }
  2360. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2361. } else {
  2362. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2363. return -1;
  2364. }
  2365. return 0;
  2366. }
  2367. /*==========================================
  2368. *
  2369. *------------------------------------------
  2370. */
  2371. int atcommand_pvpon(
  2372. const int fd, struct map_session_data* sd,
  2373. const char* command, const char* message)
  2374. {
  2375. struct map_session_data *pl_sd;
  2376. int i;
  2377. nullpo_retr(-1, sd);
  2378. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2379. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2380. return -1;
  2381. }
  2382. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2383. map[sd->bl.m].flag.pvp = 1;
  2384. clif_send0199(sd->bl.m, 1);
  2385. for (i = 0; i < fd_max; i++) {
  2386. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2387. if (sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2388. pl_sd->pvp_timer = add_timer(gettick() + 200,
  2389. pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2390. pl_sd->pvp_rank = 0;
  2391. pl_sd->pvp_lastusers = 0;
  2392. pl_sd->pvp_point = 5;
  2393. }
  2394. }
  2395. }
  2396. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2397. } else {
  2398. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2399. return -1;
  2400. }
  2401. return 0;
  2402. }
  2403. /*==========================================
  2404. *
  2405. *------------------------------------------
  2406. */
  2407. int atcommand_gvgoff(
  2408. const int fd, struct map_session_data* sd,
  2409. const char* command, const char* message)
  2410. {
  2411. nullpo_retr(-1, sd);
  2412. if (map[sd->bl.m].flag.gvg) {
  2413. map[sd->bl.m].flag.gvg = 0;
  2414. clif_send0199(sd->bl.m, 0);
  2415. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2416. } else {
  2417. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2418. return -1;
  2419. }
  2420. return 0;
  2421. }
  2422. /*==========================================
  2423. *
  2424. *------------------------------------------
  2425. */
  2426. int atcommand_gvgon(
  2427. const int fd, struct map_session_data* sd,
  2428. const char* command, const char* message)
  2429. {
  2430. nullpo_retr(-1, sd);
  2431. if (!map[sd->bl.m].flag.gvg) {
  2432. map[sd->bl.m].flag.gvg = 1;
  2433. clif_send0199(sd->bl.m, 3);
  2434. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2435. } else {
  2436. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2437. return -1;
  2438. }
  2439. return 0;
  2440. }
  2441. /*==========================================
  2442. *
  2443. *------------------------------------------
  2444. */
  2445. int atcommand_model(
  2446. const int fd, struct map_session_data* sd,
  2447. const char* command, const char* message)
  2448. {
  2449. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2450. char output[200];
  2451. nullpo_retr(-1, sd);
  2452. memset(output, '\0', sizeof(output));
  2453. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2454. sprintf(output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2455. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2456. clif_displaymessage(fd, output);
  2457. return -1;
  2458. }
  2459. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2460. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2461. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2462. //服の色変更
  2463. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2464. //服の色未実装職の判定
  2465. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2466. return -1;
  2467. } else {
  2468. pc_changelook(sd, LOOK_HAIR, hair_style);
  2469. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2470. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2471. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2472. }
  2473. } else {
  2474. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2475. return -1;
  2476. }
  2477. return 0;
  2478. }
  2479. /*==========================================
  2480. * @dye && @ccolor
  2481. *------------------------------------------
  2482. */
  2483. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2484. {
  2485. int cloth_color = 0;
  2486. char output[200];
  2487. nullpo_retr(-1, sd);
  2488. memset(output, '\0', sizeof(output));
  2489. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2490. sprintf(output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2491. clif_displaymessage(fd, output);
  2492. return -1;
  2493. }
  2494. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2495. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2496. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2497. return -1;
  2498. } else {
  2499. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2500. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2501. }
  2502. } else {
  2503. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2504. return -1;
  2505. }
  2506. return 0;
  2507. }
  2508. /*==========================================
  2509. * @hairstyle && @hstyle
  2510. *------------------------------------------
  2511. */
  2512. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2513. {
  2514. int hair_style = 0;
  2515. char output[200];
  2516. nullpo_retr(-1, sd);
  2517. memset(output, '\0', sizeof(output));
  2518. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2519. sprintf(output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2520. clif_displaymessage(fd, output);
  2521. return -1;
  2522. }
  2523. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2524. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2525. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2526. return -1;
  2527. } else {
  2528. pc_changelook(sd, LOOK_HAIR, hair_style);
  2529. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2530. }
  2531. } else {
  2532. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2533. return -1;
  2534. }
  2535. return 0;
  2536. }
  2537. /*==========================================
  2538. * @charhairstyle by [MouseJstr]
  2539. *------------------------------------------
  2540. */
  2541. int
  2542. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2543. const char* command, const char* message)
  2544. {
  2545. nullpo_retr(-1, sd);
  2546. return 0;
  2547. }
  2548. /*==========================================
  2549. * @haircolor && @hcolor
  2550. *------------------------------------------
  2551. */
  2552. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2553. {
  2554. int hair_color = 0;
  2555. char output[200];
  2556. nullpo_retr(-1, sd);
  2557. memset(output, '\0', sizeof(output));
  2558. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2559. sprintf(output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2560. clif_displaymessage(fd, output);
  2561. return -1;
  2562. }
  2563. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2564. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2565. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2566. return -1;
  2567. } else {
  2568. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2569. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2570. }
  2571. } else {
  2572. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2573. return -1;
  2574. }
  2575. return 0;
  2576. }
  2577. /*==========================================
  2578. * @go [city_number/city_name]: improved by [yor] to add city names and help
  2579. *------------------------------------------
  2580. */
  2581. int atcommand_go(
  2582. const int fd, struct map_session_data* sd,
  2583. const char* command, const char* message)
  2584. {
  2585. int i;
  2586. int town;
  2587. char map_name[100];
  2588. char output[200];
  2589. int m;
  2590. const struct { char map[16]; int x, y; } data[] = {
  2591. { "prontera.gat", 156, 191 }, // 0=Prontera
  2592. { "morocc.gat", 156, 93 }, // 1=Morroc
  2593. { "geffen.gat", 119, 59 }, // 2=Geffen
  2594. { "payon.gat", 162, 233 }, // 3=Payon
  2595. { "alberta.gat", 192, 147 }, // 4=Alberta
  2596. { "izlude.gat", 128, 114 }, // 5=Izlude
  2597. { "aldebaran.gat",140, 131 }, // 6=Al de Baran
  2598. { "xmas.gat", 147, 134 }, // 7=Lutie
  2599. { "comodo.gat", 209, 143 }, // 8=Comodo
  2600. { "yuno.gat", 157, 51 }, // 9=Yuno
  2601. { "amatsu.gat", 198, 84 }, // 10=Amatsu
  2602. { "gonryun.gat", 160, 120 }, // 11=Gon Ryun
  2603. { "umbala.gat", 89, 157 }, // 12=Umbala
  2604. { "niflheim.gat", 21, 153 }, // 13=Niflheim
  2605. { "louyang.gat", 217, 40 }, // 14=Lou Yang
  2606. { "new_1-1.gat", 53, 111 }, // 15=Start point
  2607. { "sec_pri.gat", 23, 61 }, // 16=Prison
  2608. { "jawaii.gat", 249, 127 }, // 17=Jawaii
  2609. { "ayothaya.gat", 151, 117 }, // 18=Ayothaya
  2610. };
  2611. nullpo_retr(-1, sd);
  2612. if(map[sd->bl.m].flag.nogo) {
  2613. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2614. return 0;
  2615. }
  2616. memset(map_name, '\0', sizeof(map_name));
  2617. memset(output, '\0', sizeof(output));
  2618. // get the number
  2619. town = atoi(message);
  2620. // if no value, display all value
  2621. if (!message || !*message || sscanf(message, "%99s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2622. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2623. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2624. clif_displaymessage(fd, "-3=(Memo point 2) 4=Alberta 11=Gon Ryun");
  2625. clif_displaymessage(fd, "-2=(Memo point 1) 5=Izlude 12=Umbala");
  2626. clif_displaymessage(fd, "-1=(Memo point 0) 6=Al de Baran 13=Niflheim");
  2627. clif_displaymessage(fd, " 0=Prontera 7=Lutie 14=Lou Yang");
  2628. clif_displaymessage(fd, " 1=Morroc 8=Comodo 15=Start point");
  2629. clif_displaymessage(fd, " 2=Geffen 9=Yuno 16=Prison");
  2630. clif_displaymessage(fd, " 3=Payon 10=Amatsu 17=Jawaii");
  2631. clif_displaymessage(fd, " 18=Ayothaya");
  2632. return -1;
  2633. } else {
  2634. // get possible name of the city and add .gat if not in the name
  2635. map_name[sizeof(map_name)-1] = '\0';
  2636. for (i = 0; map_name[i]; i++)
  2637. map_name[i] = tolower(map_name[i]);
  2638. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  2639. strcat(map_name, ".gat");
  2640. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2641. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2642. town = 0;
  2643. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2644. town = 1;
  2645. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2646. town = 2;
  2647. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2648. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2649. town = 3;
  2650. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2651. town = 4;
  2652. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2653. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2654. town = 5;
  2655. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2656. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2657. town = 6;
  2658. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2659. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2660. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2661. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2662. town = 7;
  2663. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2664. town = 8;
  2665. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2666. town = 9;
  2667. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2668. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2669. town = 10;
  2670. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2671. town = 11;
  2672. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2673. town = 12;
  2674. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2675. town = 13;
  2676. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2677. town = 14;
  2678. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2679. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2680. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2681. town = 15;
  2682. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2683. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2684. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2685. town = 16;
  2686. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2687. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2688. town = 17;
  2689. } else if (strncmp(map_name, "ayothaya.gat", 4) == 0 || // 3 first characters
  2690. strncmp(map_name, "ayotaya.gat", 4) == 0) { // writing error (3 first characters)
  2691. town = 18;
  2692. }
  2693. if (town >= -3 && town <= -1) {
  2694. if (sd->status.memo_point[-town-1].map[0]) {
  2695. m = map_mapname2mapid(sd->status.memo_point[-town-1].map);
  2696. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2697. clif_displaymessage(fd, "You are not authorised to warp you to this memo map.");
  2698. return -1;
  2699. }
  2700. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2701. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2702. return -1;
  2703. }
  2704. if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
  2705. clif_displaymessage(fd, msg_table[0]); // Warped.
  2706. } else {
  2707. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2708. return -1;
  2709. }
  2710. } else {
  2711. sprintf(output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2712. clif_displaymessage(fd, output);
  2713. return -1;
  2714. }
  2715. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2716. m = map_mapname2mapid((char *)data[town].map);
  2717. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2718. clif_displaymessage(fd, "You are not authorised to warp you to this destination map.");
  2719. return -1;
  2720. }
  2721. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2722. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2723. return -1;
  2724. }
  2725. if (pc_setpos(sd, (char *)data[town].map, data[town].x, data[town].y, 3) == 0) {
  2726. clif_displaymessage(fd, msg_table[0]); // Warped.
  2727. } else {
  2728. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2729. return -1;
  2730. }
  2731. } else { // if you arrive here, you have an error in town variable when reading of names
  2732. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2733. return -1;
  2734. }
  2735. }
  2736. return 0;
  2737. }
  2738. /*==========================================
  2739. *
  2740. *------------------------------------------
  2741. */
  2742. int atcommand_monster(
  2743. const int fd, struct map_session_data* sd,
  2744. const char* command, const char* message)
  2745. {
  2746. char name[100];
  2747. char monster[100];
  2748. char output[200];
  2749. int mob_id;
  2750. int number = 0;
  2751. int x = 0, y = 0;
  2752. int count;
  2753. int i, j, k;
  2754. int mx, my, range;
  2755. nullpo_retr(-1, sd);
  2756. memset(name, '\0', sizeof(name));
  2757. memset(monster, '\0', sizeof(monster));
  2758. memset(output, '\0', sizeof(output));
  2759. if (!message || !*message ||
  2760. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2761. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2762. sscanf(message, "%99s %99s %d %d %d", name, monster, &number, &x, &y) < 2)) {
  2763. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2764. return -1;
  2765. }
  2766. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2767. mob_id = mobdb_checkid(atoi(monster));
  2768. if (mob_id == 0) {
  2769. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2770. return -1;
  2771. }
  2772. if (mob_id == 1288) {
  2773. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2774. return -1;
  2775. }
  2776. if (number <= 0)
  2777. number = 1;
  2778. if (strlen(name) < 1)
  2779. strcpy(name, "--ja--");
  2780. // 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
  2781. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2782. number = battle_config.atc_spawn_quantity_limit;
  2783. if (battle_config.etc_log)
  2784. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2785. count = 0;
  2786. range = sqrt(number) / 2;
  2787. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2788. for (i = 0; i < number; i++) {
  2789. j = 0;
  2790. k = 0;
  2791. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2792. if (x <= 0)
  2793. mx = sd->bl.x + (rand() % range - (range / 2));
  2794. else
  2795. mx = x;
  2796. if (y <= 0)
  2797. my = sd->bl.y + (rand() % range - (range / 2));
  2798. else
  2799. my = y;
  2800. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2801. }
  2802. count += (k != 0) ? 1 : 0;
  2803. }
  2804. if (count != 0)
  2805. if (number == count)
  2806. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2807. else {
  2808. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2809. clif_displaymessage(fd, output);
  2810. }
  2811. else {
  2812. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2813. return -1;
  2814. }
  2815. return 0;
  2816. }
  2817. /*==========================================
  2818. *
  2819. *------------------------------------------
  2820. */
  2821. int atcommand_spawn(
  2822. const int fd, struct map_session_data* sd,
  2823. const char* command, const char* message) {
  2824. char name[100];
  2825. char monster[100];
  2826. char output[200];
  2827. int mob_id;
  2828. int number = 0;
  2829. int x = 0, y = 0;
  2830. int count;
  2831. int i, j, k;
  2832. int mx, my, range;
  2833. nullpo_retr(-1, sd);
  2834. memset(name, '\0', sizeof(name));
  2835. memset(monster, '\0', sizeof(monster));
  2836. memset(output, '\0', sizeof(output));
  2837. if (!message || !*message ||
  2838. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2839. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2840. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1)) {
  2841. clif_displaymessage(fd, msg_table[143]); // Give a monster name/id please.
  2842. return -1;
  2843. }
  2844. // If monster identifier/name argument is a name
  2845. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2846. mob_id = mobdb_checkid(atoi(monster));
  2847. if (mob_id == 0) {
  2848. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2849. return -1;
  2850. }
  2851. if (mob_id == 1288) {
  2852. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2853. return -1;
  2854. }
  2855. if (number <= 0)
  2856. number = 1;
  2857. if (strlen(name) < 1)
  2858. strcpy(name, "--ja--");
  2859. // 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
  2860. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2861. number = battle_config.atc_spawn_quantity_limit;
  2862. if (battle_config.etc_log)
  2863. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2864. count = 0;
  2865. range = sqrt(number) / 2;
  2866. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2867. for (i = 0; i < number; i++) {
  2868. j = 0;
  2869. k = 0;
  2870. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2871. if (x <= 0)
  2872. mx = sd->bl.x + (rand() % range - (range / 2));
  2873. else
  2874. mx = x;
  2875. if (y <= 0)
  2876. my = sd->bl.y + (rand() % range - (range / 2));
  2877. else
  2878. my = y;
  2879. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2880. }
  2881. count += (k != 0) ? 1 : 0;
  2882. }
  2883. if (count != 0)
  2884. if (number == count)
  2885. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2886. else {
  2887. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2888. clif_displaymessage(fd, output);
  2889. }
  2890. else {
  2891. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2892. return -1;
  2893. }
  2894. return 0;
  2895. }
  2896. // small monster spawning [Valaris]
  2897. int atcommand_monstersmall(
  2898. const int fd, struct map_session_data* sd,
  2899. const char* command, const char* message) {
  2900. char name[100] = "";
  2901. char monster[100] = "";
  2902. int mob_id = 0;
  2903. int number = 0;
  2904. int x = 0;
  2905. int y = 0;
  2906. int count;
  2907. int i;
  2908. nullpo_retr(-1, sd);
  2909. if (!message || !*message) {
  2910. clif_displaymessage(fd, "Give a monster name/id please.");
  2911. return 0;
  2912. }
  2913. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2914. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2915. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2916. clif_displaymessage(fd, "Give a monster name/id please.");
  2917. return 0;
  2918. }
  2919. // If monster identifier/name argument is a name
  2920. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2921. mob_id = atoi(monster);
  2922. if (mob_id == 0) {
  2923. clif_displaymessage(fd, "Monster name hasn't been found.");
  2924. return 0;
  2925. }
  2926. if (mob_id == 1288) {
  2927. clif_displaymessage(fd, "Cannot spawn emperium.");
  2928. return 0;
  2929. }
  2930. if (mob_id > 2000) {
  2931. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2932. return 0;
  2933. }
  2934. if (number <= 0)
  2935. number = 1;
  2936. if (strlen(name) < 1)
  2937. strcpy(name, "--ja--");
  2938. // 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
  2939. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2940. number = battle_config.atc_spawn_quantity_limit;
  2941. count = 0;
  2942. for (i = 0; i < number; i++) {
  2943. int mx, my;
  2944. if (x <= 0)
  2945. mx = sd->bl.x + (rand() % 11 - 5);
  2946. else
  2947. mx = x;
  2948. if (y <= 0)
  2949. my = sd->bl.y + (rand() % 11 - 5);
  2950. else
  2951. my = y;
  2952. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2000, 1, "") != 0) ? 1 : 0;
  2953. }
  2954. if (count != 0)
  2955. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2956. else
  2957. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2958. return 0;
  2959. }
  2960. // big monster spawning [Valaris]
  2961. int atcommand_monsterbig(
  2962. const int fd, struct map_session_data* sd,
  2963. const char* command, const char* message) {
  2964. char name[100] = "";
  2965. char monster[100] = "";
  2966. int mob_id = 0;
  2967. int number = 0;
  2968. int x = 0;
  2969. int y = 0;
  2970. int count;
  2971. int i;
  2972. nullpo_retr(-1, sd);
  2973. if (!message || !*message) {
  2974. clif_displaymessage(fd, "Give a monster name/id please.");
  2975. return 0;
  2976. }
  2977. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2978. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2979. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2980. clif_displaymessage(fd, "Give a monster name/id please.");
  2981. return 0;
  2982. }
  2983. // If monster identifier/name argument is a name
  2984. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2985. mob_id = atoi(monster);
  2986. if (mob_id == 0) {
  2987. clif_displaymessage(fd, "Monster name hasn't been found.");
  2988. return 0;
  2989. }
  2990. if (mob_id == 1288) {
  2991. clif_displaymessage(fd, "Cannot spawn emperium.");
  2992. return 0;
  2993. }
  2994. if (mob_id > 2000) {
  2995. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2996. return 0;
  2997. }
  2998. if (number <= 0)
  2999. number = 1;
  3000. if (strlen(name) < 1)
  3001. strcpy(name, "--ja--");
  3002. // 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
  3003. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3004. number = battle_config.atc_spawn_quantity_limit;
  3005. count = 0;
  3006. for (i = 0; i < number; i++) {
  3007. int mx, my;
  3008. if (x <= 0)
  3009. mx = sd->bl.x + (rand() % 11 - 5);
  3010. else
  3011. mx = x;
  3012. if (y <= 0)
  3013. my = sd->bl.y + (rand() % 11 - 5);
  3014. else
  3015. my = y;
  3016. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+4000, 1, "") != 0) ? 1 : 0;
  3017. }
  3018. if (count != 0)
  3019. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3020. else
  3021. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3022. return 0;
  3023. }
  3024. /*==========================================
  3025. *
  3026. *------------------------------------------
  3027. */
  3028. void atcommand_killmonster_sub(
  3029. const int fd, struct map_session_data* sd, const char* message,
  3030. const int drop)
  3031. {
  3032. int map_id;
  3033. char map_name[100];
  3034. if (!sd) return;
  3035. memset(map_name, '\0', sizeof(map_name));
  3036. if (!message || !*message || sscanf(message, "%99s", map_name) < 1)
  3037. map_id = sd->bl.m;
  3038. else {
  3039. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  3040. strcat(map_name, ".gat");
  3041. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3042. map_id = sd->bl.m;
  3043. }
  3044. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, drop);
  3045. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3046. return;
  3047. }
  3048. /*==========================================
  3049. *
  3050. *------------------------------------------
  3051. */
  3052. int atcommand_killmonster(
  3053. const int fd, struct map_session_data* sd,
  3054. const char* command, const char* message)
  3055. {
  3056. if (!sd) return 0;
  3057. atcommand_killmonster_sub(fd, sd, message, 1);
  3058. return 0;
  3059. }
  3060. /*==========================================
  3061. *
  3062. *------------------------------------------
  3063. */
  3064. int atcommand_killmonster2(
  3065. const int fd, struct map_session_data* sd,
  3066. const char* command, const char* message)
  3067. {
  3068. if (!sd) return 0;
  3069. atcommand_killmonster_sub(fd, sd, message, 0);
  3070. return 0;
  3071. }
  3072. /*==========================================
  3073. *
  3074. *------------------------------------------
  3075. */
  3076. int atcommand_refine(
  3077. const int fd, struct map_session_data* sd,
  3078. const char* command, const char* message)
  3079. {
  3080. int i, position = 0, refine = 0, current_position, final_refine;
  3081. int count;
  3082. char output[200];
  3083. nullpo_retr(-1, sd);
  3084. memset(output, '\0', sizeof(output));
  3085. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3086. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3087. return -1;
  3088. }
  3089. if (refine < -10)
  3090. refine = -10;
  3091. else if (refine > 10)
  3092. refine = 10;
  3093. else if (refine == 0)
  3094. refine = 1;
  3095. count = 0;
  3096. for (i = 0; i < MAX_INVENTORY; i++) {
  3097. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3098. (sd->status.inventory[i].equip & position ||
  3099. (sd->status.inventory[i].equip && !position))) {
  3100. final_refine = sd->status.inventory[i].refine + refine;
  3101. if (final_refine > 10)
  3102. final_refine = 10;
  3103. else if (final_refine < 0)
  3104. final_refine = 0;
  3105. if (sd->status.inventory[i].refine != final_refine) {
  3106. sd->status.inventory[i].refine = final_refine;
  3107. current_position = sd->status.inventory[i].equip;
  3108. pc_unequipitem(sd, i, 3);
  3109. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3110. clif_delitem(sd, i, 1);
  3111. clif_additem(sd, i, 1, 0);
  3112. pc_equipitem(sd, i, current_position);
  3113. clif_misceffect((struct block_list*)&sd->bl, 3);
  3114. count++;
  3115. }
  3116. }
  3117. }
  3118. if (count == 0)
  3119. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3120. else if (count == 1)
  3121. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3122. else {
  3123. sprintf(output, msg_table[168], count); // %d items have been refined!
  3124. clif_displaymessage(fd, output);
  3125. }
  3126. return 0;
  3127. }
  3128. /*==========================================
  3129. *
  3130. *------------------------------------------
  3131. */
  3132. int atcommand_produce(
  3133. const int fd, struct map_session_data* sd,
  3134. const char* command, const char* message)
  3135. {
  3136. char item_name[100];
  3137. int item_id, attribute = 0, star = 0;
  3138. int flag = 0;
  3139. struct item_data *item_data;
  3140. struct item tmp_item;
  3141. char output[200];
  3142. nullpo_retr(-1, sd);
  3143. memset(output, '\0', sizeof(output));
  3144. memset(item_name, '\0', sizeof(item_name));
  3145. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3146. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3147. return -1;
  3148. }
  3149. item_id = 0;
  3150. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3151. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3152. item_id = item_data->nameid;
  3153. if (itemdb_exists(item_id) &&
  3154. (item_id <= 500 || item_id > 1099) &&
  3155. (item_id < 4001 || item_id > 4148) &&
  3156. (item_id < 7001 || item_id > 10019) &&
  3157. itemdb_isequip(item_id)) {
  3158. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3159. attribute = ATTRIBUTE_NORMAL;
  3160. if (star < MIN_STAR || star > MAX_STAR)
  3161. star = 0;
  3162. memset(&tmp_item, 0, sizeof tmp_item);
  3163. tmp_item.nameid = item_id;
  3164. tmp_item.amount = 1;
  3165. tmp_item.identify = 1;
  3166. tmp_item.card[0] = 0x00ff;
  3167. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3168. *((unsigned long *)(&tmp_item.card[2])) = sd->char_id;
  3169. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3170. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3171. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3172. clif_additem(sd, 0, 0, flag);
  3173. } else {
  3174. if (battle_config.error_log)
  3175. printf("@produce NOT WEAPON [%d]\n", item_id);
  3176. if (item_id != 0 && itemdb_exists(item_id))
  3177. sprintf(output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3178. else
  3179. sprintf(output, msg_table[170]); // This item is not an equipment.
  3180. clif_displaymessage(fd, output);
  3181. return -1;
  3182. }
  3183. return 0;
  3184. }
  3185. /*==========================================
  3186. * Sub-function to display actual memo points
  3187. *------------------------------------------
  3188. */
  3189. void atcommand_memo_sub(struct map_session_data* sd) {
  3190. int i;
  3191. char output[200];
  3192. if (!sd) return;
  3193. memset(output, '\0', sizeof(output));
  3194. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3195. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3196. if (sd->status.memo_point[i].map[0])
  3197. sprintf(output, "%d - %s (%d,%d)", i, sd->status.memo_point[i].map, sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  3198. else
  3199. sprintf(output, msg_table[171], i); // %d - void
  3200. clif_displaymessage(sd->fd, output);
  3201. }
  3202. return;
  3203. }
  3204. /*==========================================
  3205. *
  3206. *------------------------------------------
  3207. */
  3208. int atcommand_memo(
  3209. const int fd, struct map_session_data* sd,
  3210. const char* command, const char* message)
  3211. {
  3212. int position = 0;
  3213. char output[200];
  3214. nullpo_retr(-1, sd);
  3215. memset(output, '\0', sizeof(output));
  3216. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3217. atcommand_memo_sub(sd);
  3218. else {
  3219. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3220. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3221. clif_displaymessage(fd, "You are not authorised to memo this map.");
  3222. return -1;
  3223. }
  3224. if (sd->status.memo_point[position].map[0]) {
  3225. sprintf(output, msg_table[172], position, sd->status.memo_point[position].map, sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
  3226. clif_displaymessage(fd, output);
  3227. }
  3228. memcpy(sd->status.memo_point[position].map, map[sd->bl.m].name, 24);
  3229. sd->status.memo_point[position].x = sd->bl.x;
  3230. sd->status.memo_point[position].y = sd->bl.y;
  3231. clif_skill_memo(sd, 0);
  3232. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3233. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3234. atcommand_memo_sub(sd);
  3235. } else {
  3236. sprintf(output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3237. clif_displaymessage(fd, output);
  3238. atcommand_memo_sub(sd);
  3239. return -1;
  3240. }
  3241. }
  3242. return 0;
  3243. }
  3244. /*==========================================
  3245. *
  3246. *------------------------------------------
  3247. */
  3248. int atcommand_gat(
  3249. const int fd, struct map_session_data* sd,
  3250. const char* command, const char* message)
  3251. {
  3252. char output[200];
  3253. int y;
  3254. nullpo_retr(-1, sd);
  3255. memset(output, '\0', sizeof(output));
  3256. for (y = 2; y >= -2; y--) {
  3257. sprintf(output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3258. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3259. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y),
  3260. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y),
  3261. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y),
  3262. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y),
  3263. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y));
  3264. clif_displaymessage(fd, output);
  3265. }
  3266. return 0;
  3267. }
  3268. /*==========================================
  3269. *
  3270. *------------------------------------------
  3271. */
  3272. int atcommand_packet(
  3273. const int fd, struct map_session_data* sd,
  3274. const char* command, const char* message)
  3275. {
  3276. int x = 0, y = 0;
  3277. nullpo_retr(-1, sd);
  3278. if (!message || !*message || sscanf(message, "%d %d", &x, &y) < 2) {
  3279. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3280. return -1;
  3281. }
  3282. clif_status_change(&sd->bl, x, y);
  3283. return 0;
  3284. }
  3285. /*==========================================
  3286. * @stpoint (Rewritten by [Yor])
  3287. *------------------------------------------
  3288. */
  3289. int atcommand_statuspoint(
  3290. const int fd, struct map_session_data* sd,
  3291. const char* command, const char* message)
  3292. {
  3293. int point, new_status_point;
  3294. if (!message || !*message || (point = atoi(message)) == 0) {
  3295. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3296. return -1;
  3297. }
  3298. new_status_point = (int)sd->status.status_point + point;
  3299. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3300. new_status_point = 0x7FFF;
  3301. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3302. new_status_point = 0;
  3303. if (new_status_point != (int)sd->status.status_point) {
  3304. sd->status.status_point = (short)new_status_point;
  3305. clif_updatestatus(sd, SP_STATUSPOINT);
  3306. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3307. } else {
  3308. if (point < 0)
  3309. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3310. else
  3311. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3312. return -1;
  3313. }
  3314. return 0;
  3315. }
  3316. /*==========================================
  3317. * @skpoint (Rewritten by [Yor])
  3318. *------------------------------------------
  3319. */
  3320. int atcommand_skillpoint(
  3321. const int fd, struct map_session_data* sd,
  3322. const char* command, const char* message)
  3323. {
  3324. int point, new_skill_point;
  3325. nullpo_retr(-1, sd);
  3326. if (!message || !*message || (point = atoi(message)) == 0) {
  3327. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3328. return -1;
  3329. }
  3330. new_skill_point = (int)sd->status.skill_point + point;
  3331. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3332. new_skill_point = 0x7FFF;
  3333. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3334. new_skill_point = 0;
  3335. if (new_skill_point != (int)sd->status.skill_point) {
  3336. sd->status.skill_point = (short)new_skill_point;
  3337. clif_updatestatus(sd, SP_SKILLPOINT);
  3338. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3339. } else {
  3340. if (point < 0)
  3341. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3342. else
  3343. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3344. return -1;
  3345. }
  3346. return 0;
  3347. }
  3348. /*==========================================
  3349. * @zeny (Rewritten by [Yor])
  3350. *------------------------------------------
  3351. */
  3352. int atcommand_zeny(
  3353. const int fd, struct map_session_data* sd,
  3354. const char* command, const char* message)
  3355. {
  3356. int zeny, new_zeny;
  3357. nullpo_retr(-1, sd);
  3358. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3359. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3360. return -1;
  3361. }
  3362. new_zeny = sd->status.zeny + zeny;
  3363. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3364. new_zeny = MAX_ZENY;
  3365. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3366. new_zeny = 0;
  3367. if (new_zeny != sd->status.zeny) {
  3368. sd->status.zeny = new_zeny;
  3369. clif_updatestatus(sd, SP_ZENY);
  3370. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3371. } else {
  3372. if (zeny < 0)
  3373. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3374. else
  3375. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3376. return -1;
  3377. }
  3378. return 0;
  3379. }
  3380. /*==========================================
  3381. *
  3382. *------------------------------------------
  3383. */
  3384. int atcommand_param(
  3385. const int fd, struct map_session_data* sd,
  3386. const char* command, const char* message)
  3387. {
  3388. int i, index, value = 0, new_value;
  3389. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3390. short* status[] = {
  3391. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3392. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3393. };
  3394. char output[200];
  3395. nullpo_retr(-1, sd);
  3396. memset(output, '\0', sizeof(output));
  3397. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3398. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3399. clif_displaymessage(fd, output);
  3400. return -1;
  3401. }
  3402. index = -1;
  3403. for (i = 0; param[i] != NULL; i++) {
  3404. if (strcmpi(command, param[i]) == 0) {
  3405. index = i;
  3406. break;
  3407. }
  3408. }
  3409. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3410. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3411. clif_displaymessage(fd, output);
  3412. return -1;
  3413. }
  3414. new_value = (int)*status[index] + value;
  3415. if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
  3416. new_value = battle_config.max_parameter;
  3417. else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3418. new_value = 1;
  3419. if (new_value != (int)*status[index]) {
  3420. *status[index] = new_value;
  3421. clif_updatestatus(sd, SP_STR + index);
  3422. clif_updatestatus(sd, SP_USTR + index);
  3423. pc_calcstatus(sd, 0);
  3424. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3425. } else {
  3426. if (value < 0)
  3427. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3428. else
  3429. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3430. return -1;
  3431. }
  3432. return 0;
  3433. }
  3434. /*==========================================
  3435. *
  3436. *------------------------------------------
  3437. */
  3438. //** Stat all by fritz (rewritten by [Yor])
  3439. int atcommand_stat_all(
  3440. const int fd, struct map_session_data* sd,
  3441. const char* command, const char* message)
  3442. {
  3443. int index, count, value = 0, new_value;
  3444. short* status[] = {
  3445. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3446. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3447. };
  3448. nullpo_retr(-1, sd);
  3449. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3450. value = battle_config.max_parameter;
  3451. count = 0;
  3452. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3453. new_value = (int)*status[index] + value;
  3454. if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
  3455. new_value = battle_config.max_parameter;
  3456. else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3457. new_value = 1;
  3458. if (new_value != (int)*status[index]) {
  3459. *status[index] = new_value;
  3460. clif_updatestatus(sd, SP_STR + index);
  3461. clif_updatestatus(sd, SP_USTR + index);
  3462. pc_calcstatus(sd, 0);
  3463. count++;
  3464. }
  3465. }
  3466. if (count > 0) // if at least 1 stat modified
  3467. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3468. else {
  3469. if (value < 0)
  3470. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3471. else
  3472. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3473. return -1;
  3474. }
  3475. return 0;
  3476. }
  3477. /*==========================================
  3478. *
  3479. *------------------------------------------
  3480. */
  3481. int atcommand_guildlevelup(
  3482. const int fd, struct map_session_data* sd,
  3483. const char* command, const char* message)
  3484. {
  3485. int level = 0;
  3486. short added_level;
  3487. struct guild *guild_info;
  3488. nullpo_retr(-1, sd);
  3489. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3490. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3491. return -1;
  3492. }
  3493. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3494. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3495. return -1;
  3496. }
  3497. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3498. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3499. return -1;
  3500. }
  3501. added_level = (short)level;
  3502. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3503. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3504. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3505. added_level = 1 - guild_info->guild_lv;
  3506. if (added_level != 0) {
  3507. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3508. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3509. } else {
  3510. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3511. return -1;
  3512. }
  3513. return 0;
  3514. }
  3515. /*==========================================
  3516. *
  3517. *------------------------------------------
  3518. */
  3519. int atcommand_makeegg(
  3520. const int fd, struct map_session_data* sd,
  3521. const char* command, const char* message)
  3522. {
  3523. struct item_data *item_data;
  3524. int id, pet_id;
  3525. nullpo_retr(-1, sd);
  3526. if (!message || !*message) {
  3527. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3528. return -1;
  3529. }
  3530. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3531. id = item_data->nameid;
  3532. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3533. id = atoi(message);
  3534. pet_id = search_petDB_index(id, PET_CLASS);
  3535. if (pet_id < 0)
  3536. pet_id = search_petDB_index(id, PET_EGG);
  3537. if (pet_id >= 0) {
  3538. sd->catch_target_class = pet_db[pet_id].class;
  3539. intif_create_pet(
  3540. sd->status.account_id, sd->status.char_id,
  3541. pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
  3542. pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
  3543. 100, 0, 1, pet_db[pet_id].jname);
  3544. } else {
  3545. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3546. return -1;
  3547. }
  3548. return 0;
  3549. }
  3550. /*==========================================
  3551. *
  3552. *------------------------------------------
  3553. */
  3554. int atcommand_hatch(
  3555. const int fd, struct map_session_data* sd,
  3556. const char* command, const char* message)
  3557. {
  3558. nullpo_retr(-1, sd);
  3559. if (sd->status.pet_id <= 0)
  3560. clif_sendegg(sd);
  3561. else {
  3562. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3563. return -1;
  3564. }
  3565. return 0;
  3566. }
  3567. /*==========================================
  3568. *
  3569. *------------------------------------------
  3570. */
  3571. int atcommand_petfriendly(
  3572. const int fd, struct map_session_data* sd,
  3573. const char* command, const char* message)
  3574. {
  3575. int friendly;
  3576. int t;
  3577. nullpo_retr(-1, sd);
  3578. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3579. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3580. return -1;
  3581. }
  3582. if (sd->status.pet_id > 0 && sd->pd) {
  3583. if (friendly >= 0 && friendly <= 1000) {
  3584. if (friendly != sd->pet.intimate) {
  3585. t = sd->pet.intimate;
  3586. sd->pet.intimate = friendly;
  3587. clif_send_petstatus(sd);
  3588. if (battle_config.pet_status_support) {
  3589. if ((sd->pet.intimate > 0 && t <= 0) ||
  3590. (sd->pet.intimate <= 0 && t > 0)) {
  3591. if (sd->bl.prev != NULL)
  3592. pc_calcstatus(sd, 0);
  3593. else
  3594. pc_calcstatus(sd, 2);
  3595. }
  3596. }
  3597. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3598. } else {
  3599. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3600. return -1;
  3601. }
  3602. } else {
  3603. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3604. return -1;
  3605. }
  3606. } else {
  3607. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3608. return -1;
  3609. }
  3610. return 0;
  3611. }
  3612. /*==========================================
  3613. *
  3614. *------------------------------------------
  3615. */
  3616. int atcommand_pethungry(
  3617. const int fd, struct map_session_data* sd,
  3618. const char* command, const char* message)
  3619. {
  3620. int hungry;
  3621. nullpo_retr(-1, sd);
  3622. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3623. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3624. return -1;
  3625. }
  3626. if (sd->status.pet_id > 0 && sd->pd) {
  3627. if (hungry >= 0 && hungry <= 100) {
  3628. if (hungry != sd->pet.hungry) {
  3629. sd->pet.hungry = hungry;
  3630. clif_send_petstatus(sd);
  3631. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3632. } else {
  3633. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3634. return -1;
  3635. }
  3636. } else {
  3637. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3638. return -1;
  3639. }
  3640. } else {
  3641. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3642. return -1;
  3643. }
  3644. return 0;
  3645. }
  3646. /*==========================================
  3647. *
  3648. *------------------------------------------
  3649. */
  3650. int atcommand_petrename(
  3651. const int fd, struct map_session_data* sd,
  3652. const char* command, const char* message)
  3653. {
  3654. nullpo_retr(-1, sd);
  3655. if (sd->status.pet_id > 0 && sd->pd) {
  3656. if (sd->pet.rename_flag != 0) {
  3657. sd->pet.rename_flag = 0;
  3658. intif_save_petdata(sd->status.account_id, &sd->pet);
  3659. clif_send_petstatus(sd);
  3660. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3661. } else {
  3662. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3663. return -1;
  3664. }
  3665. } else {
  3666. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3667. return -1;
  3668. }
  3669. return 0;
  3670. }
  3671. /*==========================================
  3672. *
  3673. *------------------------------------------
  3674. */
  3675. int
  3676. atcommand_recall(
  3677. const int fd, struct map_session_data* sd,
  3678. const char* command, const char* message)
  3679. {
  3680. char character[100];
  3681. char output[200];
  3682. struct map_session_data *pl_sd = NULL;
  3683. nullpo_retr(-1, sd);
  3684. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3685. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3686. return -1;
  3687. }
  3688. memset(character, '\0', sizeof character);
  3689. if(sscanf(message, "%99[^\n]", character) < 1)
  3690. return -1;
  3691. if(strncmp(sd->status.name,character,24)==0)
  3692. return -1;
  3693. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3694. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3695. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3696. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3697. return -1;
  3698. }
  3699. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3700. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  3701. return -1;
  3702. }
  3703. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  3704. sprintf(output, msg_table[46], character); // %s recalled!
  3705. clif_displaymessage(fd, output);
  3706. } else {
  3707. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3708. return -1;
  3709. }
  3710. } else {
  3711. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3712. return -1;
  3713. }
  3714. return 0;
  3715. }
  3716. /*==========================================
  3717. *
  3718. *------------------------------------------
  3719. */
  3720. int atcommand_revive(
  3721. const int fd, struct map_session_data* sd,
  3722. const char* command, const char* message)
  3723. {
  3724. char character[100];
  3725. struct map_session_data *pl_sd;
  3726. nullpo_retr(-1, sd);
  3727. memset(character, '\0', sizeof(character));
  3728. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3729. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3730. return -1;
  3731. }
  3732. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3733. if (pc_isdead(pl_sd)) {
  3734. pl_sd->status.hp = pl_sd->status.max_hp;
  3735. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3736. pc_setstand(pl_sd);
  3737. if (battle_config.pc_invincible_time > 0)
  3738. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3739. clif_updatestatus(pl_sd, SP_HP);
  3740. clif_updatestatus(pl_sd, SP_SP);
  3741. clif_resurrection(&pl_sd->bl, 1);
  3742. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3743. return 0;
  3744. }
  3745. return -1;
  3746. } else {
  3747. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3748. return -1;
  3749. }
  3750. return 0;
  3751. }
  3752. /*==========================================
  3753. * charchangesex command (usage: charchangesex <player_name>)
  3754. *------------------------------------------
  3755. */
  3756. int atcommand_char_change_sex(
  3757. const int fd, struct map_session_data* sd,
  3758. const char* command, const char* message)
  3759. {
  3760. char character[100];
  3761. nullpo_retr(-1, sd);
  3762. memset(character, '\0', sizeof(character));
  3763. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3764. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  3765. return -1;
  3766. }
  3767. // check player name
  3768. if (strlen(character) < 4) {
  3769. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3770. return -1;
  3771. } else if (strlen(character) > 23) {
  3772. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3773. return -1;
  3774. } else {
  3775. chrif_char_ask_name(sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
  3776. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3777. }
  3778. return 0;
  3779. }
  3780. /*==========================================
  3781. * charblock command (usage: charblock <player_name>)
  3782. * This command do a definitiv ban on a player
  3783. *------------------------------------------
  3784. */
  3785. int atcommand_char_block(
  3786. const int fd, struct map_session_data* sd,
  3787. const char* command, const char* message)
  3788. {
  3789. char character[100];
  3790. nullpo_retr(-1, sd);
  3791. memset(character, '\0', sizeof(character));
  3792. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3793. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3794. return -1;
  3795. }
  3796. // check player name
  3797. if (strlen(character) < 4) {
  3798. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3799. return -1;
  3800. } else if (strlen(character) > 23) {
  3801. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3802. return -1;
  3803. } else {
  3804. chrif_char_ask_name(sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3805. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3806. }
  3807. return 0;
  3808. }
  3809. /*==========================================
  3810. * charban command (usage: charban <time> <player_name>)
  3811. * This command do a limited ban on a player
  3812. * Time is done as follows:
  3813. * Adjustment value (-1, 1, +1, etc...)
  3814. * Modified element:
  3815. * a or y: year
  3816. * m: month
  3817. * j or d: day
  3818. * h: hour
  3819. * mn: minute
  3820. * s: second
  3821. * <example> @ban +1m-2mn1s-6y test_player
  3822. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3823. *------------------------------------------
  3824. */
  3825. int atcommand_char_ban(
  3826. const int fd, struct map_session_data* sd,
  3827. const char* command, const char* message)
  3828. {
  3829. char modif[100], character[100];
  3830. char * modif_p;
  3831. int year, month, day, hour, minute, second, value;
  3832. nullpo_retr(-1, sd);
  3833. memset(modif, '\0', sizeof(modif));
  3834. memset(character, '\0', sizeof(character));
  3835. if (!message || !*message || sscanf(message, "%s %99[^\n]", modif, character) < 2) {
  3836. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3837. return -1;
  3838. }
  3839. modif[sizeof(modif)-1] = '\0';
  3840. character[sizeof(character)-1] = '\0';
  3841. modif_p = modif;
  3842. year = month = day = hour = minute = second = 0;
  3843. while (modif_p[0] != '\0') {
  3844. value = atoi(modif_p);
  3845. if (value == 0)
  3846. modif_p++;
  3847. else {
  3848. if (modif_p[0] == '-' || modif_p[0] == '+')
  3849. modif_p++;
  3850. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3851. modif_p++;
  3852. if (modif_p[0] == 's') {
  3853. second = value;
  3854. modif_p++;
  3855. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3856. minute = value;
  3857. modif_p = modif_p + 2;
  3858. } else if (modif_p[0] == 'h') {
  3859. hour = value;
  3860. modif_p++;
  3861. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3862. day = value;
  3863. modif_p++;
  3864. } else if (modif_p[0] == 'm') {
  3865. month = value;
  3866. modif_p++;
  3867. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3868. year = value;
  3869. modif_p++;
  3870. } else if (modif_p[0] != '\0') {
  3871. modif_p++;
  3872. }
  3873. }
  3874. }
  3875. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3876. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  3877. return -1;
  3878. }
  3879. // check player name
  3880. if (strlen(character) < 4) {
  3881. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3882. return -1;
  3883. } else if (strlen(character) > 23) {
  3884. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3885. return -1;
  3886. } else {
  3887. chrif_char_ask_name(sd->status.account_id, character, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3888. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3889. }
  3890. return 0;
  3891. }
  3892. /*==========================================
  3893. * charunblock command (usage: charunblock <player_name>)
  3894. *------------------------------------------
  3895. */
  3896. int atcommand_char_unblock(
  3897. const int fd, struct map_session_data* sd,
  3898. const char* command, const char* message)
  3899. {
  3900. char character[100];
  3901. nullpo_retr(-1, sd);
  3902. memset(character, '\0', sizeof(character));
  3903. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3904. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3905. return -1;
  3906. }
  3907. // check player name
  3908. if (strlen(character) < 4) {
  3909. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3910. return -1;
  3911. } else if (strlen(character) > 23) {
  3912. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3913. return -1;
  3914. } else {
  3915. // send answer to login server via char-server
  3916. chrif_char_ask_name(sd->status.account_id, character, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3917. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3918. }
  3919. return 0;
  3920. }
  3921. /*==========================================
  3922. * charunban command (usage: charunban <player_name>)
  3923. *------------------------------------------
  3924. */
  3925. int atcommand_char_unban(
  3926. const int fd, struct map_session_data* sd,
  3927. const char* command, const char* message)
  3928. {
  3929. char character[100];
  3930. nullpo_retr(-1, sd);
  3931. memset(character, '\0', sizeof(character));
  3932. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3933. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3934. return -1;
  3935. }
  3936. // check player name
  3937. if (strlen(character) < 4) {
  3938. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3939. return -1;
  3940. } else if (strlen(character) > 23) {
  3941. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3942. return -1;
  3943. } else {
  3944. // send answer to login server via char-server
  3945. chrif_char_ask_name(sd->status.account_id, character, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3946. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3947. }
  3948. return 0;
  3949. }
  3950. /*==========================================
  3951. *
  3952. *------------------------------------------
  3953. */
  3954. int atcommand_night(
  3955. const int fd, struct map_session_data* sd,
  3956. const char* command, const char* message)
  3957. {
  3958. struct map_session_data *pl_sd;
  3959. int i;
  3960. nullpo_retr(-1, sd);
  3961. if (night_flag != 1) {
  3962. night_flag = 1; // 0=day, 1=night [Yor]
  3963. for(i = 0; i < fd_max; i++) {
  3964. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !map[sd->bl.m].flag.indoors) {
  3965. //pl_sd->opt2 |= STATE_BLIND;
  3966. //clif_changeoption(&pl_sd->bl);
  3967. if (battle_config.night_darkness_level > 0)
  3968. clif_specialeffect(&pl_sd->bl, 474 + battle_config.night_darkness_level, 0);
  3969. else {
  3970. //clif_specialeffect(&pl_sd->bl, 483, 0); // default darkness level
  3971. pl_sd->opt2 |= STATE_BLIND;
  3972. clif_changeoption(&pl_sd->bl);
  3973. }
  3974. clif_displaymessage(pl_sd->fd, msg_table[59]); // Night has fallen.
  3975. }
  3976. }
  3977. } else {
  3978. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  3979. return -1;
  3980. }
  3981. return 0;
  3982. }
  3983. /*==========================================
  3984. *
  3985. *------------------------------------------
  3986. */
  3987. int atcommand_day(
  3988. const int fd, struct map_session_data* sd,
  3989. const char* command, const char* message)
  3990. {
  3991. struct map_session_data *pl_sd;
  3992. int i;
  3993. nullpo_retr(-1, sd);
  3994. if (night_flag != 0) {
  3995. night_flag = 0; // 0=day, 1=night [Yor]
  3996. for(i = 0; i < fd_max; i++) {
  3997. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  3998. pl_sd->opt2 &= ~STATE_BLIND;
  3999. clif_changeoption(&pl_sd->bl);
  4000. clif_displaymessage(pl_sd->fd, msg_table[60]); // Day has arrived.
  4001. }
  4002. }
  4003. } else {
  4004. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4005. return -1;
  4006. }
  4007. return 0;
  4008. }
  4009. /*==========================================
  4010. *
  4011. *------------------------------------------
  4012. */
  4013. int atcommand_doom(
  4014. const int fd, struct map_session_data* sd,
  4015. const char* command, const char* message)
  4016. {
  4017. struct map_session_data *pl_sd;
  4018. int i;
  4019. nullpo_retr(-1, sd);
  4020. clif_specialeffect(&sd->bl,450,2);
  4021. for(i = 0; i < fd_max; i++) {
  4022. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd &&
  4023. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4024. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4025. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4026. }
  4027. }
  4028. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4029. return 0;
  4030. }
  4031. /*==========================================
  4032. *
  4033. *------------------------------------------
  4034. */
  4035. int atcommand_doommap(
  4036. const int fd, struct map_session_data* sd,
  4037. const char* command, const char* message)
  4038. {
  4039. struct map_session_data *pl_sd;
  4040. int i;
  4041. nullpo_retr(-1, sd);
  4042. clif_specialeffect(&sd->bl,450,3);
  4043. for (i = 0; i < fd_max; i++) {
  4044. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd && sd->bl.m == pl_sd->bl.m &&
  4045. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4046. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4047. // clif_specialeffect(&pl_sd->bl,450,1);
  4048. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4049. }
  4050. }
  4051. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4052. return 0;
  4053. }
  4054. /*==========================================
  4055. *
  4056. *------------------------------------------
  4057. */
  4058. static void atcommand_raise_sub(struct map_session_data* sd)
  4059. {
  4060. if (sd && sd->state.auth && pc_isdead(sd)) {
  4061. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4062. sd->status.hp = sd->status.max_hp;
  4063. sd->status.sp = sd->status.max_sp;
  4064. pc_setstand(sd);
  4065. clif_updatestatus(sd, SP_HP);
  4066. clif_updatestatus(sd, SP_SP);
  4067. clif_resurrection(&sd->bl, 1);
  4068. if (battle_config.pc_invincible_time > 0)
  4069. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4070. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4071. }
  4072. }
  4073. /*==========================================
  4074. *
  4075. *------------------------------------------
  4076. */
  4077. int atcommand_raise(
  4078. const int fd, struct map_session_data* sd,
  4079. const char* command, const char* message)
  4080. {
  4081. int i;
  4082. nullpo_retr(-1, sd);
  4083. for (i = 0; i < fd_max; i++) {
  4084. if (session[i])
  4085. atcommand_raise_sub(session[i]->session_data);
  4086. }
  4087. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4088. return 0;
  4089. }
  4090. /*==========================================
  4091. *
  4092. *------------------------------------------
  4093. */
  4094. int atcommand_raisemap(
  4095. const int fd, struct map_session_data* sd,
  4096. const char* command, const char* message)
  4097. {
  4098. struct map_session_data *pl_sd;
  4099. int i;
  4100. nullpo_retr(-1, sd);
  4101. for (i = 0; i < fd_max; i++) {
  4102. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->bl.m == pl_sd->bl.m)
  4103. atcommand_raise_sub(pl_sd);
  4104. }
  4105. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4106. return 0;
  4107. }
  4108. /*==========================================
  4109. * atcommand_character_baselevel @charbaselvlで対象キャラのレベルを上げる
  4110. *------------------------------------------
  4111. */
  4112. int atcommand_character_baselevel(
  4113. const int fd, struct map_session_data* sd,
  4114. const char* command, const char* message)
  4115. {
  4116. struct map_session_data *pl_sd;
  4117. char character[100];
  4118. int level = 0, i;
  4119. nullpo_retr(-1, sd);
  4120. memset(character, '\0', sizeof(character));
  4121. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4122. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charbaselvl <#> <nickname>).");
  4123. return -1;
  4124. }
  4125. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4126. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  4127. if (level > 0) {
  4128. if (pl_sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  4129. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  4130. return 0;
  4131. } // End Addition
  4132. if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
  4133. level = battle_config.maximum_level - pl_sd->status.base_level;
  4134. for (i = 1; i <= level; i++)
  4135. pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5;
  4136. pl_sd->status.base_level += level;
  4137. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4138. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4139. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4140. pc_calcstatus(pl_sd, 0);
  4141. pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp);
  4142. clif_misceffect(&pl_sd->bl, 0);
  4143. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  4144. } else {
  4145. if (pl_sd->status.base_level == 1) {
  4146. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  4147. return -1;
  4148. }
  4149. if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) // fix negativ overflow
  4150. level = 1 - pl_sd->status.base_level;
  4151. if (pl_sd->status.status_point > 0) {
  4152. for (i = 0; i > level; i--)
  4153. pl_sd->status.status_point -= (pl_sd->status.base_level + i + 14) / 5;
  4154. if (pl_sd->status.status_point < 0)
  4155. pl_sd->status.status_point = 0;
  4156. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4157. } // to add: remove status points from stats
  4158. pl_sd->status.base_level += level;
  4159. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4160. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4161. pc_calcstatus(pl_sd, 0);
  4162. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  4163. }
  4164. } else {
  4165. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4166. return -1;
  4167. }
  4168. } else {
  4169. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4170. return -1;
  4171. }
  4172. return 0; //正常終了
  4173. }
  4174. /*==========================================
  4175. * atcommand_character_joblevel @charjoblvlで対象キャラのJobレベルを上げる
  4176. *------------------------------------------
  4177. */
  4178. int atcommand_character_joblevel(
  4179. const int fd, struct map_session_data* sd,
  4180. const char* command, const char* message)
  4181. {
  4182. struct map_session_data *pl_sd;
  4183. char character[100];
  4184. int max_level = 50, level = 0;
  4185. //転生や養子の場合の元の職業を算出する
  4186. struct pc_base_job pl_s_class;
  4187. nullpo_retr(-1, sd);
  4188. memset(character, '\0', sizeof(character));
  4189. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4190. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charjlvl <#> <nickname>).");
  4191. return -1;
  4192. }
  4193. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4194. pl_s_class = pc_calc_base_job(pl_sd->status.class);
  4195. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  4196. if (pl_s_class.job == 0)
  4197. max_level -= 40;
  4198. // super novices can go up to 99 [celest]
  4199. else if (pl_s_class.job == 23)
  4200. max_level += 49;
  4201. else if (pl_sd->status.class > 4007 && pl_sd->status.class < 4023)
  4202. max_level += 20;
  4203. if (level > 0) {
  4204. if (pl_sd->status.job_level == max_level) {
  4205. clif_displaymessage(fd, msg_table[67]); // Character's job level can't go any higher.
  4206. return -1;
  4207. }
  4208. if (pl_sd->status.job_level + level > max_level)
  4209. level = max_level - pl_sd->status.job_level;
  4210. pl_sd->status.job_level += level;
  4211. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4212. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4213. pl_sd->status.skill_point += level;
  4214. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4215. pc_calcstatus(pl_sd, 0);
  4216. clif_misceffect(&pl_sd->bl, 1);
  4217. clif_displaymessage(fd, msg_table[68]); // character's job level raised.
  4218. } else {
  4219. if (pl_sd->status.job_level == 1) {
  4220. clif_displaymessage(fd, msg_table[194]); // Character's job level can't go any lower.
  4221. return -1;
  4222. }
  4223. if (pl_sd->status.job_level + level < 1)
  4224. level = 1 - pl_sd->status.job_level;
  4225. pl_sd->status.job_level += level;
  4226. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4227. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4228. if (pl_sd->status.skill_point > 0) {
  4229. pl_sd->status.skill_point += level;
  4230. if (pl_sd->status.skill_point < 0)
  4231. pl_sd->status.skill_point = 0;
  4232. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4233. } // to add: remove status points from skills
  4234. pc_calcstatus(pl_sd, 0);
  4235. clif_displaymessage(fd, msg_table[69]); // Character's job level lowered.
  4236. }
  4237. } else {
  4238. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4239. return -1;
  4240. }
  4241. } else {
  4242. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4243. return -1;
  4244. }
  4245. return 0;
  4246. }
  4247. /*==========================================
  4248. *
  4249. *------------------------------------------
  4250. */
  4251. int atcommand_kick(
  4252. const int fd, struct map_session_data* sd,
  4253. const char* command, const char* message)
  4254. {
  4255. struct map_session_data *pl_sd;
  4256. char character[100];
  4257. nullpo_retr(-1, sd);
  4258. memset(character, '\0', sizeof(character));
  4259. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4260. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4261. return -1;
  4262. }
  4263. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4264. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4265. clif_GM_kick(sd, pl_sd, 1);
  4266. else {
  4267. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4268. return -1;
  4269. }
  4270. } else {
  4271. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4272. return -1;
  4273. }
  4274. return 0;
  4275. }
  4276. /*==========================================
  4277. *
  4278. *------------------------------------------
  4279. */
  4280. int atcommand_kickall(
  4281. const int fd, struct map_session_data* sd,
  4282. const char* command, const char* message)
  4283. {
  4284. struct map_session_data *pl_sd;
  4285. int i;
  4286. nullpo_retr(-1, sd);
  4287. for (i = 0; i < fd_max; i++) {
  4288. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4289. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4290. if (sd->status.account_id != pl_sd->status.account_id)
  4291. clif_GM_kick(sd, pl_sd, 0);
  4292. }
  4293. }
  4294. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4295. return 0;
  4296. }
  4297. /*==========================================
  4298. *
  4299. *------------------------------------------
  4300. */
  4301. int atcommand_allskill(
  4302. const int fd, struct map_session_data* sd,
  4303. const char* command, const char* message)
  4304. {
  4305. nullpo_retr(-1, sd);
  4306. pc_allskillup(sd); // all skills
  4307. sd->status.skill_point = 0; // 0 skill points
  4308. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4309. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4310. return 0;
  4311. }
  4312. /*==========================================
  4313. *
  4314. *------------------------------------------
  4315. */
  4316. int atcommand_questskill(
  4317. const int fd, struct map_session_data* sd,
  4318. const char* command, const char* message)
  4319. {
  4320. int skill_id;
  4321. nullpo_retr(-1, sd);
  4322. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4323. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4324. return -1;
  4325. }
  4326. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4327. if (skill_get_inf2(skill_id) & 0x01) {
  4328. if (pc_checkskill(sd, skill_id) == 0) {
  4329. pc_skill(sd, skill_id, 1, 0);
  4330. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4331. } else {
  4332. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4333. return -1;
  4334. }
  4335. } else {
  4336. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4337. return -1;
  4338. }
  4339. } else {
  4340. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4341. return -1;
  4342. }
  4343. return 0;
  4344. }
  4345. /*==========================================
  4346. *
  4347. *------------------------------------------
  4348. */
  4349. int atcommand_charquestskill(
  4350. const int fd, struct map_session_data* sd,
  4351. const char* command, const char* message)
  4352. {
  4353. char character[100];
  4354. struct map_session_data *pl_sd;
  4355. int skill_id = 0;
  4356. nullpo_retr(-1, sd);
  4357. memset(character, '\0', sizeof(character));
  4358. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4359. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charquestskill <#:0+> <char_name>).");
  4360. return -1;
  4361. }
  4362. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4363. if (skill_get_inf2(skill_id) & 0x01) {
  4364. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4365. if (pc_checkskill(pl_sd, skill_id) == 0) {
  4366. pc_skill(pl_sd, skill_id, 1, 0);
  4367. clif_displaymessage(fd, msg_table[199]); // This player has learned the skill.
  4368. } else {
  4369. clif_displaymessage(fd, msg_table[200]); // This player already has this quest skill.
  4370. return -1;
  4371. }
  4372. } else {
  4373. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4374. return -1;
  4375. }
  4376. } else {
  4377. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4378. return -1;
  4379. }
  4380. } else {
  4381. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4382. return -1;
  4383. }
  4384. return 0;
  4385. }
  4386. /*==========================================
  4387. *
  4388. *------------------------------------------
  4389. */
  4390. int atcommand_lostskill(
  4391. const int fd, struct map_session_data* sd,
  4392. const char* command, const char* message)
  4393. {
  4394. int skill_id;
  4395. nullpo_retr(-1, sd);
  4396. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4397. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4398. return -1;
  4399. }
  4400. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4401. if (skill_get_inf2(skill_id) & 0x01) {
  4402. if (pc_checkskill(sd, skill_id) > 0) {
  4403. sd->status.skill[skill_id].lv = 0;
  4404. sd->status.skill[skill_id].flag = 0;
  4405. clif_skillinfoblock(sd);
  4406. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4407. } else {
  4408. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4409. return -1;
  4410. }
  4411. } else {
  4412. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4413. return -1;
  4414. }
  4415. } else {
  4416. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4417. return -1;
  4418. }
  4419. return 0;
  4420. }
  4421. /*==========================================
  4422. *
  4423. *------------------------------------------
  4424. */
  4425. int atcommand_charlostskill(
  4426. const int fd, struct map_session_data* sd,
  4427. const char* command, const char* message)
  4428. {
  4429. char character[100];
  4430. struct map_session_data *pl_sd;
  4431. int skill_id = 0;
  4432. nullpo_retr(-1, sd);
  4433. memset(character, '\0', sizeof(character));
  4434. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4435. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  4436. return -1;
  4437. }
  4438. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4439. if (skill_get_inf2(skill_id) & 0x01) {
  4440. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4441. if (pc_checkskill(pl_sd, skill_id) > 0) {
  4442. pl_sd->status.skill[skill_id].lv = 0;
  4443. pl_sd->status.skill[skill_id].flag = 0;
  4444. clif_skillinfoblock(pl_sd);
  4445. clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill.
  4446. } else {
  4447. clif_displaymessage(fd, msg_table[203]); // This player doesn't have this quest skill.
  4448. return -1;
  4449. }
  4450. } else {
  4451. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4452. return -1;
  4453. }
  4454. } else {
  4455. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4456. return -1;
  4457. }
  4458. } else {
  4459. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4460. return -1;
  4461. }
  4462. return 0;
  4463. }
  4464. /*==========================================
  4465. *
  4466. *------------------------------------------
  4467. */
  4468. int atcommand_spiritball(
  4469. const int fd, struct map_session_data* sd,
  4470. const char* command, const char* message)
  4471. {
  4472. int number;
  4473. nullpo_retr(-1, sd);
  4474. if (!message || !*message || (number = atoi(message)) < 0) {
  4475. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4476. return -1;
  4477. }
  4478. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4479. if (number > 500)
  4480. number = 500;
  4481. if (number >= 0 && number <= 0x7FFF) {
  4482. if (sd->spiritball != number || number > 499) {
  4483. if (sd->spiritball > 0)
  4484. pc_delspiritball(sd, sd->spiritball, 1);
  4485. sd->spiritball = number;
  4486. clif_spiritball(sd);
  4487. // no message, player can look the difference
  4488. if (number > 1000)
  4489. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4490. } else {
  4491. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4492. return -1;
  4493. }
  4494. } else {
  4495. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4496. return -1;
  4497. }
  4498. return 0;
  4499. }
  4500. /*==========================================
  4501. *
  4502. *------------------------------------------
  4503. */
  4504. int atcommand_party(
  4505. const int fd, struct map_session_data* sd,
  4506. const char* command, const char* message)
  4507. {
  4508. char party[100];
  4509. nullpo_retr(-1, sd);
  4510. memset(party, '\0', sizeof(party));
  4511. if (!message || !*message || sscanf(message, "%99[^\n]", party) < 1) {
  4512. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4513. return -1;
  4514. }
  4515. party_create(sd, party);
  4516. return 0;
  4517. }
  4518. /*==========================================
  4519. *
  4520. *------------------------------------------
  4521. */
  4522. int atcommand_guild(
  4523. const int fd, struct map_session_data* sd,
  4524. const char* command, const char* message)
  4525. {
  4526. char guild[100];
  4527. int prev;
  4528. nullpo_retr(-1, sd);
  4529. memset(guild, '\0', sizeof(guild));
  4530. if (!message || !*message || sscanf(message, "%99[^\n]", guild) < 1) {
  4531. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4532. return -1;
  4533. }
  4534. prev = battle_config.guild_emperium_check;
  4535. battle_config.guild_emperium_check = 0;
  4536. guild_create(sd, guild);
  4537. battle_config.guild_emperium_check = prev;
  4538. return 0;
  4539. }
  4540. /*==========================================
  4541. *
  4542. *------------------------------------------
  4543. */
  4544. int atcommand_agitstart(
  4545. const int fd, struct map_session_data* sd,
  4546. const char* command, const char* message)
  4547. {
  4548. nullpo_retr(-1, sd);
  4549. if (agit_flag == 1) {
  4550. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4551. return -1;
  4552. }
  4553. agit_flag = 1;
  4554. guild_agit_start();
  4555. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4556. return 0;
  4557. }
  4558. /*==========================================
  4559. *
  4560. *------------------------------------------
  4561. */
  4562. int atcommand_agitend(
  4563. const int fd, struct map_session_data* sd,
  4564. const char* command, const char* message)
  4565. {
  4566. nullpo_retr(-1, sd);
  4567. if (agit_flag == 0) {
  4568. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4569. return -1;
  4570. }
  4571. agit_flag = 0;
  4572. guild_agit_end();
  4573. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4574. return 0;
  4575. }
  4576. /*==========================================
  4577. * @mapexitでマップサーバーを終了させる
  4578. *------------------------------------------
  4579. */
  4580. int atcommand_mapexit(
  4581. const int fd, struct map_session_data* sd,
  4582. const char* command, const char* message)
  4583. {
  4584. struct map_session_data *pl_sd;
  4585. int i;
  4586. nullpo_retr(-1, sd);
  4587. for (i = 0; i < fd_max; i++) {
  4588. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4589. if (sd->status.account_id != pl_sd->status.account_id)
  4590. clif_GM_kick(sd, pl_sd, 0);
  4591. }
  4592. }
  4593. clif_GM_kick(sd, sd, 0);
  4594. runflag = 0;
  4595. return 0;
  4596. }
  4597. /*==========================================
  4598. * idsearch <part_of_name>: revrited by [Yor]
  4599. *------------------------------------------
  4600. */
  4601. int atcommand_idsearch(
  4602. const int fd, struct map_session_data* sd,
  4603. const char* command, const char* message)
  4604. {
  4605. char item_name[100];
  4606. char output[200];
  4607. int i, match;
  4608. struct item_data *item;
  4609. nullpo_retr(-1, sd);
  4610. memset(item_name, '\0', sizeof(item_name));
  4611. memset(output, '\0', sizeof(output));
  4612. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4613. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4614. return -1;
  4615. }
  4616. sprintf(output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4617. clif_displaymessage(fd, output);
  4618. match = 0;
  4619. for(i = 0; i < 20000; i++) {
  4620. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4621. match++;
  4622. sprintf(output, msg_table[78], item->jname, item->nameid); // %s: %d
  4623. clif_displaymessage(fd, output);
  4624. }
  4625. }
  4626. sprintf(output, msg_table[79], match); // It is %d affair above.
  4627. clif_displaymessage(fd, output);
  4628. return 0;
  4629. }
  4630. /*==========================================
  4631. * Character Skill Reset
  4632. *------------------------------------------
  4633. */
  4634. int atcommand_charskreset(
  4635. const int fd, struct map_session_data* sd,
  4636. const char* command, const char* message)
  4637. {
  4638. char character[100];
  4639. char output[200];
  4640. struct map_session_data *pl_sd;
  4641. nullpo_retr(-1, sd);
  4642. memset(character, '\0', sizeof(character));
  4643. memset(output, '\0', sizeof(output));
  4644. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4645. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  4646. return -1;
  4647. }
  4648. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4649. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  4650. pc_resetskill(pl_sd);
  4651. sprintf(output, msg_table[206], character); // '%s' skill points reseted!
  4652. clif_displaymessage(fd, output);
  4653. } else {
  4654. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4655. return -1;
  4656. }
  4657. } else {
  4658. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4659. return -1;
  4660. }
  4661. return 0;
  4662. }
  4663. /*==========================================
  4664. * Character Stat Reset
  4665. *------------------------------------------
  4666. */
  4667. int atcommand_charstreset(
  4668. const int fd, struct map_session_data* sd,
  4669. const char* command, const char* message)
  4670. {
  4671. char character[100];
  4672. char output[200];
  4673. struct map_session_data *pl_sd;
  4674. nullpo_retr(-1, sd);
  4675. memset(character, '\0', sizeof(character));
  4676. memset(output, '\0', sizeof(output));
  4677. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4678. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  4679. return -1;
  4680. }
  4681. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4682. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  4683. pc_resetstate(pl_sd);
  4684. sprintf(output, msg_table[207], character); // '%s' stats points reseted!
  4685. clif_displaymessage(fd, output);
  4686. } else {
  4687. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4688. return -1;
  4689. }
  4690. } else {
  4691. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4692. return -1;
  4693. }
  4694. return 0;
  4695. }
  4696. /*==========================================
  4697. * Character Model by chbrules
  4698. *------------------------------------------
  4699. */
  4700. int atcommand_charmodel(
  4701. const int fd, struct map_session_data* sd,
  4702. const char* command, const char* message)
  4703. {
  4704. int hair_style = 0, hair_color = 0, cloth_color = 0;
  4705. struct map_session_data *pl_sd;
  4706. char character[100];
  4707. char output[200];
  4708. nullpo_retr(-1, sd);
  4709. memset(character, '\0', sizeof(character));
  4710. memset(output, '\0', sizeof(output));
  4711. if (!message || !*message || sscanf(message, "%d %d %d %99[^\n]", &hair_style, &hair_color, &cloth_color, character) < 4 || hair_style < 0 || hair_color < 0 || cloth_color < 0) {
  4712. sprintf(output, "Please, enter a valid model and a player name (usage: @charmodel <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d> <name>).",
  4713. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  4714. clif_displaymessage(fd, output);
  4715. return -1;
  4716. }
  4717. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4718. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  4719. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  4720. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  4721. if (cloth_color != 0 &&
  4722. pl_sd->status.sex == 1 &&
  4723. (pl_sd->status.class == 12 || pl_sd->status.class == 17)) {
  4724. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  4725. return -1;
  4726. } else {
  4727. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  4728. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  4729. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  4730. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  4731. }
  4732. } else {
  4733. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4734. return -1;
  4735. }
  4736. } else {
  4737. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4738. return -1;
  4739. }
  4740. return 0;
  4741. }
  4742. /*==========================================
  4743. * Character Skill Point (Rewritten by [Yor])
  4744. *------------------------------------------
  4745. */
  4746. int atcommand_charskpoint(
  4747. const int fd, struct map_session_data* sd,
  4748. const char* command, const char* message)
  4749. {
  4750. struct map_session_data *pl_sd;
  4751. char character[100];
  4752. int new_skill_point;
  4753. int point = 0;
  4754. nullpo_retr(-1, sd);
  4755. memset(character, '\0', sizeof(character));
  4756. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4757. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  4758. return -1;
  4759. }
  4760. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4761. new_skill_point = (int)pl_sd->status.skill_point + point;
  4762. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  4763. new_skill_point = 0x7FFF;
  4764. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  4765. new_skill_point = 0;
  4766. if (new_skill_point != (int)pl_sd->status.skill_point) {
  4767. pl_sd->status.skill_point = new_skill_point;
  4768. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4769. clif_displaymessage(fd, msg_table[209]); // Character's number of skill points changed!
  4770. } else {
  4771. if (point < 0)
  4772. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4773. else
  4774. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4775. return -1;
  4776. }
  4777. } else {
  4778. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4779. return -1;
  4780. }
  4781. return 0;
  4782. }
  4783. /*==========================================
  4784. * Character Status Point (rewritten by [Yor])
  4785. *------------------------------------------
  4786. */
  4787. int atcommand_charstpoint(
  4788. const int fd, struct map_session_data* sd,
  4789. const char* command, const char* message)
  4790. {
  4791. struct map_session_data *pl_sd;
  4792. char character[100];
  4793. int new_status_point;
  4794. int point = 0;
  4795. nullpo_retr(-1, sd);
  4796. memset(character, '\0', sizeof(character));
  4797. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4798. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  4799. return -1;
  4800. }
  4801. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4802. new_status_point = (int)pl_sd->status.status_point + point;
  4803. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  4804. new_status_point = 0x7FFF;
  4805. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  4806. new_status_point = 0;
  4807. if (new_status_point != (int)pl_sd->status.status_point) {
  4808. pl_sd->status.status_point = new_status_point;
  4809. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4810. clif_displaymessage(fd, msg_table[210]); // Character's number of status points changed!
  4811. } else {
  4812. if (point < 0)
  4813. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4814. else
  4815. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4816. return -1;
  4817. }
  4818. } else {
  4819. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4820. return -1;
  4821. }
  4822. return 0;
  4823. }
  4824. /*==========================================
  4825. * Character Zeny Point (Rewritten by [Yor])
  4826. *------------------------------------------
  4827. */
  4828. int atcommand_charzeny(
  4829. const int fd, struct map_session_data* sd,
  4830. const char* command, const char* message)
  4831. {
  4832. struct map_session_data *pl_sd;
  4833. char character[100];
  4834. int zeny = 0, new_zeny;
  4835. nullpo_retr(-1, sd);
  4836. memset(character, '\0', sizeof(character));
  4837. if (!message || !*message || sscanf(message, "%d %99[^\n]", &zeny, character) < 2 || zeny == 0) {
  4838. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charzeny <zeny> <name>).");
  4839. return -1;
  4840. }
  4841. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4842. new_zeny = pl_sd->status.zeny + zeny;
  4843. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  4844. new_zeny = MAX_ZENY;
  4845. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  4846. new_zeny = 0;
  4847. if (new_zeny != pl_sd->status.zeny) {
  4848. pl_sd->status.zeny = new_zeny;
  4849. clif_updatestatus(pl_sd, SP_ZENY);
  4850. clif_displaymessage(fd, msg_table[211]); // Character's number of zenys changed!
  4851. } else {
  4852. if (zeny < 0)
  4853. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4854. else
  4855. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4856. return -1;
  4857. }
  4858. } else {
  4859. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4860. return -1;
  4861. }
  4862. return 0;
  4863. }
  4864. /*==========================================
  4865. * Recall All Characters Online To Your Location
  4866. *------------------------------------------
  4867. */
  4868. int atcommand_recallall(
  4869. const int fd, struct map_session_data* sd,
  4870. const char* command, const char* message)
  4871. {
  4872. struct map_session_data *pl_sd;
  4873. int i;
  4874. int count;
  4875. char output[200];
  4876. nullpo_retr(-1, sd);
  4877. memset(output, '\0', sizeof(output));
  4878. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4879. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4880. return -1;
  4881. }
  4882. count = 0;
  4883. for (i = 0; i < fd_max; i++) {
  4884. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id &&
  4885. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4886. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4887. count++;
  4888. else
  4889. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4890. }
  4891. }
  4892. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4893. if (count) {
  4894. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4895. clif_displaymessage(fd, output);
  4896. }
  4897. return 0;
  4898. }
  4899. /*==========================================
  4900. * Recall online characters of a guild to your location
  4901. *------------------------------------------
  4902. */
  4903. int atcommand_guildrecall(
  4904. const int fd, struct map_session_data* sd,
  4905. const char* command, const char* message)
  4906. {
  4907. struct map_session_data *pl_sd;
  4908. int i;
  4909. char guild_name[100];
  4910. char output[200];
  4911. struct guild *g;
  4912. int count;
  4913. nullpo_retr(-1, sd);
  4914. memset(guild_name, '\0', sizeof(guild_name));
  4915. memset(output, '\0', sizeof(output));
  4916. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  4917. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4918. return -1;
  4919. }
  4920. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4921. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4922. return -1;
  4923. }
  4924. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4925. (g = guild_search(atoi(message))) != NULL) {
  4926. count = 0;
  4927. for (i = 0; i < fd_max; i++) {
  4928. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4929. sd->status.account_id != pl_sd->status.account_id &&
  4930. pl_sd->status.guild_id == g->guild_id) {
  4931. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4932. count++;
  4933. else
  4934. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4935. }
  4936. }
  4937. sprintf(output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4938. clif_displaymessage(fd, output);
  4939. if (count) {
  4940. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4941. clif_displaymessage(fd, output);
  4942. }
  4943. } else {
  4944. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4945. return -1;
  4946. }
  4947. return 0;
  4948. }
  4949. /*==========================================
  4950. * Recall online characters of a party to your location
  4951. *------------------------------------------
  4952. */
  4953. int atcommand_partyrecall(
  4954. const int fd, struct map_session_data* sd,
  4955. const char* command, const char* message)
  4956. {
  4957. int i;
  4958. struct map_session_data *pl_sd;
  4959. char party_name[100];
  4960. char output[200];
  4961. struct party *p;
  4962. int count;
  4963. nullpo_retr(-1, sd);
  4964. memset(party_name, '\0', sizeof(party_name));
  4965. memset(output, '\0', sizeof(output));
  4966. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  4967. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4968. return -1;
  4969. }
  4970. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4971. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4972. return -1;
  4973. }
  4974. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4975. (p = party_search(atoi(message))) != NULL) {
  4976. count = 0;
  4977. for (i = 0; i < fd_max; i++) {
  4978. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4979. sd->status.account_id != pl_sd->status.account_id &&
  4980. pl_sd->status.party_id == p->party_id) {
  4981. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4982. count++;
  4983. else
  4984. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4985. }
  4986. }
  4987. sprintf(output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4988. clif_displaymessage(fd, output);
  4989. if (count) {
  4990. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4991. clif_displaymessage(fd, output);
  4992. }
  4993. } else {
  4994. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4995. return -1;
  4996. }
  4997. return 0;
  4998. }
  4999. /*==========================================
  5000. *
  5001. *------------------------------------------
  5002. */
  5003. int atcommand_reloaditemdb(
  5004. const int fd, struct map_session_data* sd,
  5005. const char* command, const char* message)
  5006. {
  5007. nullpo_retr(-1, sd);
  5008. itemdb_reload();
  5009. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  5010. return 0;
  5011. }
  5012. /*==========================================
  5013. *
  5014. *------------------------------------------
  5015. */
  5016. int atcommand_reloadmobdb(
  5017. const int fd, struct map_session_data* sd,
  5018. const char* command, const char* message)
  5019. {
  5020. nullpo_retr(-1, sd);
  5021. mob_reload();
  5022. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  5023. return 0;
  5024. }
  5025. /*==========================================
  5026. *
  5027. *------------------------------------------
  5028. */
  5029. int atcommand_reloadskilldb(
  5030. const int fd, struct map_session_data* sd,
  5031. const char* command, const char* message)
  5032. {
  5033. nullpo_retr(-1, sd);
  5034. skill_reload();
  5035. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  5036. return 0;
  5037. }
  5038. /*==========================================
  5039. *
  5040. *------------------------------------------
  5041. */
  5042. #ifndef TXT_ONLY
  5043. int atcommand_rehash(
  5044. #else /* TXT_ONLY */
  5045. int atcommand_reloadscript(
  5046. #endif /* TXT_ONLY */
  5047. const int fd, struct map_session_data* sd,
  5048. const char* command, const char* message)
  5049. {
  5050. nullpo_retr(-1, sd);
  5051. #ifndef TXT_ONLY
  5052. atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." );
  5053. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  5054. rehash( fd, sd );
  5055. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  5056. #endif /* not TXT_ONLY */
  5057. do_init_npc();
  5058. do_init_script();
  5059. npc_event_do_oninit();
  5060. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  5061. return 0;
  5062. }
  5063. /*==========================================
  5064. *
  5065. *------------------------------------------
  5066. */
  5067. int atcommand_reloadgmdb( // by [Yor]
  5068. const int fd, struct map_session_data* sd,
  5069. const char* command, const char* message)
  5070. {
  5071. nullpo_retr(-1, sd);
  5072. chrif_reloadGMdb();
  5073. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  5074. return 0;
  5075. }
  5076. /*==========================================
  5077. * @mapinfo <map name> [0-3] by MC_Cameri
  5078. * => Shows information about the map [map name]
  5079. * 0 = no additional information
  5080. * 1 = Show users in that map and their location
  5081. * 2 = Shows NPCs in that map
  5082. * 3 = Shows the shops/chats in that map (not implemented)
  5083. *------------------------------------------
  5084. */
  5085. int atcommand_mapinfo(
  5086. const int fd, struct map_session_data* sd,
  5087. const char* command, const char* message)
  5088. {
  5089. struct map_session_data *pl_sd;
  5090. struct npc_data *nd = NULL;
  5091. struct chat_data *cd = NULL;
  5092. char output[200], map_name[100];
  5093. char direction[12];
  5094. int m_id, i, chat_num, list = 0;
  5095. nullpo_retr(-1, sd);
  5096. memset(output, '\0', sizeof(output));
  5097. memset(map_name, '\0', sizeof(map_name));
  5098. memset(direction, '\0', sizeof(direction));
  5099. sscanf(message, "%d %99[^\n]", &list, map_name);
  5100. if (list < 0 || list > 3) {
  5101. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5102. return -1;
  5103. }
  5104. if (map_name[0] == '\0')
  5105. strcpy(map_name, sd->mapname);
  5106. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  5107. strcat(map_name, ".gat");
  5108. if ((m_id = map_mapname2mapid(map_name)) < 0) {
  5109. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5110. return -1;
  5111. }
  5112. clif_displaymessage(fd, "------ Map Info ------");
  5113. sprintf(output, "Map Name: %s", map_name);
  5114. clif_displaymessage(fd, output);
  5115. sprintf(output, "Players In Map: %d", map[m_id].users);
  5116. clif_displaymessage(fd, output);
  5117. sprintf(output, "NPCs In Map: %d", map[m_id].npc_num);
  5118. clif_displaymessage(fd, output);
  5119. chat_num = 0;
  5120. for (i = 0; i < fd_max; i++) {
  5121. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5122. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5123. chat_num++;
  5124. }
  5125. }
  5126. sprintf(output, "Chats In Map: %d", chat_num);
  5127. clif_displaymessage(fd, output);
  5128. clif_displaymessage(fd, "------ Map Flags ------");
  5129. sprintf(output, "Player vs Player: %s | No Guild: %s | No Party: %s",
  5130. (map[m_id].flag.pvp) ? "True" : "False",
  5131. (map[m_id].flag.pvp_noguild) ? "True" : "False",
  5132. (map[m_id].flag.pvp_noparty) ? "True" : "False");
  5133. clif_displaymessage(fd, output);
  5134. sprintf(output, "Guild vs Guild: %s | No Party: %s", (map[m_id].flag.gvg) ? "True" : "False", (map[m_id].flag.gvg_noparty) ? "True" : "False");
  5135. clif_displaymessage(fd, output);
  5136. sprintf(output, "No Dead Branch: %s", (map[m_id].flag.nobranch) ? "True" : "False");
  5137. clif_displaymessage(fd, output);
  5138. sprintf(output, "No Memo: %s", (map[m_id].flag.nomemo) ? "True" : "False");
  5139. clif_displaymessage(fd, output);
  5140. sprintf(output, "No Penalty: %s", (map[m_id].flag.nopenalty) ? "True" : "False");
  5141. clif_displaymessage(fd, output);
  5142. sprintf(output, "No Return: %s", (map[m_id].flag.noreturn) ? "True" : "False");
  5143. clif_displaymessage(fd, output);
  5144. sprintf(output, "No Save: %s", (map[m_id].flag.nosave) ? "True" : "False");
  5145. clif_displaymessage(fd, output);
  5146. sprintf(output, "No Teleport: %s", (map[m_id].flag.noteleport) ? "True" : "False");
  5147. clif_displaymessage(fd, output);
  5148. sprintf(output, "No Monster Teleport: %s", (map[m_id].flag.monster_noteleport) ? "True" : "False");
  5149. clif_displaymessage(fd, output);
  5150. sprintf(output, "No Zeny Penalty: %s", (map[m_id].flag.nozenypenalty) ? "True" : "False");
  5151. clif_displaymessage(fd, output);
  5152. switch (list) {
  5153. case 0:
  5154. // Do nothing. It's list 0, no additional display.
  5155. break;
  5156. case 1:
  5157. clif_displaymessage(fd, "----- Players in Map -----");
  5158. for (i = 0; i < fd_max; i++) {
  5159. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && strcmp(pl_sd->mapname, map_name) == 0) {
  5160. sprintf(output, "Player '%s' (session #%d) | Location: %d,%d",
  5161. pl_sd->status.name, i, pl_sd->bl.x, pl_sd->bl.y);
  5162. clif_displaymessage(fd, output);
  5163. }
  5164. }
  5165. break;
  5166. case 2:
  5167. clif_displaymessage(fd, "----- NPCs in Map -----");
  5168. for (i = 0; i < map[m_id].npc_num;) {
  5169. nd = map[m_id].npc[i];
  5170. switch(nd->dir) {
  5171. case 0: strcpy(direction, "North"); break;
  5172. case 1: strcpy(direction, "North West"); break;
  5173. case 2: strcpy(direction, "West"); break;
  5174. case 3: strcpy(direction, "South West"); break;
  5175. case 4: strcpy(direction, "South"); break;
  5176. case 5: strcpy(direction, "South East"); break;
  5177. case 6: strcpy(direction, "East"); break;
  5178. case 7: strcpy(direction, "North East"); break;
  5179. case 9: strcpy(direction, "North"); break;
  5180. default: strcpy(direction, "Unknown"); break;
  5181. }
  5182. sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5183. ++i, nd->name, direction, nd->class, nd->bl.x, nd->bl.y);
  5184. clif_displaymessage(fd, output);
  5185. }
  5186. break;
  5187. case 3:
  5188. clif_displaymessage(fd, "----- Chats in Map -----");
  5189. for (i = 0; i < fd_max; i++) {
  5190. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5191. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5192. strcmp(pl_sd->mapname, map_name) == 0 &&
  5193. cd->usersd[0] == pl_sd) {
  5194. sprintf(output, "Chat %d: %s | Player: %s | Location: %d %d",
  5195. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5196. clif_displaymessage(fd, output);
  5197. sprintf(output, " Users: %d/%d | Password: %s | Public: %s",
  5198. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5199. clif_displaymessage(fd, output);
  5200. }
  5201. }
  5202. break;
  5203. default: // normally impossible to arrive here
  5204. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5205. return -1;
  5206. break;
  5207. }
  5208. return 0;
  5209. }
  5210. /*==========================================
  5211. *
  5212. *------------------------------------------
  5213. */
  5214. int atcommand_mount_peco(
  5215. const int fd, struct map_session_data* sd,
  5216. const char* command, const char* message)
  5217. {
  5218. nullpo_retr(-1, sd);
  5219. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5220. clif_displaymessage(fd, msg_table[212]); // Cannot mount a Peco while in disguise.
  5221. return -1;
  5222. }
  5223. if (!pc_isriding(sd)) { // if actually no peco
  5224. if (sd->status.class == 7 || sd->status.class == 14 || sd->status.class == 4008 || sd->status.class == 4015) {
  5225. if (sd->status.class == 7)
  5226. sd->status.class = sd->view_class = 13;
  5227. else if (sd->status.class == 14)
  5228. sd->status.class = sd->view_class = 21;
  5229. else if (sd->status.class == 4008)
  5230. sd->status.class = sd->view_class = 4014;
  5231. else if (sd->status.class == 4015)
  5232. sd->status.class = sd->view_class = 4022;
  5233. pc_setoption(sd, sd->status.option | 0x0020);
  5234. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5235. } else {
  5236. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5237. return -1;
  5238. }
  5239. } else {
  5240. if (sd->status.class == 13)
  5241. sd->status.class = sd->view_class = 7;
  5242. else if (sd->status.class == 21)
  5243. sd->status.class = sd->view_class = 14;
  5244. else if (sd->status.class == 4014)
  5245. sd->status.class = sd->view_class = 4008;
  5246. else if (sd->status.class == 4022)
  5247. sd->status.class = sd->view_class = 4015;
  5248. pc_setoption(sd, sd->status.option & ~0x0020);
  5249. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5250. }
  5251. return 0;
  5252. }
  5253. /*==========================================
  5254. *
  5255. *------------------------------------------
  5256. */
  5257. int atcommand_char_mount_peco(
  5258. const int fd, struct map_session_data* sd,
  5259. const char* command, const char* message)
  5260. {
  5261. char character[100];
  5262. struct map_session_data *pl_sd;
  5263. nullpo_retr(-1, sd);
  5264. memset(character, '\0', sizeof(character));
  5265. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5266. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5267. return -1;
  5268. }
  5269. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5270. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5271. clif_displaymessage(fd, msg_table[215]); // This player cannot mount a Peco while in disguise.
  5272. return -1;
  5273. }
  5274. if (!pc_isriding(pl_sd)) { // if actually no peco
  5275. if (pl_sd->status.class == 7 || pl_sd->status.class == 14 || pl_sd->status.class == 4008 || pl_sd->status.class == 4015) {
  5276. if (pl_sd->status.class == 7)
  5277. pl_sd->status.class = pl_sd->view_class = 13;
  5278. else if (pl_sd->status.class == 14)
  5279. pl_sd->status.class = pl_sd->view_class = 21;
  5280. else if (pl_sd->status.class == 4008)
  5281. pl_sd->status.class = pl_sd->view_class = 4014;
  5282. else if (pl_sd->status.class == 4015)
  5283. pl_sd->status.class = pl_sd->view_class = 4022;
  5284. pc_setoption(pl_sd, pl_sd->status.option | 0x0020);
  5285. clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco.
  5286. } else {
  5287. clif_displaymessage(fd, msg_table[217]); // This player can not mount a peco with his/her job.
  5288. return -1;
  5289. }
  5290. } else {
  5291. if (pl_sd->status.class == 13)
  5292. pl_sd->status.class = pl_sd->view_class = 7;
  5293. else if (pl_sd->status.class == 21)
  5294. pl_sd->status.class = pl_sd->view_class = 14;
  5295. else if (pl_sd->status.class == 4014)
  5296. pl_sd->status.class = pl_sd->view_class = 4008;
  5297. else if (pl_sd->status.class == 4022)
  5298. pl_sd->status.class = pl_sd->view_class = 4015;
  5299. pc_setoption(pl_sd, pl_sd->status.option & ~0x0020);
  5300. clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco.
  5301. }
  5302. } else {
  5303. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5304. return -1;
  5305. }
  5306. return 0;
  5307. }
  5308. /*==========================================
  5309. *Spy Commands by Syrus22
  5310. *------------------------------------------
  5311. */
  5312. int atcommand_guildspy(
  5313. const int fd, struct map_session_data* sd,
  5314. const char* command, const char* message)
  5315. {
  5316. char guild_name[100];
  5317. char output[200];
  5318. struct guild *g;
  5319. nullpo_retr(-1, sd);
  5320. memset(guild_name, '\0', sizeof(guild_name));
  5321. memset(output, '\0', sizeof(output));
  5322. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  5323. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5324. return -1;
  5325. }
  5326. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5327. (g = guild_search(atoi(message))) != NULL) {
  5328. if (sd->guildspy == g->guild_id) {
  5329. sd->guildspy = 0;
  5330. sprintf(output, msg_table[103], g->name); // No longer spying on the %s guild.
  5331. clif_displaymessage(fd, output);
  5332. } else {
  5333. sd->guildspy = g->guild_id;
  5334. sprintf(output, msg_table[104], g->name); // Spying on the %s guild.
  5335. clif_displaymessage(fd, output);
  5336. }
  5337. } else {
  5338. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5339. return -1;
  5340. }
  5341. return 0;
  5342. }
  5343. /*==========================================
  5344. *
  5345. *------------------------------------------
  5346. */
  5347. int atcommand_partyspy(
  5348. const int fd, struct map_session_data* sd,
  5349. const char* command, const char* message)
  5350. {
  5351. char party_name[100];
  5352. char output[200];
  5353. struct party *p;
  5354. nullpo_retr(-1, sd);
  5355. memset(party_name, '\0', sizeof(party_name));
  5356. memset(output, '\0', sizeof(output));
  5357. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  5358. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5359. return -1;
  5360. }
  5361. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5362. (p = party_search(atoi(message))) != NULL) {
  5363. if (sd->partyspy == p->party_id) {
  5364. sd->partyspy = 0;
  5365. sprintf(output, msg_table[105], p->name); // No longer spying on the %s party.
  5366. clif_displaymessage(fd, output);
  5367. } else {
  5368. sd->partyspy = p->party_id;
  5369. sprintf(output, msg_table[106], p->name); // Spying on the %s party.
  5370. clif_displaymessage(fd, output);
  5371. }
  5372. } else {
  5373. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5374. return -1;
  5375. }
  5376. return 0;
  5377. }
  5378. /*==========================================
  5379. * @repairall [Valaris]
  5380. *------------------------------------------
  5381. */
  5382. int atcommand_repairall(
  5383. const int fd, struct map_session_data* sd,
  5384. const char* command, const char* message)
  5385. {
  5386. int count, i;
  5387. nullpo_retr(-1, sd);
  5388. count = 0;
  5389. for (i = 0; i < MAX_INVENTORY; i++) {
  5390. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5391. sd->status.inventory[i].attribute = 0;
  5392. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5393. count++;
  5394. }
  5395. }
  5396. if (count > 0) {
  5397. clif_misceffect(&sd->bl, 3);
  5398. clif_equiplist(sd);
  5399. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5400. } else {
  5401. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5402. return -1;
  5403. }
  5404. return 0;
  5405. }
  5406. /* Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5407. int atcommand_nuke(
  5408. const int fd, struct map_session_data* sd,
  5409. const char* command, const char* message)
  5410. {
  5411. char character[100];
  5412. struct map_session_data *pl_sd;
  5413. nullpo_retr(-1, sd);
  5414. memset(character, '\0', sizeof(character));
  5415. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5416. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5417. return -1;
  5418. }
  5419. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5420. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5421. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5422. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5423. } else {
  5424. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5425. return -1;
  5426. }
  5427. } else {
  5428. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5429. return -1;
  5430. }
  5431. return 0;
  5432. }
  5433. */
  5434. /*==========================================
  5435. *
  5436. *------------------------------------------
  5437. */
  5438. int atcommand_enablenpc(const int fd, struct map_session_data* sd,
  5439. const char* command, const char* message)
  5440. {
  5441. char NPCname[100];
  5442. nullpo_retr(-1, sd);
  5443. memset(NPCname, '\0', sizeof(NPCname));
  5444. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5445. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcon <NPC_name>).");
  5446. return -1;
  5447. }
  5448. if (npc_name2id(NPCname) != NULL) {
  5449. npc_enable(NPCname, 1);
  5450. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5451. } else {
  5452. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5453. return -1;
  5454. }
  5455. return 0;
  5456. }
  5457. /*==========================================
  5458. *
  5459. *------------------------------------------
  5460. */
  5461. int atcommand_disablenpc(const int fd, struct map_session_data* sd,
  5462. const char* command, const char* message)
  5463. {
  5464. char NPCname[100];
  5465. nullpo_retr(-1, sd);
  5466. memset(NPCname, '\0', sizeof(NPCname));
  5467. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5468. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5469. return -1;
  5470. }
  5471. if (npc_name2id(NPCname) != NULL) {
  5472. npc_enable(NPCname, 0);
  5473. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5474. } else {
  5475. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5476. return -1;
  5477. }
  5478. return 0;
  5479. }
  5480. /*==========================================
  5481. * time in txt for time command (by [Yor])
  5482. *------------------------------------------
  5483. */
  5484. char * txt_time(unsigned int duration) {
  5485. int days, hours, minutes, seconds;
  5486. char temp[256];
  5487. static char temp1[256];
  5488. memset(temp, '\0', sizeof(temp));
  5489. memset(temp1, '\0', sizeof(temp1));
  5490. if (duration < 0)
  5491. duration = 0;
  5492. days = duration / (60 * 60 * 24);
  5493. duration = duration - (60 * 60 * 24 * days);
  5494. hours = duration / (60 * 60);
  5495. duration = duration - (60 * 60 * hours);
  5496. minutes = duration / 60;
  5497. seconds = duration - (60 * minutes);
  5498. if (days < 2)
  5499. sprintf(temp, msg_table[219], days); // %d day
  5500. else
  5501. sprintf(temp, msg_table[220], days); // %d days
  5502. if (hours < 2)
  5503. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5504. else
  5505. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5506. if (minutes < 2)
  5507. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5508. else
  5509. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5510. if (seconds < 2)
  5511. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5512. else
  5513. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5514. return temp1;
  5515. }
  5516. /*==========================================
  5517. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5518. * Calculation management of GM modification (@day/@night GM commands) is done
  5519. *------------------------------------------
  5520. */
  5521. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5522. const char* command, const char* message)
  5523. {
  5524. struct TimerData * timer_data;
  5525. struct TimerData * timer_data2;
  5526. time_t time_server; // variable for number of seconds (used with time() function)
  5527. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5528. char temp[256];
  5529. nullpo_retr(-1, sd);
  5530. memset(temp, '\0', sizeof(temp));
  5531. time(&time_server); // get time in seconds since 1/1/1970
  5532. datetime = localtime(&time_server); // convert seconds in structure
  5533. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5534. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5535. clif_displaymessage(fd, temp);
  5536. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5537. if (night_flag == 0)
  5538. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5539. else
  5540. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5541. } else if (battle_config.night_duration == 0)
  5542. if (night_flag == 1) { // we start with night
  5543. timer_data = get_timer(day_timer_tid);
  5544. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5545. clif_displaymessage(fd, temp);
  5546. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5547. } else
  5548. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5549. else if (battle_config.day_duration == 0)
  5550. if (night_flag == 0) { // we start with day
  5551. timer_data = get_timer(night_timer_tid);
  5552. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5553. clif_displaymessage(fd, temp);
  5554. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5555. } else
  5556. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5557. else {
  5558. if (night_flag == 0) {
  5559. timer_data = get_timer(night_timer_tid);
  5560. timer_data2 = get_timer(day_timer_tid);
  5561. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5562. clif_displaymessage(fd, temp);
  5563. if (timer_data->tick > timer_data2->tick)
  5564. sprintf(temp, msg_table[237], txt_time((timer_data->interval - abs(timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5565. else
  5566. sprintf(temp, msg_table[237], txt_time(abs(timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in night for %s.
  5567. clif_displaymessage(fd, temp);
  5568. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5569. clif_displaymessage(fd, temp);
  5570. } else {
  5571. timer_data = get_timer(day_timer_tid);
  5572. timer_data2 = get_timer(night_timer_tid);
  5573. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5574. clif_displaymessage(fd, temp);
  5575. if (timer_data->tick > timer_data2->tick)
  5576. sprintf(temp, msg_table[239], txt_time((timer_data->interval - abs(timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5577. else
  5578. sprintf(temp, msg_table[239], txt_time(abs(timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5579. clif_displaymessage(fd, temp);
  5580. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5581. clif_displaymessage(fd, temp);
  5582. }
  5583. }
  5584. return 0;
  5585. }
  5586. /*==========================================
  5587. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5588. * removes <quantity> item from a character
  5589. * item can be equiped or not.
  5590. * Inspired from a old command created by RoVeRT
  5591. *------------------------------------------
  5592. */
  5593. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5594. const char* command, const char* message)
  5595. {
  5596. struct map_session_data *pl_sd;
  5597. char character[100];
  5598. char item_name[100];
  5599. int i, number = 0, item_id, item_position, count;
  5600. char output[200];
  5601. struct item_data *item_data;
  5602. nullpo_retr(-1, sd);
  5603. memset(character, '\0', sizeof(character));
  5604. memset(item_name, '\0', sizeof(item_name));
  5605. memset(output, '\0', sizeof(output));
  5606. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, character) < 3 || number < 1) {
  5607. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5608. return -1;
  5609. }
  5610. item_id = 0;
  5611. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5612. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5613. item_id = item_data->nameid;
  5614. if (item_id > 500) {
  5615. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5616. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5617. item_position = pc_search_inventory(pl_sd, item_id);
  5618. if (item_position >= 0) {
  5619. count = 0;
  5620. for(i = 0; i < number && item_position >= 0; i++) {
  5621. pc_delitem(pl_sd, item_position, 1, 0);
  5622. count++;
  5623. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5624. }
  5625. sprintf(output, msg_table[113], count); // %d item(s) removed by a GM.
  5626. clif_displaymessage(pl_sd->fd, output);
  5627. if (number == count)
  5628. sprintf(output, msg_table[114], count); // %d item(s) removed from the player.
  5629. else
  5630. sprintf(output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5631. clif_displaymessage(fd, output);
  5632. } else {
  5633. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5634. return -1;
  5635. }
  5636. } else {
  5637. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5638. return -1;
  5639. }
  5640. } else {
  5641. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5642. return -1;
  5643. }
  5644. } else {
  5645. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5646. return -1;
  5647. }
  5648. return 0;
  5649. }
  5650. /*==========================================
  5651. * @jail <char_name> by [Yor]
  5652. * Special warp! No check with nowarp and nowarpto flag
  5653. *------------------------------------------
  5654. */
  5655. int atcommand_jail(
  5656. const int fd, struct map_session_data* sd,
  5657. const char* command, const char* message)
  5658. {
  5659. char character[100];
  5660. struct map_session_data *pl_sd;
  5661. int x, y;
  5662. nullpo_retr(-1, sd);
  5663. memset(character, '\0', sizeof(character));
  5664. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5665. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5666. return -1;
  5667. }
  5668. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5669. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5670. switch(rand() % 2) {
  5671. case 0:
  5672. x = 24;
  5673. y = 75;
  5674. break;
  5675. default:
  5676. x = 49;
  5677. y = 75;
  5678. break;
  5679. }
  5680. if (pc_setpos(pl_sd, "sec_pri.gat", x, y, 3) == 0) {
  5681. pc_setsavepoint(pl_sd, "sec_pri.gat", x, y); // Save Char Respawn Point in the jail room [Lupus]
  5682. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5683. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5684. } else {
  5685. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5686. return -1;
  5687. }
  5688. } else {
  5689. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5690. return -1;
  5691. }
  5692. } else {
  5693. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5694. return -1;
  5695. }
  5696. return 0;
  5697. }
  5698. /*==========================================
  5699. * @unjail/@discharge <char_name> by [Yor]
  5700. * Special warp! No check with nowarp and nowarpto flag
  5701. *------------------------------------------
  5702. */
  5703. int atcommand_unjail(
  5704. const int fd, struct map_session_data* sd,
  5705. const char* command, const char* message)
  5706. {
  5707. char character[100];
  5708. struct map_session_data *pl_sd;
  5709. memset(character, '\0', sizeof(character));
  5710. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5711. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5712. return -1;
  5713. }
  5714. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5715. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5716. if (pl_sd->bl.m != map_mapname2mapid("sec_pri.gat")) {
  5717. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5718. return -1;
  5719. } else if (pc_setpos(pl_sd, "prontera.gat", 156, 191, 3) == 0) {
  5720. pc_setsavepoint(pl_sd, "prontera.gat", 156, 191); // Save char respawn point in Prontera
  5721. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5722. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5723. } else {
  5724. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5725. return -1;
  5726. }
  5727. } else {
  5728. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5729. return -1;
  5730. }
  5731. } else {
  5732. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5733. return -1;
  5734. }
  5735. return 0;
  5736. }
  5737. /*==========================================
  5738. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5739. *------------------------------------------
  5740. */
  5741. int atcommand_disguise(
  5742. const int fd, struct map_session_data* sd,
  5743. const char* command, const char* message)
  5744. {
  5745. int mob_id = 0;
  5746. nullpo_retr(-1, sd);
  5747. if (!message || !*message) {
  5748. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5749. return -1;
  5750. }
  5751. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5752. mob_id = atoi(message);
  5753. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5754. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5755. (mob_id >= 813 && mob_id <= 834) || // NPC
  5756. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5757. if (pc_isriding(sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5758. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5759. return -1;
  5760. }
  5761. sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5762. sd->disguise = mob_id;
  5763. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5764. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5765. } else {
  5766. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5767. return -1;
  5768. }
  5769. return 0;
  5770. }
  5771. /*==========================================
  5772. * @undisguise by [Yor]
  5773. *------------------------------------------
  5774. */
  5775. int atcommand_undisguise(
  5776. const int fd, struct map_session_data* sd,
  5777. const char* command, const char* message)
  5778. {
  5779. nullpo_retr(-1, sd);
  5780. if (sd->disguise) {
  5781. clif_clearchar(&sd->bl, 9);
  5782. sd->disguise = 0;
  5783. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5784. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5785. } else {
  5786. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5787. return -1;
  5788. }
  5789. return 0;
  5790. }
  5791. /*==========================================
  5792. * @broadcast by [Valaris]
  5793. *------------------------------------------
  5794. */
  5795. int atcommand_broadcast(
  5796. const int fd, struct map_session_data* sd,
  5797. const char* command, const char* message)
  5798. {
  5799. char output[200];
  5800. nullpo_retr(-1, sd);
  5801. memset(output, '\0', sizeof(output));
  5802. if (!message || !*message) {
  5803. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5804. return -1;
  5805. }
  5806. sprintf(output, "%s : %s", sd->status.name, message);
  5807. intif_GMmessage(output, strlen(output) + 1, 0);
  5808. return 0;
  5809. }
  5810. /*==========================================
  5811. * @localbroadcast by [Valaris]
  5812. *------------------------------------------
  5813. */
  5814. int atcommand_localbroadcast(
  5815. const int fd, struct map_session_data* sd,
  5816. const char* command, const char* message)
  5817. {
  5818. char output[200];
  5819. nullpo_retr(-1, sd);
  5820. memset(output, '\0', sizeof(output));
  5821. if (!message || !*message) {
  5822. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5823. return -1;
  5824. }
  5825. sprintf(output, "%s : %s", sd->status.name, message);
  5826. clif_GMmessage(&sd->bl, output, strlen(output) + 1, 1); // 1: ALL_SAMEMAP
  5827. return 0;
  5828. }
  5829. /*==========================================
  5830. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5831. *------------------------------------------
  5832. */
  5833. int atcommand_chardisguise(
  5834. const int fd, struct map_session_data* sd,
  5835. const char* command, const char* message)
  5836. {
  5837. int mob_id;
  5838. char character[100];
  5839. char mob_name[100];
  5840. struct map_session_data* pl_sd;
  5841. nullpo_retr(-1, sd);
  5842. memset(character, '\0', sizeof(character));
  5843. memset(mob_name, '\0', sizeof(mob_name));
  5844. if (!message || !*message || sscanf(message, "%s %99[^\n]", mob_name, character) < 2) {
  5845. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5846. return -1;
  5847. }
  5848. if ((mob_id = mobdb_searchname(mob_name)) == 0) // check name first (to avoid possible name begining by a number)
  5849. mob_id = atoi(mob_name);
  5850. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5851. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5852. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5853. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5854. (mob_id >= 813 && mob_id <= 834) || // NPC
  5855. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5856. if (pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5857. clif_displaymessage(fd, msg_table[228]); // Character cannot wear disguise while riding a Peco.
  5858. return -1;
  5859. }
  5860. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5861. pl_sd->disguise = mob_id;
  5862. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5863. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5864. } else {
  5865. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5866. return -1;
  5867. }
  5868. } else {
  5869. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5870. return -1;
  5871. }
  5872. } else {
  5873. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5874. return -1;
  5875. }
  5876. return 0;
  5877. }
  5878. /*==========================================
  5879. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5880. *------------------------------------------
  5881. */
  5882. int atcommand_charundisguise(
  5883. const int fd, struct map_session_data* sd,
  5884. const char* command, const char* message)
  5885. {
  5886. char character[100];
  5887. struct map_session_data* pl_sd;
  5888. nullpo_retr(-1, sd);
  5889. memset(character, '\0', sizeof(character));
  5890. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5891. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5892. return -1;
  5893. }
  5894. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5895. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5896. if (pl_sd->disguise) {
  5897. clif_clearchar(&pl_sd->bl, 9);
  5898. pl_sd->disguise = 0;
  5899. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5900. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5901. } else {
  5902. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5903. return -1;
  5904. }
  5905. } else {
  5906. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5907. return -1;
  5908. }
  5909. } else {
  5910. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5911. return -1;
  5912. }
  5913. return 0;
  5914. }
  5915. /*==========================================
  5916. * @email <actual@email> <new@email> by [Yor]
  5917. *------------------------------------------
  5918. */
  5919. int atcommand_email(
  5920. const int fd, struct map_session_data* sd,
  5921. const char* command, const char* message)
  5922. {
  5923. char actual_email[100];
  5924. char new_email[100];
  5925. nullpo_retr(-1, sd);
  5926. memset(actual_email, '\0', sizeof(actual_email));
  5927. memset(new_email, '\0', sizeof(new_email));
  5928. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5929. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5930. return -1;
  5931. }
  5932. if (e_mail_check(actual_email) == 0) {
  5933. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5934. return -1;
  5935. } else if (e_mail_check(new_email) == 0) {
  5936. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5937. return -1;
  5938. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5939. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5940. return -1;
  5941. } else if (strcmpi(actual_email, new_email) == 0) {
  5942. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5943. return -1;
  5944. } else {
  5945. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5946. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5947. }
  5948. return 0;
  5949. }
  5950. /*==========================================
  5951. *@effect
  5952. *------------------------------------------
  5953. */
  5954. int atcommand_effect(
  5955. const int fd, struct map_session_data* sd,
  5956. const char* command, const char* message)
  5957. {
  5958. struct map_session_data *pl_sd;
  5959. int type = 0, flag = 0, i;
  5960. nullpo_retr(-1, sd);
  5961. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5962. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5963. return -1;
  5964. }
  5965. if(flag <=0){
  5966. clif_specialeffect(&sd->bl, type, flag);
  5967. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5968. }
  5969. else{
  5970. for (i = 0; i < fd_max; i++) {
  5971. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  5972. clif_specialeffect(&pl_sd->bl, type, flag);
  5973. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5974. }
  5975. }
  5976. }
  5977. return 0;
  5978. }
  5979. /*==========================================
  5980. * @charcartlist <character>: Displays the items list of a player's cart.
  5981. *------------------------------------------
  5982. */
  5983. int
  5984. atcommand_character_cart_list(
  5985. const int fd, struct map_session_data* sd,
  5986. const char* command, const char* message)
  5987. {
  5988. struct map_session_data *pl_sd;
  5989. struct item_data *item_data, *item_temp;
  5990. int i, j, count, counter, counter2;
  5991. char character[100], output[200], outputtmp[200];
  5992. nullpo_retr(-1, sd);
  5993. memset(character, '\0', sizeof(character));
  5994. memset(output, '\0', sizeof(output));
  5995. memset(outputtmp, '\0', sizeof(outputtmp));
  5996. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5997. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5998. return -1;
  5999. }
  6000. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6001. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6002. counter = 0;
  6003. count = 0;
  6004. for (i = 0; i < MAX_CART; i++) {
  6005. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6006. counter = counter + pl_sd->status.cart[i].amount;
  6007. count++;
  6008. if (count == 1) {
  6009. sprintf(output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6010. clif_displaymessage(fd, output);
  6011. }
  6012. if (pl_sd->status.cart[i].refine)
  6013. sprintf(output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  6014. else
  6015. sprintf(output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  6016. clif_displaymessage(fd, output);
  6017. memset(output, '\0', sizeof(output));
  6018. counter2 = 0;
  6019. for (j = 0; j < item_data->slot; j++) {
  6020. if (pl_sd->status.cart[i].card[j]) {
  6021. if ((item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6022. if (output[0] == '\0')
  6023. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6024. else
  6025. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6026. strcat(output, outputtmp);
  6027. }
  6028. }
  6029. }
  6030. if (output[0] != '\0') {
  6031. output[strlen(output) - 2] = ')';
  6032. output[strlen(output) - 1] = '\0';
  6033. clif_displaymessage(fd, output);
  6034. }
  6035. }
  6036. }
  6037. if (count == 0)
  6038. clif_displaymessage(fd, "No item found in the cart of this player.");
  6039. else {
  6040. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6041. clif_displaymessage(fd, output);
  6042. }
  6043. } else {
  6044. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6045. return -1;
  6046. }
  6047. } else {
  6048. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6049. return -1;
  6050. }
  6051. return 0;
  6052. }
  6053. /*==========================================
  6054. * @killer by MouseJstr
  6055. * enable killing players even when not in pvp
  6056. *------------------------------------------
  6057. */
  6058. int
  6059. atcommand_killer(
  6060. const int fd, struct map_session_data* sd,
  6061. const char* command, const char* message)
  6062. {
  6063. nullpo_retr(-1, sd);
  6064. sd->special_state.killer = !sd->special_state.killer;
  6065. if(sd->special_state.killer)
  6066. clif_displaymessage(fd, msg_table[241]);
  6067. else
  6068. clif_displaymessage(fd, msg_table[242]);
  6069. return 0;
  6070. }
  6071. /*==========================================
  6072. * @killable by MouseJstr
  6073. * enable other people killing you
  6074. *------------------------------------------
  6075. */
  6076. int
  6077. atcommand_killable(
  6078. const int fd, struct map_session_data* sd,
  6079. const char* command, const char* message)
  6080. {
  6081. nullpo_retr(-1, sd);
  6082. sd->special_state.killable = !sd->special_state.killable;
  6083. if(sd->special_state.killable)
  6084. clif_displaymessage(fd, msg_table[242]);
  6085. else
  6086. clif_displaymessage(fd, msg_table[241]);
  6087. return 0;
  6088. }
  6089. /*==========================================
  6090. * @charkillable by MouseJstr
  6091. * enable another player to be killed
  6092. *------------------------------------------
  6093. */
  6094. int
  6095. atcommand_charkillable(
  6096. const int fd, struct map_session_data* sd,
  6097. const char* command, const char* message)
  6098. {
  6099. struct map_session_data *pl_sd = NULL;
  6100. nullpo_retr(-1, sd);
  6101. if (!message || !*message)
  6102. return -1;
  6103. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6104. return -1;
  6105. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6106. if(pl_sd->special_state.killable)
  6107. clif_displaymessage(fd, "The player is now killable");
  6108. else
  6109. clif_displaymessage(fd, "The player is no longer killable");
  6110. return 0;
  6111. }
  6112. /*==========================================
  6113. * @skillon by MouseJstr
  6114. * turn skills on for the map
  6115. *------------------------------------------
  6116. */
  6117. int
  6118. atcommand_skillon(
  6119. const int fd, struct map_session_data* sd,
  6120. const char* command, const char* message)
  6121. {
  6122. nullpo_retr(-1, sd);
  6123. map[sd->bl.m].flag.noskill = 0;
  6124. clif_displaymessage(fd, msg_table[244]);
  6125. return 0;
  6126. }
  6127. /*==========================================
  6128. * @skilloff by MouseJstr
  6129. * Turn skills off on the map
  6130. *------------------------------------------
  6131. */
  6132. int
  6133. atcommand_skilloff(
  6134. const int fd, struct map_session_data* sd,
  6135. const char* command, const char* message)
  6136. {
  6137. nullpo_retr(-1, sd);
  6138. map[sd->bl.m].flag.noskill = 1;
  6139. clif_displaymessage(fd, msg_table[243]);
  6140. return 0;
  6141. }
  6142. /*==========================================
  6143. * @npcmove by MouseJstr
  6144. *
  6145. * move a npc
  6146. *------------------------------------------
  6147. */
  6148. int
  6149. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6150. const char* command, const char* message)
  6151. {
  6152. char character[100];
  6153. int x = 0, y = 0;
  6154. struct npc_data *nd = 0;
  6155. nullpo_retr(-1, sd);
  6156. if (!message || !*message)
  6157. return -1;
  6158. memset(character, '\0', sizeof character);
  6159. if (sscanf(message, "%d %d %99[^\n]", &x, &y, character) < 3) {
  6160. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6161. return -1;
  6162. }
  6163. nullpo_retr(-1, (nd = npc_name2id(character)));
  6164. npc_enable(character, 0);
  6165. nd->bl.x = x;
  6166. nd->bl.y = y;
  6167. npc_enable(character, 1);
  6168. return 0;
  6169. }
  6170. /*==========================================
  6171. * @addwarp by MouseJstr
  6172. *
  6173. * Create a new static warp point.
  6174. *------------------------------------------
  6175. */
  6176. int
  6177. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6178. const char* command, const char* message)
  6179. {
  6180. char w1[64], w3[64], w4[64];
  6181. char map[30], output[200];
  6182. int x,y,ret;
  6183. nullpo_retr(-1, sd);
  6184. if (!message || !*message)
  6185. return -1;
  6186. if (sscanf(message, "%99s %d %d[^\n]", map, &x, &y ) < 3)
  6187. return -1;
  6188. sprintf(w1,"%s,%d,%d", sd->mapname, sd->bl.x, sd->bl.y);
  6189. sprintf(w3,"%s%d%d%d%d", map,sd->bl.x, sd->bl.y, x, y);
  6190. sprintf(w4,"1,1,%s.gat,%d,%d", map, x, y);
  6191. ret = npc_parse_warp(w1, "warp", w3, w4);
  6192. sprintf(output, "New warp NPC => %s",w3);
  6193. clif_displaymessage(fd, output);
  6194. return ret;
  6195. }
  6196. /*==========================================
  6197. * @follow by [MouseJstr]
  6198. *
  6199. * Follow a player .. staying no more then 5 spaces away
  6200. *------------------------------------------
  6201. */
  6202. int
  6203. atcommand_follow(const int fd, struct map_session_data* sd,
  6204. const char* command, const char* message)
  6205. {
  6206. struct map_session_data *pl_sd = NULL;
  6207. nullpo_retr(-1, sd);
  6208. if (!message || !*message)
  6209. return -1;
  6210. if((pl_sd=map_nick2sd((char *) message)) != NULL)
  6211. pc_follow(sd, pl_sd->bl.id);
  6212. else
  6213. return 1;
  6214. return 0;
  6215. }
  6216. /*==========================================
  6217. * @dropall by [MouseJstr]
  6218. *
  6219. * Drop all your possession on the ground
  6220. *------------------------------------------
  6221. */
  6222. int
  6223. atcommand_dropall(const int fd, struct map_session_data* sd,
  6224. const char* command, const char* message)
  6225. {
  6226. int i;
  6227. nullpo_retr(-1, sd);
  6228. for (i = 0; i < MAX_INVENTORY; i++) {
  6229. if (sd->status.inventory[i].amount) {
  6230. if(sd->status.inventory[i].equip != 0)
  6231. pc_unequipitem(sd, i, 3);
  6232. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6233. }
  6234. }
  6235. return 0;
  6236. }
  6237. /*==========================================
  6238. * @chardropall by [MouseJstr]
  6239. *
  6240. * Throw all the characters possessions on the ground. Normally
  6241. * done in response to them being disrespectful of a GM
  6242. *------------------------------------------
  6243. */
  6244. int
  6245. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6246. const char* command, const char* message)
  6247. {
  6248. int i;
  6249. struct map_session_data *pl_sd = NULL;
  6250. nullpo_retr(-1, sd);
  6251. if (!message || !*message)
  6252. return -1;
  6253. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6254. return -1;
  6255. for (i = 0; i < MAX_INVENTORY; i++) {
  6256. if (pl_sd->status.inventory[i].amount) {
  6257. if(pl_sd->status.inventory[i].equip != 0)
  6258. pc_unequipitem(pl_sd, i, 3);
  6259. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6260. }
  6261. }
  6262. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6263. clif_displaymessage(fd, "It is done");
  6264. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6265. return 0;
  6266. }
  6267. /*==========================================
  6268. * @storeall by [MouseJstr]
  6269. *
  6270. * Put everything into storage to simplify your inventory to make
  6271. * debugging easie
  6272. *------------------------------------------
  6273. */
  6274. int
  6275. atcommand_storeall(const int fd, struct map_session_data* sd,
  6276. const char* command, const char* message)
  6277. {
  6278. int i;
  6279. nullpo_retr(-1, sd);
  6280. if (storage_storageopen(sd) == 1) {
  6281. clif_displaymessage(fd, "run this command again..");
  6282. return 0;
  6283. }
  6284. for (i = 0; i < MAX_INVENTORY; i++) {
  6285. if (sd->status.inventory[i].amount) {
  6286. if(sd->status.inventory[i].equip != 0)
  6287. pc_unequipitem(sd, i, 3);
  6288. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6289. }
  6290. }
  6291. storage_storageclose(sd);
  6292. clif_displaymessage(fd, "It is done");
  6293. return 0;
  6294. }
  6295. /*==========================================
  6296. * @charstoreall by [MouseJstr]
  6297. *
  6298. * A way to screw with players who piss you off
  6299. *------------------------------------------
  6300. */
  6301. int
  6302. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6303. const char* command, const char* message)
  6304. {
  6305. int i;
  6306. struct map_session_data *pl_sd = NULL;
  6307. nullpo_retr(-1, sd);
  6308. if (!message || !*message)
  6309. return -1;
  6310. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6311. return -1;
  6312. if (storage_storageopen(pl_sd) == 1) {
  6313. clif_displaymessage(fd, "Had to open the characters storage window...");
  6314. clif_displaymessage(fd, "run this command again..");
  6315. return 0;
  6316. }
  6317. for (i = 0; i < MAX_INVENTORY; i++) {
  6318. if (pl_sd->status.inventory[i].amount) {
  6319. if(pl_sd->status.inventory[i].equip != 0)
  6320. pc_unequipitem(pl_sd, i, 3);
  6321. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6322. }
  6323. }
  6324. storage_storageclose(pl_sd);
  6325. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6326. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6327. clif_displaymessage(pl_sd->fd, " -- the management");
  6328. clif_displaymessage(fd, "It is done");
  6329. return 0;
  6330. }
  6331. /*==========================================
  6332. * @skillid by [MouseJstr]
  6333. *
  6334. * lookup a skill by name
  6335. *------------------------------------------
  6336. */
  6337. int
  6338. atcommand_skillid(const int fd, struct map_session_data* sd,
  6339. const char* command, const char* message)
  6340. {
  6341. int skillen = 0, idx = 0;
  6342. nullpo_retr(-1, sd);
  6343. if (!message || !*message)
  6344. return -1;
  6345. skillen = strlen(message);
  6346. while (skill_names[idx].id != 0) {
  6347. if ((strnicmp(skill_names[idx].name, message, skillen) == 0) ||
  6348. (strnicmp(skill_names[idx].desc, message, skillen) == 0)) {
  6349. char output[255];
  6350. sprintf(output, "skill %d: %s", skill_names[idx].id, skill_names[idx].desc);
  6351. clif_displaymessage(fd, output);
  6352. }
  6353. idx++;
  6354. }
  6355. return 0;
  6356. }
  6357. /*==========================================
  6358. * @useskill by [MouseJstr]
  6359. *
  6360. * A way of using skills without having to find them in the skills menu
  6361. *------------------------------------------
  6362. */
  6363. int
  6364. atcommand_useskill(const int fd, struct map_session_data* sd,
  6365. const char* command, const char* message)
  6366. {
  6367. struct map_session_data *pl_sd = NULL;
  6368. int skillnum;
  6369. int skilllv;
  6370. int inf;
  6371. char target[255];
  6372. nullpo_retr(-1, sd);
  6373. if (!message || !*message)
  6374. return -1;
  6375. if(sscanf(message, "%d %d %s", &skillnum, &skilllv, target) != 3) {
  6376. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6377. return -1;
  6378. }
  6379. if((pl_sd=map_nick2sd(target)) == NULL) {
  6380. return -1;
  6381. }
  6382. inf = skill_get_inf(skillnum);
  6383. if ((inf == 2) || (inf == 1))
  6384. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6385. else
  6386. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6387. return 0;
  6388. }
  6389. /*==========================================
  6390. * @skilltree by [MouseJstr]
  6391. *
  6392. * prints the skill tree for a player required to get to a skill
  6393. *------------------------------------------
  6394. */
  6395. int
  6396. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6397. const char* command, const char* message)
  6398. {
  6399. struct map_session_data *pl_sd = NULL;
  6400. int skillnum, skillidx = -1;
  6401. int meets = 1, j, c=0, s=0;
  6402. struct pc_base_job s_class;
  6403. char target[255], *tbl;
  6404. char output[255];
  6405. struct skill_tree_entry *ent;
  6406. nullpo_retr(-1, sd);
  6407. if (!message || !*message)
  6408. return -1;
  6409. if(sscanf(message, "%d %[^\r\n]", &skillnum, target) != 2) {
  6410. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6411. return -1;
  6412. }
  6413. if((pl_sd=map_nick2sd(target)) == NULL)
  6414. return -1;
  6415. s_class = pc_calc_base_job(pl_sd->status.class);
  6416. c = s_class.job;
  6417. s = s_class.upper;
  6418. c = pc_calc_skilltree_normalize_job(c, pl_sd);
  6419. tbl = job_name(c);
  6420. sprintf(output, "Player is using %s %s skill tree (%d basic points)",
  6421. s_class.upper ? "upper" : "lower",
  6422. tbl, pc_checkskill(pl_sd, 1));
  6423. clif_displaymessage(fd, output);
  6424. for (j = 0; j < MAX_SKILL; j++) {
  6425. if (skill_tree[s][c][j].id == skillnum) {
  6426. skillidx = j;
  6427. break;
  6428. }
  6429. }
  6430. if (skillidx == -1) {
  6431. sprintf(output, "I do not believe the player can use that skill");
  6432. clif_displaymessage(fd, output);
  6433. return 0;
  6434. }
  6435. ent = &skill_tree[s][c][skillidx];
  6436. for(j=0;j<5;j++)
  6437. if( ent->need[j].id &&
  6438. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6439. {
  6440. int idx = 0;
  6441. char *desc;
  6442. while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id)
  6443. idx++;
  6444. if (skill_names[idx].id == 0)
  6445. desc = "Unknown skill";
  6446. else
  6447. desc = skill_names[idx].desc;
  6448. sprintf(output, "player requires level %d of skill %s",
  6449. ent->need[j].lv, desc);
  6450. clif_displaymessage(fd, output);
  6451. meets = 0;
  6452. }
  6453. if (meets == 1) {
  6454. sprintf(output, "I believe the player meets all the requirements for that skill");
  6455. clif_displaymessage(fd, output);
  6456. }
  6457. return 0;
  6458. }
  6459. /*==========================================
  6460. * @marry by [MouseJstr]
  6461. *
  6462. * Marry two players
  6463. *------------------------------------------
  6464. */
  6465. int
  6466. atcommand_marry(const int fd, struct map_session_data* sd,
  6467. const char* command, const char* message)
  6468. {
  6469. struct map_session_data *pl_sd1 = NULL;
  6470. struct map_session_data *pl_sd2 = NULL;
  6471. char player1[255], player2[255];
  6472. nullpo_retr(-1, sd);
  6473. if (!message || !*message)
  6474. return -1;
  6475. if (sscanf(message, "%[^,],%[^\r\n]", player1, player2) != 2) {
  6476. clif_displaymessage(fd, "usage: @marry <player1> <player2>.");
  6477. return -1;
  6478. }
  6479. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6480. sprintf(player2, "Cannot find player %s online", player1);
  6481. clif_displaymessage(fd, player2);
  6482. return -1;
  6483. }
  6484. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6485. sprintf(player1, "Cannot find player %s online", player2);
  6486. clif_displaymessage(fd, player1);
  6487. return -1;
  6488. }
  6489. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6490. clif_displaymessage(fd, "They are married.. wish them well");
  6491. return 0;
  6492. } else
  6493. return -1;
  6494. }
  6495. /*==========================================
  6496. * @divorce by [MouseJstr]
  6497. *
  6498. * divorce two players
  6499. *------------------------------------------
  6500. */
  6501. int
  6502. atcommand_divorce(const int fd, struct map_session_data* sd,
  6503. const char* command, const char* message)
  6504. {
  6505. struct map_session_data *pl_sd = NULL;
  6506. nullpo_retr(-1, sd);
  6507. if (!message || !*message)
  6508. return -1;
  6509. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6510. return pc_divorce(pl_sd);
  6511. clif_displaymessage(fd, "They are now divorced.");
  6512. } else
  6513. clif_displaymessage(fd, "The divorce has failed.. talk to the judge..");
  6514. return 0;
  6515. }
  6516. /*==========================================
  6517. * @rings by [MouseJstr]
  6518. *
  6519. * Give two players rings
  6520. *------------------------------------------
  6521. */
  6522. int
  6523. atcommand_rings(const int fd, struct map_session_data* sd,
  6524. const char* command, const char* message)
  6525. {
  6526. struct item item_tmp;
  6527. int flag;
  6528. memset(&item_tmp, 0, sizeof(item_tmp));
  6529. item_tmp.nameid = 2634;
  6530. item_tmp.identify = 1;
  6531. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6532. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6533. item_tmp.nameid = 2635;
  6534. item_tmp.identify = 1;
  6535. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6536. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6537. clif_displaymessage(fd, "You have rings! Give them to the lovers.");
  6538. return 0;
  6539. }
  6540. /*==========================================
  6541. * @grind by [MouseJstr]
  6542. *------------------------------------------
  6543. */
  6544. int
  6545. atcommand_grind(const int fd, struct map_session_data* sd,
  6546. const char* command, const char* message)
  6547. {
  6548. struct map_session_data *pl_sd = NULL;
  6549. int skillnum;
  6550. int inf;
  6551. char target[255];
  6552. nullpo_retr(-1, sd);
  6553. if (!message || !*message)
  6554. return -1;
  6555. if(sscanf(message, "%s", target) != 1) {
  6556. clif_displaymessage(fd, "Usage: @grind <target>");
  6557. return -1;
  6558. }
  6559. if((pl_sd=map_nick2sd(target)) == NULL)
  6560. return -1;
  6561. for (skillnum = 1; skillnum < 500; skillnum++) {
  6562. sd->status.sp = sd->status.max_sp;
  6563. atcommand_alive(fd, sd, command, message);
  6564. inf = skill_get_inf(skillnum);
  6565. if ((inf == 2) || (inf == 1))
  6566. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6567. else
  6568. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6569. }
  6570. return 0;
  6571. }
  6572. /*==========================================
  6573. * It is made to rain.
  6574. *------------------------------------------
  6575. */
  6576. int
  6577. atcommand_rain(
  6578. const int fd, struct map_session_data* sd,
  6579. const char* command, const char* message)
  6580. {
  6581. int effno = 0;
  6582. nullpo_retr(-1, sd);
  6583. effno = 161;
  6584. if (map[sd->bl.m].flag.rain) {
  6585. map[sd->bl.m].flag.rain=0;
  6586. clif_displaymessage(fd, "The rain has stopped.");
  6587. } else {
  6588. map[sd->bl.m].flag.rain=1;
  6589. clif_specialeffect(&sd->bl,effno,2);
  6590. clif_displaymessage(fd, "It is made to rain.");
  6591. }
  6592. return 0;
  6593. }
  6594. /*==========================================
  6595. * It is made to snow.
  6596. *------------------------------------------
  6597. */
  6598. int
  6599. atcommand_snow(
  6600. const int fd, struct map_session_data* sd,
  6601. const char* command, const char* message)
  6602. {
  6603. int effno = 0;
  6604. effno = 162;
  6605. nullpo_retr(-1, sd);
  6606. if (map[sd->bl.m].flag.snow) {
  6607. map[sd->bl.m].flag.snow=0;
  6608. clif_displaymessage(fd, "Snow has stopped falling.");
  6609. } else {
  6610. map[sd->bl.m].flag.snow=1;
  6611. clif_specialeffect(&sd->bl,effno,2);
  6612. clif_displaymessage(fd, "It is made to snow.");
  6613. }
  6614. return 0;
  6615. }
  6616. /*==========================================
  6617. * Cherry tree snowstorm is made to fall. (Sakura)
  6618. *------------------------------------------
  6619. */
  6620. int
  6621. atcommand_sakura(
  6622. const int fd, struct map_session_data* sd,
  6623. const char* command, const char* message)
  6624. {
  6625. int effno = 0;
  6626. effno = 163;
  6627. nullpo_retr(-1, sd);
  6628. if (map[sd->bl.m].flag.sakura) {
  6629. map[sd->bl.m].flag.sakura=0;
  6630. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6631. } else {
  6632. map[sd->bl.m].flag.sakura=1;
  6633. clif_specialeffect(&sd->bl,effno,2);
  6634. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6635. }
  6636. return 0;
  6637. }
  6638. /*==========================================
  6639. * Fog hangs over.
  6640. *------------------------------------------
  6641. */
  6642. int
  6643. atcommand_fog(
  6644. const int fd, struct map_session_data* sd,
  6645. const char* command, const char* message)
  6646. {
  6647. int effno = 0;
  6648. effno = 233;
  6649. nullpo_retr(-1, sd);
  6650. if (map[sd->bl.m].flag.fog) {
  6651. map[sd->bl.m].flag.fog=0;
  6652. clif_displaymessage(fd, "The fog has gone.");
  6653. } else {
  6654. map[sd->bl.m].flag.fog=1;
  6655. clif_specialeffect(&sd->bl,effno,2);
  6656. clif_displaymessage(fd, "Fog hangs over.");
  6657. }
  6658. return 0;
  6659. }
  6660. /*==========================================
  6661. * Fallen leaves fall.
  6662. *------------------------------------------
  6663. */
  6664. int
  6665. atcommand_leaves(
  6666. const int fd, struct map_session_data* sd,
  6667. const char* command, const char* message)
  6668. {
  6669. int effno = 0;
  6670. effno = 333;
  6671. nullpo_retr(-1, sd);
  6672. if (map[sd->bl.m].flag.leaves) {
  6673. map[sd->bl.m].flag.leaves=0;
  6674. clif_displaymessage(fd, "Leaves no longer fall.");
  6675. } else {
  6676. map[sd->bl.m].flag.leaves=1;
  6677. clif_specialeffect(&sd->bl,effno,2);
  6678. clif_displaymessage(fd, "Fallen leaves fall.");
  6679. }
  6680. return 0;
  6681. }
  6682. /*==========================================
  6683. * Clearing Weather Effects by Dexity
  6684. *------------------------------------------
  6685. */
  6686. int
  6687. atcommand_clearweather(
  6688. const int fd, struct map_session_data* sd,
  6689. const char* command, const char* message)
  6690. {
  6691. //int effno = 0;
  6692. nullpo_retr(-1, sd);
  6693. map[sd->bl.m].flag.rain=0;
  6694. map[sd->bl.m].flag.snow=0;
  6695. map[sd->bl.m].flag.sakura=0;
  6696. map[sd->bl.m].flag.fog=0;
  6697. map[sd->bl.m].flag.leaves=0;
  6698. //clif_specialeffect(&sd->bl,effno,2); // not required. [celest]
  6699. return 0;
  6700. }
  6701. /*==========================================
  6702. *
  6703. *------------------------------------------
  6704. */
  6705. int
  6706. atcommand_summon(
  6707. const int fd, struct map_session_data* sd,
  6708. const char* command, const char* message)
  6709. {
  6710. char name[100];
  6711. int mob_id = 0;
  6712. int x = 0;
  6713. int y = 0;
  6714. int id = 0;
  6715. struct mob_data *md;
  6716. unsigned int tick=gettick();
  6717. nullpo_retr(-1, sd);
  6718. if (!message || !*message)
  6719. return -1;
  6720. if (sscanf(message, "%99s", name) < 1)
  6721. return -1;
  6722. if ((mob_id = atoi(name)) == 0)
  6723. mob_id = mobdb_searchname(name);
  6724. if(mob_id == 0)
  6725. return -1;
  6726. x = sd->bl.x + (rand() % 10 - 5);
  6727. y = sd->bl.y + (rand() % 10 - 5);
  6728. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  6729. if((md=(struct mob_data *)map_id2bl(id))){
  6730. md->master_id=sd->bl.id;
  6731. md->state.special_mob_ai=1;
  6732. md->mode=mob_db[md->class].mode|0x04;
  6733. md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0);
  6734. clif_misceffect2(&md->bl,344);
  6735. }
  6736. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  6737. return 0;
  6738. }
  6739. /*==========================================
  6740. * @adjcmdlvl by [MouseJstr]
  6741. *
  6742. * Temp adjust the GM level required to use a GM command
  6743. *
  6744. * Used during beta testing to allow players to use GM commands
  6745. * for short periods of time
  6746. *------------------------------------------
  6747. */
  6748. int
  6749. atcommand_adjcmdlvl(
  6750. const int fd, struct map_session_data* sd,
  6751. const char* command, const char* message)
  6752. {
  6753. int i, newlev;
  6754. char cmd[100];
  6755. nullpo_retr(-1, sd);
  6756. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  6757. clif_displaymessage(fd, "usage: @adjcmdlvl <lvl> <command>.");
  6758. return -1;
  6759. }
  6760. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  6761. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  6762. atcommand_info[i].level = newlev;
  6763. clif_displaymessage(fd, "@command level changed.");
  6764. return 0;
  6765. }
  6766. clif_displaymessage(fd, "@command not found.");
  6767. return -1;
  6768. }
  6769. /*==========================================
  6770. * @adjgmlvl by [MouseJstr]
  6771. *
  6772. * Create a temp GM
  6773. *
  6774. * Used during beta testing to allow players to use GM commands
  6775. * for short periods of time
  6776. *------------------------------------------
  6777. */
  6778. int
  6779. atcommand_adjgmlvl(
  6780. const int fd, struct map_session_data* sd,
  6781. const char* command, const char* message)
  6782. {
  6783. int newlev;
  6784. char user[100];
  6785. struct map_session_data *pl_sd;
  6786. nullpo_retr(-1, sd);
  6787. if (!message || !*message || sscanf(message, "%d %[^\r\n]", &newlev, user) != 2) {
  6788. clif_displaymessage(fd, "usage: @adjgmlvl <lvl> <user>.");
  6789. return -1;
  6790. }
  6791. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  6792. return -1;
  6793. pc_set_gm_level(pl_sd->status.account_id, newlev);
  6794. return 0;
  6795. }
  6796. /*==========================================
  6797. * @trade by [MouseJstr]
  6798. *
  6799. * Open a trade window with a remote player
  6800. *
  6801. * If I have to jump to a remote player one more time, I am
  6802. * gonna scream!
  6803. *------------------------------------------
  6804. */
  6805. int
  6806. atcommand_trade(
  6807. const int fd, struct map_session_data* sd,
  6808. const char* command, const char* message)
  6809. {
  6810. struct map_session_data *pl_sd = NULL;
  6811. nullpo_retr(-1, sd);
  6812. if (!message || !*message)
  6813. return -1;
  6814. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6815. trade_traderequest(sd, pl_sd->bl.id);
  6816. return 0;
  6817. }
  6818. return -1;
  6819. }
  6820. /*==========================================
  6821. * @setbattleflag by [MouseJstr]
  6822. *
  6823. * set a battle_config flag without having to reboot
  6824. */
  6825. int
  6826. atcommand_setbattleflag(
  6827. const int fd, struct map_session_data* sd,
  6828. const char* command, const char* message)
  6829. {
  6830. char flag[128], value[128];
  6831. nullpo_retr(-1, sd);
  6832. if (!message || !*message || sscanf(message, "%s %s", flag, value) != 2) {
  6833. clif_displaymessage(fd, "usage: @setbattleflag <flag> <value>.");
  6834. return -1;
  6835. }
  6836. if (battle_set_value(flag, value) == 0)
  6837. clif_displaymessage(fd, "unknown battle_config flag");
  6838. else
  6839. clif_displaymessage(fd, "battle_config set as requested");
  6840. return 0;
  6841. }
  6842. /*===========================
  6843. * @unmute [Valaris]
  6844. *===========================
  6845. */
  6846. int atcommand_unmute(
  6847. const int fd, struct map_session_data* sd,
  6848. const char* command, const char* message)
  6849. {
  6850. struct map_session_data *pl_sd = NULL;
  6851. nullpo_retr(-1, sd);
  6852. if (!message || !*message)
  6853. return -1;
  6854. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6855. if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) {
  6856. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  6857. skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  6858. clif_displaymessage(sd->fd,"Player unmuted");
  6859. }
  6860. else
  6861. clif_displaymessage(sd->fd,"Player is not muted");
  6862. }
  6863. return 0;
  6864. }
  6865. /*==========================================
  6866. * @uptime by MC Cameri
  6867. *------------------------------------------
  6868. */
  6869. int
  6870. atcommand_uptime(
  6871. const int fd, struct map_session_data* sd,
  6872. const char* command, const char* message)
  6873. {
  6874. char output[200];
  6875. long seconds = 0, day = 24*60*60, hour = 60*60,
  6876. minute = 60, days = 0, hours = 0, minutes = 0;
  6877. nullpo_retr(-1, sd);
  6878. seconds = (gettick()-ticks)/CLOCKS_PER_SEC;
  6879. days = seconds/day;
  6880. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6881. hours = seconds/hour;
  6882. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6883. minutes = seconds/minute;
  6884. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6885. snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds);
  6886. clif_displaymessage(fd,output);
  6887. return 0;
  6888. }
  6889. /*==========================================
  6890. * @changesex <sex>
  6891. * => Changes one's sex. Argument sex can be
  6892. * 0 or 1, m or f, male or female.
  6893. *------------------------------------------
  6894. */
  6895. int
  6896. atcommand_changesex(
  6897. const int fd, struct map_session_data* sd,
  6898. const char* command, const char* message)
  6899. {
  6900. nullpo_retr(-1, sd);
  6901. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  6902. return 0;
  6903. }
  6904. /*================================================
  6905. * @mute - Mutes a player for a set amount of time
  6906. *------------------------------------------------
  6907. */
  6908. int atcommand_mute(
  6909. const int fd, struct map_session_data* sd,
  6910. const char* command, const char* message)
  6911. {
  6912. struct map_session_data *pl_sd = NULL;
  6913. char character[100];
  6914. int manner;
  6915. nullpo_retr(-1, sd);
  6916. if (!message || !*message || sscanf(message, "%d %99[^\n]", &manner, character) < 1) {
  6917. clif_displaymessage(fd, "usage: @mute <time> <character name>.");
  6918. return -1;
  6919. }
  6920. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6921. pl_sd->status.manner -= manner;
  6922. if(pl_sd->status.manner < 0)
  6923. skill_status_change_start(&pl_sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  6924. }
  6925. else {
  6926. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6927. return -1;
  6928. }
  6929. return 0;
  6930. }
  6931. /*==========================================
  6932. * @refresh (like @jumpto <<yourself>>)
  6933. *------------------------------------------
  6934. */
  6935. int atcommand_refresh(
  6936. const int fd, struct map_session_data* sd,
  6937. const char* command, const char* message)
  6938. {
  6939. nullpo_retr(-1, sd);
  6940. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  6941. return 0;
  6942. }
  6943. /*==========================================
  6944. * @petid <part of pet name>
  6945. * => Displays a list of matching pets.
  6946. *------------------------------------------
  6947. */
  6948. int
  6949. atcommand_petid(const int fd, struct map_session_data* sd,
  6950. const char* command, const char* message)
  6951. {
  6952. char searchtext[100];
  6953. char temp0[100];
  6954. char temp1[100];
  6955. int cnt = 0, i = 0;
  6956. nullpo_retr(-1, sd);
  6957. if (!message || !*message)
  6958. return -1;
  6959. if (sscanf(message, "%99s", searchtext) < 1)
  6960. return -1;
  6961. estr_lower(searchtext);
  6962. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  6963. clif_displaymessage(fd,temp0);
  6964. while (i < MAX_PET_DB) {
  6965. strcpy(temp1,pet_db[i].name);
  6966. strcpy(temp1, estr_lower(temp1));
  6967. strcpy(temp0,pet_db[i].jname);
  6968. strcpy(temp0, estr_lower(temp1));
  6969. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  6970. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class,
  6971. pet_db[i].jname);
  6972. if (cnt >= 100) { // Only if there are custom pets
  6973. clif_displaymessage(fd, "Be more specific, can't send more than"
  6974. " 100 results.");
  6975. } else {
  6976. clif_displaymessage(fd, temp0);
  6977. }
  6978. cnt++;
  6979. }
  6980. i++;
  6981. }
  6982. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  6983. clif_displaymessage(fd, temp0);
  6984. return 0;
  6985. }
  6986. /*==========================================
  6987. * @identify
  6988. * => GM's magnifier.
  6989. *------------------------------------------
  6990. */
  6991. int
  6992. atcommand_identify(
  6993. const int fd, struct map_session_data* sd,
  6994. const char* command, const char* message)
  6995. {
  6996. int i,num;
  6997. nullpo_retr(-1, sd);
  6998. for(i=num=0;i<MAX_INVENTORY;i++){
  6999. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7000. num++;
  7001. }
  7002. }
  7003. if (num > 0) {
  7004. clif_item_identify_list(sd);
  7005. } else {
  7006. clif_displaymessage(fd,"There are no items to appraise.");
  7007. }
  7008. return 0;
  7009. }
  7010. /*==========================================
  7011. * @gmotd (Global MOTD)
  7012. * by davidsiaw :P
  7013. *------------------------------------------
  7014. */
  7015. int
  7016. atcommand_gmotd(
  7017. const int fd, struct map_session_data* sd,
  7018. const char* command, const char* message)
  7019. {
  7020. char buf[256];
  7021. FILE *fp;
  7022. nullpo_retr(-1, sd);
  7023. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7024. while (fgets(buf, 250, fp) != NULL){
  7025. int i;
  7026. for( i=0; buf[i]; i++){
  7027. if( buf[i]=='\r' || buf[i]=='\n'){
  7028. buf[i]=0;
  7029. break;
  7030. }
  7031. }
  7032. intif_GMmessage(buf,strlen(buf)+1,8);
  7033. }
  7034. fclose(fp);
  7035. }
  7036. return 0;
  7037. }
  7038. int atcommand_misceffect(
  7039. const int fd, struct map_session_data* sd,
  7040. const char* command, const char* message)
  7041. {
  7042. int effect = 0;
  7043. nullpo_retr(-1, sd);
  7044. if (!message || !*message)
  7045. return -1;
  7046. if (sscanf(message, "%d", &effect) < 1)
  7047. return -1;
  7048. clif_misceffect(&sd->bl,effect);
  7049. return 0;
  7050. }
  7051. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7052. /*==========================================
  7053. * Mail System commands by [Valaris]
  7054. *------------------------------------------
  7055. */
  7056. int atcommand_listmail(
  7057. const int fd, struct map_session_data* sd,
  7058. const char* command, const char* message)
  7059. {
  7060. if(!battle_config.mail_system)
  7061. return 0;
  7062. nullpo_retr(-1, sd);
  7063. if(strlen(command)==12)
  7064. mail_check(sd,3);
  7065. else if(strlen(command)==9)
  7066. mail_check(sd,2);
  7067. else
  7068. mail_check(sd,1);
  7069. return 0;
  7070. }
  7071. int atcommand_readmail(
  7072. const int fd, struct map_session_data* sd,
  7073. const char* command, const char* message)
  7074. {
  7075. if(!battle_config.mail_system)
  7076. return 0;
  7077. nullpo_retr(-1, sd);
  7078. if (!message || !*message) {
  7079. clif_displaymessage(sd->fd,"You must specify a message number.");
  7080. return 0;
  7081. }
  7082. if(strlen(command)==11)
  7083. mail_delete(sd,atoi(message));
  7084. else
  7085. mail_read(sd,atoi(message));
  7086. return 0;
  7087. }
  7088. int atcommand_sendmail(
  7089. const int fd, struct map_session_data* sd,
  7090. const char* command, const char* message)
  7091. {
  7092. char name[24],text[80];
  7093. if(!battle_config.mail_system)
  7094. return 0;
  7095. nullpo_retr(-1, sd);
  7096. if (!message || !*message) {
  7097. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7098. return 0;
  7099. }
  7100. if ((sscanf(message, "\"%[^\"]\" %79[^\n]", name, text) < 2) &&
  7101. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7102. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7103. return 0;
  7104. }
  7105. if(strlen(command)==17)
  7106. mail_send(sd,name,text,1);
  7107. else
  7108. mail_send(sd,name,text,0);
  7109. return 0;
  7110. }
  7111. /*==========================================
  7112. * Refresh online command for SQL [Valaris]
  7113. * Will refresh and check online column of
  7114. * players and set correctly.
  7115. *------------------------------------------
  7116. */
  7117. int atcommand_refreshonline(
  7118. const int fd, struct map_session_data* sd,
  7119. const char* command, const char* message)
  7120. {
  7121. nullpo_retr(-1, sd);
  7122. char_online_check();
  7123. return 0;
  7124. }
  7125. #endif /* end sql only */