atcommand.c 304 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include "../common/socket.h"
  9. #include "../common/timer.h"
  10. #include "../common/nullpo.h"
  11. #include "../common/mmo.h"
  12. #include "../common/core.h"
  13. #include "../common/showmsg.h"
  14. #include "log.h"
  15. #include "clif.h"
  16. #include "chrif.h"
  17. #include "intif.h"
  18. #include "itemdb.h"
  19. #include "map.h"
  20. #include "pc.h"
  21. #include "status.h"
  22. #include "skill.h"
  23. #include "mob.h"
  24. #include "pet.h"
  25. #include "battle.h"
  26. #include "party.h"
  27. #include "guild.h"
  28. #include "atcommand.h"
  29. #include "script.h"
  30. #include "npc.h"
  31. #include "trade.h"
  32. #ifndef TXT_ONLY
  33. #include "mail.h"
  34. #endif
  35. static char command_symbol = '@'; // first char of the commands (by [Yor])
  36. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  37. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  38. ACMD_FUNC(broadcast);
  39. ACMD_FUNC(localbroadcast);
  40. ACMD_FUNC(rura);
  41. ACMD_FUNC(where);
  42. ACMD_FUNC(jumpto);
  43. ACMD_FUNC(jump);
  44. ACMD_FUNC(who);
  45. ACMD_FUNC(who2);
  46. ACMD_FUNC(who3);
  47. ACMD_FUNC(whomap);
  48. ACMD_FUNC(whomap2);
  49. ACMD_FUNC(whomap3);
  50. ACMD_FUNC(whogm); // by Yor
  51. ACMD_FUNC(whozeny); // [Valaris]
  52. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  53. ACMD_FUNC(save);
  54. ACMD_FUNC(load);
  55. ACMD_FUNC(speed);
  56. ACMD_FUNC(storage);
  57. ACMD_FUNC(guildstorage);
  58. ACMD_FUNC(option);
  59. ACMD_FUNC(hide);
  60. ACMD_FUNC(jobchange);
  61. ACMD_FUNC(die);
  62. ACMD_FUNC(kill);
  63. ACMD_FUNC(alive);
  64. ACMD_FUNC(kami);
  65. ACMD_FUNC(heal);
  66. ACMD_FUNC(item);
  67. ACMD_FUNC(item2);
  68. ACMD_FUNC(itemreset);
  69. ACMD_FUNC(itemcheck);
  70. ACMD_FUNC(baselevelup);
  71. ACMD_FUNC(joblevelup);
  72. ACMD_FUNC(help);
  73. ACMD_FUNC(help2);
  74. ACMD_FUNC(gm);
  75. ACMD_FUNC(pvpoff);
  76. ACMD_FUNC(pvpon);
  77. ACMD_FUNC(gvgoff);
  78. ACMD_FUNC(gvgon);
  79. ACMD_FUNC(model);
  80. ACMD_FUNC(go);
  81. ACMD_FUNC(monster);
  82. ACMD_FUNC(monstersmall);
  83. ACMD_FUNC(monsterbig);
  84. ACMD_FUNC(spawn);
  85. ACMD_FUNC(killmonster);
  86. ACMD_FUNC(killmonster2);
  87. ACMD_FUNC(refine);
  88. ACMD_FUNC(produce);
  89. ACMD_FUNC(memo);
  90. ACMD_FUNC(gat);
  91. ACMD_FUNC(packet);
  92. ACMD_FUNC(waterlevel);
  93. ACMD_FUNC(statuspoint);
  94. ACMD_FUNC(skillpoint);
  95. ACMD_FUNC(zeny);
  96. ACMD_FUNC(param);
  97. ACMD_FUNC(guildlevelup);
  98. ACMD_FUNC(makeegg);
  99. ACMD_FUNC(hatch);
  100. ACMD_FUNC(petfriendly);
  101. ACMD_FUNC(pethungry);
  102. ACMD_FUNC(petrename);
  103. ACMD_FUNC(recall);
  104. ACMD_FUNC(recallall);
  105. ACMD_FUNC(revive);
  106. ACMD_FUNC(night);
  107. ACMD_FUNC(day);
  108. ACMD_FUNC(doom);
  109. ACMD_FUNC(doommap);
  110. ACMD_FUNC(raise);
  111. ACMD_FUNC(raisemap);
  112. ACMD_FUNC(kick);
  113. ACMD_FUNC(kickall);
  114. ACMD_FUNC(allskill);
  115. ACMD_FUNC(questskill);
  116. ACMD_FUNC(lostskill);
  117. ACMD_FUNC(spiritball);
  118. ACMD_FUNC(party);
  119. ACMD_FUNC(guild);
  120. ACMD_FUNC(agitstart);
  121. ACMD_FUNC(agitend);
  122. ACMD_FUNC(reloaditemdb);
  123. ACMD_FUNC(reloadmobdb);
  124. ACMD_FUNC(reloadskilldb);
  125. ACMD_FUNC(reloadscript);
  126. ACMD_FUNC(reloadgmdb); // by Yor
  127. ACMD_FUNC(reloadatcommand);
  128. ACMD_FUNC(reloadbattleconf);
  129. ACMD_FUNC(reloadstatusdb);
  130. ACMD_FUNC(reloadpcdb);
  131. ACMD_FUNC(reloadmotd); // [Valaris]
  132. ACMD_FUNC(mapexit);
  133. ACMD_FUNC(idsearch);
  134. ACMD_FUNC(mapinfo);
  135. ACMD_FUNC(dye); //** by fritz
  136. ACMD_FUNC(hair_style); //** by fritz
  137. ACMD_FUNC(hair_color); //** by fritz
  138. ACMD_FUNC(stat_all); //** by fritz
  139. ACMD_FUNC(char_block); // by Yor
  140. ACMD_FUNC(char_ban); // by Yor
  141. ACMD_FUNC(char_unblock); // by Yor
  142. ACMD_FUNC(char_unban); // by Yor
  143. ACMD_FUNC(mount_peco); // by Valaris
  144. ACMD_FUNC(char_mount_peco); // by Yor
  145. ACMD_FUNC(guildspy); // [Syrus22]
  146. ACMD_FUNC(partyspy); // [Syrus22]
  147. ACMD_FUNC(repairall); // [Valaris]
  148. ACMD_FUNC(guildrecall); // by Yor
  149. ACMD_FUNC(partyrecall); // by Yor
  150. ACMD_FUNC(nuke); // [Valaris]
  151. ACMD_FUNC(shownpc);
  152. ACMD_FUNC(hidenpc);
  153. ACMD_FUNC(loadnpc);
  154. ACMD_FUNC(unloadnpc);
  155. ACMD_FUNC(servertime); // by Yor
  156. ACMD_FUNC(chardelitem); // by Yor
  157. ACMD_FUNC(jail); // by Yor
  158. ACMD_FUNC(unjail); // by Yor
  159. ACMD_FUNC(disguise); // [Valaris]
  160. ACMD_FUNC(undisguise); // by Yor
  161. ACMD_FUNC(chardisguise); // Kalaspuff
  162. ACMD_FUNC(charundisguise); // Kalaspuff
  163. ACMD_FUNC(email); // by Yor
  164. ACMD_FUNC(effect);//by Apple
  165. ACMD_FUNC(character_cart_list); // by Yor
  166. ACMD_FUNC(addwarp); // by MouseJstr
  167. ACMD_FUNC(follow); // by MouseJstr
  168. ACMD_FUNC(skillon); // by MouseJstr
  169. ACMD_FUNC(skilloff); // by MouseJstr
  170. ACMD_FUNC(killer); // by MouseJstr
  171. ACMD_FUNC(npcmove); // by MouseJstr
  172. ACMD_FUNC(killable); // by MouseJstr
  173. ACMD_FUNC(charkillable); // by MouseJstr
  174. ACMD_FUNC(dropall); // by MouseJstr
  175. ACMD_FUNC(chardropall); // by MouseJstr
  176. ACMD_FUNC(storeall); // by MouseJstr
  177. ACMD_FUNC(charstoreall); // by MouseJstr
  178. ACMD_FUNC(skillid); // by MouseJstr
  179. ACMD_FUNC(useskill); // by MouseJstr
  180. ACMD_FUNC(summon);
  181. ACMD_FUNC(rain);
  182. ACMD_FUNC(snow);
  183. ACMD_FUNC(sakura);
  184. ACMD_FUNC(clouds);
  185. ACMD_FUNC(clouds2); // [Valaris]
  186. ACMD_FUNC(fog);
  187. ACMD_FUNC(fireworks);
  188. ACMD_FUNC(leaves);
  189. ACMD_FUNC(adjgmlvl); // by MouseJstr
  190. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  191. ACMD_FUNC(trade); // by MouseJstr
  192. ACMD_FUNC(send); // by davidsiaw
  193. ACMD_FUNC(setbattleflag); // by MouseJstr
  194. ACMD_FUNC(unmute); // [Valaris]
  195. ACMD_FUNC(clearweather); // Dexity
  196. ACMD_FUNC(uptime); // by MC Cameri
  197. ACMD_FUNC(changesex); // by MC Cameri
  198. ACMD_FUNC(mute); // celest
  199. ACMD_FUNC(refresh); // by MC Cameri
  200. ACMD_FUNC(petid); // by MC Cameri
  201. ACMD_FUNC(identify); // by MC Cameri
  202. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  203. ACMD_FUNC(misceffect); // by MC Cameri
  204. ACMD_FUNC(mobsearch);
  205. ACMD_FUNC(cleanmap);
  206. ACMD_FUNC(npctalk);
  207. ACMD_FUNC(pettalk);
  208. ACMD_FUNC(users);
  209. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  210. #ifndef TXT_ONLY
  211. ACMD_FUNC(checkmail); // [Valaris]
  212. ACMD_FUNC(listmail); // [Valaris]
  213. ACMD_FUNC(listnewmail); // [Valaris]
  214. ACMD_FUNC(readmail); // [Valaris]
  215. ACMD_FUNC(sendmail); // [Valaris]
  216. ACMD_FUNC(sendprioritymail); // [Valaris]
  217. ACMD_FUNC(deletemail); // [Valaris]
  218. ACMD_FUNC(refreshonline); // [Valaris]
  219. #endif /* TXT_ONLY */
  220. ACMD_FUNC(skilltree); // by MouseJstr
  221. ACMD_FUNC(marry); // by MouseJstr
  222. ACMD_FUNC(divorce); // by MouseJstr
  223. ACMD_FUNC(grind); // by MouseJstr
  224. ACMD_FUNC(grind2); // by MouseJstr
  225. #ifdef DMALLOC
  226. ACMD_FUNC(dmstart); // by MouseJstr
  227. ACMD_FUNC(dmtick); // by MouseJstr
  228. #endif
  229. ACMD_FUNC(jumptoid); // by Dino9021
  230. ACMD_FUNC(jumptoid2); // by Dino9021
  231. ACMD_FUNC(recallid); // by Dino9021
  232. ACMD_FUNC(recallid2); // by Dino9021
  233. ACMD_FUNC(kickid); // by Dino9021
  234. ACMD_FUNC(kickid2); // by Dino9021
  235. ACMD_FUNC(reviveid); // by Dino9021
  236. ACMD_FUNC(reviveid2); // by Dino9021
  237. ACMD_FUNC(killid); // by Dino9021
  238. ACMD_FUNC(killid2); // by Dino9021
  239. ACMD_FUNC(charkillableid); // by Dino9021
  240. ACMD_FUNC(charkillableid2); // by Dino9021
  241. ACMD_FUNC(sound);
  242. ACMD_FUNC(undisguiseall);
  243. ACMD_FUNC(disguiseall);
  244. ACMD_FUNC(changelook);
  245. ACMD_FUNC(mobinfo); //by Lupus
  246. ACMD_FUNC(adopt); // by Veider
  247. ACMD_FUNC(version); // by Ancyker
  248. ACMD_FUNC(mutearea); // by MouseJstr
  249. ACMD_FUNC(shuffle); // by MouseJstr
  250. ACMD_FUNC(rates); // by MouseJstr
  251. ACMD_FUNC(iteminfo); // Lupus
  252. ACMD_FUNC(mapflag); // Lupus
  253. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  254. ACMD_FUNC(monsterignore); // [Valaris]
  255. ACMD_FUNC(fakename); //[Valaris]
  256. ACMD_FUNC(size); //[Valaris]
  257. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  258. ACMD_FUNC(showzeny);
  259. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  260. ACMD_FUNC(autotrade);// durf
  261. ACMD_FUNC(changeleader);// [Skotlex]
  262. ACMD_FUNC(changegm);// durf
  263. // Duel [LuzZza]
  264. ACMD_FUNC(invite);
  265. ACMD_FUNC(duel);
  266. ACMD_FUNC(leave);
  267. ACMD_FUNC(accept);
  268. ACMD_FUNC(reject);
  269. ACMD_FUNC(away); // LuzZza
  270. ACMD_FUNC(main); // LuzZza
  271. ACMD_FUNC(clone); // [Valaris]
  272. /*==========================================
  273. *AtCommandInfo atcommand_info[]構造体の定義
  274. *------------------------------------------
  275. */
  276. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  277. // to set default level, read atcommand_athena.conf first please.
  278. static AtCommandInfo atcommand_info[] = {
  279. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  280. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  281. { AtCommand_Where, "@where", 1, atcommand_where },
  282. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  283. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  284. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  285. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  286. { AtCommand_Who, "@who", 20, atcommand_who },
  287. { AtCommand_Who, "@whois", 20, atcommand_who },
  288. { AtCommand_Who, "@w", 20, atcommand_who },
  289. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  290. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  291. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  292. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  293. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  294. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  295. { AtCommand_Save, "@save", 40, atcommand_save },
  296. { AtCommand_Load, "@return", 40, atcommand_load },
  297. { AtCommand_Load, "@load", 40, atcommand_load },
  298. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  299. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  300. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  301. { AtCommand_Option, "@option", 40, atcommand_option },
  302. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  303. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  304. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  305. { AtCommand_Die, "@die", 1, atcommand_die },
  306. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  307. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  308. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  309. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  310. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  311. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  312. { AtCommand_Item, "@item", 60, atcommand_item },
  313. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  314. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  315. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  316. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  317. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  318. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  319. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  320. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  321. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  322. { AtCommand_H, "@h", 20, atcommand_help },
  323. { AtCommand_Help, "@help", 20, atcommand_help },
  324. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  325. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  326. { AtCommand_GM, "@gm", 100,atcommand_gm },
  327. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  328. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  329. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  330. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  331. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  332. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  333. { AtCommand_Model, "@model", 20, atcommand_model },
  334. { AtCommand_Go, "@go", 10, atcommand_go },
  335. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  336. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  337. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  338. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  339. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  340. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  341. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  342. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  343. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  344. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  345. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  346. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  347. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  348. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  349. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  350. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  351. { AtCommand_Strength, "@str", 60, atcommand_param },
  352. { AtCommand_Agility, "@agi", 60, atcommand_param },
  353. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  354. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  355. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  356. { AtCommand_Luck, "@luk", 60, atcommand_param },
  357. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  358. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  359. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  360. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  361. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  362. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  363. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  364. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  365. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  366. { AtCommand_Night, "@night", 80, atcommand_night },
  367. { AtCommand_Day, "@day", 80, atcommand_day },
  368. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  369. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  370. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  371. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  372. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  373. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  374. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  375. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  376. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  377. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  378. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  379. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  380. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  381. { AtCommand_Party, "@party", 1, atcommand_party },
  382. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  383. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  384. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  385. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  386. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  387. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  388. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  389. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  390. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  391. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  392. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  393. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  394. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  395. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  396. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  397. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  398. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  399. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  400. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  401. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  402. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  403. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  404. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  405. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  406. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  407. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  408. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  409. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  410. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  411. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  412. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  413. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  414. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  415. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  416. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  417. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  418. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  419. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  420. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  421. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  422. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  423. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  424. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  425. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  426. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  427. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  428. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  429. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  430. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  431. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  432. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  433. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  434. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  435. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  436. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  437. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  438. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  439. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  440. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  441. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  442. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  443. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  444. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  445. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  446. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  447. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  448. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  449. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  450. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  451. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  452. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  453. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  454. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  455. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  456. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  457. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  458. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  459. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  460. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  461. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  462. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  463. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  464. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  465. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  466. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  467. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  468. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  469. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  470. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  471. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  472. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  473. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  474. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  475. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  476. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  477. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  478. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  479. { AtCommand_Send, "@send", 60, atcommand_send },
  480. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  481. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  482. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  483. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  484. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken]
  485. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  486. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  487. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  488. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  489. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  490. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  491. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  492. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  493. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  494. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  495. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  496. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  497. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  498. { AtCommand_Users, "@users", 40, atcommand_users },
  499. { AtCommand_ResetState, "/reset", 40, NULL },
  500. #ifndef TXT_ONLY // sql-only commands
  501. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  502. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  503. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  504. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  505. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  506. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  507. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  508. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  509. #endif /* TXT_ONLY */
  510. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  511. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  512. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  513. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  514. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  515. #ifdef DMALLOC
  516. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  517. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  518. #endif
  519. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  520. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  521. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  522. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  523. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  524. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  525. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  526. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  527. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  528. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  529. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  530. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  531. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  532. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  533. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  534. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  535. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  536. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  537. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  538. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  539. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  540. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  541. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  542. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  543. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  544. { AtCommand_Version, "@version", 1, atcommand_version },
  545. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  546. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  547. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  548. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  549. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  550. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  551. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  552. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  553. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  554. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  555. { AtCommand_Size, "@size", 20, atcommand_size },
  556. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  557. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  558. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  559. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  560. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  561. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  562. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  563. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  564. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  565. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  566. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  567. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  568. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  569. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  570. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  571. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  572. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  573. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  574. // add new commands before this line
  575. { AtCommand_Unknown, NULL, 1, NULL }
  576. };
  577. /*=========================================
  578. * Generic variables
  579. *-----------------------------------------
  580. */
  581. char atcmd_output[200];
  582. char atcmd_player_name[100];
  583. char atcmd_temp[100];
  584. /*==========================================
  585. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  586. *------------------------------------------
  587. */
  588. char *estr_lower(char *str)
  589. {
  590. int i;
  591. for (i=0; str[i]; i++)
  592. if ((str[i] >= 65) && (str[i] <= 90))
  593. str[i] += 32;
  594. return str;
  595. }
  596. // compare function for sorting high to lowest
  597. int hightolow_compare (const void * a, const void * b)
  598. {
  599. return ( *(int*)b - *(int*)a );
  600. }
  601. // compare function for sorting lowest to highest
  602. int lowtohigh_compare (const void * a, const void * b)
  603. {
  604. return ( *(int*)a - *(int*)b );
  605. }
  606. //-----------------------------------------------------------
  607. // Return the message string of the specified number by [Yor]
  608. //-----------------------------------------------------------
  609. char * msg_txt(int msg_number) {
  610. if (msg_number >= 0 && msg_number < MAX_MSG &&
  611. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  612. return msg_table[msg_number];
  613. return "??";
  614. }
  615. //-----------------------------------------------------------
  616. // Returns Players title (from msg_athena.conf) [Lupus]
  617. //-----------------------------------------------------------
  618. char * player_title_txt(int level) {
  619. if (level < battle_config.title_lvl1)
  620. return ""; //w/o any titles
  621. if (level >= battle_config.title_lvl8)
  622. sprintf(atcmd_temp, msg_table[332], level);
  623. else
  624. if (level >= battle_config.title_lvl7)
  625. sprintf(atcmd_temp, msg_table[331], level);
  626. else
  627. if (level >= battle_config.title_lvl6)
  628. sprintf(atcmd_temp, msg_table[330], level);
  629. else
  630. if (level >= battle_config.title_lvl5)
  631. sprintf(atcmd_temp, msg_table[329], level);
  632. else
  633. if (level >= battle_config.title_lvl4)
  634. sprintf(atcmd_temp, msg_table[328], level);
  635. else
  636. if (level >= battle_config.title_lvl3)
  637. sprintf(atcmd_temp, msg_table[327], level);
  638. else
  639. if (level >= battle_config.title_lvl2)
  640. sprintf(atcmd_temp, msg_table[326], level);
  641. else
  642. sprintf(atcmd_temp, msg_table[325], level); //lvl1
  643. return atcmd_temp;
  644. }
  645. //------------------------------------------------------------
  646. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  647. //------------------------------------------------------------
  648. int e_mail_check(char *email) {
  649. char ch;
  650. char* last_arobas;
  651. // athena limits
  652. if (strlen(email) < 3 || strlen(email) > 39)
  653. return 0;
  654. // part of RFC limits (official reference of e-mail description)
  655. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  656. return 0;
  657. if (email[strlen(email)-1] == '.')
  658. return 0;
  659. last_arobas = strrchr(email, '@');
  660. if (strstr(last_arobas, "@.") != NULL ||
  661. strstr(last_arobas, "..") != NULL)
  662. return 0;
  663. for(ch = 1; ch < 32; ch++) {
  664. if (strchr(last_arobas, ch) != NULL) {
  665. return 0;
  666. break;
  667. }
  668. }
  669. if (strchr(last_arobas, ' ') != NULL ||
  670. strchr(last_arobas, ';') != NULL)
  671. return 0;
  672. // all correct
  673. return 1;
  674. }
  675. /*==========================================
  676. * get_atcommand_level @コマンドの必要レベルを取得
  677. *------------------------------------------
  678. */
  679. int get_atcommand_level(const AtCommandType type) {
  680. int i;
  681. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  682. if (atcommand_info[i].type == type)
  683. return atcommand_info[i].level;
  684. return 100; // 100: command can not be used
  685. }
  686. /*==========================================
  687. *is_atcommand @コマンドに存在するかどうか確認する
  688. *------------------------------------------
  689. */
  690. AtCommandType
  691. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  692. const char* str = message;
  693. int s_flag = 0;
  694. AtCommandInfo info;
  695. AtCommandType type;
  696. nullpo_retr(AtCommand_None, sd);
  697. if (!battle_config.allow_atcommand_when_mute &&
  698. sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1) {
  699. return AtCommand_Unknown;
  700. }
  701. if (!message || !*message)
  702. return AtCommand_None;
  703. memset(&info, 0, sizeof(info));
  704. str += strlen(sd->status.name);
  705. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  706. if (*str == ':')
  707. s_flag = 1;
  708. str++;
  709. }
  710. if (!*str)
  711. return AtCommand_None;
  712. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  713. if (type != AtCommand_None) {
  714. char command[100];
  715. const char* p = str;
  716. memset(command, '\0', sizeof(command));
  717. memset(atcmd_output, '\0', sizeof(atcmd_output));
  718. while (*p && !isspace(*p))
  719. p++;
  720. if (p - str >= sizeof(command)) // too long
  721. return AtCommand_Unknown;
  722. strncpy(command, str, p - str);
  723. while (isspace(*p))
  724. p++;
  725. if (type == AtCommand_Unknown || info.proc == NULL) {
  726. sprintf(atcmd_output, msg_table[153], command); // %s is Unknown Command.
  727. clif_displaymessage(fd, atcmd_output);
  728. } else {
  729. if (info.proc(fd, sd, command, p) != 0) {
  730. // Command can not be executed
  731. sprintf(atcmd_output, msg_table[154], command); // %s failed.
  732. clif_displaymessage(fd, atcmd_output);
  733. }
  734. }
  735. return info.type;
  736. }
  737. return AtCommand_None;
  738. }
  739. /*==========================================
  740. *
  741. *------------------------------------------
  742. */
  743. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  744. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  745. if (!info)
  746. return AtCommand_None;
  747. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  748. return AtCommand_None;
  749. if (!p || !*p) {
  750. ShowError("at command message is empty\n");
  751. return AtCommand_None;
  752. }
  753. if (*p == command_symbol) { // check first char.
  754. char command[101];
  755. int i = 0;
  756. memset(info, 0, sizeof(AtCommandInfo));
  757. sscanf(p, "%100s", command);
  758. command[sizeof(command)-1] = '\0';
  759. while (atcommand_info[i].type != AtCommand_Unknown) {
  760. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  761. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  762. break;
  763. }
  764. i++;
  765. }
  766. if (atcommand_info[i].type == AtCommand_Unknown) {
  767. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  768. if (level == 0)
  769. return AtCommand_None;
  770. else
  771. return AtCommand_Unknown;
  772. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  773. log_atcommand(sd, message);
  774. }
  775. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  776. } else {
  777. return AtCommand_None;
  778. }
  779. return info->type;
  780. }
  781. /*==========================================
  782. * Read Message Data
  783. *------------------------------------------
  784. */
  785. int msg_config_read(const char *cfgName) {
  786. int msg_number;
  787. char line[1024], w1[1024], w2[1024];
  788. FILE *fp;
  789. static int called = 1;
  790. if ((fp = fopen(cfgName, "r")) == NULL) {
  791. ShowError("Messages file not found: %s\n", cfgName);
  792. return 1;
  793. }
  794. if ((--called) == 0)
  795. memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
  796. while(fgets(line, sizeof(line)-1, fp)) {
  797. if (line[0] == '/' && line[1] == '/')
  798. continue;
  799. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  800. if (strcmpi(w1, "import") == 0) {
  801. msg_config_read(w2);
  802. } else {
  803. msg_number = atoi(w1);
  804. if (msg_number >= 0 && msg_number < MAX_MSG) {
  805. if (msg_table[msg_number] != NULL)
  806. aFree(msg_table[msg_number]);
  807. msg_table[msg_number] = (char *)aCalloc(strlen(w2) + 1, sizeof (char));
  808. strcpy(msg_table[msg_number],w2);
  809. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  810. }
  811. }
  812. }
  813. }
  814. fclose(fp);
  815. return 0;
  816. }
  817. /*==========================================
  818. * Cleanup Message Data
  819. *------------------------------------------
  820. */
  821. void do_final_msg (void) {
  822. int i;
  823. for (i = 0; i < MAX_MSG; i++)
  824. aFree(msg_table[i]);
  825. return;
  826. }
  827. /*==========================================
  828. *
  829. *------------------------------------------
  830. */
  831. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  832. int i;
  833. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  834. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  835. return &atcommand_info[i];
  836. return NULL;
  837. }
  838. /*==========================================
  839. *
  840. *------------------------------------------
  841. */
  842. int atcommand_config_read(const char *cfgName) {
  843. char line[1024], w1[1024], w2[1024];
  844. AtCommandInfo* p;
  845. FILE* fp;
  846. if ((fp = fopen(cfgName, "r")) == NULL) {
  847. ShowError("At commands configuration file not found: %s\n", cfgName);
  848. return 1;
  849. }
  850. while (fgets(line, sizeof(line)-1, fp)) {
  851. if (line[0] == '/' && line[1] == '/')
  852. continue;
  853. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  854. continue;
  855. p = get_atcommandinfo_byname(w1);
  856. if (p != NULL) {
  857. p->level = atoi(w2);
  858. if (p->level > 100)
  859. p->level = 100;
  860. else if (p->level < 0)
  861. p->level = 0;
  862. }
  863. if (strcmpi(w1, "import") == 0)
  864. atcommand_config_read(w2);
  865. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  866. w2[0] != '/' && // symbol of standard ragnarok GM commands
  867. w2[0] != '%' && // symbol of party chat speaking
  868. w2[0] != '$' && // symbol of guild chat
  869. w2[0] != '#') // symbol of charcommand
  870. command_symbol = w2[0];
  871. }
  872. fclose(fp);
  873. return 0;
  874. }
  875. /*==========================================
  876. * Duel organizing functions [LuzZza]
  877. *------------------------------------------
  878. */
  879. void duel_msg_foreach_sameduel_wos(
  880. const unsigned int did, struct map_session_data* sd, char *output)
  881. {
  882. int i;
  883. struct map_session_data* msg_sd;
  884. for(i=0; i<fd_max; i++)
  885. if(session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  886. && msg_sd->state.auth && msg_sd->duel_group == did && msg_sd != sd)
  887. clif_disp_onlyself(msg_sd, output, strlen(output));
  888. return;
  889. }
  890. void duel_savetime(struct map_session_data* sd) {
  891. time_t timer;
  892. struct tm *t;
  893. time(&timer);
  894. t = localtime(&timer);
  895. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  896. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  897. return;
  898. }
  899. int duel_checktime(struct map_session_data* sd) {
  900. int diff;
  901. time_t timer;
  902. struct tm *t;
  903. time(&timer);
  904. t = localtime(&timer);
  905. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  906. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  907. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  908. }
  909. int duel_showinfo(
  910. const unsigned int did, struct map_session_data* sd)
  911. {
  912. int i, p=0;
  913. char output[256];
  914. struct map_session_data* msg_sd;
  915. if(duel_list[did].max_players_limit > 0)
  916. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  917. did, duel_count,
  918. duel_list[did].members_count,
  919. duel_list[did].members_count + duel_list[did].invites_count,
  920. duel_list[did].max_players_limit);
  921. else
  922. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  923. did, duel_count,
  924. duel_list[did].members_count,
  925. duel_list[did].members_count + duel_list[did].invites_count);
  926. clif_disp_onlyself(sd, output, strlen(output));
  927. for(i=0; i<fd_max; i++)
  928. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  929. && msg_sd->state.auth && msg_sd->duel_group == did) {
  930. sprintf(output, " %d. %s", ++p, (unsigned char *) msg_sd->status.name);
  931. clif_disp_onlyself(sd, output, strlen(output));
  932. }
  933. return 0;
  934. }
  935. int duel_create(
  936. struct map_session_data* sd, const unsigned int maxpl)
  937. {
  938. int i=1;
  939. char output[256];
  940. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  941. if(i == MAX_DUEL) return 0;
  942. duel_count++;
  943. sd->duel_group = i;
  944. duel_list[i].members_count++;
  945. duel_list[i].invites_count = 0;
  946. duel_list[i].max_players_limit = maxpl;
  947. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  948. clif_disp_onlyself(sd, output, strlen(output));
  949. clif_set0199(sd->fd, 1);
  950. //clif_misceffect2(&sd->bl, 159);
  951. return i;
  952. }
  953. int duel_invite(
  954. const unsigned int did, struct map_session_data* sd,
  955. struct map_session_data* target_sd)
  956. {
  957. char output[256];
  958. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  959. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  960. duel_msg_foreach_sameduel_wos(did, sd, output);
  961. target_sd->duel_invite = did;
  962. duel_list[did].invites_count++;
  963. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  964. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  965. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  966. return 0;
  967. }
  968. int duel_leave(
  969. const unsigned int did, struct map_session_data* sd)
  970. {
  971. int i;
  972. char output[256];
  973. struct map_session_data* msg_sd;
  974. // " <- Player %s has left duel --"
  975. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  976. duel_msg_foreach_sameduel_wos(did, sd, output);
  977. duel_list[did].members_count--;
  978. if(duel_list[did].members_count == 0) {
  979. for (i=0; i<fd_max; i++)
  980. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  981. && msg_sd->state.auth && msg_sd->duel_invite == did && msg_sd != sd) {
  982. msg_sd->duel_invite = 0;
  983. }
  984. duel_count--;
  985. }
  986. sd->duel_group = 0;
  987. duel_savetime(sd);
  988. clif_set0199(sd->fd, 0);
  989. return 0;
  990. }
  991. int duel_accept(
  992. const unsigned int did, struct map_session_data* sd)
  993. {
  994. char output[256];
  995. // " -> Player %s has accepted duel --"
  996. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  997. duel_msg_foreach_sameduel_wos(did, sd, output);
  998. duel_list[did].members_count++;
  999. sd->duel_group = sd->duel_invite;
  1000. duel_list[did].invites_count--;
  1001. sd->duel_invite = 0;
  1002. clif_set0199(sd->fd, 1);
  1003. //clif_misceffect2(&sd->bl, 159);
  1004. return 0;
  1005. }
  1006. int duel_reject(
  1007. const unsigned int did, struct map_session_data* sd)
  1008. {
  1009. char output[256];
  1010. // " -- Player %s has rejected duel --"
  1011. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1012. duel_msg_foreach_sameduel_wos(did, sd, output);
  1013. duel_list[did].invites_count--;
  1014. sd->duel_invite = 0;
  1015. return 0;
  1016. }
  1017. /*==========================================
  1018. // @ command processing functions
  1019. *------------------------------------------
  1020. */
  1021. /*==========================================
  1022. * @send (used for testing packet sends from the client)
  1023. *------------------------------------------
  1024. */
  1025. int atcommand_send(
  1026. const int fd, struct map_session_data* sd,
  1027. const char* command, const char* message)
  1028. {
  1029. int i,type=0;
  1030. int info[20];
  1031. if (!message || !*message || sscanf(message, "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &type, &info[1], &info[2], &info[3], &info[4], &info[5], &info[6], &info[7], &info[8], &info[9], &info[10], &info[11], &info[12], &info[13], &info[14], &info[15], &info[16], &info[17], &info[18], &info[19], &info[20]) < 1) {
  1032. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1033. return -1;
  1034. }
  1035. if (type > 0 && type < MAX_PACKET_DB) {
  1036. switch (type)
  1037. {
  1038. case 0x209: {
  1039. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1040. WFIFOW(fd,0) = 0x209;
  1041. WFIFOW(fd,2) = 2;
  1042. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1043. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1044. break;
  1045. }
  1046. case 0x1b1:
  1047. case 0x1c2:
  1048. //case xxx:
  1049. // add others here
  1050. // break;
  1051. default: {
  1052. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1053. WFIFOW(fd,0) = type;
  1054. for(i=1;i<=sizeof(info);i++)
  1055. if(info[i])
  1056. WFIFOW(fd,i) = info[i];
  1057. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1058. break;
  1059. }
  1060. }
  1061. sprintf (atcmd_output, msg_table[258], type, type);
  1062. clif_displaymessage(fd, atcmd_output);
  1063. } else {
  1064. clif_displaymessage(fd, msg_table[259]);
  1065. }
  1066. return 0;
  1067. }
  1068. // @rura
  1069. /*==========================================
  1070. *
  1071. *------------------------------------------
  1072. */
  1073. int atcommand_rura(
  1074. const int fd, struct map_session_data* sd,
  1075. const char* command, const char* message)
  1076. {
  1077. char map_name[MAP_NAME_LENGTH];
  1078. unsigned short mapindex;
  1079. int x = 0, y = 0;
  1080. int m = -1;
  1081. nullpo_retr(-1, sd);
  1082. memset(map_name, '\0', sizeof(map_name));
  1083. if (!message || !*message || sscanf(message, "%15s %d %d", map_name, &x, &y) < 1) {
  1084. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1085. return -1;
  1086. }
  1087. if (x <= 0)
  1088. x = rand() % 399 + 1;
  1089. if (y <= 0)
  1090. y = rand() % 399 + 1;
  1091. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1092. strcat(map_name, ".gat");
  1093. mapindex = mapindex_name2id(map_name);
  1094. if (mapindex)
  1095. m = map_mapindex2mapid(mapindex);
  1096. if (!mapindex || m < 0) {
  1097. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1098. return -1;
  1099. }
  1100. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1101. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1102. clif_displaymessage(fd, msg_table[247]);
  1103. return -1;
  1104. }
  1105. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1106. clif_displaymessage(fd, msg_table[248]);
  1107. return -1;
  1108. }
  1109. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1110. clif_displaymessage(fd, msg_table[0]); // Warped.
  1111. else {
  1112. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1113. return -1;
  1114. }
  1115. } else {
  1116. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1117. return -1;
  1118. }
  1119. return 0;
  1120. }
  1121. /*==========================================
  1122. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1123. *------------------------------------------
  1124. */
  1125. int atcommand_where(
  1126. const int fd, struct map_session_data* sd,
  1127. const char* command, const char* message)
  1128. {
  1129. struct map_session_data *pl_sd = NULL;
  1130. int GM_level, pl_GM_level;
  1131. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1132. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1133. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1134. return -1;
  1135. }
  1136. pl_sd = map_nick2sd(atcmd_player_name);
  1137. nullpo_retr(-1, sd);
  1138. if (pl_sd == NULL)
  1139. return -1;
  1140. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  1141. return -1;
  1142. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1143. pl_GM_level = pc_isGM(pl_sd);
  1144. if (battle_config.hide_GM_session) {
  1145. if(!(GM_level >= pl_GM_level)) {
  1146. if (!(battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid)) {
  1147. return -1;
  1148. }
  1149. }
  1150. }
  1151. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1152. atcmd_player_name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1153. clif_displaymessage(fd, atcmd_output);
  1154. return 0;
  1155. }
  1156. /*==========================================
  1157. *
  1158. *------------------------------------------
  1159. */
  1160. int atcommand_jumpto(
  1161. const int fd, struct map_session_data* sd,
  1162. const char* command, const char* message)
  1163. {
  1164. struct map_session_data *pl_sd = NULL;
  1165. nullpo_retr(-1, sd);
  1166. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1167. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1168. return -1;
  1169. }
  1170. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1171. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1172. return -1;
  1173. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1174. return -1;
  1175. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1176. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1177. clif_displaymessage(fd, msg_table[247]);
  1178. return -1;
  1179. }
  1180. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1181. clif_displaymessage(fd, msg_table[248]);
  1182. return -1;
  1183. }
  1184. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1185. sprintf(atcmd_output, msg_table[4], atcmd_player_name); // Jump to %s
  1186. clif_displaymessage(fd, atcmd_output);
  1187. } else {
  1188. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1189. return -1;
  1190. }
  1191. return 0;
  1192. }
  1193. /*==========================================
  1194. *
  1195. *------------------------------------------
  1196. */
  1197. int atcommand_jump(
  1198. const int fd, struct map_session_data* sd,
  1199. const char* command, const char* message)
  1200. {
  1201. int x = 0, y = 0;
  1202. nullpo_retr(-1, sd);
  1203. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1204. sscanf(message, "%d %d", &x, &y);
  1205. if (x <= 0) //If coordinates are 'wrong', random jump.
  1206. x = -1;
  1207. if (y <= 0)
  1208. y = -1;
  1209. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarp || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1210. clif_displaymessage(fd, msg_table[248]);
  1211. return -1;
  1212. }
  1213. pc_setpos(sd, sd->mapindex, x, y, 3);
  1214. sprintf(atcmd_output, msg_table[5], sd->bl.x, sd->bl.y); // Jump to %d %d
  1215. clif_displaymessage(fd, atcmd_output);
  1216. return 0;
  1217. }
  1218. /*==========================================
  1219. * @who3 = Player name, his location
  1220. *------------------------------------------
  1221. */
  1222. int atcommand_who3(
  1223. const int fd, struct map_session_data* sd,
  1224. const char* command, const char* message)
  1225. {
  1226. char temp0[100];
  1227. struct map_session_data *pl_sd, **pl_allsd;
  1228. int i, j, count, users;
  1229. int pl_GM_level, GM_level;
  1230. char match_text[100];
  1231. char player_name[NAME_LENGTH];
  1232. nullpo_retr(-1, sd);
  1233. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1234. memset(match_text, '\0', sizeof(match_text));
  1235. memset(player_name, '\0', sizeof(player_name));
  1236. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1237. strcpy(match_text, "");
  1238. for (j = 0; match_text[j]; j++)
  1239. match_text[j] = tolower(match_text[j]);
  1240. count = 0;
  1241. GM_level = pc_isGM(sd);
  1242. pl_allsd = map_getallusers(&users);
  1243. for (i = 0; i < users; i++) {
  1244. if ((pl_sd = pl_allsd[i])) {
  1245. pl_GM_level = pc_isGM(pl_sd);
  1246. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1247. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1248. for (j = 0; player_name[j]; j++)
  1249. player_name[j] = tolower(player_name[j]);
  1250. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1251. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1252. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1253. } else {
  1254. atcmd_output[0]=0;
  1255. }
  1256. //Player name
  1257. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1258. strcat(atcmd_output,temp0);
  1259. //Player title, if exists
  1260. if (pl_GM_level > 0) {
  1261. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1262. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1263. strcat(atcmd_output,temp0);
  1264. }
  1265. //Players Location: map x y
  1266. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1267. strcat(atcmd_output,temp0);
  1268. clif_displaymessage(fd, atcmd_output);
  1269. count++;
  1270. }
  1271. }
  1272. }
  1273. }
  1274. if (count == 0)
  1275. clif_displaymessage(fd, msg_table[28]); // No player found.
  1276. else if (count == 1)
  1277. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1278. else {
  1279. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1280. clif_displaymessage(fd, atcmd_output);
  1281. }
  1282. return 0;
  1283. }
  1284. /*==========================================
  1285. * Player name, BLevel, Job,
  1286. *------------------------------------------
  1287. */
  1288. int atcommand_who2(
  1289. const int fd, struct map_session_data* sd,
  1290. const char* command, const char* message)
  1291. {
  1292. char temp0[100];
  1293. struct map_session_data *pl_sd, **pl_allsd;
  1294. int i, j, count, users;
  1295. int pl_GM_level, GM_level;
  1296. char match_text[100];
  1297. char player_name[NAME_LENGTH];
  1298. nullpo_retr(-1, sd);
  1299. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1300. memset(match_text, '\0', sizeof(match_text));
  1301. memset(player_name, '\0', sizeof(player_name));
  1302. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1303. strcpy(match_text, "");
  1304. for (j = 0; match_text[j]; j++)
  1305. match_text[j] = tolower(match_text[j]);
  1306. count = 0;
  1307. GM_level = pc_isGM(sd);
  1308. pl_allsd = map_getallusers(&users);
  1309. for (i = 0; i < users; i++) {
  1310. if ((pl_sd = pl_allsd[i])) {
  1311. pl_GM_level = pc_isGM(pl_sd);
  1312. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1313. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1314. for (j = 0; player_name[j]; j++)
  1315. player_name[j] = tolower(player_name[j]);
  1316. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1317. //Players Name
  1318. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1319. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1320. //Player title, if exists
  1321. if (pl_GM_level > 0) {
  1322. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1323. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1324. strcat(atcmd_output,temp0);
  1325. }
  1326. //Players Base Level / Job name
  1327. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1328. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1329. strcat(atcmd_output,temp0);
  1330. clif_displaymessage(fd, atcmd_output);
  1331. count++;
  1332. }
  1333. }
  1334. }
  1335. }
  1336. if (count == 0)
  1337. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1338. else if (count == 1)
  1339. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1340. else {
  1341. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1342. clif_displaymessage(fd, atcmd_output);
  1343. }
  1344. return 0;
  1345. }
  1346. /*==========================================
  1347. * Player name, Playrs Party / Guild name
  1348. *------------------------------------------
  1349. */
  1350. int atcommand_who(
  1351. const int fd, struct map_session_data* sd,
  1352. const char* command, const char* message)
  1353. {
  1354. char temp0[100];
  1355. struct map_session_data *pl_sd, **pl_allsd;
  1356. int i, j, count, users;
  1357. int pl_GM_level, GM_level;
  1358. char match_text[100];
  1359. char player_name[NAME_LENGTH];
  1360. struct guild *g;
  1361. struct party *p;
  1362. nullpo_retr(-1, sd);
  1363. memset(temp0, '\0', sizeof(temp0));
  1364. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1365. memset(match_text, '\0', sizeof(match_text));
  1366. memset(player_name, '\0', sizeof(player_name));
  1367. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1368. strcpy(match_text, "");
  1369. for (j = 0; match_text[j]; j++)
  1370. match_text[j] = tolower(match_text[j]);
  1371. count = 0;
  1372. GM_level = pc_isGM(sd);
  1373. pl_allsd = map_getallusers(&users);
  1374. for (i = 0; i < users; i++) {
  1375. if ((pl_sd = pl_allsd[i])) {
  1376. pl_GM_level = pc_isGM(pl_sd);
  1377. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1378. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1379. for (j = 0; player_name[j]; j++)
  1380. player_name[j] = tolower(player_name[j]);
  1381. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1382. g = guild_search(pl_sd->status.guild_id);
  1383. p = party_search(pl_sd->status.party_id);
  1384. //Players Name
  1385. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1386. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1387. //Player title, if exists
  1388. if (pl_GM_level > 0) {
  1389. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1390. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1391. strcat(atcmd_output,temp0);
  1392. }
  1393. //Players Party if exists
  1394. if (p != NULL) {
  1395. //sprintf(temp0," | Party: '%s'", p->name);
  1396. sprintf(temp0, msg_txt(335), p->name);
  1397. strcat(atcmd_output,temp0);
  1398. }
  1399. //Players Guild if exists
  1400. if (g != NULL) {
  1401. //sprintf(temp0," | Guild: '%s'", g->name);
  1402. sprintf(temp0, msg_txt(336), g->name);
  1403. strcat(atcmd_output,temp0);
  1404. }
  1405. clif_displaymessage(fd, atcmd_output);
  1406. count++;
  1407. }
  1408. }
  1409. }
  1410. }
  1411. if (count == 0)
  1412. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1413. else if (count == 1)
  1414. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1415. else {
  1416. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1417. clif_displaymessage(fd, atcmd_output);
  1418. }
  1419. return 0;
  1420. }
  1421. /*==========================================
  1422. *
  1423. *------------------------------------------
  1424. */
  1425. int atcommand_whomap3(
  1426. const int fd, struct map_session_data* sd,
  1427. const char* command, const char* message)
  1428. {
  1429. struct map_session_data *pl_sd, **pl_allsd;
  1430. int i, count, users;
  1431. int pl_GM_level, GM_level;
  1432. int map_id;
  1433. char map_name[MAP_NAME_LENGTH];
  1434. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1435. memset(map_name, '\0', sizeof(map_name));
  1436. if (!message || !*message)
  1437. map_id = sd->bl.m;
  1438. else {
  1439. sscanf(message, "%15s", map_name);
  1440. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1441. strcat(map_name, ".gat");
  1442. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1443. map_id = sd->bl.m;
  1444. }
  1445. count = 0;
  1446. GM_level = pc_isGM(sd);
  1447. pl_allsd = map_getallusers(&users);
  1448. for (i = 0; i < users; i++) {
  1449. if ((pl_sd = pl_allsd[i])) {
  1450. pl_GM_level = pc_isGM(pl_sd);
  1451. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1452. if (pl_sd->bl.m == map_id) {
  1453. if (pl_GM_level > 0)
  1454. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1455. else
  1456. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1457. clif_displaymessage(fd, atcmd_output);
  1458. count++;
  1459. }
  1460. }
  1461. }
  1462. }
  1463. if (count == 0)
  1464. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1465. else if (count == 1)
  1466. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1467. else {
  1468. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1469. }
  1470. clif_displaymessage(fd, atcmd_output);
  1471. return 0;
  1472. }
  1473. /*==========================================
  1474. *
  1475. *------------------------------------------
  1476. */
  1477. int atcommand_whomap2(
  1478. const int fd, struct map_session_data* sd,
  1479. const char* command, const char* message)
  1480. {
  1481. struct map_session_data *pl_sd, **pl_allsd;
  1482. int i, count, users;
  1483. int pl_GM_level, GM_level;
  1484. int map_id = 0;
  1485. char map_name[MAP_NAME_LENGTH];
  1486. nullpo_retr(-1, sd);
  1487. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1488. memset(map_name, '\0', sizeof(map_name));
  1489. if (!message || !*message)
  1490. map_id = sd->bl.m;
  1491. else {
  1492. sscanf(message, "%15s", map_name);
  1493. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1494. strcat(map_name, ".gat");
  1495. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1496. map_id = sd->bl.m;
  1497. }
  1498. count = 0;
  1499. GM_level = pc_isGM(sd);
  1500. pl_allsd = map_getallusers(&users);
  1501. for (i = 0; i < users; i++) {
  1502. if ((pl_sd = pl_allsd[i])) {
  1503. pl_GM_level = pc_isGM(pl_sd);
  1504. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1505. if (pl_sd->bl.m == map_id) {
  1506. if (pl_GM_level > 0)
  1507. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1508. else
  1509. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1510. clif_displaymessage(fd, atcmd_output);
  1511. count++;
  1512. }
  1513. }
  1514. }
  1515. }
  1516. if (count == 0)
  1517. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1518. else if (count == 1)
  1519. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1520. else {
  1521. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1522. }
  1523. clif_displaymessage(fd, atcmd_output);
  1524. return 0;
  1525. }
  1526. /*==========================================
  1527. *
  1528. *------------------------------------------
  1529. */
  1530. int atcommand_whomap(
  1531. const int fd, struct map_session_data* sd,
  1532. const char* command, const char* message)
  1533. {
  1534. char temp0[100];
  1535. char temp1[100];
  1536. struct map_session_data *pl_sd, **pl_allsd;
  1537. int i, count, users;
  1538. int pl_GM_level, GM_level;
  1539. int map_id = 0;
  1540. char map_name[MAP_NAME_LENGTH];
  1541. struct guild *g;
  1542. struct party *p;
  1543. nullpo_retr(-1, sd);
  1544. memset(temp0, '\0', sizeof(temp0));
  1545. memset(temp1, '\0', sizeof(temp1));
  1546. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1547. memset(map_name, '\0', sizeof(map_name));
  1548. if (!message || !*message)
  1549. map_id = sd->bl.m;
  1550. else {
  1551. sscanf(message, "%15s", map_name);
  1552. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1553. strcat(map_name, ".gat");
  1554. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1555. map_id = sd->bl.m;
  1556. }
  1557. count = 0;
  1558. GM_level = pc_isGM(sd);
  1559. pl_allsd = map_getallusers(&users);
  1560. for (i = 0; i < users; i++) {
  1561. if ((pl_sd = pl_allsd[i])) {
  1562. pl_GM_level = pc_isGM(pl_sd);
  1563. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1564. if (pl_sd->bl.m == map_id) {
  1565. g = guild_search(pl_sd->status.guild_id);
  1566. if (g == NULL)
  1567. sprintf(temp1, "None");
  1568. else
  1569. sprintf(temp1, "%s", g->name);
  1570. p = party_search(pl_sd->status.party_id);
  1571. if (p == NULL)
  1572. sprintf(temp0, "None");
  1573. else
  1574. sprintf(temp0, "%s", p->name);
  1575. if (pl_GM_level > 0)
  1576. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1577. else
  1578. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1579. clif_displaymessage(fd, atcmd_output);
  1580. count++;
  1581. }
  1582. }
  1583. }
  1584. }
  1585. if (count == 0)
  1586. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1587. else if (count == 1)
  1588. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1589. else {
  1590. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1591. }
  1592. clif_displaymessage(fd, atcmd_output);
  1593. return 0;
  1594. }
  1595. /*==========================================
  1596. *
  1597. *------------------------------------------
  1598. */
  1599. int atcommand_whogm(
  1600. const int fd, struct map_session_data* sd,
  1601. const char* command, const char* message)
  1602. {
  1603. char temp0[100];
  1604. char temp1[100];
  1605. struct map_session_data *pl_sd, **pl_allsd;
  1606. int i, j, count, users;
  1607. int pl_GM_level, GM_level;
  1608. char match_text[100];
  1609. char player_name[NAME_LENGTH];
  1610. struct guild *g;
  1611. struct party *p;
  1612. nullpo_retr(-1, sd);
  1613. memset(temp0, '\0', sizeof(temp0));
  1614. memset(temp1, '\0', sizeof(temp1));
  1615. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1616. memset(match_text, '\0', sizeof(match_text));
  1617. memset(player_name, '\0', sizeof(player_name));
  1618. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1619. strcpy(match_text, "");
  1620. for (j = 0; match_text[j]; j++)
  1621. match_text[j] = tolower(match_text[j]);
  1622. count = 0;
  1623. GM_level = pc_isGM(sd);
  1624. pl_allsd = map_getallusers(&users);
  1625. for (i = 0; i < users; i++) {
  1626. if ((pl_sd = pl_allsd[i])) {
  1627. pl_GM_level = pc_isGM(pl_sd);
  1628. if (pl_GM_level > 0) {
  1629. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1630. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1631. for (j = 0; player_name[j]; j++)
  1632. player_name[j] = tolower(player_name[j]);
  1633. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1634. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1635. clif_displaymessage(fd, atcmd_output);
  1636. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1637. clif_displaymessage(fd, atcmd_output);
  1638. g = guild_search(pl_sd->status.guild_id);
  1639. if (g == NULL)
  1640. sprintf(temp1, "None");
  1641. else
  1642. sprintf(temp1, "%s", g->name);
  1643. p = party_search(pl_sd->status.party_id);
  1644. if (p == NULL)
  1645. sprintf(temp0, "None");
  1646. else
  1647. sprintf(temp0, "%s", p->name);
  1648. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1649. clif_displaymessage(fd, atcmd_output);
  1650. count++;
  1651. }
  1652. }
  1653. }
  1654. }
  1655. }
  1656. if (count == 0)
  1657. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1658. else if (count == 1)
  1659. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1660. else {
  1661. sprintf(atcmd_output, msg_table[152], count); // %d GMs found.
  1662. clif_displaymessage(fd, atcmd_output);
  1663. }
  1664. return 0;
  1665. }
  1666. int atcommand_whozeny(
  1667. const int fd, struct map_session_data* sd,
  1668. const char* command, const char* message)
  1669. {
  1670. struct map_session_data *pl_sd, **pl_allsd;
  1671. int i, j, count,c, users;
  1672. char match_text[100];
  1673. char player_name[NAME_LENGTH];
  1674. int *zeny;
  1675. int *counted;
  1676. nullpo_retr(-1, sd);
  1677. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1678. memset(match_text, '\0', sizeof(match_text));
  1679. memset(player_name, '\0', sizeof(player_name));
  1680. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1681. strcpy(match_text, "");
  1682. for (j = 0; match_text[j]; j++)
  1683. match_text[j] = tolower(match_text[j]);
  1684. count = 0;
  1685. pl_allsd = map_getallusers(&users);
  1686. if (users < 1)
  1687. {
  1688. clif_displaymessage(fd, msg_table[28]); // No player found.
  1689. return 0;
  1690. }
  1691. zeny = (int *)aCallocA(users, sizeof(int));
  1692. counted = (int *)aCallocA(users, sizeof(int));
  1693. for (i = 0; i < users; i++) {
  1694. if ((pl_sd = pl_allsd[i])) {
  1695. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1696. for (j = 0; player_name[j]; j++)
  1697. player_name[j] = tolower(player_name[j]);
  1698. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1699. zeny[count]=pl_sd->status.zeny;
  1700. counted[i]=0;
  1701. count++;
  1702. }
  1703. }
  1704. }
  1705. qsort(zeny, count, sizeof(int), hightolow_compare);
  1706. for (c = 0; c < count && c < 50; c++) {
  1707. if(!zeny[c])
  1708. continue;
  1709. for (i = 0; i < users; i++) {
  1710. if(!zeny[c])
  1711. continue;
  1712. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1713. if(pl_sd->status.zeny==zeny[c]) {
  1714. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1715. clif_displaymessage(fd, atcmd_output);
  1716. zeny[c]=0;
  1717. counted[i]=1;
  1718. }
  1719. }
  1720. }
  1721. }
  1722. if (count == 0)
  1723. clif_displaymessage(fd, msg_table[28]); // No player found.
  1724. else if (count == 1)
  1725. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1726. else {
  1727. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1728. clif_displaymessage(fd, atcmd_output);
  1729. }
  1730. aFree(zeny);
  1731. aFree(counted);
  1732. return 0;
  1733. }
  1734. // cause random emote on all online players [Valaris]
  1735. int atcommand_happyhappyjoyjoy(
  1736. const int fd, struct map_session_data* sd,
  1737. const char* command, const char* message)
  1738. {
  1739. struct map_session_data *pl_sd, **pl_allsd;
  1740. int i,e, users;
  1741. nullpo_retr(-1, sd);
  1742. pl_allsd = map_getallusers(&users);
  1743. for (i = 0; i < users; i++) {
  1744. if ((pl_sd = pl_allsd[i])) {
  1745. e=rand()%40;
  1746. if(e==34)
  1747. e = 0;
  1748. clif_emotion(&pl_sd->bl,e);
  1749. }
  1750. }
  1751. return 0;
  1752. }
  1753. /*==========================================
  1754. *
  1755. *------------------------------------------
  1756. */
  1757. int atcommand_save(
  1758. const int fd, struct map_session_data* sd,
  1759. const char* command, const char* message)
  1760. {
  1761. nullpo_retr(-1, sd);
  1762. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1763. if (sd->status.pet_id > 0 && sd->pd)
  1764. intif_save_petdata(sd->status.account_id, &sd->pet);
  1765. chrif_save(sd,0);
  1766. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1767. return 0;
  1768. }
  1769. /*==========================================
  1770. *
  1771. *------------------------------------------
  1772. */
  1773. int atcommand_load(
  1774. const int fd, struct map_session_data* sd,
  1775. const char* command, const char* message)
  1776. {
  1777. int m;
  1778. nullpo_retr(-1, sd);
  1779. m = map_mapindex2mapid(sd->status.save_point.map);
  1780. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1781. clif_displaymessage(fd, msg_table[249]);
  1782. return -1;
  1783. }
  1784. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1785. clif_displaymessage(fd, msg_table[248]);
  1786. return -1;
  1787. }
  1788. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1789. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1790. return 0;
  1791. }
  1792. /*==========================================
  1793. *
  1794. *------------------------------------------
  1795. */
  1796. int atcommand_speed(
  1797. const int fd, struct map_session_data* sd,
  1798. const char* command, const char* message)
  1799. {
  1800. int speed;
  1801. nullpo_retr(-1, sd);
  1802. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1803. if (!message || !*message) {
  1804. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1805. clif_displaymessage(fd, atcmd_output);
  1806. return -1;
  1807. }
  1808. speed = atoi(message);
  1809. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1810. sd->speed = speed;
  1811. //sd->walktimer = x;
  1812. //この文を追加 by れ�
  1813. clif_updatestatus(sd, SP_SPEED);
  1814. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1815. } else {
  1816. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1817. clif_displaymessage(fd, atcmd_output);
  1818. return -1;
  1819. }
  1820. return 0;
  1821. }
  1822. /*==========================================
  1823. *
  1824. *------------------------------------------
  1825. */
  1826. int atcommand_storage(
  1827. const int fd, struct map_session_data* sd,
  1828. const char* command, const char* message)
  1829. {
  1830. struct storage *stor; //changes from Freya/Yor
  1831. nullpo_retr(-1, sd);
  1832. if (sd->state.storage_flag) {
  1833. clif_displaymessage(fd, msg_table[250]);
  1834. return -1;
  1835. }
  1836. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1837. clif_displaymessage(fd, msg_table[250]);
  1838. return -1;
  1839. }
  1840. storage_storageopen(sd);
  1841. return 0;
  1842. }
  1843. /*==========================================
  1844. *
  1845. *------------------------------------------
  1846. */
  1847. int atcommand_guildstorage(
  1848. const int fd, struct map_session_data* sd,
  1849. const char* command, const char* message)
  1850. {
  1851. struct storage *stor; //changes from Freya/Yor
  1852. nullpo_retr(-1, sd);
  1853. if (sd->status.guild_id > 0) {
  1854. if (sd->state.storage_flag) {
  1855. clif_displaymessage(fd, msg_table[251]);
  1856. return -1;
  1857. }
  1858. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1859. clif_displaymessage(fd, msg_table[251]);
  1860. return -1;
  1861. }
  1862. storage_guild_storageopen(sd);
  1863. } else {
  1864. clif_displaymessage(fd, msg_table[252]);
  1865. return -1;
  1866. }
  1867. return 0;
  1868. }
  1869. /*==========================================
  1870. *
  1871. *------------------------------------------
  1872. */
  1873. int atcommand_option(
  1874. const int fd, struct map_session_data* sd,
  1875. const char* command, const char* message)
  1876. {
  1877. int param1 = 0, param2 = 0, param3 = 0;
  1878. nullpo_retr(-1, sd);
  1879. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1880. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1881. return -1;
  1882. }
  1883. sd->sc.opt1 = param1;
  1884. sd->sc.opt2 = param2;
  1885. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1886. if (sd->status.class_ == JOB_BABY_MERCHANT)
  1887. clif_cart_itemlist(sd);
  1888. clif_cart_equiplist(sd);
  1889. clif_updatestatus(sd, SP_CARTINFO);
  1890. }
  1891. pc_setoption(sd, param3);
  1892. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1893. return 0;
  1894. }
  1895. /*==========================================
  1896. *
  1897. *------------------------------------------
  1898. */
  1899. int atcommand_hide(
  1900. const int fd, struct map_session_data* sd,
  1901. const char* command, const char* message)
  1902. {
  1903. nullpo_retr(-1, sd);
  1904. if (sd->sc.option & OPTION_INVISIBLE) {
  1905. sd->sc.option &= ~OPTION_INVISIBLE;
  1906. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1907. } else {
  1908. sd->sc.option |= OPTION_INVISIBLE;
  1909. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1910. }
  1911. clif_changeoption(&sd->bl);
  1912. return 0;
  1913. }
  1914. /*==========================================
  1915. * 転職する upperを指定すると転生や養子にもなれる
  1916. *------------------------------------------
  1917. */
  1918. int atcommand_jobchange(
  1919. const int fd, struct map_session_data* sd,
  1920. const char* command, const char* message)
  1921. {
  1922. int job = 0, upper = 0;
  1923. nullpo_retr(-1, sd);
  1924. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1925. int i, found = 0;
  1926. const struct { char name[16]; int id; } jobs[] = {
  1927. { "novice", 0 },
  1928. { "swordsman", 1 },
  1929. { "mage", 2 },
  1930. { "archer", 3 },
  1931. { "acolyte", 4 },
  1932. { "merchant", 5 },
  1933. { "thief", 6 },
  1934. { "knight", 7 },
  1935. { "priest", 8 },
  1936. { "priestess", 8 },
  1937. { "wizard", 9 },
  1938. { "blacksmith", 10 },
  1939. { "hunter", 11 },
  1940. { "assassin", 12 },
  1941. { "crusader", 14 },
  1942. { "monk", 15 },
  1943. { "sage", 16 },
  1944. { "rogue", 17 },
  1945. { "alchemist", 18 },
  1946. { "bard", 19 },
  1947. { "dancer", 20 },
  1948. { "super novice", 23 },
  1949. { "supernovice", 23 },
  1950. { "high novice", 4001 },
  1951. { "swordsman high", 4002 },
  1952. { "mage high", 4003 },
  1953. { "archer high", 4004 },
  1954. { "acolyte high", 4005 },
  1955. { "merchant high", 4006 },
  1956. { "thief high", 4007 },
  1957. { "lord knight", 4008 },
  1958. { "high priest", 4009 },
  1959. { "high priestess", 4009 },
  1960. { "high wizard", 4010 },
  1961. { "whitesmith", 4011 },
  1962. { "sniper", 4012 },
  1963. { "assassin cross", 4013 },
  1964. { "paladin", 4015 },
  1965. { "champion", 4016 },
  1966. { "professor", 4017 },
  1967. { "stalker", 4018 },
  1968. { "creator", 4019 },
  1969. { "clown", 4020 },
  1970. { "gypsy", 4021 },
  1971. { "baby novice", 4023 },
  1972. { "baby swordsman", 4024 },
  1973. { "baby mage", 4025 },
  1974. { "baby archer", 4026 },
  1975. { "baby acolyte", 4027 },
  1976. { "baby merchant", 4028 },
  1977. { "baby thief", 4029 },
  1978. { "baby knight", 4030 },
  1979. { "baby priest", 4031 },
  1980. { "baby priestess", 4031 },
  1981. { "baby wizard", 4032 },
  1982. { "baby blacksmith",4033 },
  1983. { "baby hunter", 4034 },
  1984. { "baby assassin", 4035 },
  1985. { "baby crusader", 4037 },
  1986. { "baby monk", 4038 },
  1987. { "baby sage", 4039 },
  1988. { "baby rogue", 4040 },
  1989. { "baby alchemist", 4041 },
  1990. { "baby bard", 4042 },
  1991. { "baby dancer", 4043 },
  1992. { "super baby", 4045 },
  1993. { "taekwon", 4046 },
  1994. { "taekwon boy", 4046 },
  1995. { "taekwon girl", 4046 },
  1996. { "star gladiator", 4047 },
  1997. { "soul linker", 4049 },
  1998. };
  1999. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2000. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2001. job = jobs[i].id;
  2002. upper = 0;
  2003. found = 1;
  2004. break;
  2005. }
  2006. }
  2007. if (!found) {
  2008. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2009. return -1;
  2010. }
  2011. }
  2012. if (job == 37 ||job == 45)
  2013. return 0;
  2014. if ((job >= 0 && job < MAX_PC_CLASS))
  2015. {
  2016. int j;
  2017. for (j=0; j < MAX_INVENTORY; j++) {
  2018. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2019. pc_unequipitem(sd, j, 3);
  2020. }
  2021. if (pc_jobchange(sd, job, upper) == 0)
  2022. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  2023. else {
  2024. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  2025. return -1;
  2026. }
  2027. } else {
  2028. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2029. return -1;
  2030. }
  2031. return 0;
  2032. }
  2033. /*==========================================
  2034. *
  2035. *------------------------------------------
  2036. */
  2037. int atcommand_die(
  2038. const int fd, struct map_session_data* sd,
  2039. const char* command, const char* message)
  2040. {
  2041. nullpo_retr(-1, sd);
  2042. clif_specialeffect(&sd->bl,450,1);
  2043. pc_damage(NULL, sd, sd->status.hp);
  2044. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  2045. return 0;
  2046. }
  2047. /*==========================================
  2048. *
  2049. *------------------------------------------
  2050. */
  2051. int atcommand_kill(
  2052. const int fd, struct map_session_data* sd,
  2053. const char* command, const char* message)
  2054. {
  2055. struct map_session_data *pl_sd;
  2056. nullpo_retr(-1, sd);
  2057. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2058. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2059. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2060. return -1;
  2061. }
  2062. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2063. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2064. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  2065. clif_displaymessage(fd, msg_table[14]); // Character killed.
  2066. } else {
  2067. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  2068. return -1;
  2069. }
  2070. } else {
  2071. clif_displaymessage(fd, msg_table[3]); // Character not found.
  2072. return -1;
  2073. }
  2074. return 0;
  2075. }
  2076. /*==========================================
  2077. *
  2078. *------------------------------------------
  2079. */
  2080. int atcommand_alive(
  2081. const int fd, struct map_session_data* sd,
  2082. const char* command, const char* message)
  2083. {
  2084. nullpo_retr(-1, sd);
  2085. if (pc_isdead(sd)) {
  2086. sd->status.hp = sd->status.max_hp;
  2087. sd->status.sp = sd->status.max_sp;
  2088. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2089. pc_setstand(sd);
  2090. if (battle_config.pc_invincible_time > 0)
  2091. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  2092. clif_updatestatus(sd, SP_HP);
  2093. clif_updatestatus(sd, SP_SP);
  2094. clif_resurrection(&sd->bl, 1);
  2095. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  2096. return 0;
  2097. }
  2098. return -1;
  2099. }
  2100. /*==========================================
  2101. * +kamic [LuzZza]
  2102. *------------------------------------------
  2103. */
  2104. int atcommand_kami(
  2105. const int fd, struct map_session_data* sd,
  2106. const char* command, const char* message)
  2107. {
  2108. unsigned long color=0;
  2109. nullpo_retr(-1, sd);
  2110. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2111. if(*(command + 5) != 'c') {
  2112. if (!message || !*message) {
  2113. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2114. return -1;
  2115. }
  2116. sscanf(message, "%199[^\n]", atcmd_output);
  2117. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b') ? 0x10 : 0);
  2118. } else {
  2119. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2120. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2121. return -1;
  2122. }
  2123. if(color < 0 || color > 0xFFFFFF) {
  2124. clif_displaymessage(fd, "Invalid color.");
  2125. return -1;
  2126. }
  2127. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2128. }
  2129. return 0;
  2130. }
  2131. /*==========================================
  2132. *
  2133. *------------------------------------------
  2134. */
  2135. int atcommand_heal(
  2136. const int fd, struct map_session_data* sd,
  2137. const char* command, const char* message)
  2138. {
  2139. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2140. nullpo_retr(-1, sd);
  2141. sscanf(message, "%d %d", &hp, &sp);
  2142. if (hp == 0 && sp == 0) {
  2143. hp = sd->status.max_hp - sd->status.hp;
  2144. sp = sd->status.max_sp - sd->status.sp;
  2145. } else {
  2146. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2147. hp = sd->status.max_hp - sd->status.hp;
  2148. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2149. hp = 1 - sd->status.hp;
  2150. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2151. sp = sd->status.max_sp - sd->status.sp;
  2152. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2153. sp = 1 - sd->status.sp;
  2154. }
  2155. if (hp > 0) // display like heal
  2156. clif_heal(fd, SP_HP, hp);
  2157. else if (hp < 0) // display like damage
  2158. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2159. if (sp > 0) // no display when we lost SP
  2160. clif_heal(fd, SP_SP, sp);
  2161. if (hp != 0 || sp != 0) {
  2162. pc_heal(sd, hp, sp);
  2163. if (hp >= 0 && sp >= 0)
  2164. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2165. else
  2166. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2167. } else {
  2168. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2169. return -1;
  2170. }
  2171. return 0;
  2172. }
  2173. /*==========================================
  2174. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2175. *------------------------------------------
  2176. */
  2177. int atcommand_item(
  2178. const int fd, struct map_session_data* sd,
  2179. const char* command, const char* message)
  2180. {
  2181. char item_name[100];
  2182. int number = 0, item_id, flag;
  2183. struct item item_tmp;
  2184. struct item_data *item_data;
  2185. int get_count, i, pet_id;
  2186. nullpo_retr(-1, sd);
  2187. memset(item_name, '\0', sizeof(item_name));
  2188. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2189. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2190. return -1;
  2191. }
  2192. if (number <= 0)
  2193. number = 1;
  2194. item_id = 0;
  2195. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2196. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2197. item_id = item_data->nameid;
  2198. if (item_id >= 500) {
  2199. get_count = number;
  2200. // check pet egg
  2201. pet_id = search_petDB_index(item_id, PET_EGG);
  2202. if (item_data->type == 4 || item_data->type == 5 ||
  2203. item_data->type == 7 || item_data->type == 8) {
  2204. get_count = 1;
  2205. }
  2206. for (i = 0; i < number; i += get_count) {
  2207. // if pet egg
  2208. if (pet_id >= 0) {
  2209. sd->catch_target_class = pet_db[pet_id].class_;
  2210. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2211. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2212. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2213. 100, 0, 1, pet_db[pet_id].jname);
  2214. // if not pet egg
  2215. } else {
  2216. memset(&item_tmp, 0, sizeof(item_tmp));
  2217. item_tmp.nameid = item_id;
  2218. item_tmp.identify = 1;
  2219. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2220. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2221. }
  2222. }
  2223. //Logs (A)dmins items [Lupus]
  2224. if(log_config.pick > 0 ) {
  2225. log_pick(sd, "A", 0, item_id, number, NULL);
  2226. }
  2227. //Logs
  2228. clif_displaymessage(fd, msg_table[18]); // Item created.
  2229. } else {
  2230. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2231. return -1;
  2232. }
  2233. return 0;
  2234. }
  2235. /*==========================================
  2236. *
  2237. *------------------------------------------
  2238. */
  2239. int atcommand_item2(
  2240. const int fd, struct map_session_data* sd,
  2241. const char* command, const char* message)
  2242. {
  2243. struct item item_tmp;
  2244. struct item_data *item_data;
  2245. char item_name[100];
  2246. int item_id, number = 0;
  2247. int identify = 0, refine = 0, attr = 0;
  2248. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2249. int flag;
  2250. int loop, get_count, i;
  2251. nullpo_retr(-1, sd);
  2252. memset(item_name, '\0', sizeof(item_name));
  2253. 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) {
  2254. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2255. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2256. return -1;
  2257. }
  2258. if (number <= 0)
  2259. number = 1;
  2260. item_id = 0;
  2261. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2262. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2263. item_id = item_data->nameid;
  2264. if (item_id > 500) {
  2265. loop = 1;
  2266. get_count = number;
  2267. if (item_data->type == 4 || item_data->type == 5 ||
  2268. item_data->type == 7 || item_data->type == 8) {
  2269. loop = number;
  2270. get_count = 1;
  2271. if (item_data->type == 7) {
  2272. identify = 1;
  2273. refine = 0;
  2274. }
  2275. if (item_data->type == 8)
  2276. refine = 0;
  2277. if (refine > 10)
  2278. refine = 10;
  2279. } else {
  2280. identify = 1;
  2281. refine = attr = 0;
  2282. }
  2283. for (i = 0; i < loop; i++) {
  2284. memset(&item_tmp, 0, sizeof(item_tmp));
  2285. item_tmp.nameid = item_id;
  2286. item_tmp.identify = identify;
  2287. item_tmp.refine = refine;
  2288. item_tmp.attribute = attr;
  2289. item_tmp.card[0] = c1;
  2290. item_tmp.card[1] = c2;
  2291. item_tmp.card[2] = c3;
  2292. item_tmp.card[3] = c4;
  2293. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2294. clif_additem(sd, 0, 0, flag);
  2295. }
  2296. //Logs (A)dmins items [Lupus]
  2297. if(log_config.pick > 0 ) {
  2298. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2299. }
  2300. //Logs
  2301. clif_displaymessage(fd, msg_table[18]); // Item created.
  2302. } else {
  2303. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2304. return -1;
  2305. }
  2306. return 0;
  2307. }
  2308. /*==========================================
  2309. *
  2310. *------------------------------------------
  2311. */
  2312. int atcommand_itemreset(
  2313. const int fd, struct map_session_data* sd,
  2314. const char* command, const char* message)
  2315. {
  2316. int i;
  2317. nullpo_retr(-1, sd);
  2318. for (i = 0; i < MAX_INVENTORY; i++) {
  2319. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2320. //Logs (A)dmins items [Lupus]
  2321. if(log_config.pick > 0 ) {
  2322. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2323. }
  2324. //Logs
  2325. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2326. }
  2327. }
  2328. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2329. return 0;
  2330. }
  2331. /*==========================================
  2332. *
  2333. *------------------------------------------
  2334. */
  2335. int atcommand_itemcheck(
  2336. const int fd, struct map_session_data* sd,
  2337. const char* command, const char* message)
  2338. {
  2339. nullpo_retr(-1, sd);
  2340. pc_checkitem(sd);
  2341. return 0;
  2342. }
  2343. /*==========================================
  2344. * Atcommand @lvlup
  2345. *------------------------------------------
  2346. */
  2347. int atcommand_baselevelup(
  2348. const int fd, struct map_session_data* sd,
  2349. const char* command, const char* message)
  2350. {
  2351. int level=0, i=0;
  2352. nullpo_retr(-1, sd);
  2353. level = atoi(message);
  2354. if (!message || !*message || !level) {
  2355. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2356. return -1;
  2357. }
  2358. if (level > 0) {
  2359. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2360. clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
  2361. return -1;
  2362. } /* End Addition */
  2363. if (level > pc_maxbaselv(sd) || level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2364. level = pc_maxbaselv(sd) - sd->status.base_level;
  2365. for (i = 1; i <= level; i++)
  2366. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2367. sd->status.base_level += level;
  2368. clif_updatestatus(sd, SP_BASELEVEL);
  2369. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2370. clif_updatestatus(sd, SP_STATUSPOINT);
  2371. status_calc_pc(sd, 0);
  2372. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2373. clif_misceffect(&sd->bl, 0);
  2374. clif_displaymessage(fd, msg_table[21]); /* Base level raised. */
  2375. } else {
  2376. if (sd->status.base_level == 1) {
  2377. clif_displaymessage(fd, msg_table[158]); /* Base level can't go any lower. */
  2378. return -1;
  2379. }
  2380. level*=-1;
  2381. if (level >= sd->status.base_level)
  2382. level = sd->status.base_level-1;
  2383. if (sd->status.status_point > 0) {
  2384. for (i = 0; i > -level; i--)
  2385. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2386. if (sd->status.status_point < 0)
  2387. sd->status.status_point = 0;
  2388. clif_updatestatus(sd, SP_STATUSPOINT);
  2389. } /* to add: remove status points from stats */
  2390. sd->status.base_level += level;
  2391. clif_updatestatus(sd, SP_BASELEVEL);
  2392. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2393. status_calc_pc(sd, 0);
  2394. clif_displaymessage(fd, msg_table[22]); /* Base level lowered. */
  2395. }
  2396. return 0;
  2397. }
  2398. /*==========================================
  2399. *
  2400. *------------------------------------------
  2401. */
  2402. int atcommand_joblevelup(
  2403. const int fd, struct map_session_data* sd,
  2404. const char* command, const char* message)
  2405. {
  2406. int level=0;
  2407. nullpo_retr(-1, sd);
  2408. level = atoi(message);
  2409. if (!message || !*message || !level) {
  2410. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2411. return -1;
  2412. }
  2413. if (level > 0) {
  2414. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2415. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2416. return -1;
  2417. }
  2418. if (level > pc_maxjoblv(sd) || level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2419. level = pc_maxjoblv(sd) - sd->status.job_level;
  2420. sd->status.job_level += level;
  2421. clif_updatestatus(sd, SP_JOBLEVEL);
  2422. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2423. sd->status.skill_point += level;
  2424. clif_updatestatus(sd, SP_SKILLPOINT);
  2425. status_calc_pc(sd, 0);
  2426. clif_misceffect(&sd->bl, 1);
  2427. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2428. } else {
  2429. if (sd->status.job_level == 1) {
  2430. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2431. return -1;
  2432. }
  2433. level *=-1;
  2434. if (level >= sd->status.job_level) // fix negativ overflow
  2435. level = sd->status.job_level-1;
  2436. sd->status.job_level -= level;
  2437. clif_updatestatus(sd, SP_JOBLEVEL);
  2438. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2439. if (sd->status.skill_point < level)
  2440. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2441. sd->status.skill_point -= level;
  2442. if (sd->status.skill_point < 0)
  2443. sd->status.skill_point = 0;
  2444. clif_updatestatus(sd, SP_SKILLPOINT);
  2445. status_calc_pc(sd, 0);
  2446. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2447. }
  2448. return 0;
  2449. }
  2450. /*==========================================
  2451. * @help
  2452. *------------------------------------------
  2453. */
  2454. int atcommand_help(
  2455. const int fd, struct map_session_data* sd,
  2456. const char* command, const char* message)
  2457. {
  2458. char buf[2048], w1[2048], w2[2048];
  2459. int i, gm_level;
  2460. FILE* fp;
  2461. nullpo_retr(-1, sd);
  2462. memset(buf, '\0', sizeof(buf));
  2463. if ((fp = fopen(help_txt, "r")) != NULL) {
  2464. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2465. gm_level = pc_isGM(sd);
  2466. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2467. if (buf[0] == '/' && buf[1] == '/')
  2468. continue;
  2469. for (i = 0; buf[i] != '\0'; i++) {
  2470. if (buf[i] == '\r' || buf[i] == '\n') {
  2471. buf[i] = '\0';
  2472. break;
  2473. }
  2474. }
  2475. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2476. clif_displaymessage(fd, buf);
  2477. else if (gm_level >= atoi(w1))
  2478. clif_displaymessage(fd, w2);
  2479. }
  2480. fclose(fp);
  2481. } else {
  2482. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2483. return -1;
  2484. }
  2485. return 0;
  2486. }
  2487. /*==========================================
  2488. * @help2 - Char commands [Kayla]
  2489. *------------------------------------------
  2490. */
  2491. int atcommand_help2(
  2492. const int fd, struct map_session_data* sd,
  2493. const char* command, const char* message)
  2494. {
  2495. char buf[2048], w1[2048], w2[2048];
  2496. int i, gm_level;
  2497. FILE* fp;
  2498. nullpo_retr(-1, sd);
  2499. memset(buf, '\0', sizeof(buf));
  2500. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2501. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2502. gm_level = pc_isGM(sd);
  2503. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2504. if (buf[0] == '/' && buf[1] == '/')
  2505. continue;
  2506. for (i = 0; buf[i] != '\0'; i++) {
  2507. if (buf[i] == '\r' || buf[i] == '\n') {
  2508. buf[i] = '\0';
  2509. break;
  2510. }
  2511. }
  2512. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2513. clif_displaymessage(fd, buf);
  2514. else if (gm_level >= atoi(w1))
  2515. clif_displaymessage(fd, w2);
  2516. }
  2517. fclose(fp);
  2518. } else {
  2519. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2520. return -1;
  2521. }
  2522. return 0;
  2523. }
  2524. /*==========================================
  2525. * @gm
  2526. *------------------------------------------
  2527. */
  2528. int atcommand_gm(
  2529. const int fd, struct map_session_data* sd,
  2530. const char* command, const char* message)
  2531. {
  2532. char password[100];
  2533. nullpo_retr(-1, sd);
  2534. memset(password, '\0', sizeof(password));
  2535. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2536. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2537. return -1;
  2538. }
  2539. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2540. clif_displaymessage(fd, msg_table[50]); /* You already have some GM powers. */
  2541. return -1;
  2542. } else
  2543. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2544. return 0;
  2545. }
  2546. /*==========================================
  2547. *
  2548. *------------------------------------------
  2549. */
  2550. int atcommand_pvpoff(
  2551. const int fd, struct map_session_data* sd,
  2552. const char* command, const char* message)
  2553. {
  2554. struct map_session_data *pl_sd, **pl_allsd;
  2555. int i, users;
  2556. nullpo_retr(-1, sd);
  2557. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2558. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2559. return -1;
  2560. }
  2561. if (map[sd->bl.m].flag.pvp) {
  2562. map[sd->bl.m].flag.pvp = 0;
  2563. clif_send0199(sd->bl.m, 0);
  2564. pl_allsd = map_getallusers(&users);
  2565. for (i = 0; i < users; i++) { //人数分ループ
  2566. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2567. clif_pvpset(pl_sd, 0, 0, 2);
  2568. if (pl_sd->pvp_timer != -1) {
  2569. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2570. pl_sd->pvp_timer = -1;
  2571. }
  2572. }
  2573. }
  2574. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2575. } else {
  2576. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2577. return -1;
  2578. }
  2579. return 0;
  2580. }
  2581. /*==========================================
  2582. *
  2583. *------------------------------------------
  2584. */
  2585. int atcommand_pvpon(
  2586. const int fd, struct map_session_data* sd,
  2587. const char* command, const char* message)
  2588. {
  2589. struct map_session_data *pl_sd, **pl_allsd;
  2590. int i, users;
  2591. nullpo_retr(-1, sd);
  2592. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2593. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2594. return -1;
  2595. }
  2596. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2597. map[sd->bl.m].flag.pvp = 1;
  2598. clif_send0199(sd->bl.m, 1);
  2599. pl_allsd = map_getallusers(&users);
  2600. for (i = 0; i < users; i++) {
  2601. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2602. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2603. pl_sd->pvp_rank = 0;
  2604. pl_sd->pvp_lastusers = 0;
  2605. pl_sd->pvp_point = 5;
  2606. pl_sd->pvp_won = 0;
  2607. pl_sd->pvp_lost = 0;
  2608. }
  2609. }
  2610. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2611. } else {
  2612. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2613. return -1;
  2614. }
  2615. return 0;
  2616. }
  2617. /*==========================================
  2618. *
  2619. *------------------------------------------
  2620. */
  2621. int atcommand_gvgoff(
  2622. const int fd, struct map_session_data* sd,
  2623. const char* command, const char* message)
  2624. {
  2625. nullpo_retr(-1, sd);
  2626. if (map[sd->bl.m].flag.gvg) {
  2627. map[sd->bl.m].flag.gvg = 0;
  2628. clif_send0199(sd->bl.m, 0);
  2629. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2630. } else {
  2631. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2632. return -1;
  2633. }
  2634. return 0;
  2635. }
  2636. /*==========================================
  2637. *
  2638. *------------------------------------------
  2639. */
  2640. int atcommand_gvgon(
  2641. const int fd, struct map_session_data* sd,
  2642. const char* command, const char* message)
  2643. {
  2644. nullpo_retr(-1, sd);
  2645. if (!map[sd->bl.m].flag.gvg) {
  2646. map[sd->bl.m].flag.gvg = 1;
  2647. clif_send0199(sd->bl.m, 3);
  2648. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2649. } else {
  2650. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2651. return -1;
  2652. }
  2653. return 0;
  2654. }
  2655. /*==========================================
  2656. *
  2657. *------------------------------------------
  2658. */
  2659. int atcommand_model(
  2660. const int fd, struct map_session_data* sd,
  2661. const char* command, const char* message)
  2662. {
  2663. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2664. nullpo_retr(-1, sd);
  2665. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2666. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2667. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2668. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2669. clif_displaymessage(fd, atcmd_output);
  2670. return -1;
  2671. }
  2672. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2673. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2674. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2675. /* Removed because this check is TOO strange. [Skotlex]
  2676. //秒フ色変更
  2677. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2678. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2679. //秒フ色未実装職の判定
  2680. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2681. return -1;
  2682. } else {
  2683. */
  2684. pc_changelook(sd, LOOK_HAIR, hair_style);
  2685. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2686. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2687. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2688. // }
  2689. } else {
  2690. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2691. return -1;
  2692. }
  2693. return 0;
  2694. }
  2695. /*==========================================
  2696. * @dye && @ccolor
  2697. *------------------------------------------
  2698. */
  2699. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2700. {
  2701. int cloth_color = 0;
  2702. nullpo_retr(-1, sd);
  2703. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2704. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2705. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2706. clif_displaymessage(fd, atcmd_output);
  2707. return -1;
  2708. }
  2709. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2710. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2711. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2712. } else {
  2713. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2714. return -1;
  2715. }
  2716. return 0;
  2717. }
  2718. /*==========================================
  2719. * @hairstyle && @hstyle
  2720. *------------------------------------------
  2721. */
  2722. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2723. {
  2724. int hair_style = 0;
  2725. nullpo_retr(-1, sd);
  2726. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2727. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2728. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2729. clif_displaymessage(fd, atcmd_output);
  2730. return -1;
  2731. }
  2732. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2733. /* Removed because this check is TOO strange. [Skotlex]
  2734. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2735. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2736. return -1;
  2737. } else {
  2738. */
  2739. pc_changelook(sd, LOOK_HAIR, hair_style);
  2740. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2741. // }
  2742. } else {
  2743. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2744. return -1;
  2745. }
  2746. return 0;
  2747. }
  2748. /*==========================================
  2749. * @charhairstyle by [MouseJstr]
  2750. *------------------------------------------
  2751. */
  2752. int
  2753. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2754. const char* command, const char* message)
  2755. {
  2756. nullpo_retr(-1, sd);
  2757. return 0;
  2758. }
  2759. /*==========================================
  2760. * @haircolor && @hcolor
  2761. *------------------------------------------
  2762. */
  2763. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2764. {
  2765. int hair_color = 0;
  2766. nullpo_retr(-1, sd);
  2767. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2768. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2769. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2770. clif_displaymessage(fd, atcmd_output);
  2771. return -1;
  2772. }
  2773. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2774. /* Removed for being such a strange check. [Skotlex]
  2775. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2776. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2777. return -1;
  2778. } else {
  2779. */
  2780. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2781. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2782. // }
  2783. } else {
  2784. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2785. return -1;
  2786. }
  2787. return 0;
  2788. }
  2789. /*==========================================
  2790. * @go [city_number or city_name] - Updated by Harbin
  2791. *------------------------------------------
  2792. */
  2793. int atcommand_go(
  2794. const int fd, struct map_session_data* sd,
  2795. const char* command, const char* message)
  2796. {
  2797. int i;
  2798. int town;
  2799. char map_name[MAP_NAME_LENGTH];
  2800. int m;
  2801. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2802. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2803. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2804. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2805. { MAP_PAYON, 162, 233 }, // 3=Payon
  2806. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2807. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2808. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2809. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2810. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2811. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2812. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2813. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2814. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2815. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2816. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2817. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2818. { MAP_JAIL, 23, 61 }, // 16=Prison
  2819. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2820. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2821. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2822. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2823. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2824. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2825. };
  2826. nullpo_retr(-1, sd);
  2827. if(map[sd->bl.m].flag.nogo) {
  2828. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2829. return 0;
  2830. }
  2831. memset(map_name, '\0', sizeof(map_name));
  2832. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2833. // get the number
  2834. town = atoi(message);
  2835. // if no value, display all value
  2836. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2837. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2838. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2839. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2840. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2841. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2842. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2843. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2844. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2845. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2846. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2847. return -1;
  2848. } else {
  2849. // get possible name of the city and add .gat if not in the name
  2850. map_name[MAP_NAME_LENGTH-1] = '\0';
  2851. for (i = 0; map_name[i]; i++)
  2852. map_name[i] = tolower(map_name[i]);
  2853. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2854. strcat(map_name, ".gat");
  2855. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2856. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2857. town = 0;
  2858. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2859. town = 1;
  2860. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2861. town = 2;
  2862. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2863. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2864. town = 3;
  2865. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2866. town = 4;
  2867. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2868. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2869. town = 5;
  2870. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2871. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2872. town = 6;
  2873. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2874. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2875. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2876. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2877. town = 7;
  2878. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2879. town = 8;
  2880. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2881. town = 9;
  2882. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2883. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2884. town = 10;
  2885. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2886. town = 11;
  2887. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2888. town = 12;
  2889. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2890. town = 13;
  2891. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2892. town = 14;
  2893. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2894. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2895. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2896. town = 15;
  2897. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2898. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2899. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2900. town = 16;
  2901. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2902. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2903. town = 17;
  2904. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2905. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2906. town = 18;
  2907. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  2908. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  2909. town = 19;
  2910. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2911. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2912. town = 20;
  2913. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  2914. town = 21;
  2915. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2916. town = 22;
  2917. }
  2918. if (town >= -3 && town <= -1) {
  2919. if (sd->status.memo_point[-town-1].map) {
  2920. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2921. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2922. clif_displaymessage(fd, msg_table[247]);
  2923. return -1;
  2924. }
  2925. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2926. clif_displaymessage(fd, msg_table[248]);
  2927. return -1;
  2928. }
  2929. 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) {
  2930. clif_displaymessage(fd, msg_table[0]); // Warped.
  2931. } else {
  2932. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2933. return -1;
  2934. }
  2935. } else {
  2936. sprintf(atcmd_output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2937. clif_displaymessage(fd, atcmd_output);
  2938. return -1;
  2939. }
  2940. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2941. m = map_mapname2mapid((char *)data[town].map);
  2942. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2943. clif_displaymessage(fd, msg_table[247]);
  2944. return -1;
  2945. }
  2946. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2947. clif_displaymessage(fd, msg_table[248]);
  2948. return -1;
  2949. }
  2950. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2951. clif_displaymessage(fd, msg_table[0]); // Warped.
  2952. } else {
  2953. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2954. return -1;
  2955. }
  2956. } else { // if you arrive here, you have an error in town variable when reading of names
  2957. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2958. return -1;
  2959. }
  2960. }
  2961. return 0;
  2962. }
  2963. /*==========================================
  2964. *
  2965. *------------------------------------------
  2966. */
  2967. int atcommand_monster(
  2968. const int fd, struct map_session_data* sd,
  2969. const char* command, const char* message)
  2970. {
  2971. char name[NAME_LENGTH];
  2972. char monster[NAME_LENGTH];
  2973. int mob_id;
  2974. int number = 0;
  2975. int x = 0, y = 0;
  2976. int count;
  2977. int i, j, k;
  2978. int mx, my, range;
  2979. nullpo_retr(-1, sd);
  2980. memset(name, '\0', sizeof(name));
  2981. memset(monster, '\0', sizeof(monster));
  2982. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2983. if (!message || !*message) {
  2984. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2985. return -1;
  2986. }
  2987. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) > 1 ||
  2988. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) > 1) {
  2989. //All data can be left as it is.
  2990. } else if ((count=sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y)) > 1) {
  2991. //Here, it is possible name was not given and we are using monster for it.
  2992. if (count < 3) //Blank mob's name.
  2993. name[0] = '\0';
  2994. } else if (sscanf(message, "%23s %23s %d %d %d", name, monster, &number, &x, &y) > 1) {
  2995. //All data can be left as it is.
  2996. } else if (sscanf(message, "%23s", monster) > 0) {
  2997. //As before, name may be already filled.
  2998. name[0] = '\0';
  2999. } else {
  3000. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3001. return -1;
  3002. }
  3003. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3004. mob_id = mobdb_checkid(atoi(monster));
  3005. if (mob_id == 0) {
  3006. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3007. return -1;
  3008. }
  3009. if (mob_id == MOBID_EMPERIUM) {
  3010. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  3011. return -1;
  3012. }
  3013. if (number <= 0)
  3014. number = 1;
  3015. if (strlen(name) < 1)
  3016. strcpy(name, "--ja--");
  3017. // 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
  3018. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3019. number = battle_config.atc_spawn_quantity_limit;
  3020. if (battle_config.etc_log)
  3021. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  3022. count = 0;
  3023. range = (int)sqrt(number) / 2;
  3024. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  3025. for (i = 0; i < number; i++) {
  3026. j = 0;
  3027. k = 0;
  3028. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  3029. if (x <= 0)
  3030. mx = sd->bl.x + (rand() % range - (range / 2));
  3031. else
  3032. mx = x;
  3033. if (y <= 0)
  3034. my = sd->bl.y + (rand() % range - (range / 2));
  3035. else
  3036. my = y;
  3037. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  3038. }
  3039. count += (k != 0) ? 1 : 0;
  3040. }
  3041. if (count != 0)
  3042. if (number == count)
  3043. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  3044. else {
  3045. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  3046. clif_displaymessage(fd, atcmd_output);
  3047. }
  3048. else {
  3049. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3050. return -1;
  3051. }
  3052. return 0;
  3053. }
  3054. // small monster spawning [Valaris]
  3055. int atcommand_monstersmall(
  3056. const int fd, struct map_session_data* sd,
  3057. const char* command, const char* message) {
  3058. char name[NAME_LENGTH] = "";
  3059. char monster[NAME_LENGTH] = "";
  3060. int mob_id = 0;
  3061. int number = 0;
  3062. int x = 0;
  3063. int y = 0;
  3064. int count;
  3065. int i;
  3066. nullpo_retr(-1, sd);
  3067. if (!message || !*message) {
  3068. clif_displaymessage(fd, "Give a monster name/id please.");
  3069. return -1;
  3070. }
  3071. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3072. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3073. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3074. clif_displaymessage(fd, "Give a monster name/id please.");
  3075. return -1;
  3076. }
  3077. // If monster identifier/name argument is a name
  3078. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3079. mob_id = atoi(monster);
  3080. if (mob_id == 0) {
  3081. clif_displaymessage(fd, msg_table[40]);
  3082. return -1;
  3083. }
  3084. if (mob_id == MOBID_EMPERIUM) {
  3085. clif_displaymessage(fd, msg_table[83]);
  3086. return -1;
  3087. }
  3088. if (mobdb_checkid(mob_id) == 0) {
  3089. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3090. return -1;
  3091. }
  3092. if (number <= 0)
  3093. number = 1;
  3094. if (strlen(name) < 1)
  3095. strcpy(name, "--ja--");
  3096. // 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
  3097. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3098. number = battle_config.atc_spawn_quantity_limit;
  3099. count = 0;
  3100. for (i = 0; i < number; i++) {
  3101. int mx, my;
  3102. if (x <= 0)
  3103. mx = sd->bl.x + (rand() % 11 - 5);
  3104. else
  3105. mx = x;
  3106. if (y <= 0)
  3107. my = sd->bl.y + (rand() % 11 - 5);
  3108. else
  3109. my = y;
  3110. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3111. }
  3112. if (count != 0)
  3113. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3114. else
  3115. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3116. return 0;
  3117. }
  3118. // big monster spawning [Valaris]
  3119. int atcommand_monsterbig(
  3120. const int fd, struct map_session_data* sd,
  3121. const char* command, const char* message) {
  3122. char name[NAME_LENGTH] = "";
  3123. char monster[NAME_LENGTH] = "";
  3124. int mob_id = 0;
  3125. int number = 0;
  3126. int x = 0;
  3127. int y = 0;
  3128. int count;
  3129. int i;
  3130. nullpo_retr(-1, sd);
  3131. if (!message || !*message) {
  3132. clif_displaymessage(fd, "Give a monster name/id please.");
  3133. return -1;
  3134. }
  3135. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3136. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3137. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3138. clif_displaymessage(fd, "Give a monster name/id please.");
  3139. return -1;
  3140. }
  3141. // If monster identifier/name argument is a name
  3142. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3143. mob_id = atoi(monster);
  3144. if (mob_id == 0) {
  3145. clif_displaymessage(fd, msg_table[40]);
  3146. return -1;
  3147. }
  3148. if (mob_id == MOBID_EMPERIUM) {
  3149. clif_displaymessage(fd, msg_table[83]);
  3150. return -1;
  3151. }
  3152. if (mobdb_checkid(mob_id) == 0) {
  3153. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3154. return -1;
  3155. }
  3156. if (number <= 0)
  3157. number = 1;
  3158. if (strlen(name) < 1)
  3159. strcpy(name, "--ja--");
  3160. // 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
  3161. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3162. number = battle_config.atc_spawn_quantity_limit;
  3163. count = 0;
  3164. for (i = 0; i < number; i++) {
  3165. int mx, my;
  3166. if (x <= 0)
  3167. mx = sd->bl.x + (rand() % 11 - 5);
  3168. else
  3169. mx = x;
  3170. if (y <= 0)
  3171. my = sd->bl.y + (rand() % 11 - 5);
  3172. else
  3173. my = y;
  3174. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2*MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3175. }
  3176. if (count != 0)
  3177. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3178. else
  3179. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3180. return 0;
  3181. }
  3182. /*==========================================
  3183. *
  3184. *------------------------------------------
  3185. */
  3186. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3187. struct mob_data *md;
  3188. int flag;
  3189. nullpo_retr(0, ap);
  3190. nullpo_retr(0, md=(struct mob_data *)bl);
  3191. flag = va_arg(ap, int);
  3192. if (flag)
  3193. mob_damage(NULL, md, md->hp, 2);
  3194. else
  3195. mob_delete(md);
  3196. return 0;
  3197. }
  3198. void atcommand_killmonster_sub(
  3199. const int fd, struct map_session_data* sd, const char* message,
  3200. const int drop)
  3201. {
  3202. int map_id;
  3203. char map_name[MAP_NAME_LENGTH];
  3204. if (!sd) return;
  3205. memset(map_name, '\0', sizeof(map_name));
  3206. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3207. map_id = sd->bl.m;
  3208. else {
  3209. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3210. strcat(map_name, ".gat");
  3211. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3212. map_id = sd->bl.m;
  3213. }
  3214. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3215. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3216. return;
  3217. }
  3218. /*==========================================
  3219. *
  3220. *------------------------------------------
  3221. */
  3222. int atcommand_killmonster(
  3223. const int fd, struct map_session_data* sd,
  3224. const char* command, const char* message)
  3225. {
  3226. if (!sd) return 0;
  3227. atcommand_killmonster_sub(fd, sd, message, 1);
  3228. return 0;
  3229. }
  3230. /*==========================================
  3231. *
  3232. *------------------------------------------
  3233. */
  3234. int atcommand_killmonster2(
  3235. const int fd, struct map_session_data* sd,
  3236. const char* command, const char* message)
  3237. {
  3238. if (!sd) return 0;
  3239. atcommand_killmonster_sub(fd, sd, message, 0);
  3240. return 0;
  3241. }
  3242. /*==========================================
  3243. *
  3244. *------------------------------------------
  3245. */
  3246. int atcommand_refine(
  3247. const int fd, struct map_session_data* sd,
  3248. const char* command, const char* message)
  3249. {
  3250. int i, position = 0, refine = 0, current_position, final_refine;
  3251. int count;
  3252. nullpo_retr(-1, sd);
  3253. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3254. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3255. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3256. return -1;
  3257. }
  3258. if (refine < -10)
  3259. refine = -10;
  3260. else if (refine > 10)
  3261. refine = 10;
  3262. else if (refine == 0)
  3263. refine = 1;
  3264. count = 0;
  3265. for (i = 0; i < MAX_INVENTORY; i++) {
  3266. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3267. (sd->status.inventory[i].equip & position ||
  3268. (sd->status.inventory[i].equip && !position))) {
  3269. final_refine = sd->status.inventory[i].refine + refine;
  3270. if (final_refine > 10)
  3271. final_refine = 10;
  3272. else if (final_refine < 0)
  3273. final_refine = 0;
  3274. if (sd->status.inventory[i].refine != final_refine) {
  3275. sd->status.inventory[i].refine = final_refine;
  3276. current_position = sd->status.inventory[i].equip;
  3277. pc_unequipitem(sd, i, 3);
  3278. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3279. clif_delitem(sd, i, 1);
  3280. clif_additem(sd, i, 1, 0);
  3281. pc_equipitem(sd, i, current_position);
  3282. clif_misceffect((struct block_list*)&sd->bl, 3);
  3283. count++;
  3284. }
  3285. }
  3286. }
  3287. if (count == 0)
  3288. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3289. else if (count == 1)
  3290. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3291. else {
  3292. sprintf(atcmd_output, msg_table[168], count); // %d items have been refined!
  3293. clif_displaymessage(fd, atcmd_output);
  3294. }
  3295. return 0;
  3296. }
  3297. /*==========================================
  3298. *
  3299. *------------------------------------------
  3300. */
  3301. int atcommand_produce(
  3302. const int fd, struct map_session_data* sd,
  3303. const char* command, const char* message)
  3304. {
  3305. char item_name[100];
  3306. int item_id, attribute = 0, star = 0;
  3307. int flag = 0;
  3308. struct item_data *item_data;
  3309. struct item tmp_item;
  3310. nullpo_retr(-1, sd);
  3311. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3312. memset(item_name, '\0', sizeof(item_name));
  3313. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3314. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3315. return -1;
  3316. }
  3317. item_id = 0;
  3318. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3319. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3320. item_id = item_data->nameid;
  3321. if (itemdb_exists(item_id) &&
  3322. (item_id <= 500 || item_id > 1099) &&
  3323. (item_id < 4001 || item_id > 4148) &&
  3324. (item_id < 7001 || item_id > 10019) &&
  3325. itemdb_isequip(item_id)) {
  3326. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3327. attribute = ATTRIBUTE_NORMAL;
  3328. if (star < MIN_STAR || star > MAX_STAR)
  3329. star = 0;
  3330. memset(&tmp_item, 0, sizeof tmp_item);
  3331. tmp_item.nameid = item_id;
  3332. tmp_item.amount = 1;
  3333. tmp_item.identify = 1;
  3334. tmp_item.card[0] = 0x00ff;
  3335. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3336. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3337. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3338. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3339. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3340. //Logs (A)dmins items [Lupus]
  3341. if(log_config.pick > 0 ) {
  3342. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3343. }
  3344. //Logs
  3345. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3346. clif_additem(sd, 0, 0, flag);
  3347. } else {
  3348. if (battle_config.error_log)
  3349. ShowError("@produce NOT WEAPON [%d]\n", item_id);
  3350. if (item_id != 0 && itemdb_exists(item_id))
  3351. sprintf(atcmd_output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3352. else
  3353. sprintf(atcmd_output, msg_table[170]); // This item is not an equipment.
  3354. clif_displaymessage(fd, atcmd_output);
  3355. return -1;
  3356. }
  3357. return 0;
  3358. }
  3359. /*==========================================
  3360. * Sub-function to display actual memo points
  3361. *------------------------------------------
  3362. */
  3363. void atcommand_memo_sub(struct map_session_data* sd) {
  3364. int i;
  3365. if (!sd) return;
  3366. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3367. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3368. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3369. if (sd->status.memo_point[i].map)
  3370. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  3371. else
  3372. sprintf(atcmd_output, msg_table[171], i); // %d - void
  3373. clif_displaymessage(sd->fd, atcmd_output);
  3374. }
  3375. return;
  3376. }
  3377. /*==========================================
  3378. *
  3379. *------------------------------------------
  3380. */
  3381. int atcommand_memo(
  3382. const int fd, struct map_session_data* sd,
  3383. const char* command, const char* message)
  3384. {
  3385. int position = 0;
  3386. nullpo_retr(-1, sd);
  3387. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3388. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3389. atcommand_memo_sub(sd);
  3390. else {
  3391. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3392. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3393. clif_displaymessage(fd, msg_table[253]);
  3394. return -1;
  3395. }
  3396. if (sd->status.memo_point[position].map) {
  3397. sprintf(atcmd_output, msg_table[172], position, mapindex_id2name(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).
  3398. clif_displaymessage(fd, atcmd_output);
  3399. }
  3400. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3401. sd->status.memo_point[position].x = sd->bl.x;
  3402. sd->status.memo_point[position].y = sd->bl.y;
  3403. clif_skill_memo(sd, 0);
  3404. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3405. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3406. atcommand_memo_sub(sd);
  3407. } else {
  3408. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3409. clif_displaymessage(fd, atcmd_output);
  3410. atcommand_memo_sub(sd);
  3411. return -1;
  3412. }
  3413. }
  3414. return 0;
  3415. }
  3416. /*==========================================
  3417. *
  3418. *------------------------------------------
  3419. */
  3420. int atcommand_gat(
  3421. const int fd, struct map_session_data* sd,
  3422. const char* command, const char* message)
  3423. {
  3424. int y;
  3425. nullpo_retr(-1, sd);
  3426. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3427. for (y = 2; y >= -2; y--) {
  3428. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3429. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3430. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3431. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3432. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3433. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3434. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3435. clif_displaymessage(fd, atcmd_output);
  3436. }
  3437. return 0;
  3438. }
  3439. /*==========================================
  3440. *
  3441. *------------------------------------------
  3442. */
  3443. int atcommand_packet(
  3444. const int fd, struct map_session_data* sd,
  3445. const char* command, const char* message)
  3446. {
  3447. static int packet_mode = 0;
  3448. int i, x = 0, y = 0;
  3449. nullpo_retr(-1, sd);
  3450. if (strstr(command, "packetmode")) {
  3451. packet_mode = atoi(message);
  3452. clif_displaymessage(fd, "Packet mode changed.");
  3453. return 0;
  3454. }
  3455. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3456. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3457. return -1;
  3458. }
  3459. if (i == 1) y = 1;
  3460. switch (packet_mode)
  3461. {
  3462. case 0:
  3463. clif_status_change(&sd->bl, x, y);
  3464. break;
  3465. case 1:
  3466. sd->status.skill[sd->cloneskill_id].id=0;
  3467. sd->status.skill[sd->cloneskill_id].lv=0;
  3468. sd->status.skill[sd->cloneskill_id].flag=0;
  3469. sd->cloneskill_id = x;
  3470. sd->status.skill[x].id = x;
  3471. sd->status.skill[x].lv = skill_get_max(x);
  3472. sd->status.skill[x].flag = 13;//cloneskill flag
  3473. clif_skillinfoblock(sd);
  3474. break;
  3475. case 2:
  3476. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3477. case 3:
  3478. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3479. default:
  3480. break;
  3481. //added later
  3482. }
  3483. return 0;
  3484. }
  3485. /*==========================================
  3486. * @waterlevel [Skotlex]
  3487. *------------------------------------------
  3488. */
  3489. int atcommand_waterlevel(
  3490. const int fd, struct map_session_data* sd,
  3491. const char* command, const char* message)
  3492. {
  3493. int newlevel;
  3494. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3495. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3496. clif_displaymessage(fd, atcmd_output);
  3497. return 0;
  3498. }
  3499. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3500. if (newlevel > 0)
  3501. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3502. else
  3503. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3504. clif_displaymessage(fd, atcmd_output);
  3505. } else {
  3506. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3507. clif_displaymessage(fd, atcmd_output);
  3508. }
  3509. return 0;
  3510. }
  3511. /*==========================================
  3512. * @stpoint (Rewritten by [Yor])
  3513. *------------------------------------------
  3514. */
  3515. int atcommand_statuspoint(
  3516. const int fd, struct map_session_data* sd,
  3517. const char* command, const char* message)
  3518. {
  3519. int point, new_status_point;
  3520. if (!message || !*message || (point = atoi(message)) == 0) {
  3521. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3522. return -1;
  3523. }
  3524. new_status_point = (int)sd->status.status_point + point;
  3525. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3526. new_status_point = 0x7FFF;
  3527. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3528. new_status_point = 0;
  3529. if (new_status_point != (int)sd->status.status_point) {
  3530. sd->status.status_point = (short)new_status_point;
  3531. clif_updatestatus(sd, SP_STATUSPOINT);
  3532. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3533. } else {
  3534. if (point < 0)
  3535. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3536. else
  3537. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3538. return -1;
  3539. }
  3540. return 0;
  3541. }
  3542. /*==========================================
  3543. * @skpoint (Rewritten by [Yor])
  3544. *------------------------------------------
  3545. */
  3546. int atcommand_skillpoint(
  3547. const int fd, struct map_session_data* sd,
  3548. const char* command, const char* message)
  3549. {
  3550. int point, new_skill_point;
  3551. nullpo_retr(-1, sd);
  3552. if (!message || !*message || (point = atoi(message)) == 0) {
  3553. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3554. return -1;
  3555. }
  3556. new_skill_point = (int)sd->status.skill_point + point;
  3557. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3558. new_skill_point = 0x7FFF;
  3559. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3560. new_skill_point = 0;
  3561. if (new_skill_point != (int)sd->status.skill_point) {
  3562. sd->status.skill_point = (short)new_skill_point;
  3563. clif_updatestatus(sd, SP_SKILLPOINT);
  3564. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3565. } else {
  3566. if (point < 0)
  3567. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3568. else
  3569. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3570. return -1;
  3571. }
  3572. return 0;
  3573. }
  3574. /*==========================================
  3575. * @zeny (Rewritten by [Yor])
  3576. *------------------------------------------
  3577. */
  3578. int atcommand_zeny(
  3579. const int fd, struct map_session_data* sd,
  3580. const char* command, const char* message)
  3581. {
  3582. int zeny, new_zeny;
  3583. nullpo_retr(-1, sd);
  3584. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3585. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3586. return -1;
  3587. }
  3588. new_zeny = sd->status.zeny + zeny;
  3589. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3590. new_zeny = MAX_ZENY;
  3591. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3592. new_zeny = 0;
  3593. if (new_zeny != sd->status.zeny) {
  3594. sd->status.zeny = new_zeny;
  3595. clif_updatestatus(sd, SP_ZENY);
  3596. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3597. } else {
  3598. if (zeny < 0)
  3599. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3600. else
  3601. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3602. return -1;
  3603. }
  3604. return 0;
  3605. }
  3606. /*==========================================
  3607. *
  3608. *------------------------------------------
  3609. */
  3610. int atcommand_param(
  3611. const int fd, struct map_session_data* sd,
  3612. const char* command, const char* message)
  3613. {
  3614. int i, index, value = 0, new_value;
  3615. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3616. short* status[] = {
  3617. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3618. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3619. };
  3620. nullpo_retr(-1, sd);
  3621. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3622. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3623. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3624. clif_displaymessage(fd, atcmd_output);
  3625. return -1;
  3626. }
  3627. index = -1;
  3628. for (i = 0; param[i] != NULL; i++) {
  3629. if (strcmpi(command, param[i]) == 0) {
  3630. index = i;
  3631. break;
  3632. }
  3633. }
  3634. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3635. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3636. clif_displaymessage(fd, atcmd_output);
  3637. return -1;
  3638. }
  3639. new_value = (int)*status[index] + value;
  3640. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3641. new_value = pc_maxparameter(sd);
  3642. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negativ overflow
  3643. new_value = 1;
  3644. if (new_value != (int)*status[index]) {
  3645. *status[index] = new_value;
  3646. clif_updatestatus(sd, SP_STR + index);
  3647. clif_updatestatus(sd, SP_USTR + index);
  3648. status_calc_pc(sd, 0);
  3649. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3650. } else {
  3651. if (value < 0)
  3652. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3653. else
  3654. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3655. return -1;
  3656. }
  3657. return 0;
  3658. }
  3659. /*==========================================
  3660. *
  3661. *------------------------------------------
  3662. */
  3663. //** Stat all by fritz (rewritten by [Yor])
  3664. int atcommand_stat_all(
  3665. const int fd, struct map_session_data* sd,
  3666. const char* command, const char* message)
  3667. {
  3668. int index, count, value = 0, new_value;
  3669. short* status[] = {
  3670. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3671. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3672. };
  3673. nullpo_retr(-1, sd);
  3674. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3675. value = pc_maxparameter(sd);
  3676. count = 0;
  3677. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3678. new_value = (int)*status[index] + value;
  3679. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3680. new_value = pc_maxparameter(sd);
  3681. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negative overflow
  3682. new_value = 1;
  3683. if (new_value != (int)*status[index]) {
  3684. *status[index] = new_value;
  3685. clif_updatestatus(sd, SP_STR + index);
  3686. clif_updatestatus(sd, SP_USTR + index);
  3687. status_calc_pc(sd, 0);
  3688. count++;
  3689. }
  3690. }
  3691. if (count > 0) // if at least 1 stat modified
  3692. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3693. else {
  3694. if (value < 0)
  3695. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3696. else
  3697. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3698. return -1;
  3699. }
  3700. return 0;
  3701. }
  3702. /*==========================================
  3703. *
  3704. *------------------------------------------
  3705. */
  3706. int atcommand_guildlevelup(
  3707. const int fd, struct map_session_data* sd,
  3708. const char* command, const char* message)
  3709. {
  3710. int level = 0;
  3711. short added_level;
  3712. struct guild *guild_info;
  3713. nullpo_retr(-1, sd);
  3714. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3715. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3716. return -1;
  3717. }
  3718. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3719. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3720. return -1;
  3721. }
  3722. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3723. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3724. return -1;
  3725. }
  3726. added_level = (short)level;
  3727. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3728. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3729. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3730. added_level = 1 - guild_info->guild_lv;
  3731. if (added_level != 0) {
  3732. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3733. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3734. } else {
  3735. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3736. return -1;
  3737. }
  3738. return 0;
  3739. }
  3740. /*==========================================
  3741. *
  3742. *------------------------------------------
  3743. */
  3744. int atcommand_makeegg(
  3745. const int fd, struct map_session_data* sd,
  3746. const char* command, const char* message)
  3747. {
  3748. struct item_data *item_data;
  3749. int id, pet_id;
  3750. nullpo_retr(-1, sd);
  3751. if (!message || !*message) {
  3752. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3753. return -1;
  3754. }
  3755. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3756. id = item_data->nameid;
  3757. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3758. id = atoi(message);
  3759. pet_id = search_petDB_index(id, PET_CLASS);
  3760. if (pet_id < 0)
  3761. pet_id = search_petDB_index(id, PET_EGG);
  3762. if (pet_id >= 0) {
  3763. sd->catch_target_class = pet_db[pet_id].class_;
  3764. intif_create_pet(
  3765. sd->status.account_id, sd->status.char_id,
  3766. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3767. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3768. 100, 0, 1, pet_db[pet_id].jname);
  3769. } else {
  3770. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3771. return -1;
  3772. }
  3773. return 0;
  3774. }
  3775. /*==========================================
  3776. *
  3777. *------------------------------------------
  3778. */
  3779. int atcommand_hatch(
  3780. const int fd, struct map_session_data* sd,
  3781. const char* command, const char* message)
  3782. {
  3783. nullpo_retr(-1, sd);
  3784. if (sd->status.pet_id <= 0)
  3785. clif_sendegg(sd);
  3786. else {
  3787. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3788. return -1;
  3789. }
  3790. return 0;
  3791. }
  3792. /*==========================================
  3793. *
  3794. *------------------------------------------
  3795. */
  3796. int atcommand_petfriendly(
  3797. const int fd, struct map_session_data* sd,
  3798. const char* command, const char* message)
  3799. {
  3800. int friendly;
  3801. int t;
  3802. nullpo_retr(-1, sd);
  3803. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3804. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3805. return -1;
  3806. }
  3807. if (sd->status.pet_id > 0 && sd->pd) {
  3808. if (friendly >= 0 && friendly <= 1000) {
  3809. if (friendly != sd->pet.intimate) {
  3810. t = sd->pet.intimate;
  3811. sd->pet.intimate = friendly;
  3812. clif_send_petstatus(sd);
  3813. if (battle_config.pet_status_support) {
  3814. if ((sd->pet.intimate > 0 && t <= 0) ||
  3815. (sd->pet.intimate <= 0 && t > 0)) {
  3816. if (sd->bl.prev != NULL)
  3817. status_calc_pc(sd, 0);
  3818. else
  3819. status_calc_pc(sd, 2);
  3820. }
  3821. }
  3822. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3823. } else {
  3824. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3825. return -1;
  3826. }
  3827. } else {
  3828. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3829. return -1;
  3830. }
  3831. } else {
  3832. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3833. return -1;
  3834. }
  3835. return 0;
  3836. }
  3837. /*==========================================
  3838. *
  3839. *------------------------------------------
  3840. */
  3841. int atcommand_pethungry(
  3842. const int fd, struct map_session_data* sd,
  3843. const char* command, const char* message)
  3844. {
  3845. int hungry;
  3846. nullpo_retr(-1, sd);
  3847. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3848. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3849. return -1;
  3850. }
  3851. if (sd->status.pet_id > 0 && sd->pd) {
  3852. if (hungry >= 0 && hungry <= 100) {
  3853. if (hungry != sd->pet.hungry) {
  3854. sd->pet.hungry = hungry;
  3855. clif_send_petstatus(sd);
  3856. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3857. } else {
  3858. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3859. return -1;
  3860. }
  3861. } else {
  3862. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3863. return -1;
  3864. }
  3865. } else {
  3866. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3867. return -1;
  3868. }
  3869. return 0;
  3870. }
  3871. /*==========================================
  3872. *
  3873. *------------------------------------------
  3874. */
  3875. int atcommand_petrename(
  3876. const int fd, struct map_session_data* sd,
  3877. const char* command, const char* message)
  3878. {
  3879. nullpo_retr(-1, sd);
  3880. if (sd->status.pet_id > 0 && sd->pd) {
  3881. if (sd->pet.rename_flag != 0) {
  3882. sd->pet.rename_flag = 0;
  3883. intif_save_petdata(sd->status.account_id, &sd->pet);
  3884. clif_send_petstatus(sd);
  3885. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3886. } else {
  3887. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3888. return -1;
  3889. }
  3890. } else {
  3891. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3892. return -1;
  3893. }
  3894. return 0;
  3895. }
  3896. /*==========================================
  3897. *
  3898. *------------------------------------------
  3899. */
  3900. int
  3901. atcommand_recall(
  3902. const int fd, struct map_session_data* sd,
  3903. const char* command, const char* message)
  3904. {
  3905. struct map_session_data *pl_sd = NULL;
  3906. nullpo_retr(-1, sd);
  3907. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3908. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3909. return -1;
  3910. }
  3911. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3912. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3913. return -1;
  3914. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3915. return -1;
  3916. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3917. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3918. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3919. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3920. return -1;
  3921. }
  3922. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3923. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3924. return -1;
  3925. }
  3926. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3927. sprintf(atcmd_output, msg_table[46], atcmd_player_name); // %s recalled!
  3928. clif_displaymessage(fd, atcmd_output);
  3929. } else {
  3930. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3931. return -1;
  3932. }
  3933. } else {
  3934. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3935. return -1;
  3936. }
  3937. return 0;
  3938. }
  3939. /*==========================================
  3940. *
  3941. *------------------------------------------
  3942. */
  3943. int atcommand_revive(
  3944. const int fd, struct map_session_data* sd,
  3945. const char* command, const char* message)
  3946. {
  3947. struct map_session_data *pl_sd;
  3948. nullpo_retr(-1, sd);
  3949. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3950. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3951. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3952. return -1;
  3953. }
  3954. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3955. if (pc_isdead(pl_sd)) {
  3956. pl_sd->status.hp = pl_sd->status.max_hp;
  3957. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3958. pc_setstand(pl_sd);
  3959. if (battle_config.pc_invincible_time > 0)
  3960. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3961. clif_updatestatus(pl_sd, SP_HP);
  3962. clif_updatestatus(pl_sd, SP_SP);
  3963. clif_resurrection(&pl_sd->bl, 1);
  3964. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3965. return 0;
  3966. }
  3967. return -1;
  3968. } else {
  3969. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3970. return -1;
  3971. }
  3972. return 0;
  3973. }
  3974. /*==========================================
  3975. * charblock command (usage: charblock <player_name>)
  3976. * This command do a definitiv ban on a player
  3977. *------------------------------------------
  3978. */
  3979. int atcommand_char_block(
  3980. const int fd, struct map_session_data* sd,
  3981. const char* command, const char* message)
  3982. {
  3983. nullpo_retr(-1, sd);
  3984. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3985. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  3986. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3987. return -1;
  3988. }
  3989. // check player name
  3990. if (strlen(atcmd_player_name) < 4) {
  3991. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3992. return -1;
  3993. } else if (strlen(atcmd_player_name) > 23) {
  3994. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3995. return -1;
  3996. } else {
  3997. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3998. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3999. }
  4000. return 0;
  4001. }
  4002. /*==========================================
  4003. * charban command (usage: charban <time> <player_name>)
  4004. * This command do a limited ban on a player
  4005. * Time is done as follows:
  4006. * Adjustment value (-1, 1, +1, etc...)
  4007. * Modified element:
  4008. * a or y: year
  4009. * m: month
  4010. * j or d: day
  4011. * h: hour
  4012. * mn: minute
  4013. * s: second
  4014. * <example> @ban +1m-2mn1s-6y test_player
  4015. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4016. *------------------------------------------
  4017. */
  4018. int atcommand_char_ban(
  4019. const int fd, struct map_session_data* sd,
  4020. const char* command, const char* message)
  4021. {
  4022. char * modif_p;
  4023. int year, month, day, hour, minute, second, value;
  4024. nullpo_retr(-1, sd);
  4025. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4026. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4027. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4028. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4029. return -1;
  4030. }
  4031. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4032. modif_p = atcmd_output;
  4033. year = month = day = hour = minute = second = 0;
  4034. while (modif_p[0] != '\0') {
  4035. value = atoi(modif_p);
  4036. if (value == 0)
  4037. modif_p++;
  4038. else {
  4039. if (modif_p[0] == '-' || modif_p[0] == '+')
  4040. modif_p++;
  4041. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4042. modif_p++;
  4043. if (modif_p[0] == 's') {
  4044. second = value;
  4045. modif_p++;
  4046. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4047. minute = value;
  4048. modif_p = modif_p + 2;
  4049. } else if (modif_p[0] == 'h') {
  4050. hour = value;
  4051. modif_p++;
  4052. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4053. day = value;
  4054. modif_p++;
  4055. } else if (modif_p[0] == 'm') {
  4056. month = value;
  4057. modif_p++;
  4058. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4059. year = value;
  4060. modif_p++;
  4061. } else if (modif_p[0] != '\0') {
  4062. modif_p++;
  4063. }
  4064. }
  4065. }
  4066. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4067. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  4068. return -1;
  4069. }
  4070. // check player name
  4071. if (strlen(atcmd_player_name) < 4) {
  4072. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4073. return -1;
  4074. } else if (strlen(atcmd_player_name) > 23) {
  4075. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4076. return -1;
  4077. } else {
  4078. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4079. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4080. }
  4081. return 0;
  4082. }
  4083. /*==========================================
  4084. * charunblock command (usage: charunblock <player_name>)
  4085. *------------------------------------------
  4086. */
  4087. int atcommand_char_unblock(
  4088. const int fd, struct map_session_data* sd,
  4089. const char* command, const char* message)
  4090. {
  4091. nullpo_retr(-1, sd);
  4092. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4093. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4094. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4095. return -1;
  4096. }
  4097. // check player name
  4098. if (strlen(atcmd_player_name) < 4) {
  4099. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4100. return -1;
  4101. } else if (strlen(atcmd_player_name) > 23) {
  4102. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4103. return -1;
  4104. } else {
  4105. // send answer to login server via char-server
  4106. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4107. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4108. }
  4109. return 0;
  4110. }
  4111. /*==========================================
  4112. * charunban command (usage: charunban <player_name>)
  4113. *------------------------------------------
  4114. */
  4115. int atcommand_char_unban(
  4116. const int fd, struct map_session_data* sd,
  4117. const char* command, const char* message)
  4118. {
  4119. nullpo_retr(-1, sd);
  4120. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4121. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4122. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4123. return -1;
  4124. }
  4125. // check player name
  4126. if (strlen(atcmd_player_name) < 4) {
  4127. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4128. return -1;
  4129. } else if (strlen(atcmd_player_name) > 23) {
  4130. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4131. return -1;
  4132. } else {
  4133. // send answer to login server via char-server
  4134. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4135. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4136. }
  4137. return 0;
  4138. }
  4139. /*==========================================
  4140. *
  4141. *------------------------------------------
  4142. */
  4143. int atcommand_night(
  4144. const int fd, struct map_session_data* sd,
  4145. const char* command, const char* message)
  4146. {
  4147. nullpo_retr(-1, sd);
  4148. if (night_flag != 1) {
  4149. map_night_timer(night_timer_tid, 0, 0, 1);
  4150. } else {
  4151. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4152. return -1;
  4153. }
  4154. return 0;
  4155. }
  4156. /*==========================================
  4157. *
  4158. *------------------------------------------
  4159. */
  4160. int atcommand_day(
  4161. const int fd, struct map_session_data* sd,
  4162. const char* command, const char* message)
  4163. {
  4164. nullpo_retr(-1, sd);
  4165. if (night_flag != 0) {
  4166. map_day_timer(day_timer_tid, 0, 0, 1);
  4167. } else {
  4168. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4169. return -1;
  4170. }
  4171. return 0;
  4172. }
  4173. /*==========================================
  4174. *
  4175. *------------------------------------------
  4176. */
  4177. int atcommand_doom(
  4178. const int fd, struct map_session_data* sd,
  4179. const char* command, const char* message)
  4180. {
  4181. struct map_session_data *pl_sd, **pl_allsd;
  4182. int i, users;
  4183. nullpo_retr(-1, sd);
  4184. clif_specialeffect(&sd->bl,450,2);
  4185. pl_allsd = map_getallusers(&users);
  4186. for(i = 0; i < users; i++) {
  4187. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4188. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4189. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4190. }
  4191. }
  4192. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4193. return 0;
  4194. }
  4195. /*==========================================
  4196. *
  4197. *------------------------------------------
  4198. */
  4199. int atcommand_doommap(
  4200. const int fd, struct map_session_data* sd,
  4201. const char* command, const char* message)
  4202. {
  4203. struct map_session_data *pl_sd, **pl_allsd;
  4204. int i, users;
  4205. nullpo_retr(-1, sd);
  4206. clif_specialeffect(&sd->bl,450,3);
  4207. pl_allsd = map_getallusers(&users);
  4208. for (i = 0; i < users; i++) {
  4209. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4210. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4211. {
  4212. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4213. // clif_specialeffect(&pl_sd->bl,450,1);
  4214. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4215. }
  4216. }
  4217. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4218. return 0;
  4219. }
  4220. /*==========================================
  4221. *
  4222. *------------------------------------------
  4223. */
  4224. static void atcommand_raise_sub(struct map_session_data* sd)
  4225. {
  4226. if (sd && sd->state.auth && pc_isdead(sd)) {
  4227. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4228. sd->status.hp = sd->status.max_hp;
  4229. sd->status.sp = sd->status.max_sp;
  4230. pc_setstand(sd);
  4231. clif_updatestatus(sd, SP_HP);
  4232. clif_updatestatus(sd, SP_SP);
  4233. clif_resurrection(&sd->bl, 1);
  4234. if (battle_config.pc_invincible_time > 0)
  4235. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4236. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4237. }
  4238. }
  4239. /*==========================================
  4240. *
  4241. *------------------------------------------
  4242. */
  4243. int atcommand_raise(
  4244. const int fd, struct map_session_data* sd,
  4245. const char* command, const char* message)
  4246. {
  4247. int i, users;
  4248. struct map_session_data **all_sd;
  4249. nullpo_retr(-1, sd);
  4250. all_sd = map_getallusers(&users);
  4251. for (i = 0; i < users; i++) {
  4252. atcommand_raise_sub(all_sd[i]);
  4253. }
  4254. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4255. return 0;
  4256. }
  4257. /*==========================================
  4258. *
  4259. *------------------------------------------
  4260. */
  4261. int atcommand_raisemap(
  4262. const int fd, struct map_session_data* sd,
  4263. const char* command, const char* message)
  4264. {
  4265. struct map_session_data **pl_allsd;
  4266. int i, users;
  4267. nullpo_retr(-1, sd);
  4268. pl_allsd = map_getallusers(&users);
  4269. for (i = 0; i < users; i++) {
  4270. if (sd->bl.m == pl_allsd[i]->bl.m)
  4271. atcommand_raise_sub(pl_allsd[i]);
  4272. }
  4273. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4274. return 0;
  4275. }
  4276. /*==========================================
  4277. *
  4278. *------------------------------------------
  4279. */
  4280. int atcommand_kick(
  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. nullpo_retr(-1, sd);
  4286. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4287. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4288. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4289. return -1;
  4290. }
  4291. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4292. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4293. clif_GM_kick(sd, pl_sd, 1);
  4294. else {
  4295. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4296. return -1;
  4297. }
  4298. } else {
  4299. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4300. return -1;
  4301. }
  4302. return 0;
  4303. }
  4304. /*==========================================
  4305. *
  4306. *------------------------------------------
  4307. */
  4308. int atcommand_kickall(
  4309. const int fd, struct map_session_data* sd,
  4310. const char* command, const char* message)
  4311. {
  4312. struct map_session_data *pl_sd, **pl_allsd;
  4313. int i, users;
  4314. nullpo_retr(-1, sd);
  4315. pl_allsd = map_getallusers(&users);
  4316. for (i = 0; i < users; i++) {
  4317. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4318. if (sd->status.account_id != pl_sd->status.account_id)
  4319. clif_GM_kick(sd, pl_sd, 0);
  4320. }
  4321. }
  4322. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4323. return 0;
  4324. }
  4325. /*==========================================
  4326. *
  4327. *------------------------------------------
  4328. */
  4329. int atcommand_allskill(
  4330. const int fd, struct map_session_data* sd,
  4331. const char* command, const char* message)
  4332. {
  4333. nullpo_retr(-1, sd);
  4334. pc_allskillup(sd); // all skills
  4335. sd->status.skill_point = 0; // 0 skill points
  4336. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4337. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4338. return 0;
  4339. }
  4340. /*==========================================
  4341. *
  4342. *------------------------------------------
  4343. */
  4344. int atcommand_questskill(
  4345. const int fd, struct map_session_data* sd,
  4346. const char* command, const char* message)
  4347. {
  4348. int skill_id;
  4349. nullpo_retr(-1, sd);
  4350. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4351. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4352. return -1;
  4353. }
  4354. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4355. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4356. if (pc_checkskill(sd, skill_id) == 0) {
  4357. pc_skill(sd, skill_id, 1, 0);
  4358. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4359. } else {
  4360. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4361. return -1;
  4362. }
  4363. } else {
  4364. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4365. return -1;
  4366. }
  4367. } else {
  4368. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4369. return -1;
  4370. }
  4371. return 0;
  4372. }
  4373. /*==========================================
  4374. *
  4375. *------------------------------------------
  4376. */
  4377. int atcommand_lostskill(
  4378. const int fd, struct map_session_data* sd,
  4379. const char* command, const char* message)
  4380. {
  4381. int skill_id;
  4382. nullpo_retr(-1, sd);
  4383. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4384. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4385. return -1;
  4386. }
  4387. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4388. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4389. if (pc_checkskill(sd, skill_id) > 0) {
  4390. sd->status.skill[skill_id].lv = 0;
  4391. sd->status.skill[skill_id].flag = 0;
  4392. clif_skillinfoblock(sd);
  4393. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4394. } else {
  4395. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4396. return -1;
  4397. }
  4398. } else {
  4399. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4400. return -1;
  4401. }
  4402. } else {
  4403. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4404. return -1;
  4405. }
  4406. return 0;
  4407. }
  4408. /*==========================================
  4409. *
  4410. *------------------------------------------
  4411. */
  4412. int atcommand_spiritball(
  4413. const int fd, struct map_session_data* sd,
  4414. const char* command, const char* message)
  4415. {
  4416. int number;
  4417. nullpo_retr(-1, sd);
  4418. if (!message || !*message || (number = atoi(message)) < 0) {
  4419. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4420. return -1;
  4421. }
  4422. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4423. if (number > 500)
  4424. number = 500;
  4425. if (number >= 0 && number <= 0x7FFF) {
  4426. if (sd->spiritball != number || number > 499) {
  4427. if (sd->spiritball > 0)
  4428. pc_delspiritball(sd, sd->spiritball, 1);
  4429. sd->spiritball = number;
  4430. clif_spiritball(sd);
  4431. // no message, player can look the difference
  4432. if (number > 1000)
  4433. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4434. } else {
  4435. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4436. return -1;
  4437. }
  4438. } else {
  4439. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4440. return -1;
  4441. }
  4442. return 0;
  4443. }
  4444. /*==========================================
  4445. *
  4446. *------------------------------------------
  4447. */
  4448. int atcommand_party(
  4449. const int fd, struct map_session_data* sd,
  4450. const char* command, const char* message)
  4451. {
  4452. char party[NAME_LENGTH];
  4453. nullpo_retr(-1, sd);
  4454. memset(party, '\0', sizeof(party));
  4455. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4456. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4457. return -1;
  4458. }
  4459. party_create(sd, party, 0, 0);
  4460. return 0;
  4461. }
  4462. /*==========================================
  4463. *
  4464. *------------------------------------------
  4465. */
  4466. int atcommand_guild(
  4467. const int fd, struct map_session_data* sd,
  4468. const char* command, const char* message)
  4469. {
  4470. char guild[NAME_LENGTH];
  4471. int prev;
  4472. nullpo_retr(-1, sd);
  4473. memset(guild, '\0', sizeof(guild));
  4474. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4475. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4476. return -1;
  4477. }
  4478. prev = battle_config.guild_emperium_check;
  4479. battle_config.guild_emperium_check = 0;
  4480. guild_create(sd, guild);
  4481. battle_config.guild_emperium_check = prev;
  4482. return 0;
  4483. }
  4484. /*==========================================
  4485. *
  4486. *------------------------------------------
  4487. */
  4488. int atcommand_agitstart(
  4489. const int fd, struct map_session_data* sd,
  4490. const char* command, const char* message)
  4491. {
  4492. nullpo_retr(-1, sd);
  4493. if (agit_flag == 1) {
  4494. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4495. return -1;
  4496. }
  4497. agit_flag = 1;
  4498. guild_agit_start();
  4499. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4500. return 0;
  4501. }
  4502. /*==========================================
  4503. *
  4504. *------------------------------------------
  4505. */
  4506. int atcommand_agitend(
  4507. const int fd, struct map_session_data* sd,
  4508. const char* command, const char* message)
  4509. {
  4510. nullpo_retr(-1, sd);
  4511. if (agit_flag == 0) {
  4512. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4513. return -1;
  4514. }
  4515. agit_flag = 0;
  4516. guild_agit_end();
  4517. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4518. return 0;
  4519. }
  4520. /*==========================================
  4521. * @mapexitでマップサーバーを終了させる
  4522. *------------------------------------------
  4523. */
  4524. int atcommand_mapexit(
  4525. const int fd, struct map_session_data* sd,
  4526. const char* command, const char* message)
  4527. {
  4528. struct map_session_data *pl_sd, **pl_allsd;
  4529. int i, users;
  4530. nullpo_retr(-1, sd);
  4531. pl_allsd = map_getallusers(&users);
  4532. for (i = 0; i < users; i++) {
  4533. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4534. clif_GM_kick(sd, pl_sd, 0);
  4535. }
  4536. clif_GM_kick(sd, sd, 0);
  4537. flush_fifos();
  4538. runflag = 0;
  4539. return 0;
  4540. }
  4541. /*==========================================
  4542. * idsearch <part_of_name>: revrited by [Yor]
  4543. *------------------------------------------
  4544. */
  4545. int atcommand_idsearch(
  4546. const int fd, struct map_session_data* sd,
  4547. const char* command, const char* message)
  4548. {
  4549. char item_name[100];
  4550. unsigned int i, match;
  4551. struct item_data *item;
  4552. nullpo_retr(-1, sd);
  4553. memset(item_name, '\0', sizeof(item_name));
  4554. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4555. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4556. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4557. return -1;
  4558. }
  4559. sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4560. clif_displaymessage(fd, atcmd_output);
  4561. match = 0;
  4562. for(i = 0; i < 20000; i++) {
  4563. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4564. match++;
  4565. sprintf(atcmd_output, msg_table[78], item->jname, item->nameid); // %s: %d
  4566. clif_displaymessage(fd, atcmd_output);
  4567. }
  4568. }
  4569. sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
  4570. clif_displaymessage(fd, atcmd_output);
  4571. return 0;
  4572. }
  4573. /*==========================================
  4574. * Recall All Characters Online To Your Location
  4575. *------------------------------------------
  4576. */
  4577. int atcommand_recallall(
  4578. const int fd, struct map_session_data* sd,
  4579. const char* command, const char* message)
  4580. {
  4581. struct map_session_data *pl_sd, **pl_allsd;
  4582. int i;
  4583. int count, users;
  4584. nullpo_retr(-1, sd);
  4585. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4586. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4587. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4588. return -1;
  4589. }
  4590. count = 0;
  4591. pl_allsd = map_getallusers(&users);
  4592. for (i = 0; i < users; i++) {
  4593. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4594. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4595. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4596. count++;
  4597. else {
  4598. if (pc_isdead(pl_sd)) { //Wake them up
  4599. pc_setstand(pl_sd);
  4600. pc_setrestartvalue(pl_sd,1);
  4601. }
  4602. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4603. }
  4604. }
  4605. }
  4606. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4607. if (count) {
  4608. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4609. clif_displaymessage(fd, atcmd_output);
  4610. }
  4611. return 0;
  4612. }
  4613. /*==========================================
  4614. * Recall online characters of a guild to your location
  4615. *------------------------------------------
  4616. */
  4617. int atcommand_guildrecall(
  4618. const int fd, struct map_session_data* sd,
  4619. const char* command, const char* message)
  4620. {
  4621. struct map_session_data *pl_sd, **pl_allsd;
  4622. int i, users, count;
  4623. char guild_name[NAME_LENGTH];
  4624. struct guild *g;
  4625. nullpo_retr(-1, sd);
  4626. memset(guild_name, '\0', sizeof(guild_name));
  4627. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4628. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4629. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4630. return -1;
  4631. }
  4632. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4633. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4634. return -1;
  4635. }
  4636. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4637. (g = guild_search(atoi(message))) != NULL) {
  4638. count = 0;
  4639. pl_allsd = map_getallusers(&users);
  4640. for (i = 0; i < users; i++) {
  4641. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4642. pl_sd->status.guild_id == g->guild_id) {
  4643. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4644. count++;
  4645. else
  4646. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4647. }
  4648. }
  4649. sprintf(atcmd_output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4650. clif_displaymessage(fd, atcmd_output);
  4651. if (count) {
  4652. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4653. clif_displaymessage(fd, atcmd_output);
  4654. }
  4655. } else {
  4656. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4657. return -1;
  4658. }
  4659. return 0;
  4660. }
  4661. /*==========================================
  4662. * Recall online characters of a party to your location
  4663. *------------------------------------------
  4664. */
  4665. int atcommand_partyrecall(
  4666. const int fd, struct map_session_data* sd,
  4667. const char* command, const char* message)
  4668. {
  4669. int i;
  4670. struct map_session_data *pl_sd, **pl_allsd;
  4671. char party_name[NAME_LENGTH];
  4672. struct party *p;
  4673. int count, users;
  4674. nullpo_retr(-1, sd);
  4675. memset(party_name, '\0', sizeof(party_name));
  4676. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4677. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4678. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4679. return -1;
  4680. }
  4681. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4682. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4683. return -1;
  4684. }
  4685. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4686. (p = party_search(atoi(message))) != NULL) {
  4687. count = 0;
  4688. pl_allsd = map_getallusers(&users);
  4689. for (i = 0; i < users; i++) {
  4690. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4691. pl_sd->status.party_id == p->party_id) {
  4692. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4693. count++;
  4694. else
  4695. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4696. }
  4697. }
  4698. sprintf(atcmd_output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4699. clif_displaymessage(fd, atcmd_output);
  4700. if (count) {
  4701. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4702. clif_displaymessage(fd, atcmd_output);
  4703. }
  4704. } else {
  4705. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4706. return -1;
  4707. }
  4708. return 0;
  4709. }
  4710. /*==========================================
  4711. *
  4712. *------------------------------------------
  4713. */
  4714. int atcommand_reloaditemdb(
  4715. const int fd, struct map_session_data* sd,
  4716. const char* command, const char* message)
  4717. {
  4718. nullpo_retr(-1, sd);
  4719. itemdb_reload();
  4720. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4721. return 0;
  4722. }
  4723. /*==========================================
  4724. *
  4725. *------------------------------------------
  4726. */
  4727. int atcommand_reloadmobdb(
  4728. const int fd, struct map_session_data* sd,
  4729. const char* command, const char* message)
  4730. {
  4731. nullpo_retr(-1, sd);
  4732. mob_reload();
  4733. do_final_pet();
  4734. read_petdb();
  4735. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4736. return 0;
  4737. }
  4738. /*==========================================
  4739. *
  4740. *------------------------------------------
  4741. */
  4742. int atcommand_reloadskilldb(
  4743. const int fd, struct map_session_data* sd,
  4744. const char* command, const char* message)
  4745. {
  4746. nullpo_retr(-1, sd);
  4747. skill_reload();
  4748. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4749. return 0;
  4750. }
  4751. /*==========================================
  4752. * @reloadatcommand
  4753. * atcommand_athena.conf のリロード
  4754. *------------------------------------------
  4755. */
  4756. int
  4757. atcommand_reloadatcommand(
  4758. const int fd, struct map_session_data* sd,
  4759. const char* command, const char* message)
  4760. {
  4761. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4762. clif_displaymessage(fd, msg_table[254]);
  4763. return 0;
  4764. }
  4765. /*==========================================
  4766. * @reloadbattleconf
  4767. * battle_athena.conf のリロード
  4768. *------------------------------------------
  4769. */
  4770. int
  4771. atcommand_reloadbattleconf(
  4772. const int fd, struct map_session_data* sd,
  4773. const char* command, const char* message)
  4774. {
  4775. battle_config_read(BATTLE_CONF_FILENAME);
  4776. mob_reload(); //Needed as well so rate changes take effect.
  4777. clif_displaymessage(fd, msg_table[255]);
  4778. return 0;
  4779. }
  4780. /*==========================================
  4781. * @reloadstatusdb
  4782. * job_db1.txt job_db2.txt job_db2-2.txt
  4783. * refine_db.txt size_fix.txt
  4784. * のリロード
  4785. *------------------------------------------
  4786. */
  4787. int
  4788. atcommand_reloadstatusdb(
  4789. const int fd, struct map_session_data* sd,
  4790. const char* command, const char* message)
  4791. {
  4792. status_readdb();
  4793. clif_displaymessage(fd, msg_table[256]);
  4794. return 0;
  4795. }
  4796. /*==========================================
  4797. * @reloadpcdb
  4798. * exp.txt skill_tree.txt attr_fix.txt
  4799. * のリロード
  4800. *------------------------------------------
  4801. */
  4802. int
  4803. atcommand_reloadpcdb(
  4804. const int fd, struct map_session_data* sd,
  4805. const char* command, const char* message)
  4806. {
  4807. pc_readdb();
  4808. clif_displaymessage(fd, msg_table[257]);
  4809. return 0;
  4810. }
  4811. /*==========================================
  4812. * @reloadmotd [Valaris]
  4813. * Reloads motd.txt
  4814. *------------------------------------------
  4815. */
  4816. int
  4817. atcommand_reloadmotd(
  4818. const int fd, struct map_session_data* sd,
  4819. const char* command, const char* message)
  4820. {
  4821. pc_read_motd();
  4822. clif_displaymessage(fd, msg_table[268]);
  4823. return 0;
  4824. }
  4825. /*==========================================
  4826. *
  4827. *------------------------------------------
  4828. */
  4829. int atcommand_reloadscript(
  4830. const int fd, struct map_session_data* sd,
  4831. const char* command, const char* message)
  4832. {
  4833. nullpo_retr(-1, sd);
  4834. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4835. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4836. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4837. flush_fifos();
  4838. //do_init_npc();
  4839. script_reload();
  4840. npc_reload();
  4841. npc_event_do_oninit();
  4842. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4843. return 0;
  4844. }
  4845. /*==========================================
  4846. *
  4847. *------------------------------------------
  4848. */
  4849. int atcommand_reloadgmdb( // by [Yor]
  4850. const int fd, struct map_session_data* sd,
  4851. const char* command, const char* message)
  4852. {
  4853. nullpo_retr(-1, sd);
  4854. chrif_reloadGMdb();
  4855. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4856. return 0;
  4857. }
  4858. /*==========================================
  4859. * @mapinfo <map name> [0-3] by MC_Cameri
  4860. * => Shows information about the map [map name]
  4861. * 0 = no additional information
  4862. * 1 = Show users in that map and their location
  4863. * 2 = Shows NPCs in that map
  4864. * 3 = Shows the shops/chats in that map (not implemented)
  4865. *------------------------------------------
  4866. */
  4867. int atcommand_mapinfo(
  4868. const int fd, struct map_session_data* sd,
  4869. const char* command, const char* message)
  4870. {
  4871. struct map_session_data *pl_sd, **pl_allsd;
  4872. struct npc_data *nd = NULL;
  4873. struct chat_data *cd = NULL;
  4874. char direction[12];
  4875. int m_id, i, chat_num, users, list = 0;
  4876. unsigned short m_index;
  4877. nullpo_retr(-1, sd);
  4878. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4879. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4880. memset(direction, '\0', sizeof(direction));
  4881. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4882. if (list < 0 || list > 3) {
  4883. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4884. return -1;
  4885. }
  4886. if (atcmd_player_name[0] == '\0') {
  4887. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4888. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4889. m_id = map_mapindex2mapid(sd->mapindex);
  4890. } else {
  4891. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4892. strcat(atcmd_player_name, ".gat");
  4893. m_id = map_mapname2mapid(atcmd_player_name);
  4894. }
  4895. if (m_id < 0) {
  4896. clif_displaymessage(fd, msg_table[1]); // Map not found.
  4897. return -1;
  4898. }
  4899. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4900. clif_displaymessage(fd, "------ Map Info ------");
  4901. chat_num = 0;
  4902. pl_allsd = map_getallusers(&users);
  4903. for (i = 0; i < users; i++) {
  4904. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4905. chat_num++;
  4906. }
  4907. }
  4908. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
  4909. clif_displaymessage(fd, atcmd_output);
  4910. if (map[m_id].flag.alias)
  4911. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4912. clif_displaymessage(fd, "------ Map Flags ------");
  4913. strcpy(atcmd_output,"PvP Flags: ");
  4914. if (map[m_id].flag.pvp)
  4915. strcat(atcmd_output, "Pvp ON | ");
  4916. if (map[m_id].flag.nopvp)
  4917. strcat(atcmd_output, "NoPvp | ");
  4918. if (map[m_id].flag.pvp_noguild)
  4919. strcat(atcmd_output, "NoGuild | ");
  4920. if (map[m_id].flag.pvp_noparty)
  4921. strcat(atcmd_output, "NoParty | ");
  4922. if (map[m_id].flag.pvp_nightmaredrop)
  4923. strcat(atcmd_output, "NightmareDrop | ");
  4924. if (map[m_id].flag.pvp_nocalcrank)
  4925. strcat(atcmd_output, "NoCalcRank | ");
  4926. clif_displaymessage(fd, atcmd_output);
  4927. strcpy(atcmd_output,"GvG Flags: ");
  4928. if (map[m_id].flag.gvg)
  4929. strcat(atcmd_output, "GvG ON | ");
  4930. if (map[m_id].flag.gvg_dungeon)
  4931. strcat(atcmd_output, "GvG Dungeon | ");
  4932. if (map[m_id].flag.gvg_castle)
  4933. strcat(atcmd_output, "GvG Castle | ");
  4934. if (map[m_id].flag.gvg_noparty)
  4935. strcat(atcmd_output, "NoParty | ");
  4936. clif_displaymessage(fd, atcmd_output);
  4937. strcpy(atcmd_output,"Teleport Flags: ");
  4938. if (map[m_id].flag.noteleport)
  4939. strcat(atcmd_output, "NoTeleport | ");
  4940. if (map[m_id].flag.monster_noteleport)
  4941. strcat(atcmd_output, "Monster NoTeleport | ");
  4942. if (map[m_id].flag.nowarp)
  4943. strcat(atcmd_output, "NoWarp | ");
  4944. if (map[m_id].flag.nowarpto)
  4945. strcat(atcmd_output, "NoWarpTo | ");
  4946. if (map[m_id].flag.noreturn)
  4947. strcat(atcmd_output, "NoReturn | ");
  4948. if (map[m_id].flag.nogo)
  4949. strcat(atcmd_output, "NoGo | ");
  4950. if (map[m_id].flag.nomemo)
  4951. strcat(atcmd_output, "NoMemo | ");
  4952. clif_displaymessage(fd, atcmd_output);
  4953. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4954. clif_displaymessage(fd, atcmd_output);
  4955. if (map[m_id].flag.nosave) {
  4956. if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4957. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4958. else
  4959. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4960. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4961. clif_displaymessage(fd, atcmd_output);
  4962. }
  4963. strcpy(atcmd_output,"Weather Flags: ");
  4964. if (map[m_id].flag.snow)
  4965. strcat(atcmd_output, "Snow | ");
  4966. if (map[m_id].flag.fog)
  4967. strcat(atcmd_output, "Fog | ");
  4968. if (map[m_id].flag.sakura)
  4969. strcat(atcmd_output, "Sakura | ");
  4970. if (map[m_id].flag.clouds)
  4971. strcat(atcmd_output, "Clouds | ");
  4972. if (map[m_id].flag.clouds2)
  4973. strcat(atcmd_output, "Clouds2 | ");
  4974. if (map[m_id].flag.fireworks)
  4975. strcat(atcmd_output, "Fireworks | ");
  4976. if (map[m_id].flag.leaves)
  4977. strcat(atcmd_output, "Leaves | ");
  4978. if (map[m_id].flag.rain)
  4979. strcat(atcmd_output, "Rain | ");
  4980. if (map[m_id].flag.indoors)
  4981. strcat(atcmd_output, "Indoors | ");
  4982. if (map[m_id].flag.nightenabled)
  4983. strcat(atcmd_output, "Displays Night | ");
  4984. clif_displaymessage(fd, atcmd_output);
  4985. strcpy(atcmd_output,"Other Flags: ");
  4986. if (map[m_id].flag.nobranch)
  4987. strcat(atcmd_output, "NoBranch | ");
  4988. if (map[m_id].flag.notrade)
  4989. strcat(atcmd_output, "NoTrade | ");
  4990. if (map[m_id].flag.noskill)
  4991. strcat(atcmd_output, "NoSkill | ");
  4992. if (map[m_id].flag.noicewall)
  4993. strcat(atcmd_output, "NoIcewall | ");
  4994. clif_displaymessage(fd, atcmd_output);
  4995. strcpy(atcmd_output,"Other Flags: ");
  4996. if (map[m_id].flag.nobaseexp)
  4997. strcat(atcmd_output, "NoBaseEXP | ");
  4998. if (map[m_id].flag.nojobexp)
  4999. strcat(atcmd_output, "NoJobEXP | ");
  5000. if (map[m_id].flag.nomobloot)
  5001. strcat(atcmd_output, "NoMobLoot | ");
  5002. if (map[m_id].flag.nomvploot)
  5003. strcat(atcmd_output, "NoMVPLoot | ");
  5004. clif_displaymessage(fd, atcmd_output);
  5005. switch (list) {
  5006. case 0:
  5007. // Do nothing. It's list 0, no additional display.
  5008. break;
  5009. case 1:
  5010. clif_displaymessage(fd, "----- Players in Map -----");
  5011. for (i = 0; i < users; i++) {
  5012. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5013. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5014. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5015. clif_displaymessage(fd, atcmd_output);
  5016. }
  5017. }
  5018. break;
  5019. case 2:
  5020. clif_displaymessage(fd, "----- NPCs in Map -----");
  5021. for (i = 0; i < map[m_id].npc_num;) {
  5022. nd = map[m_id].npc[i];
  5023. switch(nd->dir) {
  5024. case 0: strcpy(direction, "North"); break;
  5025. case 1: strcpy(direction, "North West"); break;
  5026. case 2: strcpy(direction, "West"); break;
  5027. case 3: strcpy(direction, "South West"); break;
  5028. case 4: strcpy(direction, "South"); break;
  5029. case 5: strcpy(direction, "South East"); break;
  5030. case 6: strcpy(direction, "East"); break;
  5031. case 7: strcpy(direction, "North East"); break;
  5032. case 9: strcpy(direction, "North"); break;
  5033. default: strcpy(direction, "Unknown"); break;
  5034. }
  5035. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5036. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5037. clif_displaymessage(fd, atcmd_output);
  5038. }
  5039. break;
  5040. case 3:
  5041. clif_displaymessage(fd, "----- Chats in Map -----");
  5042. for (i = 0; i < users; i++) {
  5043. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5044. pl_sd->mapindex == m_index &&
  5045. cd->usersd[0] == pl_sd) {
  5046. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5047. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5048. clif_displaymessage(fd, atcmd_output);
  5049. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5050. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5051. clif_displaymessage(fd, atcmd_output);
  5052. }
  5053. }
  5054. break;
  5055. default: // normally impossible to arrive here
  5056. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5057. return -1;
  5058. break;
  5059. }
  5060. return 0;
  5061. }
  5062. /*==========================================
  5063. *
  5064. *------------------------------------------
  5065. */
  5066. int atcommand_mount_peco(
  5067. const int fd, struct map_session_data* sd,
  5068. const char* command, const char* message)
  5069. {
  5070. nullpo_retr(-1, sd);
  5071. if (!pc_isriding(sd)) { // if actually no peco
  5072. if (pc_checkskill(sd, KN_RIDING)) {
  5073. pc_setoption(sd, sd->sc.option | 0x0020);
  5074. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5075. } else {
  5076. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5077. return -1;
  5078. }
  5079. } else { //Dismount
  5080. pc_setoption(sd, sd->sc.option & ~0x0020);
  5081. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5082. }
  5083. return 0;
  5084. }
  5085. /*==========================================
  5086. *
  5087. *------------------------------------------
  5088. */
  5089. int atcommand_char_mount_peco(
  5090. const int fd, struct map_session_data* sd,
  5091. const char* command, const char* message)
  5092. {
  5093. struct map_session_data *pl_sd;
  5094. nullpo_retr(-1, sd);
  5095. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5096. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5097. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5098. return -1;
  5099. }
  5100. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5101. if (!pc_isriding(pl_sd)) { // if actually no peco
  5102. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5103. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5104. clif_displaymessage(fd, msg_table[216]); // Mounted Peco.
  5105. } else {
  5106. clif_displaymessage(fd, msg_table[217]); // You can not mount a peco with your job.
  5107. return -1;
  5108. }
  5109. } else { //Dismount
  5110. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5111. clif_displaymessage(fd, msg_table[218]); // Unmounted Peco.
  5112. }
  5113. } else {
  5114. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5115. return -1;
  5116. }
  5117. return 0;
  5118. }
  5119. /*==========================================
  5120. *Spy Commands by Syrus22
  5121. *------------------------------------------
  5122. */
  5123. int atcommand_guildspy(
  5124. const int fd, struct map_session_data* sd,
  5125. const char* command, const char* message)
  5126. {
  5127. char guild_name[NAME_LENGTH];
  5128. struct guild *g;
  5129. nullpo_retr(-1, sd);
  5130. memset(guild_name, '\0', sizeof(guild_name));
  5131. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5132. if (!enable_spy)
  5133. {
  5134. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5135. return -1;
  5136. }
  5137. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5138. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5139. return -1;
  5140. }
  5141. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5142. (g = guild_search(atoi(message))) != NULL) {
  5143. if (sd->guildspy == g->guild_id) {
  5144. sd->guildspy = 0;
  5145. sprintf(atcmd_output, msg_table[103], g->name); // No longer spying on the %s guild.
  5146. clif_displaymessage(fd, atcmd_output);
  5147. } else {
  5148. sd->guildspy = g->guild_id;
  5149. sprintf(atcmd_output, msg_table[104], g->name); // Spying on the %s guild.
  5150. clif_displaymessage(fd, atcmd_output);
  5151. }
  5152. } else {
  5153. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5154. return -1;
  5155. }
  5156. return 0;
  5157. }
  5158. /*==========================================
  5159. *
  5160. *------------------------------------------
  5161. */
  5162. int atcommand_partyspy(
  5163. const int fd, struct map_session_data* sd,
  5164. const char* command, const char* message)
  5165. {
  5166. char party_name[NAME_LENGTH];
  5167. struct party *p;
  5168. nullpo_retr(-1, sd);
  5169. memset(party_name, '\0', sizeof(party_name));
  5170. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5171. if (!enable_spy)
  5172. {
  5173. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5174. return -1;
  5175. }
  5176. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5177. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5178. return -1;
  5179. }
  5180. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5181. (p = party_search(atoi(message))) != NULL) {
  5182. if (sd->partyspy == p->party_id) {
  5183. sd->partyspy = 0;
  5184. sprintf(atcmd_output, msg_table[105], p->name); // No longer spying on the %s party.
  5185. clif_displaymessage(fd, atcmd_output);
  5186. } else {
  5187. sd->partyspy = p->party_id;
  5188. sprintf(atcmd_output, msg_table[106], p->name); // Spying on the %s party.
  5189. clif_displaymessage(fd, atcmd_output);
  5190. }
  5191. } else {
  5192. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5193. return -1;
  5194. }
  5195. return 0;
  5196. }
  5197. /*==========================================
  5198. * @repairall [Valaris]
  5199. *------------------------------------------
  5200. */
  5201. int atcommand_repairall(
  5202. const int fd, struct map_session_data* sd,
  5203. const char* command, const char* message)
  5204. {
  5205. int count, i;
  5206. nullpo_retr(-1, sd);
  5207. count = 0;
  5208. for (i = 0; i < MAX_INVENTORY; i++) {
  5209. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5210. sd->status.inventory[i].attribute = 0;
  5211. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5212. count++;
  5213. }
  5214. }
  5215. if (count > 0) {
  5216. clif_misceffect(&sd->bl, 3);
  5217. clif_equiplist(sd);
  5218. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5219. } else {
  5220. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5221. return -1;
  5222. }
  5223. return 0;
  5224. }
  5225. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5226. int atcommand_nuke(
  5227. const int fd, struct map_session_data* sd,
  5228. const char* command, const char* message)
  5229. {
  5230. struct map_session_data *pl_sd;
  5231. nullpo_retr(-1, sd);
  5232. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5233. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5234. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5235. return -1;
  5236. }
  5237. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5238. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5239. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5240. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5241. } else {
  5242. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5243. return -1;
  5244. }
  5245. } else {
  5246. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5247. return -1;
  5248. }
  5249. return 0;
  5250. }
  5251. /*==========================================
  5252. *
  5253. *------------------------------------------
  5254. */
  5255. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5256. const char* command, const char* message)
  5257. {
  5258. char NPCname[NAME_LENGTH];
  5259. nullpo_retr(-1, sd);
  5260. memset(NPCname, '\0', sizeof(NPCname));
  5261. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5262. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5263. return -1;
  5264. }
  5265. if (npc_name2id(NPCname) != NULL) {
  5266. npc_enable(NPCname, 1);
  5267. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5268. } else {
  5269. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5270. return -1;
  5271. }
  5272. return 0;
  5273. }
  5274. /*==========================================
  5275. *
  5276. *------------------------------------------
  5277. */
  5278. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5279. const char* command, const char* message)
  5280. {
  5281. char NPCname[NAME_LENGTH];
  5282. nullpo_retr(-1, sd);
  5283. memset(NPCname, '\0', sizeof(NPCname));
  5284. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5285. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5286. return -1;
  5287. }
  5288. if (npc_name2id(NPCname) != NULL) {
  5289. npc_enable(NPCname, 0);
  5290. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5291. } else {
  5292. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5293. return -1;
  5294. }
  5295. return 0;
  5296. }
  5297. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5298. const char* command, const char* message)
  5299. {
  5300. FILE *fp;
  5301. if (!message || !*message) {
  5302. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5303. return -1;
  5304. }
  5305. // check if script file exists
  5306. if ((fp = fopen(message, "r")) == NULL) {
  5307. clif_displaymessage(fd, msg_table[261]);
  5308. return -1;
  5309. }
  5310. fclose(fp);
  5311. // add to list of script sources and run it
  5312. npc_addsrcfile((char *)message);
  5313. npc_parsesrcfile((char *)message);
  5314. clif_displaymessage(fd, msg_table[262]);
  5315. return 0;
  5316. }
  5317. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5318. const char* command, const char* message)
  5319. {
  5320. struct npc_data *nd;
  5321. char NPCname[NAME_LENGTH];
  5322. nullpo_retr(-1, sd);
  5323. memset(NPCname, '\0', sizeof(NPCname));
  5324. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5325. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5326. return -1;
  5327. }
  5328. if ((nd = npc_name2id(NPCname)) != NULL) {
  5329. npc_unload(nd);
  5330. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5331. } else {
  5332. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5333. return -1;
  5334. }
  5335. return 0;
  5336. }
  5337. /*==========================================
  5338. * time in txt for time command (by [Yor])
  5339. *------------------------------------------
  5340. */
  5341. char * txt_time(unsigned int duration) {
  5342. int days, hours, minutes, seconds;
  5343. char temp[256];
  5344. static char temp1[256];
  5345. memset(temp, '\0', sizeof(temp));
  5346. memset(temp1, '\0', sizeof(temp1));
  5347. if (duration < 0)
  5348. duration = 0;
  5349. days = duration / (60 * 60 * 24);
  5350. duration = duration - (60 * 60 * 24 * days);
  5351. hours = duration / (60 * 60);
  5352. duration = duration - (60 * 60 * hours);
  5353. minutes = duration / 60;
  5354. seconds = duration - (60 * minutes);
  5355. if (days < 2)
  5356. sprintf(temp, msg_table[219], days); // %d day
  5357. else
  5358. sprintf(temp, msg_table[220], days); // %d days
  5359. if (hours < 2)
  5360. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5361. else
  5362. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5363. if (minutes < 2)
  5364. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5365. else
  5366. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5367. if (seconds < 2)
  5368. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5369. else
  5370. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5371. return temp1;
  5372. }
  5373. /*==========================================
  5374. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5375. * Calculation management of GM modification (@day/@night GM commands) is done
  5376. *------------------------------------------
  5377. */
  5378. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5379. const char* command, const char* message)
  5380. {
  5381. struct TimerData * timer_data;
  5382. struct TimerData * timer_data2;
  5383. time_t time_server; // variable for number of seconds (used with time() function)
  5384. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5385. char temp[256];
  5386. nullpo_retr(-1, sd);
  5387. memset(temp, '\0', sizeof(temp));
  5388. time(&time_server); // get time in seconds since 1/1/1970
  5389. datetime = localtime(&time_server); // convert seconds in structure
  5390. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5391. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5392. clif_displaymessage(fd, temp);
  5393. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5394. if (night_flag == 0)
  5395. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5396. else
  5397. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5398. } else if (battle_config.night_duration == 0)
  5399. if (night_flag == 1) { // we start with night
  5400. timer_data = get_timer(day_timer_tid);
  5401. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5402. clif_displaymessage(fd, temp);
  5403. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5404. } else
  5405. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5406. else if (battle_config.day_duration == 0)
  5407. if (night_flag == 0) { // we start with day
  5408. timer_data = get_timer(night_timer_tid);
  5409. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5410. clif_displaymessage(fd, temp);
  5411. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5412. } else
  5413. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5414. else {
  5415. if (night_flag == 0) {
  5416. timer_data = get_timer(night_timer_tid);
  5417. timer_data2 = get_timer(day_timer_tid);
  5418. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5419. clif_displaymessage(fd, temp);
  5420. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5421. sprintf(temp, msg_table[237], txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5422. else
  5423. sprintf(temp, msg_table[237], txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5424. clif_displaymessage(fd, temp);
  5425. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5426. clif_displaymessage(fd, temp);
  5427. } else {
  5428. timer_data = get_timer(day_timer_tid);
  5429. timer_data2 = get_timer(night_timer_tid);
  5430. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5431. clif_displaymessage(fd, temp);
  5432. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5433. sprintf(temp, msg_table[239], txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5434. else
  5435. sprintf(temp, msg_table[239], txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5436. clif_displaymessage(fd, temp);
  5437. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5438. clif_displaymessage(fd, temp);
  5439. }
  5440. }
  5441. return 0;
  5442. }
  5443. /*==========================================
  5444. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5445. * removes <quantity> item from a character
  5446. * item can be equiped or not.
  5447. * Inspired from a old command created by RoVeRT
  5448. *------------------------------------------
  5449. */
  5450. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5451. const char* command, const char* message)
  5452. {
  5453. struct map_session_data *pl_sd;
  5454. char item_name[100];
  5455. int i, number = 0, item_id, item_position, count;
  5456. struct item_data *item_data;
  5457. nullpo_retr(-1, sd);
  5458. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5459. memset(item_name, '\0', sizeof(item_name));
  5460. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5461. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5462. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5463. return -1;
  5464. }
  5465. item_id = 0;
  5466. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5467. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5468. item_id = item_data->nameid;
  5469. if (item_id > 500) {
  5470. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5471. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5472. item_position = pc_search_inventory(pl_sd, item_id);
  5473. if (item_position >= 0) {
  5474. count = 0;
  5475. for(i = 0; i < number && item_position >= 0; i++) {
  5476. //Logs (A)dmins items [Lupus]
  5477. if(log_config.pick > 0 ) {
  5478. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5479. }
  5480. //Logs
  5481. pc_delitem(pl_sd, item_position, 1, 0);
  5482. count++;
  5483. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5484. }
  5485. sprintf(atcmd_output, msg_table[113], count); // %d item(s) removed by a GM.
  5486. clif_displaymessage(pl_sd->fd, atcmd_output);
  5487. if (number == count)
  5488. sprintf(atcmd_output, msg_table[114], count); // %d item(s) removed from the player.
  5489. else
  5490. sprintf(atcmd_output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5491. clif_displaymessage(fd, atcmd_output);
  5492. } else {
  5493. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5494. return -1;
  5495. }
  5496. } else {
  5497. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5498. return -1;
  5499. }
  5500. } else {
  5501. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5502. return -1;
  5503. }
  5504. } else {
  5505. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5506. return -1;
  5507. }
  5508. return 0;
  5509. }
  5510. /*==========================================
  5511. * @jail <char_name> by [Yor]
  5512. * Special warp! No check with nowarp and nowarpto flag
  5513. *------------------------------------------
  5514. */
  5515. int atcommand_jail(
  5516. const int fd, struct map_session_data* sd,
  5517. const char* command, const char* message)
  5518. {
  5519. struct map_session_data *pl_sd;
  5520. int x, y;
  5521. unsigned short m_index;
  5522. nullpo_retr(-1, sd);
  5523. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5524. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5525. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5526. return -1;
  5527. }
  5528. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5529. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5530. switch(rand() % 2) {
  5531. case 0:
  5532. x = 24;
  5533. y = 75;
  5534. break;
  5535. default:
  5536. x = 49;
  5537. y = 75;
  5538. break;
  5539. }
  5540. m_index = mapindex_name2id(MAP_JAIL);
  5541. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0) {
  5542. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5543. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5544. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5545. } else {
  5546. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5547. return -1;
  5548. }
  5549. } else {
  5550. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5551. return -1;
  5552. }
  5553. } else {
  5554. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5555. return -1;
  5556. }
  5557. return 0;
  5558. }
  5559. /*==========================================
  5560. * @unjail/@discharge <char_name> by [Yor]
  5561. * Special warp! No check with nowarp and nowarpto flag
  5562. *------------------------------------------
  5563. */
  5564. int atcommand_unjail(
  5565. const int fd, struct map_session_data* sd,
  5566. const char* command, const char* message)
  5567. {
  5568. struct map_session_data *pl_sd;
  5569. unsigned short m_index;
  5570. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5571. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5572. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5573. return -1;
  5574. }
  5575. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5576. m_index = mapindex_name2id(MAP_PRONTERA);
  5577. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5578. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5579. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5580. return -1;
  5581. } else if (pc_setpos(pl_sd, m_index, 0, 0, 3) == 0) { //old coords: 156,191
  5582. pc_setsavepoint(pl_sd, m_index, 0, 0); // Save char respawn point in Prontera
  5583. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5584. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5585. } else {
  5586. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5587. return -1;
  5588. }
  5589. } else {
  5590. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5591. return -1;
  5592. }
  5593. } else {
  5594. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5595. return -1;
  5596. }
  5597. return 0;
  5598. }
  5599. /*==========================================
  5600. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5601. *------------------------------------------
  5602. */
  5603. int atcommand_disguise(
  5604. const int fd, struct map_session_data* sd,
  5605. const char* command, const char* message)
  5606. {
  5607. int id = 0;
  5608. nullpo_retr(-1, sd);
  5609. if (!message || !*message) {
  5610. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5611. return -1;
  5612. }
  5613. if ((id = atoi(message)) > 0)
  5614. { //Acquired an ID
  5615. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5616. id = 0; //Invalid id for either mobs or npcs.
  5617. } else { //Acquired a Name
  5618. if ((id = mobdb_searchname(message)) == 0)
  5619. {
  5620. struct npc_data* nd = npc_name2id(message);
  5621. if (nd != NULL)
  5622. id = nd->n;
  5623. }
  5624. }
  5625. if (id == 0)
  5626. { // Monster/NPC name/id hasn't been found.
  5627. clif_displaymessage(fd, msg_table[123]);
  5628. return -1;
  5629. }
  5630. /* The previous way....
  5631. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5632. mob_id = atoi(message);
  5633. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5634. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5635. (mob_id >= 813 && mob_id <= 858) || // NPC
  5636. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5637. */
  5638. pc_stop_walking(sd,0);
  5639. clif_clearchar(&sd->bl, 0);
  5640. sd->disguise = id;
  5641. sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5642. clif_changeoption(&sd->bl);
  5643. clif_spawnpc(sd);
  5644. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5645. return 0;
  5646. }
  5647. /*==========================================
  5648. * DisguiseAll
  5649. *------------------------------------------
  5650. */
  5651. int atcommand_disguiseall(
  5652. const int fd, struct map_session_data* sd,
  5653. const char* command, const char* message)
  5654. {
  5655. int mob_id=0, i=0, users;
  5656. struct map_session_data *pl_sd, **pl_allsd;
  5657. nullpo_retr(-1, sd);
  5658. if (!message || !*message) {
  5659. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5660. return -1;
  5661. }
  5662. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5663. mob_id = atoi(message);
  5664. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5665. pl_allsd = map_getallusers(&users);
  5666. for(i=0; i < users; i++) {
  5667. if((pl_sd = pl_allsd[i])) {
  5668. pc_stop_walking(pl_sd,0);
  5669. clif_clearchar(&pl_sd->bl, 0);
  5670. pl_sd->disguise = mob_id;
  5671. pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5672. clif_changeoption(&pl_sd->bl);
  5673. clif_spawnpc(pl_sd);
  5674. }
  5675. }
  5676. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5677. } else {
  5678. return -1;
  5679. }
  5680. return 0;
  5681. }
  5682. /*==========================================
  5683. * @undisguise by [Yor]
  5684. *------------------------------------------
  5685. */
  5686. int atcommand_undisguise(
  5687. const int fd, struct map_session_data* sd,
  5688. const char* command, const char* message)
  5689. {
  5690. nullpo_retr(-1, sd);
  5691. if (sd->disguise) {
  5692. pc_stop_walking(sd,0);
  5693. clif_clearchar(&sd->bl, 0);
  5694. sd->disguise = 0;
  5695. clif_changeoption(&sd->bl);
  5696. clif_spawnpc(sd);
  5697. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5698. } else {
  5699. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5700. return -1;
  5701. }
  5702. return 0;
  5703. }
  5704. /*==========================================
  5705. * UndisguiseAll
  5706. *------------------------------------------
  5707. */
  5708. int atcommand_undisguiseall(
  5709. const int fd, struct map_session_data* sd,
  5710. const char* command, const char* message)
  5711. {
  5712. struct map_session_data *pl_sd, **pl_allsd;
  5713. int i, users;
  5714. nullpo_retr(-1, sd);
  5715. pl_allsd = map_getallusers(&users);
  5716. for(i=0; i < users; i++) {
  5717. if((pl_sd = pl_allsd[i]) && pl_sd->disguise) {
  5718. pc_stop_walking(pl_sd,0);
  5719. clif_clearchar(&pl_sd->bl, 0);
  5720. pl_sd->disguise = 0;
  5721. clif_changeoption(&pl_sd->bl);
  5722. clif_spawnpc(pl_sd);
  5723. }
  5724. }
  5725. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5726. return 0;
  5727. }
  5728. /*==========================================
  5729. * @broadcast by [Valaris]
  5730. *------------------------------------------
  5731. */
  5732. int atcommand_broadcast(
  5733. const int fd, struct map_session_data* sd,
  5734. const char* command, const char* message)
  5735. {
  5736. nullpo_retr(-1, sd);
  5737. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5738. if (!message || !*message) {
  5739. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5740. return -1;
  5741. }
  5742. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5743. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5744. return 0;
  5745. }
  5746. /*==========================================
  5747. * @localbroadcast by [Valaris]
  5748. *------------------------------------------
  5749. */
  5750. int atcommand_localbroadcast(
  5751. const int fd, struct map_session_data* sd,
  5752. const char* command, const char* message)
  5753. {
  5754. nullpo_retr(-1, sd);
  5755. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5756. if (!message || !*message) {
  5757. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5758. return -1;
  5759. }
  5760. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5761. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5762. return 0;
  5763. }
  5764. /*==========================================
  5765. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5766. *------------------------------------------
  5767. */
  5768. int atcommand_chardisguise(
  5769. const int fd, struct map_session_data* sd,
  5770. const char* command, const char* message)
  5771. {
  5772. int mob_id;
  5773. char mob_name[NAME_LENGTH];
  5774. struct map_session_data* pl_sd;
  5775. nullpo_retr(-1, sd);
  5776. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5777. memset(mob_name, '\0', sizeof(mob_name));
  5778. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5779. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5780. return -1;
  5781. }
  5782. if ((mob_id = atoi(mob_name)) > 0)
  5783. { //Acquired an ID
  5784. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5785. mob_id = 0; //Invalid id for either mobs or npcs.
  5786. } else { //Acquired a Name
  5787. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5788. {
  5789. struct npc_data* nd = npc_name2id(mob_name);
  5790. if (nd != NULL)
  5791. mob_id = nd->n;
  5792. }
  5793. }
  5794. if (mob_id == 0)
  5795. {
  5796. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5797. return -1;
  5798. }
  5799. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5800. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5801. pc_stop_walking(pl_sd,0);
  5802. clif_clearchar(&pl_sd->bl, 0);
  5803. pl_sd->disguise = mob_id;
  5804. pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5805. clif_changeoption(&pl_sd->bl);
  5806. clif_spawnpc(pl_sd);
  5807. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5808. } else {
  5809. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5810. return -1;
  5811. }
  5812. } else {
  5813. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5814. return -1;
  5815. }
  5816. return 0;
  5817. }
  5818. /*==========================================
  5819. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5820. *------------------------------------------
  5821. */
  5822. int atcommand_charundisguise(
  5823. const int fd, struct map_session_data* sd,
  5824. const char* command, const char* message)
  5825. {
  5826. struct map_session_data* pl_sd;
  5827. nullpo_retr(-1, sd);
  5828. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5829. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5830. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5831. return -1;
  5832. }
  5833. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5834. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5835. if (pl_sd->disguise) {
  5836. pc_stop_walking(pl_sd,0);
  5837. clif_clearchar(&pl_sd->bl, 0);
  5838. pl_sd->disguise = 0;
  5839. clif_changeoption(&pl_sd->bl);
  5840. clif_spawnpc(pl_sd);
  5841. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5842. } else {
  5843. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5844. return -1;
  5845. }
  5846. } else {
  5847. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5848. return -1;
  5849. }
  5850. } else {
  5851. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5852. return -1;
  5853. }
  5854. return 0;
  5855. }
  5856. /*==========================================
  5857. * @email <actual@email> <new@email> by [Yor]
  5858. *------------------------------------------
  5859. */
  5860. int atcommand_email(
  5861. const int fd, struct map_session_data* sd,
  5862. const char* command, const char* message)
  5863. {
  5864. char actual_email[100];
  5865. char new_email[100];
  5866. nullpo_retr(-1, sd);
  5867. memset(actual_email, '\0', sizeof(actual_email));
  5868. memset(new_email, '\0', sizeof(new_email));
  5869. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5870. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5871. return -1;
  5872. }
  5873. if (e_mail_check(actual_email) == 0) {
  5874. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5875. return -1;
  5876. } else if (e_mail_check(new_email) == 0) {
  5877. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5878. return -1;
  5879. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5880. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5881. return -1;
  5882. } else if (strcmpi(actual_email, new_email) == 0) {
  5883. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5884. return -1;
  5885. } else {
  5886. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5887. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5888. }
  5889. return 0;
  5890. }
  5891. /*==========================================
  5892. *@effect
  5893. *------------------------------------------
  5894. */
  5895. int atcommand_effect(
  5896. const int fd, struct map_session_data* sd,
  5897. const char* command, const char* message)
  5898. {
  5899. struct map_session_data *pl_sd, **pl_allsd;
  5900. int type = 0, flag = 0, i, users;
  5901. nullpo_retr(-1, sd);
  5902. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5903. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5904. return -1;
  5905. }
  5906. if(flag <=0){
  5907. clif_specialeffect(&sd->bl, type, flag);
  5908. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5909. }
  5910. else{
  5911. pl_allsd = map_getallusers(&users);
  5912. for (i = 0; i < users; i++) {
  5913. if ((pl_sd = pl_allsd[i])) {
  5914. clif_specialeffect(&pl_sd->bl, type, flag);
  5915. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5916. }
  5917. }
  5918. }
  5919. return 0;
  5920. }
  5921. /*==========================================
  5922. * @charcartlist <character>: Displays the items list of a player's cart.
  5923. *------------------------------------------
  5924. */
  5925. int
  5926. atcommand_character_cart_list(
  5927. const int fd, struct map_session_data* sd,
  5928. const char* command, const char* message)
  5929. {
  5930. char outputtmp[200];
  5931. struct map_session_data *pl_sd;
  5932. struct item_data *item_data, *item_temp;
  5933. int i, j, count, counter, counter2;
  5934. nullpo_retr(-1, sd);
  5935. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5936. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5937. memset(outputtmp, '\0', sizeof(outputtmp));
  5938. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5939. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5940. return -1;
  5941. }
  5942. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5943. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5944. counter = 0;
  5945. count = 0;
  5946. for (i = 0; i < MAX_CART; i++) {
  5947. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5948. counter = counter + pl_sd->status.cart[i].amount;
  5949. count++;
  5950. if (count == 1) {
  5951. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  5952. clif_displaymessage(fd, atcmd_output);
  5953. }
  5954. if (pl_sd->status.cart[i].refine)
  5955. sprintf(atcmd_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);
  5956. else
  5957. sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  5958. clif_displaymessage(fd, atcmd_output);
  5959. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5960. counter2 = 0;
  5961. for (j = 0; j < item_data->slot; j++) {
  5962. if (pl_sd->status.cart[i].card[j]) {
  5963. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  5964. if (atcmd_output[0] == '\0')
  5965. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  5966. else
  5967. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  5968. strcat(atcmd_output, outputtmp);
  5969. }
  5970. }
  5971. }
  5972. if (atcmd_output[0] != '\0') {
  5973. atcmd_output[strlen(atcmd_output) - 2] = ')';
  5974. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  5975. clif_displaymessage(fd, atcmd_output);
  5976. }
  5977. }
  5978. }
  5979. if (count == 0)
  5980. clif_displaymessage(fd, "No item found in the cart of this player.");
  5981. else {
  5982. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  5983. clif_displaymessage(fd, atcmd_output);
  5984. }
  5985. } else {
  5986. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5987. return -1;
  5988. }
  5989. } else {
  5990. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5991. return -1;
  5992. }
  5993. return 0;
  5994. }
  5995. /*==========================================
  5996. * @killer by MouseJstr
  5997. * enable killing players even when not in pvp
  5998. *------------------------------------------
  5999. */
  6000. int
  6001. atcommand_killer(
  6002. const int fd, struct map_session_data* sd,
  6003. const char* command, const char* message)
  6004. {
  6005. nullpo_retr(-1, sd);
  6006. sd->special_state.killer = !sd->special_state.killer;
  6007. if(sd->special_state.killer)
  6008. clif_displaymessage(fd, msg_table[241]);
  6009. else
  6010. clif_displaymessage(fd, msg_table[242]);
  6011. return 0;
  6012. }
  6013. /*==========================================
  6014. * @killable by MouseJstr
  6015. * enable other people killing you
  6016. *------------------------------------------
  6017. */
  6018. int
  6019. atcommand_killable(
  6020. const int fd, struct map_session_data* sd,
  6021. const char* command, const char* message)
  6022. {
  6023. nullpo_retr(-1, sd);
  6024. sd->special_state.killable = !sd->special_state.killable;
  6025. if(sd->special_state.killable)
  6026. clif_displaymessage(fd, msg_table[242]);
  6027. else
  6028. clif_displaymessage(fd, msg_table[241]);
  6029. return 0;
  6030. }
  6031. /*==========================================
  6032. * @charkillable by MouseJstr
  6033. * enable another player to be killed
  6034. *------------------------------------------
  6035. */
  6036. int
  6037. atcommand_charkillable(
  6038. const int fd, struct map_session_data* sd,
  6039. const char* command, const char* message)
  6040. {
  6041. struct map_session_data *pl_sd = NULL;
  6042. nullpo_retr(-1, sd);
  6043. if (!message || !*message)
  6044. return -1;
  6045. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6046. return -1;
  6047. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6048. if(pl_sd->special_state.killable)
  6049. clif_displaymessage(fd, "The player is now killable");
  6050. else
  6051. clif_displaymessage(fd, "The player is no longer killable");
  6052. return 0;
  6053. }
  6054. /*==========================================
  6055. * @skillon by MouseJstr
  6056. * turn skills on for the map
  6057. *------------------------------------------
  6058. */
  6059. int
  6060. atcommand_skillon(
  6061. const int fd, struct map_session_data* sd,
  6062. const char* command, const char* message)
  6063. {
  6064. nullpo_retr(-1, sd);
  6065. map[sd->bl.m].flag.noskill = 0;
  6066. clif_displaymessage(fd, msg_table[244]);
  6067. return 0;
  6068. }
  6069. /*==========================================
  6070. * @skilloff by MouseJstr
  6071. * Turn skills off on the map
  6072. *------------------------------------------
  6073. */
  6074. int
  6075. atcommand_skilloff(
  6076. const int fd, struct map_session_data* sd,
  6077. const char* command, const char* message)
  6078. {
  6079. nullpo_retr(-1, sd);
  6080. map[sd->bl.m].flag.noskill = 1;
  6081. clif_displaymessage(fd, msg_table[243]);
  6082. return 0;
  6083. }
  6084. /*==========================================
  6085. * @npcmove by MouseJstr
  6086. *
  6087. * move a npc
  6088. *------------------------------------------
  6089. */
  6090. int
  6091. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6092. const char* command, const char* message)
  6093. {
  6094. int x = 0, y = 0;
  6095. struct npc_data *nd = 0;
  6096. nullpo_retr(-1, sd);
  6097. if (!message || !*message)
  6098. return -1;
  6099. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6100. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6101. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6102. return -1;
  6103. }
  6104. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6105. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6106. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6107. return -1;
  6108. npc_enable(atcmd_player_name, 0);
  6109. nd->bl.x = x;
  6110. nd->bl.y = y;
  6111. npc_enable(atcmd_player_name, 1);
  6112. return 0;
  6113. }
  6114. /*==========================================
  6115. * @addwarp by MouseJstr
  6116. *
  6117. * Create a new static warp point.
  6118. *------------------------------------------
  6119. */
  6120. int
  6121. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6122. const char* command, const char* message)
  6123. {
  6124. char w1[64], w3[64], w4[64];
  6125. int x,y,ret;
  6126. nullpo_retr(-1, sd);
  6127. if (!message || !*message)
  6128. return -1;
  6129. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6130. return -1;
  6131. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6132. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6133. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6134. ret = npc_parse_warp(w1, "warp", w3, w4);
  6135. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6136. clif_displaymessage(fd, atcmd_output);
  6137. return ret;
  6138. }
  6139. /*==========================================
  6140. * @follow by [MouseJstr]
  6141. *
  6142. * Follow a player .. staying no more then 5 spaces away
  6143. *------------------------------------------
  6144. */
  6145. int
  6146. atcommand_follow(const int fd, struct map_session_data* sd,
  6147. const char* command, const char* message)
  6148. {
  6149. struct map_session_data *pl_sd = NULL;
  6150. nullpo_retr(-1, sd);
  6151. if (!message || !*message) {
  6152. if (sd->followtarget == -1)
  6153. return -1;
  6154. pc_stop_following (sd);
  6155. clif_displaymessage(fd, "Stop following");
  6156. return 0;
  6157. }
  6158. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6159. if (sd->followtarget == pl_sd->bl.id)
  6160. pc_stop_following (sd);
  6161. else
  6162. pc_follow(sd, pl_sd->bl.id);
  6163. return 0;
  6164. }
  6165. return 1;
  6166. }
  6167. /*==========================================
  6168. * @dropall by [MouseJstr]
  6169. *
  6170. * Drop all your possession on the ground
  6171. *------------------------------------------
  6172. */
  6173. int
  6174. atcommand_dropall(const int fd, struct map_session_data* sd,
  6175. const char* command, const char* message)
  6176. {
  6177. int i;
  6178. nullpo_retr(-1, sd);
  6179. for (i = 0; i < MAX_INVENTORY; i++) {
  6180. if (sd->status.inventory[i].amount) {
  6181. if(sd->status.inventory[i].equip != 0)
  6182. pc_unequipitem(sd, i, 3);
  6183. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6184. }
  6185. }
  6186. return 0;
  6187. }
  6188. /*==========================================
  6189. * @chardropall by [MouseJstr]
  6190. *
  6191. * Throw all the characters possessions on the ground. Normally
  6192. * done in response to them being disrespectful of a GM
  6193. *------------------------------------------
  6194. */
  6195. int
  6196. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6197. const char* command, const char* message)
  6198. {
  6199. int i;
  6200. struct map_session_data *pl_sd = NULL;
  6201. nullpo_retr(-1, sd);
  6202. if (!message || !*message)
  6203. return -1;
  6204. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6205. return -1;
  6206. for (i = 0; i < MAX_INVENTORY; i++) {
  6207. if (pl_sd->status.inventory[i].amount) {
  6208. if(pl_sd->status.inventory[i].equip != 0)
  6209. pc_unequipitem(pl_sd, i, 3);
  6210. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6211. }
  6212. }
  6213. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6214. clif_displaymessage(fd, "It is done");
  6215. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6216. return 0;
  6217. }
  6218. /*==========================================
  6219. * @storeall by [MouseJstr]
  6220. *
  6221. * Put everything into storage to simplify your inventory to make
  6222. * debugging easie
  6223. *------------------------------------------
  6224. */
  6225. int
  6226. atcommand_storeall(const int fd, struct map_session_data* sd,
  6227. const char* command, const char* message)
  6228. {
  6229. int i;
  6230. nullpo_retr(-1, sd);
  6231. if (storage_storageopen(sd) == 1) {
  6232. clif_displaymessage(fd, "run this command again..");
  6233. return 0;
  6234. }
  6235. for (i = 0; i < MAX_INVENTORY; i++) {
  6236. if (sd->status.inventory[i].amount) {
  6237. if(sd->status.inventory[i].equip != 0)
  6238. pc_unequipitem(sd, i, 3);
  6239. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6240. }
  6241. }
  6242. storage_storageclose(sd);
  6243. clif_displaymessage(fd, "It is done");
  6244. return 0;
  6245. }
  6246. /*==========================================
  6247. * @charstoreall by [MouseJstr]
  6248. *
  6249. * A way to screw with players who piss you off
  6250. *------------------------------------------
  6251. */
  6252. int
  6253. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6254. const char* command, const char* message)
  6255. {
  6256. int i;
  6257. struct map_session_data *pl_sd = NULL;
  6258. nullpo_retr(-1, sd);
  6259. if (!message || !*message)
  6260. return -1;
  6261. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6262. return -1;
  6263. if (storage_storageopen(pl_sd) == 1) {
  6264. clif_displaymessage(fd, "Had to open the characters storage window...");
  6265. clif_displaymessage(fd, "run this command again..");
  6266. return 0;
  6267. }
  6268. for (i = 0; i < MAX_INVENTORY; i++) {
  6269. if (pl_sd->status.inventory[i].amount) {
  6270. if(pl_sd->status.inventory[i].equip != 0)
  6271. pc_unequipitem(pl_sd, i, 3);
  6272. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6273. }
  6274. }
  6275. storage_storageclose(pl_sd);
  6276. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6277. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6278. clif_displaymessage(pl_sd->fd, " -- the management");
  6279. clif_displaymessage(fd, "It is done");
  6280. return 0;
  6281. }
  6282. /*==========================================
  6283. * @skillid by [MouseJstr]
  6284. *
  6285. * lookup a skill by name
  6286. *------------------------------------------
  6287. */
  6288. int
  6289. atcommand_skillid(const int fd, struct map_session_data* sd,
  6290. const char* command, const char* message)
  6291. {
  6292. int skillen, idx;
  6293. nullpo_retr(-1, sd);
  6294. if (!message || !*message)
  6295. return -1;
  6296. skillen = strlen(message);
  6297. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6298. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6299. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6300. {
  6301. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6302. clif_displaymessage(fd, atcmd_output);
  6303. }
  6304. }
  6305. return 0;
  6306. }
  6307. /*==========================================
  6308. * @useskill by [MouseJstr]
  6309. *
  6310. * A way of using skills without having to find them in the skills menu
  6311. *------------------------------------------
  6312. */
  6313. int
  6314. atcommand_useskill(const int fd, struct map_session_data* sd,
  6315. const char* command, const char* message)
  6316. {
  6317. struct map_session_data *pl_sd = NULL;
  6318. int skillnum;
  6319. int skilllv;
  6320. char target[255];
  6321. nullpo_retr(-1, sd);
  6322. if (!message || !*message)
  6323. return -1;
  6324. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6325. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6326. return -1;
  6327. }
  6328. if((pl_sd=map_nick2sd(target)) == NULL) {
  6329. return -1;
  6330. }
  6331. if (skill_get_inf(skillnum) & INF_GROUND_SKILL)
  6332. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6333. else
  6334. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6335. return 0;
  6336. }
  6337. /*==========================================
  6338. * @skilltree by [MouseJstr]
  6339. *
  6340. * prints the skill tree for a player required to get to a skill
  6341. *------------------------------------------
  6342. */
  6343. int
  6344. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6345. const char* command, const char* message)
  6346. {
  6347. struct map_session_data *pl_sd = NULL;
  6348. int skillnum, skillidx = -1;
  6349. int meets = 1, j, c=0;
  6350. char target[NAME_LENGTH], *tbl;
  6351. struct skill_tree_entry *ent;
  6352. nullpo_retr(-1, sd);
  6353. if (!message || !*message)
  6354. return -1;
  6355. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6356. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6357. return -1;
  6358. }
  6359. if((pl_sd=map_nick2sd(target)) == NULL)
  6360. return -1;
  6361. c = pc_calc_skilltree_normalize_job(pl_sd);
  6362. tbl = job_name(c);
  6363. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6364. tbl, pc_checkskill(pl_sd, 1));
  6365. clif_displaymessage(fd, atcmd_output);
  6366. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6367. if (skill_tree[c][j].id == skillnum) {
  6368. skillidx = j;
  6369. break;
  6370. }
  6371. }
  6372. if (skillidx == -1) {
  6373. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6374. clif_displaymessage(fd, atcmd_output);
  6375. return 0;
  6376. }
  6377. ent = &skill_tree[c][skillidx];
  6378. for(j=0;j<5;j++)
  6379. if( ent->need[j].id &&
  6380. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6381. {
  6382. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6383. sprintf(atcmd_output, "player requires level %d of skill %s",
  6384. ent->need[j].lv, desc);
  6385. clif_displaymessage(fd, atcmd_output);
  6386. meets = 0;
  6387. }
  6388. if (meets == 1) {
  6389. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6390. clif_displaymessage(fd, atcmd_output);
  6391. }
  6392. return 0;
  6393. }
  6394. // Hand a ring with partners name on it to this char
  6395. void getring (struct map_session_data *sd)
  6396. {
  6397. int flag,item_id = 0;
  6398. struct item item_tmp;
  6399. if(sd->status.sex==0)
  6400. item_id = 2635;
  6401. else
  6402. item_id = 2634;
  6403. memset(&item_tmp,0,sizeof(item_tmp));
  6404. item_tmp.nameid=item_id;
  6405. item_tmp.identify=1;
  6406. item_tmp.card[0]=255;
  6407. item_tmp.card[2]=sd->status.partner_id;
  6408. item_tmp.card[3]=sd->status.partner_id >> 16;
  6409. //Logs (A)dmins items [Lupus]
  6410. if(log_config.pick > 0 ) {
  6411. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6412. }
  6413. //Logs
  6414. if((flag = pc_additem(sd,&item_tmp,1))) {
  6415. clif_additem(sd,0,0,flag);
  6416. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6417. }
  6418. }
  6419. /*==========================================
  6420. * @marry by [MouseJstr], fixed by Lupus
  6421. *
  6422. * Marry two players
  6423. *------------------------------------------
  6424. */
  6425. int
  6426. atcommand_marry(const int fd, struct map_session_data* sd,
  6427. const char* command, const char* message)
  6428. {
  6429. struct map_session_data *pl_sd1 = NULL;
  6430. struct map_session_data *pl_sd2 = NULL;
  6431. char player1[128], player2[128]; //Length used for return error msgs
  6432. nullpo_retr(-1, sd);
  6433. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6434. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6435. return -1;
  6436. }
  6437. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6438. sprintf(player2, "Cannot find player '%s' online", player1);
  6439. clif_displaymessage(fd, player2);
  6440. return -1;
  6441. }
  6442. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6443. sprintf(player1, "Cannot find player '%s' online", player2);
  6444. clif_displaymessage(fd, player1);
  6445. return -1;
  6446. }
  6447. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6448. clif_displaymessage(fd, "They are married.. wish them well");
  6449. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6450. // Auto-give named rings (Aru)
  6451. getring (pl_sd1);
  6452. getring (pl_sd2);
  6453. return 0;
  6454. }
  6455. return -1;
  6456. }
  6457. /*==========================================
  6458. * @divorce by [MouseJstr], fixed by [Lupus]
  6459. *
  6460. * divorce two players
  6461. *------------------------------------------
  6462. */
  6463. int
  6464. atcommand_divorce(const int fd, struct map_session_data* sd,
  6465. const char* command, const char* message)
  6466. {
  6467. struct map_session_data *pl_sd = NULL;
  6468. nullpo_retr(-1, sd);
  6469. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6470. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6471. return -1;
  6472. }
  6473. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6474. if (pc_divorce(pl_sd) != 0) {
  6475. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6476. clif_displaymessage(fd, atcmd_output);
  6477. return -1;
  6478. } else {
  6479. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6480. clif_displaymessage(fd, atcmd_output);
  6481. return 0;
  6482. }
  6483. }
  6484. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6485. clif_displaymessage(fd, atcmd_output);
  6486. return -1;
  6487. }
  6488. #ifdef DMALLOC
  6489. unsigned long dmark_;
  6490. int
  6491. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6492. const char* command, const char* message)
  6493. {
  6494. dmark_ = dmalloc_mark();
  6495. clif_displaymessage(fd, "debug mark set");
  6496. return 0;
  6497. }
  6498. int
  6499. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6500. const char* command, const char* message)
  6501. {
  6502. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6503. dmark_ = dmalloc_mark();
  6504. clif_displaymessage(fd, "malloc changes logged");
  6505. return 0;
  6506. }
  6507. #endif
  6508. /*==========================================
  6509. * @grind by [MouseJstr]
  6510. *------------------------------------------
  6511. */
  6512. int
  6513. atcommand_grind(const int fd, struct map_session_data* sd,
  6514. const char* command, const char* message)
  6515. {
  6516. struct map_session_data *pl_sd = NULL;
  6517. int skillnum;
  6518. int inf;
  6519. char target[NAME_LENGTH];
  6520. nullpo_retr(-1, sd);
  6521. if (!message || !*message)
  6522. return -1;
  6523. if(sscanf(message, "%23s", target) != 1) {
  6524. clif_displaymessage(fd, "Usage: @grind <target>");
  6525. return -1;
  6526. }
  6527. if((pl_sd=map_nick2sd(target)) == NULL)
  6528. return -1;
  6529. for (skillnum = 1; skillnum < 500; skillnum++) {
  6530. sd->status.sp = sd->status.max_sp;
  6531. atcommand_alive(fd, sd, command, message);
  6532. inf = skill_get_inf(skillnum);
  6533. if (inf & INF_GROUND_SKILL)
  6534. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6535. else if (!(inf & INF_SUPPORT_SKILL))
  6536. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6537. }
  6538. return 0;
  6539. }
  6540. /*==========================================
  6541. * @grind2 by [MouseJstr]
  6542. *------------------------------------------
  6543. */
  6544. int
  6545. atcommand_grind2(const int fd, struct map_session_data* sd,
  6546. const char* command, const char* message)
  6547. {
  6548. int i, x, y, id;
  6549. for (i = 1000; i <2000; i++) {
  6550. x = sd->bl.x + (rand() % 10 - 5);
  6551. y = sd->bl.y + (rand() % 10 - 5);
  6552. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6553. }
  6554. return 0;
  6555. }
  6556. /*==========================================
  6557. * @changelook by [Celest]
  6558. *------------------------------------------
  6559. */
  6560. int
  6561. atcommand_changelook(const int fd, struct map_session_data* sd,
  6562. const char* command, const char* message)
  6563. {
  6564. int i, j = 0, k = 0;
  6565. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6566. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6567. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6568. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6569. return -1;
  6570. } else if (i == 2) {
  6571. if (j < 1) j = 1;
  6572. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6573. j = pos[j - 1];
  6574. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6575. k = j; // swap
  6576. j = LOOK_HEAD_TOP;
  6577. }
  6578. clif_changelook(&sd->bl,j,k);
  6579. return 0;
  6580. }
  6581. /*==========================================
  6582. *Turns on/off Autotrade for a specific player
  6583. *------------------------------------------
  6584. *by durf (changed by Lupus)
  6585. */
  6586. int
  6587. atcommand_autotrade(
  6588. const int fd, struct map_session_data* sd,
  6589. const char* command, const char* message)
  6590. {
  6591. nullpo_retr(-1, sd);
  6592. if (sd->vender_id) //check if player's vending
  6593. {
  6594. sd->state.autotrade = 1;
  6595. clif_authfail_fd(fd, 15);
  6596. }
  6597. else
  6598. {
  6599. //"You should be vending to use @Autotrade."
  6600. clif_displaymessage(fd, msg_txt(549));
  6601. }
  6602. return 0;
  6603. }
  6604. /*==========================================
  6605. * Changes Master of your Guild to a specified guild member
  6606. *------------------------------------------
  6607. *by durf (changed by Lupus)
  6608. */
  6609. int
  6610. atcommand_changegm(
  6611. const int fd, struct map_session_data* sd,
  6612. const char* command, const char* message)
  6613. {
  6614. struct guild *g;
  6615. struct map_session_data *pl_sd;
  6616. nullpo_retr(-1, sd);
  6617. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6618. {
  6619. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6620. return -1;
  6621. }
  6622. if (strlen(message)==0)
  6623. {
  6624. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6625. return -1;
  6626. }
  6627. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6628. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6629. return -1;
  6630. }
  6631. guild_gm_change(sd->status.guild_id, pl_sd);
  6632. return 0;
  6633. }
  6634. /*==========================================
  6635. *Changes the leader of a party.
  6636. *------------------------------------------
  6637. *by Skotlex
  6638. */
  6639. int
  6640. atcommand_changeleader(
  6641. const int fd, struct map_session_data* sd,
  6642. const char* command, const char* message)
  6643. {
  6644. struct party *p;
  6645. struct map_session_data *pl_sd;
  6646. int mi, pl_mi;
  6647. nullpo_retr(-1, sd);
  6648. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6649. {
  6650. clif_displaymessage(fd, "You need to be a party's leader to use this command.");
  6651. return -1;
  6652. }
  6653. for (mi = 0; mi < MAX_PARTY && p->member[mi].sd != sd; mi++);
  6654. if (mi == MAX_PARTY)
  6655. return -1; //Shouldn't happen
  6656. if (!p->member[mi].leader)
  6657. {
  6658. clif_displaymessage(fd, "You need to be the party's leader to use this command.");
  6659. return -1;
  6660. }
  6661. if (strlen(message)==0)
  6662. {
  6663. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6664. return -1;
  6665. }
  6666. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6667. clif_displaymessage(fd, "Target character must be online and be in your party.");
  6668. return -1;
  6669. }
  6670. for (pl_mi = 0; pl_mi < MAX_PARTY && p->member[pl_mi].sd != pl_sd; pl_mi++);
  6671. if (pl_mi == MAX_PARTY)
  6672. return -1; //Shouldn't happen
  6673. //Change leadership.
  6674. p->member[mi].leader = 0;
  6675. if (p->member[mi].sd->fd)
  6676. clif_displaymessage(p->member[mi].sd->fd, "Leadership transferred.");
  6677. p->member[pl_mi].leader = 1;
  6678. if (p->member[pl_mi].sd->fd)
  6679. clif_displaymessage(p->member[pl_mi].sd->fd, "You've become the party leader.");
  6680. intif_party_leaderchange(p->party_id,p->member[pl_mi].account_id,p->member[pl_mi].char_id);
  6681. //Update info.
  6682. clif_party_main_info(p,-1);
  6683. clif_party_info(p,-1);
  6684. return 0;
  6685. }
  6686. /*==========================================
  6687. *Turns on/off AutoLoot for a specific player
  6688. *------------------------------------------
  6689. *by Upa-Kun
  6690. */
  6691. int
  6692. atcommand_autoloot(
  6693. const int fd, struct map_session_data* sd,
  6694. const char* command, const char* message)
  6695. {
  6696. int rate;
  6697. double drate;
  6698. nullpo_retr(-1, sd);
  6699. if (!message || !*message) {
  6700. if (sd->state.autoloot)
  6701. rate = 0;
  6702. else
  6703. rate = 10000;
  6704. } else {
  6705. drate = atof(message);
  6706. rate = (int)(drate*100);
  6707. }
  6708. if (rate > 10000) rate = 10000;
  6709. else if (rate < 0) rate = 0;
  6710. sd->state.autoloot = rate;
  6711. if (sd->state.autoloot) {
  6712. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6713. clif_displaymessage(fd, atcmd_output);
  6714. }else
  6715. clif_displaymessage(fd, "Autoloot is now off.");
  6716. return 0;
  6717. }
  6718. /*==========================================
  6719. * It is made to rain.
  6720. *------------------------------------------
  6721. */
  6722. int
  6723. atcommand_rain(
  6724. const int fd, struct map_session_data* sd,
  6725. const char* command, const char* message)
  6726. {
  6727. nullpo_retr(-1, sd);
  6728. if (map[sd->bl.m].flag.rain) {
  6729. map[sd->bl.m].flag.rain=0;
  6730. clif_weather(sd->bl.m);
  6731. clif_displaymessage(fd, "The rain has stopped.");
  6732. } else {
  6733. map[sd->bl.m].flag.rain=1;
  6734. clif_weather(sd->bl.m);
  6735. clif_displaymessage(fd, "It is made to rain.");
  6736. }
  6737. return 0;
  6738. }
  6739. /*==========================================
  6740. * It is made to snow.
  6741. *------------------------------------------
  6742. */
  6743. int
  6744. atcommand_snow(
  6745. const int fd, struct map_session_data* sd,
  6746. const char* command, const char* message)
  6747. {
  6748. nullpo_retr(-1, sd);
  6749. if (map[sd->bl.m].flag.snow) {
  6750. map[sd->bl.m].flag.snow=0;
  6751. clif_weather(sd->bl.m);
  6752. clif_displaymessage(fd, "Snow has stopped falling.");
  6753. } else {
  6754. map[sd->bl.m].flag.snow=1;
  6755. clif_weather(sd->bl.m);
  6756. clif_displaymessage(fd, "It is made to snow.");
  6757. }
  6758. return 0;
  6759. }
  6760. /*==========================================
  6761. * Cherry tree snowstorm is made to fall. (Sakura)
  6762. *------------------------------------------
  6763. */
  6764. int
  6765. atcommand_sakura(
  6766. const int fd, struct map_session_data* sd,
  6767. const char* command, const char* message)
  6768. {
  6769. nullpo_retr(-1, sd);
  6770. if (map[sd->bl.m].flag.sakura) {
  6771. map[sd->bl.m].flag.sakura=0;
  6772. clif_weather(sd->bl.m);
  6773. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6774. } else {
  6775. map[sd->bl.m].flag.sakura=1;
  6776. clif_weather(sd->bl.m);
  6777. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6778. }
  6779. return 0;
  6780. }
  6781. /*==========================================
  6782. * Clouds appear.
  6783. *------------------------------------------
  6784. */
  6785. int
  6786. atcommand_clouds(
  6787. const int fd, struct map_session_data* sd,
  6788. const char* command, const char* message)
  6789. {
  6790. nullpo_retr(-1, sd);
  6791. if (map[sd->bl.m].flag.clouds) {
  6792. map[sd->bl.m].flag.clouds=0;
  6793. clif_weather(sd->bl.m);
  6794. clif_displaymessage(fd, "The clouds has disappear.");
  6795. } else {
  6796. map[sd->bl.m].flag.clouds=1;
  6797. clif_weather(sd->bl.m);
  6798. clif_displaymessage(fd, "Clouds appear.");
  6799. }
  6800. return 0;
  6801. }
  6802. /*==========================================
  6803. * Different type of clouds using effect 516
  6804. *------------------------------------------
  6805. */
  6806. int
  6807. atcommand_clouds2(
  6808. const int fd, struct map_session_data* sd,
  6809. const char* command, const char* message)
  6810. {
  6811. nullpo_retr(-1, sd);
  6812. if (map[sd->bl.m].flag.clouds2) {
  6813. map[sd->bl.m].flag.clouds2=0;
  6814. clif_weather(sd->bl.m);
  6815. clif_displaymessage(fd, "The alternative clouds disappear.");
  6816. } else {
  6817. map[sd->bl.m].flag.clouds2=1;
  6818. clif_weather(sd->bl.m);
  6819. clif_displaymessage(fd, "Alternative clouds appear.");
  6820. }
  6821. return 0;
  6822. }
  6823. /*==========================================
  6824. * Fog hangs over.
  6825. *------------------------------------------
  6826. */
  6827. int
  6828. atcommand_fog(
  6829. const int fd, struct map_session_data* sd,
  6830. const char* command, const char* message)
  6831. {
  6832. nullpo_retr(-1, sd);
  6833. if (map[sd->bl.m].flag.fog) {
  6834. map[sd->bl.m].flag.fog=0;
  6835. clif_weather(sd->bl.m);
  6836. clif_displaymessage(fd, "The fog has gone.");
  6837. } else {
  6838. map[sd->bl.m].flag.fog=1;
  6839. clif_weather(sd->bl.m);
  6840. clif_displaymessage(fd, "Fog hangs over.");
  6841. }
  6842. return 0;
  6843. }
  6844. /*==========================================
  6845. * Fallen leaves fall.
  6846. *------------------------------------------
  6847. */
  6848. int
  6849. atcommand_leaves(
  6850. const int fd, struct map_session_data* sd,
  6851. const char* command, const char* message)
  6852. {
  6853. nullpo_retr(-1, sd);
  6854. if (map[sd->bl.m].flag.leaves) {
  6855. map[sd->bl.m].flag.leaves=0;
  6856. clif_weather(sd->bl.m);
  6857. clif_displaymessage(fd, "Leaves no longer fall.");
  6858. } else {
  6859. map[sd->bl.m].flag.leaves=1;
  6860. clif_weather(sd->bl.m);
  6861. clif_displaymessage(fd, "Fallen leaves fall.");
  6862. }
  6863. return 0;
  6864. }
  6865. /*==========================================
  6866. * Fireworks appear.
  6867. *------------------------------------------
  6868. */
  6869. int
  6870. atcommand_fireworks(
  6871. const int fd, struct map_session_data* sd,
  6872. const char* command, const char* message)
  6873. {
  6874. nullpo_retr(-1, sd);
  6875. if (map[sd->bl.m].flag.fireworks) {
  6876. map[sd->bl.m].flag.fireworks=0;
  6877. clif_weather(sd->bl.m);
  6878. clif_displaymessage(fd, "Fireworks are ended.");
  6879. } else {
  6880. map[sd->bl.m].flag.fireworks=1;
  6881. clif_weather(sd->bl.m);
  6882. clif_displaymessage(fd, "Fireworks are launched.");
  6883. }
  6884. return 0;
  6885. }
  6886. /*==========================================
  6887. * Clearing Weather Effects by Dexity
  6888. *------------------------------------------
  6889. */
  6890. int
  6891. atcommand_clearweather(
  6892. const int fd, struct map_session_data* sd,
  6893. const char* command, const char* message)
  6894. {
  6895. nullpo_retr(-1, sd);
  6896. map[sd->bl.m].flag.rain=0;
  6897. map[sd->bl.m].flag.snow=0;
  6898. map[sd->bl.m].flag.sakura=0;
  6899. map[sd->bl.m].flag.clouds=0;
  6900. map[sd->bl.m].flag.clouds2=0;
  6901. map[sd->bl.m].flag.fog=0;
  6902. map[sd->bl.m].flag.fireworks=0;
  6903. map[sd->bl.m].flag.leaves=0;
  6904. clif_weather(sd->bl.m);
  6905. return 0;
  6906. }
  6907. /*===============================================================
  6908. * Sound Command - plays a sound for everyone! [Codemaster]
  6909. *---------------------------------------------------------------
  6910. */
  6911. int
  6912. atcommand_sound(
  6913. const int fd, struct map_session_data *sd,
  6914. const char *command, const char *message)
  6915. {
  6916. char sound_file[100];
  6917. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6918. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6919. return -1;
  6920. }
  6921. memset(sound_file, '\0', sizeof(sound_file));
  6922. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6923. return -1;
  6924. if(strstr(sound_file, ".wav") == NULL)
  6925. strcat(sound_file, ".wav");
  6926. clif_soundeffectall(&sd->bl, sound_file,0);
  6927. return 0;
  6928. }
  6929. /*==========================================
  6930. * MOB Search
  6931. *------------------------------------------
  6932. */
  6933. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  6934. {
  6935. int mob_id,fd;
  6936. static int number=0;
  6937. struct mob_data *md;
  6938. nullpo_retr(0, bl);
  6939. if(!ap){
  6940. number=0;
  6941. return 0;
  6942. }
  6943. mob_id = va_arg(ap,int);
  6944. fd = va_arg(ap,int);
  6945. md = (struct mob_data *)bl;
  6946. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  6947. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  6948. ++number,bl->x, bl->y,md->name);
  6949. clif_displaymessage(fd, atcmd_output);
  6950. }
  6951. return 0;
  6952. }
  6953. int atcommand_mobsearch(
  6954. const int fd, struct map_session_data* sd,
  6955. const char* command, const char* message)
  6956. {
  6957. char mob_name[100];
  6958. int mob_id,map_id = 0;
  6959. nullpo_retr(-1, sd);
  6960. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6961. return -1;
  6962. if ((mob_id = atoi(mob_name)) == 0)
  6963. mob_id = mobdb_searchname(mob_name);
  6964. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6965. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6966. clif_displaymessage(fd, atcmd_output);
  6967. return 0;
  6968. }
  6969. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6970. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6971. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6972. map_id = sd->bl.m;
  6973. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6974. mob_name, mapindex_id2name(sd->mapindex));
  6975. clif_displaymessage(fd, atcmd_output);
  6976. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  6977. atmobsearch_sub(&sd->bl,0); // 番号リセット
  6978. return 0;
  6979. }
  6980. /*==========================================
  6981. * ドロップアイテムの掃除
  6982. *------------------------------------------
  6983. */
  6984. /*==========================================
  6985. * cleanmap
  6986. *------------------------------------------
  6987. */
  6988. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  6989. {
  6990. nullpo_retr(0, bl);
  6991. map_clearflooritem(bl->id);
  6992. return 0;
  6993. }
  6994. int
  6995. atcommand_cleanmap(
  6996. const int fd, struct map_session_data* sd,
  6997. const char* command, const char* message)
  6998. {
  6999. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7000. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7001. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7002. BL_ITEM);
  7003. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7004. return 0;
  7005. }
  7006. /*==========================================
  7007. * NPC/PETに話させる
  7008. *------------------------------------------
  7009. */
  7010. int
  7011. atcommand_npctalk(
  7012. const int fd, struct map_session_data* sd,
  7013. const char* command, const char* message)
  7014. {
  7015. char name[NAME_LENGTH],mes[100],temp[100];
  7016. struct npc_data *nd;
  7017. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7018. return -1;
  7019. if (!(nd = npc_name2id(name)))
  7020. return -1;
  7021. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7022. clif_message(&nd->bl, temp);
  7023. return 0;
  7024. }
  7025. int
  7026. atcommand_pettalk(
  7027. const int fd, struct map_session_data* sd,
  7028. const char* command, const char* message)
  7029. {
  7030. char mes[100],temp[100];
  7031. struct pet_data *pd;
  7032. nullpo_retr(-1, sd);
  7033. if(!sd->status.pet_id || !(pd=sd->pd))
  7034. return -1;
  7035. if (sscanf(message, "%99[^\n]", mes) < 1)
  7036. return -1;
  7037. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  7038. clif_message(&pd->bl, temp);
  7039. return 0;
  7040. }
  7041. /*==========================================
  7042. * @users
  7043. * サーバー内の人数マップを表示させる
  7044. * 手抜きのため汚くなっているのは仕様です。
  7045. *------------------------------------------
  7046. */
  7047. static struct dbt *users_db = NULL;
  7048. static int users_all;
  7049. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7050. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7051. users_all++;
  7052. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7053. return 0;
  7054. }
  7055. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7056. char buf[256];
  7057. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7058. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7059. clif_displaymessage(sd->fd,buf);
  7060. return 0;
  7061. }
  7062. int
  7063. atcommand_users(
  7064. const int fd, struct map_session_data* sd,
  7065. const char* command, const char* message)
  7066. {
  7067. char buf[256];
  7068. users_all = 0;
  7069. users_db->clear(users_db, NULL);
  7070. clif_foreachclient(atcommand_users_sub1);
  7071. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7072. sprintf(buf,"all : %d",users_all);
  7073. clif_displaymessage(fd,buf);
  7074. return 0;
  7075. }
  7076. /*==========================================
  7077. *
  7078. *------------------------------------------
  7079. */
  7080. int
  7081. atcommand_summon(
  7082. const int fd, struct map_session_data* sd,
  7083. const char* command, const char* message)
  7084. {
  7085. char name[NAME_LENGTH];
  7086. int mob_id = 0;
  7087. int x = 0;
  7088. int y = 0;
  7089. int id = 0;
  7090. int duration = 0;
  7091. struct mob_data *md;
  7092. unsigned int tick=gettick();
  7093. nullpo_retr(-1, sd);
  7094. if (!message || !*message)
  7095. return -1;
  7096. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7097. return -1;
  7098. if (duration < 1)
  7099. duration =1;
  7100. else if (duration > 60)
  7101. duration =60;
  7102. if ((mob_id = atoi(name)) == 0)
  7103. mob_id = mobdb_searchname(name);
  7104. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7105. return -1;
  7106. x = sd->bl.x + (rand() % 10 - 5);
  7107. y = sd->bl.y + (rand() % 10 - 5);
  7108. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  7109. if((md=(struct mob_data *)map_id2bl(id))){
  7110. md->master_id=sd->bl.id;
  7111. md->special_state.ai=1;
  7112. md->mode=md->db->mode|MD_AGGRESSIVE;
  7113. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7114. clif_misceffect2(&md->bl,344);
  7115. }
  7116. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  7117. return 0;
  7118. }
  7119. /*==========================================
  7120. * @adjcmdlvl by [MouseJstr]
  7121. *
  7122. * Temp adjust the GM level required to use a GM command
  7123. *
  7124. * Used during beta testing to allow players to use GM commands
  7125. * for short periods of time
  7126. *------------------------------------------
  7127. */
  7128. int
  7129. atcommand_adjcmdlvl(
  7130. const int fd, struct map_session_data* sd,
  7131. const char* command, const char* message)
  7132. {
  7133. int i, newlev;
  7134. char cmd[100];
  7135. nullpo_retr(-1, sd);
  7136. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7137. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7138. return -1;
  7139. }
  7140. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7141. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7142. atcommand_info[i].level = newlev;
  7143. clif_displaymessage(fd, "@command level changed.");
  7144. return 0;
  7145. }
  7146. clif_displaymessage(fd, "@command not found.");
  7147. return -1;
  7148. }
  7149. /*==========================================
  7150. * @adjgmlvl by [MouseJstr]
  7151. *
  7152. * Create a temp GM
  7153. *
  7154. * Used during beta testing to allow players to use GM commands
  7155. * for short periods of time
  7156. *------------------------------------------
  7157. */
  7158. int
  7159. atcommand_adjgmlvl(
  7160. const int fd, struct map_session_data* sd,
  7161. const char* command, const char* message)
  7162. {
  7163. int newlev;
  7164. char user[NAME_LENGTH];
  7165. struct map_session_data *pl_sd;
  7166. nullpo_retr(-1, sd);
  7167. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7168. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7169. return -1;
  7170. }
  7171. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7172. return -1;
  7173. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7174. return 0;
  7175. }
  7176. /*==========================================
  7177. * @trade by [MouseJstr]
  7178. *
  7179. * Open a trade window with a remote player
  7180. *
  7181. * If I have to jump to a remote player one more time, I am
  7182. * gonna scream!
  7183. *------------------------------------------
  7184. */
  7185. int
  7186. atcommand_trade(
  7187. const int fd, struct map_session_data* sd,
  7188. const char* command, const char* message)
  7189. {
  7190. struct map_session_data *pl_sd = NULL;
  7191. nullpo_retr(-1, sd);
  7192. if (!message || !*message)
  7193. return -1;
  7194. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7195. trade_traderequest(sd, pl_sd->bl.id);
  7196. return 0;
  7197. }
  7198. return -1;
  7199. }
  7200. /*==========================================
  7201. * @setbattleflag by [MouseJstr]
  7202. *
  7203. * set a battle_config flag without having to reboot
  7204. */
  7205. int
  7206. atcommand_setbattleflag(
  7207. const int fd, struct map_session_data* sd,
  7208. const char* command, const char* message)
  7209. {
  7210. char flag[128], value[128];
  7211. nullpo_retr(-1, sd);
  7212. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7213. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7214. return -1;
  7215. }
  7216. if (battle_set_value(flag, value) == 0)
  7217. clif_displaymessage(fd, "unknown battle_config flag");
  7218. else
  7219. clif_displaymessage(fd, "battle_config set as requested");
  7220. return 0;
  7221. }
  7222. /*===========================
  7223. * @unmute [Valaris]
  7224. *===========================
  7225. */
  7226. int atcommand_unmute(
  7227. const int fd, struct map_session_data* sd,
  7228. const char* command, const char* message)
  7229. {
  7230. struct map_session_data *pl_sd = NULL;
  7231. nullpo_retr(-1, sd);
  7232. if(!battle_config.muting_players) {
  7233. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7234. return 0;
  7235. }
  7236. if (!message || !*message)
  7237. return -1;
  7238. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7239. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7240. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7241. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7242. clif_displaymessage(sd->fd,"Player unmuted");
  7243. }
  7244. else
  7245. clif_displaymessage(sd->fd,"Player is not muted");
  7246. }
  7247. return 0;
  7248. }
  7249. /*==========================================
  7250. * @uptime by MC Cameri
  7251. *------------------------------------------
  7252. */
  7253. int
  7254. atcommand_uptime(
  7255. const int fd, struct map_session_data* sd,
  7256. const char* command, const char* message)
  7257. {
  7258. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7259. minute = 60, days = 0, hours = 0, minutes = 0;
  7260. nullpo_retr(-1, sd);
  7261. seconds = get_uptime();
  7262. days = seconds/day;
  7263. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7264. hours = seconds/hour;
  7265. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7266. minutes = seconds/minute;
  7267. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7268. snprintf(atcmd_output, sizeof(atcmd_output), msg_table[245], days, hours, minutes, seconds);
  7269. clif_displaymessage(fd, atcmd_output);
  7270. return 0;
  7271. }
  7272. /*==========================================
  7273. * @changesex <sex>
  7274. * => Changes one's sex. Argument sex can be
  7275. * 0 or 1, m or f, male or female.
  7276. *------------------------------------------
  7277. */
  7278. int
  7279. atcommand_changesex(
  7280. const int fd, struct map_session_data* sd,
  7281. const char* command, const char* message)
  7282. {
  7283. nullpo_retr(-1, sd);
  7284. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7285. return 0;
  7286. }
  7287. /*================================================
  7288. * @mute - Mutes a player for a set amount of time
  7289. *------------------------------------------------
  7290. */
  7291. int atcommand_mute(
  7292. const int fd, struct map_session_data* sd,
  7293. const char* command, const char* message)
  7294. {
  7295. struct map_session_data *pl_sd = NULL;
  7296. int manner;
  7297. nullpo_retr(-1, sd);
  7298. if(!battle_config.muting_players) {
  7299. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7300. return 0;
  7301. }
  7302. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7303. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7304. return -1;
  7305. }
  7306. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7307. clif_GM_silence(sd, pl_sd, 0);
  7308. pl_sd->status.manner -= manner;
  7309. if(pl_sd->status.manner < 0)
  7310. status_change_start(&pl_sd->bl,SC_NOCHAT,100,0,0,0,0,0,0);
  7311. }
  7312. else {
  7313. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7314. return -1;
  7315. }
  7316. return 0;
  7317. }
  7318. /*==========================================
  7319. * @refresh (like @jumpto <<yourself>>)
  7320. *------------------------------------------
  7321. */
  7322. int atcommand_refresh(
  7323. const int fd, struct map_session_data* sd,
  7324. const char* command, const char* message)
  7325. {
  7326. nullpo_retr(-1, sd);
  7327. clif_refresh(sd);
  7328. return 0;
  7329. }
  7330. /*==========================================
  7331. * @petid <part of pet name>
  7332. * => Displays a list of matching pets.
  7333. *------------------------------------------
  7334. */
  7335. int
  7336. atcommand_petid(const int fd, struct map_session_data* sd,
  7337. const char* command, const char* message)
  7338. {
  7339. char searchtext[100];
  7340. char temp0[100];
  7341. char temp1[100];
  7342. int cnt = 0, i = 0;
  7343. nullpo_retr(-1, sd);
  7344. if (!message || !*message)
  7345. return -1;
  7346. if (sscanf(message, "%99s", searchtext) < 1)
  7347. return -1;
  7348. estr_lower(searchtext);
  7349. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7350. clif_displaymessage(fd,temp0);
  7351. while (i < MAX_PET_DB) {
  7352. strcpy(temp1,pet_db[i].name);
  7353. strcpy(temp1, estr_lower(temp1));
  7354. strcpy(temp0,pet_db[i].jname);
  7355. strcpy(temp0, estr_lower(temp1));
  7356. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7357. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7358. pet_db[i].jname);
  7359. if (cnt >= 100) { // Only if there are custom pets
  7360. clif_displaymessage(fd, "Be more specific, can't send more than"
  7361. " 100 results.");
  7362. } else {
  7363. clif_displaymessage(fd, temp0);
  7364. }
  7365. cnt++;
  7366. }
  7367. i++;
  7368. }
  7369. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7370. clif_displaymessage(fd, temp0);
  7371. return 0;
  7372. }
  7373. /*==========================================
  7374. * @identify
  7375. * => GM's magnifier.
  7376. *------------------------------------------
  7377. */
  7378. int
  7379. atcommand_identify(
  7380. const int fd, struct map_session_data* sd,
  7381. const char* command, const char* message)
  7382. {
  7383. int i,num;
  7384. nullpo_retr(-1, sd);
  7385. for(i=num=0;i<MAX_INVENTORY;i++){
  7386. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7387. num++;
  7388. }
  7389. }
  7390. if (num > 0) {
  7391. clif_item_identify_list(sd);
  7392. } else {
  7393. clif_displaymessage(fd,"There are no items to appraise.");
  7394. }
  7395. return 0;
  7396. }
  7397. /*==========================================
  7398. * @gmotd (Global MOTD)
  7399. * by davidsiaw :P
  7400. *------------------------------------------
  7401. */
  7402. int
  7403. atcommand_gmotd(
  7404. const int fd, struct map_session_data* sd,
  7405. const char* command, const char* message)
  7406. {
  7407. char buf[256];
  7408. FILE *fp;
  7409. nullpo_retr(-1, sd);
  7410. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7411. while (fgets(buf, 250, fp) != NULL){
  7412. int i;
  7413. for( i=0; buf[i]; i++){
  7414. if( buf[i]=='\r' || buf[i]=='\n'){
  7415. buf[i]=0;
  7416. break;
  7417. }
  7418. }
  7419. intif_GMmessage(buf,strlen(buf)+1,8);
  7420. }
  7421. fclose(fp);
  7422. }
  7423. return 0;
  7424. }
  7425. int atcommand_misceffect(
  7426. const int fd, struct map_session_data* sd,
  7427. const char* command, const char* message)
  7428. {
  7429. int effect = 0;
  7430. nullpo_retr(-1, sd);
  7431. if (!message || !*message)
  7432. return -1;
  7433. if (sscanf(message, "%d", &effect) < 1)
  7434. return -1;
  7435. clif_misceffect(&sd->bl,effect);
  7436. return 0;
  7437. }
  7438. int charid2sessionid(int charid)
  7439. {
  7440. struct map_session_data *pl_sd = NULL;
  7441. pl_sd = map_charid2sd(charid);
  7442. if (pl_sd) return pl_sd->fd;
  7443. return 0;
  7444. }
  7445. int accountid2sessionid(int accountid)
  7446. {
  7447. struct map_session_data *pl_sd = NULL;
  7448. pl_sd = map_id2sd(accountid);
  7449. if (pl_sd) return pl_sd->fd;
  7450. return 0;
  7451. }
  7452. /*==========================================
  7453. * Jump to a player by PID number
  7454. * Original by Dino9021
  7455. * Added in by nsstrunks
  7456. *------------------------------------------
  7457. */
  7458. int atcommand_jumptoid(
  7459. const int fd, struct map_session_data* sd,
  7460. const char* command, const char* message)
  7461. {
  7462. int cid=0;
  7463. int session_id=0;
  7464. struct map_session_data *pl_sd;
  7465. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7466. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7467. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7468. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7469. return -1;
  7470. }
  7471. cid=atoi(message);
  7472. if ((session_id=charid2sessionid(cid))!=0)
  7473. {
  7474. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7475. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7476. clif_displaymessage(fd, msg_table[247]);
  7477. return -1;
  7478. }
  7479. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7480. clif_displaymessage(fd, msg_table[248]);
  7481. return -1;
  7482. }
  7483. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7484. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7485. clif_displaymessage(fd, atcmd_output);
  7486. } else {
  7487. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7488. return -1;
  7489. }
  7490. }
  7491. else
  7492. {
  7493. clif_displaymessage(fd,msg_table[3]);
  7494. }
  7495. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7496. return 0;
  7497. }
  7498. /*==========================================
  7499. * Jump to a player by PID number
  7500. * Original by Dino9021
  7501. * Added in by nsstrunks
  7502. *------------------------------------------
  7503. */
  7504. int atcommand_jumptoid2(
  7505. const int fd, struct map_session_data* sd,
  7506. const char* command, const char* message)
  7507. {
  7508. int aid=0;
  7509. int session_id=0;
  7510. struct map_session_data *pl_sd;
  7511. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7512. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7513. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7514. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7515. return -1;
  7516. }
  7517. aid=atoi(message);
  7518. if ((session_id=accountid2sessionid(aid))!=0)
  7519. {
  7520. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7521. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7522. clif_displaymessage(fd, msg_table[247]);
  7523. return -1;
  7524. }
  7525. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7526. clif_displaymessage(fd, msg_table[248]);
  7527. return -1;
  7528. }
  7529. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7530. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7531. clif_displaymessage(fd, atcmd_output);
  7532. } else {
  7533. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7534. return -1;
  7535. }
  7536. }
  7537. else
  7538. {
  7539. clif_displaymessage(fd,msg_table[3]);
  7540. }
  7541. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7542. return 0;
  7543. }
  7544. /*==========================================
  7545. * Recall a player by PID number
  7546. * Original by Dino9021
  7547. * Added in by nsstrunks
  7548. *------------------------------------------
  7549. */
  7550. int atcommand_recallid(
  7551. const int fd, struct map_session_data* sd,
  7552. const char* command, const char* message)
  7553. {
  7554. int cid=0;
  7555. int session_id=0;
  7556. struct map_session_data *pl_sd;
  7557. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7558. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7559. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7560. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7561. return -1;
  7562. }
  7563. cid=atoi(message);
  7564. if ((session_id=charid2sessionid(cid))!=0)
  7565. {
  7566. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7567. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7568. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7569. clif_displaymessage(fd, msg_table[247]);
  7570. return -1;
  7571. }
  7572. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7573. clif_displaymessage(fd, msg_table[248]);
  7574. return -1;
  7575. }
  7576. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7577. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7578. clif_displaymessage(fd, atcmd_output);
  7579. } else {
  7580. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7581. return -1;
  7582. }
  7583. } else {
  7584. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7585. return -1;
  7586. }
  7587. }
  7588. else
  7589. {
  7590. clif_displaymessage(fd,msg_table[3]);
  7591. }
  7592. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7593. return 0;
  7594. }
  7595. /*==========================================
  7596. * Recall a player by PID number
  7597. * Original by Dino9021
  7598. * Added in by nsstrunks
  7599. *------------------------------------------
  7600. */
  7601. int atcommand_recallid2(
  7602. const int fd, struct map_session_data* sd,
  7603. const char* command, const char* message)
  7604. {
  7605. int aid=0;
  7606. int session_id=0;
  7607. struct map_session_data *pl_sd;
  7608. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7609. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7610. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7611. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7612. return -1;
  7613. }
  7614. aid=atoi(message);
  7615. if ((session_id=accountid2sessionid(aid))!=0)
  7616. {
  7617. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7618. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7619. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7620. clif_displaymessage(fd, msg_table[247]);
  7621. return -1;
  7622. }
  7623. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7624. clif_displaymessage(fd, msg_table[248]);
  7625. return -1;
  7626. }
  7627. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7628. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7629. clif_displaymessage(fd, atcmd_output);
  7630. } else {
  7631. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7632. return -1;
  7633. }
  7634. } else {
  7635. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7636. return -1;
  7637. }
  7638. }
  7639. else
  7640. {
  7641. clif_displaymessage(fd,msg_table[3]);
  7642. }
  7643. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7644. return 0;
  7645. }
  7646. /*==========================================
  7647. * Kick a player by PID number
  7648. * Original by Dino9021
  7649. * Added in by nsstrunks
  7650. *------------------------------------------
  7651. */
  7652. int atcommand_kickid(
  7653. const int fd, struct map_session_data* sd,
  7654. const char* command, const char* message)
  7655. {
  7656. struct map_session_data *pl_sd;
  7657. int cid=0;
  7658. int session_id=0;
  7659. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7660. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7661. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7662. return -1;
  7663. }
  7664. cid=atoi(message);
  7665. if ((session_id=charid2sessionid(cid))!=0)
  7666. {
  7667. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7668. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7669. clif_GM_kick(sd, pl_sd, 1);
  7670. else {
  7671. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7672. return -1;
  7673. }
  7674. } else {
  7675. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7676. return -1;
  7677. }
  7678. }
  7679. else
  7680. {
  7681. clif_displaymessage(fd,msg_table[3]);
  7682. }
  7683. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7684. return 0;
  7685. }
  7686. /*==========================================
  7687. * Kick a player by PID number
  7688. * Original by Dino9021
  7689. * Added in by nsstrunks
  7690. *------------------------------------------
  7691. */
  7692. int atcommand_kickid2(
  7693. const int fd, struct map_session_data* sd,
  7694. const char* command, const char* message)
  7695. {
  7696. struct map_session_data *pl_sd;
  7697. int aid=0;
  7698. int session_id=0;
  7699. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7700. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7701. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7702. return -1;
  7703. }
  7704. aid=atoi(message);
  7705. if ((session_id=accountid2sessionid(aid))!=0)
  7706. {
  7707. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7708. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7709. clif_GM_kick(sd, pl_sd, 1);
  7710. else {
  7711. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7712. return -1;
  7713. }
  7714. } else {
  7715. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7716. return -1;
  7717. }
  7718. }
  7719. else
  7720. {
  7721. clif_displaymessage(fd,msg_table[3]);
  7722. }
  7723. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7724. return 0;
  7725. }
  7726. /*==========================================
  7727. * Revive a player by PID number
  7728. * Original by Dino9021
  7729. * Added in by nsstrunks
  7730. *------------------------------------------
  7731. */
  7732. int atcommand_reviveid(
  7733. const int fd, struct map_session_data* sd,
  7734. const char* command, const char* message)
  7735. {
  7736. int cid=0;
  7737. int session_id=0;
  7738. struct map_session_data *pl_sd;
  7739. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7740. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7741. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7742. return -1;
  7743. }
  7744. cid=atoi(message);
  7745. if ((session_id=charid2sessionid(cid))!=0)
  7746. {
  7747. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7748. pl_sd->status.hp = pl_sd->status.max_hp;
  7749. pc_setstand(pl_sd);
  7750. if (battle_config.pc_invincible_time > 0)
  7751. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7752. clif_updatestatus(pl_sd, SP_HP);
  7753. clif_updatestatus(pl_sd, SP_SP);
  7754. clif_resurrection(&pl_sd->bl, 1);
  7755. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7756. } else {
  7757. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7758. return -1;
  7759. }
  7760. }
  7761. else
  7762. {
  7763. clif_displaymessage(fd,msg_table[3]);
  7764. }
  7765. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7766. return 0;
  7767. }
  7768. /*==========================================
  7769. * Revive a player by PID number
  7770. * Original by Dino9021
  7771. * Added in by nsstrunks
  7772. *------------------------------------------
  7773. */
  7774. int atcommand_reviveid2(
  7775. const int fd, struct map_session_data* sd,
  7776. const char* command, const char* message)
  7777. {
  7778. int aid=0;
  7779. int session_id=0;
  7780. struct map_session_data *pl_sd;
  7781. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7782. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7783. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7784. return -1;
  7785. }
  7786. aid=atoi(message);
  7787. if ((session_id=accountid2sessionid(aid))!=0)
  7788. {
  7789. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7790. pl_sd->status.hp = pl_sd->status.max_hp;
  7791. pc_setstand(pl_sd);
  7792. if (battle_config.pc_invincible_time > 0)
  7793. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7794. clif_updatestatus(pl_sd, SP_HP);
  7795. clif_updatestatus(pl_sd, SP_SP);
  7796. clif_resurrection(&pl_sd->bl, 1);
  7797. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7798. } else {
  7799. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7800. return -1;
  7801. }
  7802. }
  7803. else
  7804. {
  7805. clif_displaymessage(fd,msg_table[3]);
  7806. }
  7807. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7808. return 0;
  7809. }
  7810. /*==========================================
  7811. * Kill a player by PID number
  7812. * Original by Dino9021
  7813. * Added in by nsstrunks
  7814. *------------------------------------------
  7815. */
  7816. int atcommand_killid(
  7817. const int fd, struct map_session_data* sd,
  7818. const char* command, const char* message)
  7819. {
  7820. int cid=0;
  7821. int session_id=0;
  7822. struct map_session_data *pl_sd;
  7823. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7824. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7825. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7826. return -1;
  7827. }
  7828. cid=atoi(message);
  7829. if ((session_id=charid2sessionid(cid))!=0)
  7830. {
  7831. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7832. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7833. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7834. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7835. } else {
  7836. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7837. return -1;
  7838. }
  7839. } else {
  7840. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7841. return -1;
  7842. }
  7843. }
  7844. else
  7845. {
  7846. clif_displaymessage(fd,msg_table[3]);
  7847. }
  7848. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7849. return 0;
  7850. }
  7851. /*==========================================
  7852. * Kill a player by PID number
  7853. * Original by Dino9021
  7854. * Added in by nsstrunks
  7855. *------------------------------------------
  7856. */
  7857. int atcommand_killid2(
  7858. const int fd, struct map_session_data* sd,
  7859. const char* command, const char* message)
  7860. {
  7861. int aid=0;
  7862. int session_id=0;
  7863. struct map_session_data *pl_sd;
  7864. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7865. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7866. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7867. return -1;
  7868. }
  7869. aid=atoi(message);
  7870. if ((session_id=accountid2sessionid(aid))!=0)
  7871. {
  7872. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7873. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7874. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7875. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7876. } else {
  7877. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7878. return -1;
  7879. }
  7880. } else {
  7881. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7882. return -1;
  7883. }
  7884. }
  7885. else
  7886. {
  7887. clif_displaymessage(fd,msg_table[3]);
  7888. }
  7889. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7890. return 0;
  7891. }
  7892. /*==========================================
  7893. * Make a player killable, by PID
  7894. * Original by Dino9021
  7895. * Added in by nsstrunks
  7896. *------------------------------------------
  7897. */
  7898. int
  7899. atcommand_charkillableid(
  7900. const int fd, struct map_session_data* sd,
  7901. const char* command, const char* message)
  7902. {
  7903. struct map_session_data *pl_sd = NULL;
  7904. int cid=0;
  7905. int session_id=0;
  7906. if (!message || (cid = atoi(message)) == 0 || !*message)
  7907. return -1;
  7908. cid=atoi(message);
  7909. if ((session_id=charid2sessionid(cid))!=0)
  7910. {
  7911. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7912. return -1;
  7913. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7914. if(pl_sd->special_state.killable)
  7915. clif_displaymessage(fd, "The player is now killable");
  7916. else
  7917. clif_displaymessage(fd, "The player is no longer killable");
  7918. }
  7919. else
  7920. {
  7921. clif_displaymessage(fd,msg_table[3]);
  7922. }
  7923. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7924. return 0;
  7925. }
  7926. /*==========================================
  7927. * Make a player killable, by PID
  7928. * Original by Dino9021
  7929. * Added in by nsstrunks
  7930. *------------------------------------------
  7931. */
  7932. int
  7933. atcommand_charkillableid2(
  7934. const int fd, struct map_session_data* sd,
  7935. const char* command, const char* message)
  7936. {
  7937. struct map_session_data *pl_sd = NULL;
  7938. int aid=0;
  7939. int session_id=0;
  7940. if (!message || (aid = atoi(message)) == 0 || !*message)
  7941. return -1;
  7942. aid=atoi(message);
  7943. if ((session_id=accountid2sessionid(aid))!=0)
  7944. {
  7945. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7946. return -1;
  7947. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7948. if(pl_sd->special_state.killable)
  7949. clif_displaymessage(fd, "The player is now killable");
  7950. else
  7951. clif_displaymessage(fd, "The player is no longer killable");
  7952. }
  7953. else
  7954. {
  7955. clif_displaymessage(fd,msg_table[3]);
  7956. }
  7957. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7958. return 0;
  7959. }
  7960. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7961. /*==========================================
  7962. * Mail System commands by [Valaris]
  7963. *------------------------------------------
  7964. */
  7965. int atcommand_listmail(
  7966. const int fd, struct map_session_data* sd,
  7967. const char* command, const char* message)
  7968. {
  7969. if(!mail_server_enable)
  7970. return 0;
  7971. nullpo_retr(-1, sd);
  7972. if(strlen(command)==12)
  7973. mail_check(sd,3);
  7974. else if(strlen(command)==9)
  7975. mail_check(sd,2);
  7976. else
  7977. mail_check(sd,1);
  7978. return 0;
  7979. }
  7980. int atcommand_readmail(
  7981. const int fd, struct map_session_data* sd,
  7982. const char* command, const char* message)
  7983. {
  7984. int index;
  7985. if(!mail_server_enable)
  7986. return 0;
  7987. nullpo_retr(-1, sd);
  7988. if (!message || !*message) {
  7989. clif_displaymessage(sd->fd,"You must specify a message number.");
  7990. return 0;
  7991. }
  7992. index = atoi(message);
  7993. if (index < 1) {
  7994. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  7995. return 0;
  7996. }
  7997. if(strlen(command)==11)
  7998. mail_delete(sd,index);
  7999. else
  8000. mail_read(sd,index);
  8001. return 0;
  8002. }
  8003. int atcommand_sendmail(
  8004. const int fd, struct map_session_data* sd,
  8005. const char* command, const char* message)
  8006. {
  8007. char name[NAME_LENGTH],text[80];
  8008. if(!mail_server_enable)
  8009. return 0;
  8010. nullpo_retr(-1, sd);
  8011. if (!message || !*message) {
  8012. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8013. return 0;
  8014. }
  8015. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8016. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8017. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8018. return 0;
  8019. }
  8020. if(strlen(command)==17)
  8021. mail_send(sd,name,text,1);
  8022. else
  8023. mail_send(sd,name,text,0);
  8024. return 0;
  8025. }
  8026. /*==========================================
  8027. * Refresh online command for SQL [Valaris]
  8028. * Will refresh and check online column of
  8029. * players and set correctly.
  8030. *------------------------------------------
  8031. */
  8032. int atcommand_refreshonline(
  8033. const int fd, struct map_session_data* sd,
  8034. const char* command, const char* message)
  8035. {
  8036. send_users_tochar(-1, gettick(), 0, 0);
  8037. return 0;
  8038. }
  8039. #endif /* end sql only */
  8040. /*==========================================
  8041. * Show Monster DB Info v 1.0
  8042. * originally by [Lupus] eAthena
  8043. *------------------------------------------
  8044. */
  8045. int atcommand_mobinfo(
  8046. const int fd, struct map_session_data* sd,
  8047. const char* command, const char* message)
  8048. {
  8049. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8050. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8051. unsigned char melement[11][8] = {"None", "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8052. char atcmd_output2[200];
  8053. struct item_data *item_data;
  8054. struct mob_db *mob;
  8055. int mob_id;
  8056. int i, j;
  8057. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8058. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8059. if (!message || !*message) {
  8060. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8061. return -1;
  8062. }
  8063. // If monster identifier/name argument is a name
  8064. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  8065. mob_id = mobdb_checkid(atoi(message));
  8066. if (mob_id == 0) {
  8067. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8068. return -1;
  8069. }
  8070. mob = mob_db(mob_id);
  8071. // stats
  8072. if (mob->mexp)
  8073. sprintf(atcmd_output, "MVP Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8074. else
  8075. sprintf(atcmd_output, "Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8076. clif_displaymessage(fd, atcmd_output);
  8077. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%d Job EXP:%d", mob->lv, mob->max_hp, mob->max_sp, mob->base_exp, mob->job_exp);
  8078. clif_displaymessage(fd, atcmd_output);
  8079. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d", mob->def, mob->mdef, mob->str, mob->agi, mob->vit, mob->int_, mob->dex, mob->luk);
  8080. clif_displaymessage(fd, atcmd_output);
  8081. if (mob->element < 20) {
  8082. //Element - None, Level 0
  8083. i = 0;
  8084. j = 0;
  8085. } else {
  8086. i = mob->element % 20 + 1;
  8087. j = mob->element / 20;
  8088. }
  8089. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)", mob->atk1, mob->atk2, mob->range, mob->range2 , mob->range3, msize[mob->size], mrace[mob->race], melement[i], j);
  8090. clif_displaymessage(fd, atcmd_output);
  8091. // drops
  8092. clif_displaymessage(fd, " Drops:");
  8093. strcpy(atcmd_output, " ");
  8094. j = 0;
  8095. for (i = 0; i < 10; i++) {
  8096. if (mob->dropitem[i].nameid <= 0 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8097. continue;
  8098. if (mob->dropitem[i].p > 0) {
  8099. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->dropitem[i].p / 100);
  8100. strcat(atcmd_output, atcmd_output2);
  8101. if (++j % 3 == 0) {
  8102. clif_displaymessage(fd, atcmd_output);
  8103. strcpy(atcmd_output, " ");
  8104. }
  8105. }
  8106. }
  8107. if (j == 0)
  8108. clif_displaymessage(fd, "This monster has no drops.");
  8109. else if (j % 3 != 0)
  8110. clif_displaymessage(fd, atcmd_output);
  8111. // mvp
  8112. if (mob->mexp) {
  8113. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8114. clif_displaymessage(fd, atcmd_output);
  8115. strcpy(atcmd_output, " MVP Items:");
  8116. j = 0;
  8117. for (i = 0; i < 3; i++) {
  8118. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8119. continue;
  8120. if (mob->mvpitem[i].p > 0) {
  8121. j++;
  8122. if (j == 1)
  8123. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8124. else
  8125. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8126. strcat(atcmd_output, atcmd_output2);
  8127. }
  8128. }
  8129. if (j == 0)
  8130. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8131. else
  8132. clif_displaymessage(fd, atcmd_output);
  8133. }
  8134. return 0;
  8135. }
  8136. /*==========================================
  8137. * Show Items DB Info v 1.0
  8138. * originally by [Lupus] eAthena
  8139. *------------------------------------------
  8140. */
  8141. int atcommand_iteminfo(
  8142. const int fd, struct map_session_data* sd,
  8143. const char* command, const char* message)
  8144. {
  8145. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8146. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8147. struct item_data *item_data;
  8148. int item_id=0;
  8149. if (!message || !*message) {
  8150. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8151. return -1;
  8152. }
  8153. if ((item_data = itemdb_searchname(message)) != NULL ||
  8154. (item_data = itemdb_exists(atoi(message))) != NULL)
  8155. item_id = item_data->nameid;
  8156. if (item_id >= 500) {
  8157. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8158. item_data->name,item_data->jname,item_data->slot,item_id,
  8159. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8160. (item_data->script==NULL)? "None" : "With script"
  8161. );
  8162. clif_displaymessage(fd, atcmd_output);
  8163. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %d ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight );
  8164. clif_displaymessage(fd, atcmd_output);
  8165. if (item_data->maxchance == 10000)
  8166. strcpy(atcmd_output, " - Available in the shops only");
  8167. else if (item_data->maxchance)
  8168. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8169. else
  8170. strcpy(atcmd_output, " - Monsters don't drop this item");
  8171. clif_displaymessage(fd, atcmd_output);
  8172. return 0;
  8173. }
  8174. clif_displaymessage(fd, "Item not found.");
  8175. return -1;
  8176. }
  8177. /*==========================================
  8178. * @adopt by [Veider]
  8179. *
  8180. * adopt a novice
  8181. *------------------------------------------
  8182. */
  8183. int
  8184. atcommand_adopt(const int fd, struct map_session_data* sd,
  8185. const char* command, const char* message)
  8186. {
  8187. struct map_session_data *pl_sd1 = NULL;
  8188. struct map_session_data *pl_sd2 = NULL;
  8189. struct map_session_data *pl_sd3 = NULL;
  8190. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8191. nullpo_retr(-1, sd);
  8192. if (!message || !*message)
  8193. return -1;
  8194. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8195. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8196. return -1;
  8197. }
  8198. if (battle_config.etc_log)
  8199. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8200. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8201. sprintf(player2, "Cannot find player %s online", player1);
  8202. clif_displaymessage(fd, player2);
  8203. return -1;
  8204. }
  8205. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8206. sprintf(player1, "Cannot find player %s online", player2);
  8207. clif_displaymessage(fd, player1);
  8208. return -1;
  8209. }
  8210. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8211. sprintf(player1, "Cannot find player %s online", player3);
  8212. clif_displaymessage(fd, player1);
  8213. return -1;
  8214. }
  8215. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8216. clif_displaymessage(fd, "They are too young to be parents!");
  8217. return -1;
  8218. }
  8219. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8220. clif_displaymessage(fd, "They are family.. wish them luck");
  8221. return 0;
  8222. }
  8223. else
  8224. return -1;
  8225. }
  8226. int atcommand_version(
  8227. const int fd, struct map_session_data* sd,
  8228. const char* command, const char* message)
  8229. {
  8230. const char * revision;
  8231. if ((revision = get_svn_revision()) != 0) {
  8232. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8233. clif_displaymessage(fd,atcmd_output);
  8234. } else
  8235. clif_displaymessage(fd,"Cannot determine SVN revision");
  8236. return 0;
  8237. }
  8238. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8239. {
  8240. int time, id;
  8241. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8242. if (pl_sd == NULL)
  8243. return 0;
  8244. id = va_arg(ap, int);
  8245. time = va_arg(ap, int);
  8246. if (id != bl->id && !pc_isGM(pl_sd)) {
  8247. pl_sd->status.manner -= time;
  8248. if (pl_sd->status.manner < 0)
  8249. status_change_start(&pl_sd->bl,SC_NOCHAT,100,0,0,0,0,0,0);
  8250. }
  8251. return 0;
  8252. }
  8253. /*==========================================
  8254. * @mutearea by MouseJstr
  8255. *------------------------------------------
  8256. */
  8257. int atcommand_mutearea(
  8258. const int fd, struct map_session_data* sd,
  8259. const char* command, const char* message)
  8260. {
  8261. int time;
  8262. nullpo_retr(0, sd);
  8263. if(!battle_config.muting_players) {
  8264. clif_displaymessage(fd, "Please enable the muting system before using it.");
  8265. return 0;
  8266. }
  8267. time = atoi(message);
  8268. if (time <= 0)
  8269. time = 15; // 15 minutes default
  8270. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8271. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8272. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8273. return 0;
  8274. }
  8275. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8276. {
  8277. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8278. if (bl == NULL)
  8279. return 0;
  8280. if (!pc_isGM(pl_sd))
  8281. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8282. return 0;
  8283. }
  8284. /*==========================================
  8285. * @shuffle by MouseJstr
  8286. *------------------------------------------
  8287. */
  8288. int atcommand_shuffle(
  8289. const int fd, struct map_session_data* sd,
  8290. const char* command, const char* message)
  8291. {
  8292. nullpo_retr(0, sd);
  8293. if (strcmp(message, "area")== 0) {
  8294. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8295. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8296. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8297. } else if (strcmp(message, "map")== 0) {
  8298. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8299. } else if (strcmp(message, "world") == 0) {
  8300. struct map_session_data **pl_allsd;
  8301. int i, users;
  8302. pl_allsd = map_getallusers(&users);
  8303. for (i = 0; i < users; i++)
  8304. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8305. } else
  8306. clif_displaymessage(fd, "options are area, map, or world");
  8307. return 0;
  8308. }
  8309. int atcommand_rates(
  8310. const int fd, struct map_session_data* sd,
  8311. const char* command, const char* message)
  8312. {
  8313. char buf[255];
  8314. nullpo_retr(0, sd);
  8315. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8316. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8317. clif_displaymessage(fd, buf);
  8318. return 0;
  8319. }
  8320. /*==========================================
  8321. * @me by lordalfa
  8322. * => Displays the OUTPUT string on top of
  8323. * the Visible players Heads.
  8324. *------------------------------------------
  8325. */
  8326. int atcommand_me(
  8327. const int fd, struct map_session_data* sd,
  8328. const char* command, const char* message)
  8329. {
  8330. char tempmes[200];
  8331. nullpo_retr(-1, sd);
  8332. memset(tempmes, '\0', sizeof(tempmes));
  8333. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8334. if (!message || !*message) {
  8335. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8336. return -1;
  8337. }
  8338. sscanf(message, "%199[^\n]", tempmes);
  8339. sprintf(atcmd_output, "* %s %s *", sd->status.name, tempmes);
  8340. clif_disp_overhead(sd, atcmd_output);
  8341. return 0;
  8342. }
  8343. /*==========================================
  8344. * @size
  8345. * => Resize your character sprite. [Valaris]
  8346. *------------------------------------------
  8347. */
  8348. int atcommand_size(
  8349. const int fd, struct map_session_data* sd,
  8350. const char* command, const char* message)
  8351. {
  8352. int size=0;
  8353. nullpo_retr(-1, sd);
  8354. if (!message || !*message)
  8355. return -1;
  8356. if (sscanf(message,"%d", &size) < 1)
  8357. return -1;
  8358. if(sd->state.size) {
  8359. sd->state.size=0;
  8360. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8361. }
  8362. if(size==1) {
  8363. sd->state.size=1;
  8364. clif_specialeffect(&sd->bl,420,0);
  8365. } else if(size==2) {
  8366. sd->state.size=2;
  8367. clif_specialeffect(&sd->bl,422,0);
  8368. }
  8369. return 0;
  8370. }
  8371. /*==========================================
  8372. * @monsterignore
  8373. * => Makes monsters ignore you. [Valaris]
  8374. *------------------------------------------
  8375. */
  8376. int atcommand_monsterignore(
  8377. const int fd, struct map_session_data* sd,
  8378. const char* command, const char* message)
  8379. {
  8380. nullpo_retr(-1, sd);
  8381. if (!sd->state.monster_ignore) {
  8382. sd->state.monster_ignore = 1;
  8383. clif_displaymessage(sd->fd, "Monsters will now ignore you.");
  8384. } else {
  8385. sd->state.monster_ignore = 0;
  8386. clif_displaymessage(sd->fd, "Monsters are no longer ignoring you.");
  8387. }
  8388. return 0;
  8389. }
  8390. /*==========================================
  8391. * @fakename
  8392. * => Gives your character a fake name. [Valaris]
  8393. *------------------------------------------
  8394. */
  8395. int atcommand_fakename(
  8396. const int fd, struct map_session_data* sd,
  8397. const char* command, const char* message)
  8398. {
  8399. char name[NAME_LENGTH];
  8400. nullpo_retr(-1, sd);
  8401. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8402. sd->fakename[0]='\0';
  8403. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8404. clif_displaymessage(sd->fd,"Returned to real name.");
  8405. return 0;
  8406. }
  8407. if (!message || !*message) {
  8408. clif_displaymessage(sd->fd,"You must enter a name.");
  8409. return 0;
  8410. }
  8411. if (sscanf(message, "%23[^\n]", name) < 1) {
  8412. return 0;
  8413. }
  8414. if(strlen(name) < 2) {
  8415. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8416. return 0;
  8417. }
  8418. memcpy(sd->fakename,name,NAME_LENGTH-1);
  8419. clif_charnameack(0, &sd->bl);
  8420. clif_displaymessage(sd->fd,"Fake name enabled.");
  8421. return 0;
  8422. }
  8423. /*==========================================
  8424. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  8425. * => Shows information about the map flags [map name]
  8426. * Also set flags
  8427. *------------------------------------------
  8428. */
  8429. int atcommand_mapflag(
  8430. const int fd, struct map_session_data* sd,
  8431. const char* command, const char* message)
  8432. {
  8433. // WIP
  8434. return 0;
  8435. }
  8436. /*===================================
  8437. * Remove some messages
  8438. *-----------------------------------
  8439. */
  8440. int atcommand_showexp(
  8441. const int fd, struct map_session_data* sd,
  8442. const char* command, const char* message)
  8443. {
  8444. if (sd->state.showexp) {
  8445. sd->state.showexp = 0;
  8446. clif_displaymessage(fd, "Gained exp will not be shown.");
  8447. return 0;
  8448. }
  8449. sd->state.showexp = 1;
  8450. clif_displaymessage(fd, "Gained exp is now shown");
  8451. return 0;
  8452. }
  8453. int atcommand_showzeny(
  8454. const int fd, struct map_session_data* sd,
  8455. const char* command, const char* message)
  8456. {
  8457. if (sd->state.showzeny) {
  8458. sd->state.showzeny = 0;
  8459. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8460. return 0;
  8461. }
  8462. sd->state.showzeny = 1;
  8463. clif_displaymessage(fd, "Gained zeny is now shown");
  8464. return 0;
  8465. }
  8466. int atcommand_showdelay(
  8467. const int fd, struct map_session_data* sd,
  8468. const char* command, const char* message)
  8469. {
  8470. if (sd->state.showdelay) {
  8471. sd->state.showdelay = 0;
  8472. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8473. return 0;
  8474. }
  8475. sd->state.showdelay = 1;
  8476. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8477. return 0;
  8478. }
  8479. /*==========================================
  8480. * Duel organizing functions [LuzZza]
  8481. *
  8482. * @duel [limit|nick] - create a duel
  8483. * @invite <nick> - invite player
  8484. * @accept - accept invitation
  8485. * @reject - reject invitation
  8486. * @leave - leave duel
  8487. *------------------------------------------
  8488. */
  8489. int atcommand_invite(
  8490. const int fd, struct map_session_data* sd,
  8491. const char* command, const char* message)
  8492. {
  8493. unsigned int did = sd->duel_group;
  8494. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8495. if(did <= 0) {
  8496. // "Duel: @invite without @duel."
  8497. clif_displaymessage(fd, msg_txt(350));
  8498. return 0;
  8499. }
  8500. if(duel_list[did].max_players_limit > 0 &&
  8501. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8502. // "Duel: Limit of players is reached."
  8503. clif_displaymessage(fd, msg_txt(351));
  8504. return 0;
  8505. }
  8506. if(target_sd == NULL) {
  8507. // "Duel: Player not found."
  8508. clif_displaymessage(fd, msg_txt(352));
  8509. return 0;
  8510. }
  8511. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8512. // "Duel: Player already in duel."
  8513. clif_displaymessage(fd, msg_txt(353));
  8514. return 0;
  8515. }
  8516. duel_invite(did, sd, target_sd);
  8517. // "Duel: Invitation has been sent."
  8518. clif_displaymessage(fd, msg_txt(354));
  8519. return 0;
  8520. }
  8521. int atcommand_duel(
  8522. const int fd, struct map_session_data* sd,
  8523. const char* command, const char* message)
  8524. {
  8525. char output[256];
  8526. unsigned int maxpl=0, newduel;
  8527. struct map_session_data *target_sd;
  8528. /* // Commnted because it can be disabled in at-comms conf.
  8529. if(!battle_config.duel_enable) {
  8530. clif_displaymessage(fd, "Duel: duel is disable.");
  8531. return 0;
  8532. }
  8533. */
  8534. if(sd->duel_group > 0) {
  8535. duel_showinfo(sd->duel_group, sd);
  8536. return 0;
  8537. }
  8538. if(sd->duel_invite > 0) {
  8539. // "Duel: @duel without @reject."
  8540. clif_displaymessage(fd, msg_txt(355));
  8541. return 0;
  8542. }
  8543. if(!duel_checktime(sd)) {
  8544. // "Duel: You can take part in duel only one time per %d minutes."
  8545. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8546. clif_displaymessage(fd, output);
  8547. return 0;
  8548. }
  8549. if(strlen(message) > 0) {
  8550. if(sscanf(message, "%d", &maxpl) >= 1) {
  8551. if(maxpl < 2 || maxpl > 65535) {
  8552. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8553. return 0;
  8554. }
  8555. duel_create(sd, maxpl);
  8556. } else {
  8557. target_sd = map_nick2sd((char *)message);
  8558. if(target_sd != NULL) {
  8559. if((newduel = duel_create(sd, 2)) != -1) {
  8560. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8561. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8562. return 0;
  8563. }
  8564. duel_invite(newduel, sd, target_sd);
  8565. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8566. }
  8567. } else {
  8568. // "Duel: Player not found."
  8569. clif_displaymessage(fd, msg_txt(352));
  8570. return 0;
  8571. }
  8572. }
  8573. } else
  8574. duel_create(sd, 0);
  8575. return 0;
  8576. }
  8577. int atcommand_leave(
  8578. const int fd, struct map_session_data* sd,
  8579. const char* command, const char* message)
  8580. {
  8581. if(sd->duel_group <= 0) {
  8582. // "Duel: @leave without @duel."
  8583. clif_displaymessage(fd, msg_txt(358));
  8584. return 0;
  8585. }
  8586. duel_leave(sd->duel_group, sd);
  8587. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8588. return 0;
  8589. }
  8590. int atcommand_accept(
  8591. const int fd, struct map_session_data* sd,
  8592. const char* command, const char* message)
  8593. {
  8594. char output[256];
  8595. if(!duel_checktime(sd)) {
  8596. // "Duel: You can take part in duel only one time per %d minutes."
  8597. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8598. clif_displaymessage(fd, output);
  8599. return 0;
  8600. }
  8601. if(sd->duel_invite <= 0) {
  8602. // "Duel: @accept without invititation."
  8603. clif_displaymessage(fd, msg_txt(360));
  8604. return 0;
  8605. }
  8606. duel_accept(sd->duel_invite, sd);
  8607. // "Duel: Invitation has been accepted."
  8608. clif_displaymessage(fd, msg_txt(361));
  8609. return 0;
  8610. }
  8611. int atcommand_reject(
  8612. const int fd, struct map_session_data* sd,
  8613. const char* command, const char* message)
  8614. {
  8615. if(sd->duel_invite <= 0) {
  8616. // "Duel: @reject without invititation."
  8617. clif_displaymessage(fd, msg_txt(352));
  8618. return 0;
  8619. }
  8620. duel_reject(sd->duel_invite, sd);
  8621. // "Duel: Invitation has been rejected."
  8622. clif_displaymessage(fd, msg_txt(352));
  8623. return 0;
  8624. }
  8625. /*===================================
  8626. * Away message (@away, @aw) [LuzZza]
  8627. *-----------------------------------
  8628. */
  8629. int atcommand_away(
  8630. const int fd, struct map_session_data* sd,
  8631. const char* command, const char* message)
  8632. {
  8633. if(strlen(message) > 0) {
  8634. if(strlen(message) > 128)
  8635. return -1;
  8636. strcpy(sd->away_message, message);
  8637. //"Away automessage has been activated."
  8638. clif_displaymessage(fd, msg_txt(546));
  8639. } else {
  8640. if(strlen(sd->away_message) > 0) {
  8641. sd->away_message[0] = 0;
  8642. //"Away automessage has been disabled."
  8643. clif_displaymessage(fd, msg_txt(547));
  8644. return 0;
  8645. }
  8646. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8647. clif_displaymessage(fd, msg_txt(548));
  8648. }
  8649. return 0;
  8650. }
  8651. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8652. int atcommand_clone(
  8653. const int fd, struct map_session_data* sd,
  8654. const char* command, const char* message)
  8655. {
  8656. int x=0,y=0,flag=0,master=0,i=0;
  8657. struct map_session_data *pl_sd=NULL;
  8658. if (!message || !*message) {
  8659. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8660. return 0;
  8661. }
  8662. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8663. clif_displaymessage(fd, "Player not found.");
  8664. return 0;
  8665. }
  8666. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8667. clif_displaymessage(fd, "Cannot clone a player of higher GM level than yourself.");
  8668. return 0;
  8669. }
  8670. if (strcmpi(command, "@clone") == 0)
  8671. flag = 1;
  8672. else if (strcmpi(command, "@slaveclone") == 0) {
  8673. flag = 2;
  8674. master = sd->bl.id;
  8675. if (battle_config.atc_slave_clone_limit
  8676. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8677. clif_displaymessage(fd, "You've reached your slave clones limit.");
  8678. return 0;
  8679. }
  8680. }
  8681. do {
  8682. x = sd->bl.x + (rand() % 10 - 5);
  8683. y = sd->bl.y + (rand() % 10 - 5);
  8684. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8685. if (i >= 10) {
  8686. x = sd->bl.x;
  8687. y = sd->bl.y;
  8688. }
  8689. if((x = mob_clone_spawn(pl_sd, (char*)mapindex_id2name(sd->mapindex), x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8690. clif_displaymessage(fd, msg_txt(126+flag*2));
  8691. return 0;
  8692. }
  8693. clif_displaymessage(fd, msg_txt(127+flag*2));
  8694. return 0;
  8695. }
  8696. /*===================================
  8697. * Main chat [LuzZza]
  8698. * Usage: @main <on|off|message>
  8699. *-----------------------------------
  8700. */
  8701. int atcommand_main(
  8702. const int fd, struct map_session_data* sd,
  8703. const char* command, const char* message)
  8704. {
  8705. if(strlen(message) > 0) {
  8706. if(strlen(message) > 128)
  8707. return -1;
  8708. if(strcmpi(message, "on") == 0) {
  8709. if(!sd->state.mainchat) {
  8710. sd->state.mainchat = 1;
  8711. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8712. } else {
  8713. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8714. }
  8715. } else if(strcmpi(message, "off") == 0) {
  8716. if(sd->state.mainchat) {
  8717. sd->state.mainchat = 0;
  8718. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8719. } else {
  8720. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8721. }
  8722. } else {
  8723. if(!sd->state.mainchat) {
  8724. sd->state.mainchat = 1;
  8725. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8726. }
  8727. if (sd->sc.data[SC_NOCHAT].timer != -1) {
  8728. clif_displaymessage(fd, msg_txt(387));
  8729. return -1;
  8730. }
  8731. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8732. // I use 0xFE000000 color for signalizing that this message is
  8733. // main chat message. 0xFE000000 is invalid color, same using
  8734. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8735. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8736. }
  8737. } else {
  8738. if(sd->state.mainchat)
  8739. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8740. clif_displaymessage(fd, msg_txt(384));
  8741. else
  8742. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8743. clif_displaymessage(fd, msg_txt(385));
  8744. }
  8745. return 0;
  8746. }
  8747. void do_init_atcommand() {
  8748. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8749. duel_count = 0;
  8750. memset(&duel_list[0], 0, sizeof(duel_list));
  8751. return;
  8752. }
  8753. void do_final_atcommand() {
  8754. users_db->destroy(users_db,NULL);
  8755. }