atcommand.c 308 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178
  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 <limits.h>
  9. #include "../common/socket.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/mmo.h"
  13. #include "../common/core.h"
  14. #include "../common/showmsg.h"
  15. #include "log.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "intif.h"
  19. #include "itemdb.h"
  20. #include "map.h"
  21. #include "pc.h"
  22. #include "status.h"
  23. #include "skill.h"
  24. #include "mob.h"
  25. #include "pet.h"
  26. #include "battle.h"
  27. #include "party.h"
  28. #include "guild.h"
  29. #include "atcommand.h"
  30. #include "script.h"
  31. #include "npc.h"
  32. #include "trade.h"
  33. #include "unit.h"
  34. #ifndef TXT_ONLY
  35. #include "mail.h"
  36. #endif
  37. static char command_symbol = '@'; // first char of the commands (by [Yor])
  38. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  39. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  40. ACMD_FUNC(broadcast);
  41. ACMD_FUNC(localbroadcast);
  42. ACMD_FUNC(rura);
  43. ACMD_FUNC(where);
  44. ACMD_FUNC(jumpto);
  45. ACMD_FUNC(jump);
  46. ACMD_FUNC(who);
  47. ACMD_FUNC(who2);
  48. ACMD_FUNC(who3);
  49. ACMD_FUNC(whomap);
  50. ACMD_FUNC(whomap2);
  51. ACMD_FUNC(whomap3);
  52. ACMD_FUNC(whogm); // by Yor
  53. ACMD_FUNC(whozeny); // [Valaris]
  54. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  55. ACMD_FUNC(save);
  56. ACMD_FUNC(load);
  57. ACMD_FUNC(speed);
  58. ACMD_FUNC(storage);
  59. ACMD_FUNC(guildstorage);
  60. ACMD_FUNC(option);
  61. ACMD_FUNC(hide);
  62. ACMD_FUNC(jobchange);
  63. ACMD_FUNC(die);
  64. ACMD_FUNC(kill);
  65. ACMD_FUNC(alive);
  66. ACMD_FUNC(kami);
  67. ACMD_FUNC(heal);
  68. ACMD_FUNC(item);
  69. ACMD_FUNC(item2);
  70. ACMD_FUNC(itemreset);
  71. ACMD_FUNC(itemcheck);
  72. ACMD_FUNC(baselevelup);
  73. ACMD_FUNC(joblevelup);
  74. ACMD_FUNC(help);
  75. ACMD_FUNC(help2);
  76. ACMD_FUNC(gm);
  77. ACMD_FUNC(pvpoff);
  78. ACMD_FUNC(pvpon);
  79. ACMD_FUNC(gvgoff);
  80. ACMD_FUNC(gvgon);
  81. ACMD_FUNC(model);
  82. ACMD_FUNC(go);
  83. ACMD_FUNC(monster);
  84. ACMD_FUNC(monstersmall);
  85. ACMD_FUNC(monsterbig);
  86. ACMD_FUNC(spawn);
  87. ACMD_FUNC(killmonster);
  88. ACMD_FUNC(killmonster2);
  89. ACMD_FUNC(refine);
  90. ACMD_FUNC(produce);
  91. ACMD_FUNC(memo);
  92. ACMD_FUNC(gat);
  93. ACMD_FUNC(packet);
  94. ACMD_FUNC(waterlevel);
  95. ACMD_FUNC(statuspoint);
  96. ACMD_FUNC(skillpoint);
  97. ACMD_FUNC(zeny);
  98. ACMD_FUNC(param);
  99. ACMD_FUNC(guildlevelup);
  100. ACMD_FUNC(makeegg);
  101. ACMD_FUNC(hatch);
  102. ACMD_FUNC(petfriendly);
  103. ACMD_FUNC(pethungry);
  104. ACMD_FUNC(petrename);
  105. ACMD_FUNC(recall);
  106. ACMD_FUNC(recallall);
  107. ACMD_FUNC(revive);
  108. ACMD_FUNC(night);
  109. ACMD_FUNC(day);
  110. ACMD_FUNC(doom);
  111. ACMD_FUNC(doommap);
  112. ACMD_FUNC(raise);
  113. ACMD_FUNC(raisemap);
  114. ACMD_FUNC(kick);
  115. ACMD_FUNC(kickall);
  116. ACMD_FUNC(allskill);
  117. ACMD_FUNC(questskill);
  118. ACMD_FUNC(lostskill);
  119. ACMD_FUNC(spiritball);
  120. ACMD_FUNC(party);
  121. ACMD_FUNC(guild);
  122. ACMD_FUNC(agitstart);
  123. ACMD_FUNC(agitend);
  124. ACMD_FUNC(reloaditemdb);
  125. ACMD_FUNC(reloadmobdb);
  126. ACMD_FUNC(reloadskilldb);
  127. ACMD_FUNC(reloadscript);
  128. ACMD_FUNC(reloadgmdb); // by Yor
  129. ACMD_FUNC(reloadatcommand);
  130. ACMD_FUNC(reloadbattleconf);
  131. ACMD_FUNC(reloadstatusdb);
  132. ACMD_FUNC(reloadpcdb);
  133. ACMD_FUNC(reloadmotd); // [Valaris]
  134. ACMD_FUNC(mapexit);
  135. ACMD_FUNC(idsearch);
  136. ACMD_FUNC(mapinfo);
  137. ACMD_FUNC(dye); //** by fritz
  138. ACMD_FUNC(hair_style); //** by fritz
  139. ACMD_FUNC(hair_color); //** by fritz
  140. ACMD_FUNC(stat_all); //** by fritz
  141. ACMD_FUNC(char_block); // by Yor
  142. ACMD_FUNC(char_ban); // by Yor
  143. ACMD_FUNC(char_unblock); // by Yor
  144. ACMD_FUNC(char_unban); // by Yor
  145. ACMD_FUNC(mount_peco); // by Valaris
  146. ACMD_FUNC(char_mount_peco); // by Yor
  147. ACMD_FUNC(guildspy); // [Syrus22]
  148. ACMD_FUNC(partyspy); // [Syrus22]
  149. ACMD_FUNC(repairall); // [Valaris]
  150. ACMD_FUNC(guildrecall); // by Yor
  151. ACMD_FUNC(partyrecall); // by Yor
  152. ACMD_FUNC(nuke); // [Valaris]
  153. ACMD_FUNC(shownpc);
  154. ACMD_FUNC(hidenpc);
  155. ACMD_FUNC(loadnpc);
  156. ACMD_FUNC(unloadnpc);
  157. ACMD_FUNC(servertime); // by Yor
  158. ACMD_FUNC(chardelitem); // by Yor
  159. ACMD_FUNC(jail); // by Yor
  160. ACMD_FUNC(unjail); // by Yor
  161. ACMD_FUNC(disguise); // [Valaris]
  162. ACMD_FUNC(undisguise); // by Yor
  163. ACMD_FUNC(chardisguise); // Kalaspuff
  164. ACMD_FUNC(charundisguise); // Kalaspuff
  165. ACMD_FUNC(email); // by Yor
  166. ACMD_FUNC(effect);//by Apple
  167. ACMD_FUNC(character_cart_list); // by Yor
  168. ACMD_FUNC(addwarp); // by MouseJstr
  169. ACMD_FUNC(follow); // by MouseJstr
  170. ACMD_FUNC(skillon); // by MouseJstr
  171. ACMD_FUNC(skilloff); // by MouseJstr
  172. ACMD_FUNC(killer); // by MouseJstr
  173. ACMD_FUNC(npcmove); // by MouseJstr
  174. ACMD_FUNC(killable); // by MouseJstr
  175. ACMD_FUNC(charkillable); // by MouseJstr
  176. ACMD_FUNC(dropall); // by MouseJstr
  177. ACMD_FUNC(chardropall); // by MouseJstr
  178. ACMD_FUNC(storeall); // by MouseJstr
  179. ACMD_FUNC(charstoreall); // by MouseJstr
  180. ACMD_FUNC(skillid); // by MouseJstr
  181. ACMD_FUNC(useskill); // by MouseJstr
  182. ACMD_FUNC(summon);
  183. ACMD_FUNC(rain);
  184. ACMD_FUNC(snow);
  185. ACMD_FUNC(sakura);
  186. ACMD_FUNC(clouds);
  187. ACMD_FUNC(clouds2); // [Valaris]
  188. ACMD_FUNC(fog);
  189. ACMD_FUNC(fireworks);
  190. ACMD_FUNC(leaves);
  191. ACMD_FUNC(adjgmlvl); // by MouseJstr
  192. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  193. ACMD_FUNC(trade); // by MouseJstr
  194. ACMD_FUNC(send); // by davidsiaw
  195. ACMD_FUNC(setbattleflag); // by MouseJstr
  196. ACMD_FUNC(unmute); // [Valaris]
  197. ACMD_FUNC(clearweather); // Dexity
  198. ACMD_FUNC(uptime); // by MC Cameri
  199. ACMD_FUNC(changesex); // by MC Cameri
  200. ACMD_FUNC(mute); // celest
  201. ACMD_FUNC(refresh); // by MC Cameri
  202. ACMD_FUNC(petid); // by MC Cameri
  203. ACMD_FUNC(identify); // by MC Cameri
  204. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  205. ACMD_FUNC(misceffect); // by MC Cameri
  206. ACMD_FUNC(mobsearch);
  207. ACMD_FUNC(cleanmap);
  208. ACMD_FUNC(npctalk);
  209. ACMD_FUNC(pettalk);
  210. ACMD_FUNC(users);
  211. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  212. #ifndef TXT_ONLY
  213. ACMD_FUNC(checkmail); // [Valaris]
  214. ACMD_FUNC(listmail); // [Valaris]
  215. ACMD_FUNC(listnewmail); // [Valaris]
  216. ACMD_FUNC(readmail); // [Valaris]
  217. ACMD_FUNC(sendmail); // [Valaris]
  218. ACMD_FUNC(sendprioritymail); // [Valaris]
  219. ACMD_FUNC(deletemail); // [Valaris]
  220. ACMD_FUNC(refreshonline); // [Valaris]
  221. #endif /* TXT_ONLY */
  222. ACMD_FUNC(skilltree); // by MouseJstr
  223. ACMD_FUNC(marry); // by MouseJstr
  224. ACMD_FUNC(divorce); // by MouseJstr
  225. ACMD_FUNC(grind); // by MouseJstr
  226. ACMD_FUNC(grind2); // by MouseJstr
  227. #ifdef DMALLOC
  228. ACMD_FUNC(dmstart); // by MouseJstr
  229. ACMD_FUNC(dmtick); // by MouseJstr
  230. #endif
  231. ACMD_FUNC(jumptoid); // by Dino9021
  232. ACMD_FUNC(jumptoid2); // by Dino9021
  233. ACMD_FUNC(recallid); // by Dino9021
  234. ACMD_FUNC(recallid2); // by Dino9021
  235. ACMD_FUNC(kickid); // by Dino9021
  236. ACMD_FUNC(kickid2); // by Dino9021
  237. ACMD_FUNC(reviveid); // by Dino9021
  238. ACMD_FUNC(reviveid2); // by Dino9021
  239. ACMD_FUNC(killid); // by Dino9021
  240. ACMD_FUNC(killid2); // by Dino9021
  241. ACMD_FUNC(charkillableid); // by Dino9021
  242. ACMD_FUNC(charkillableid2); // by Dino9021
  243. ACMD_FUNC(sound);
  244. ACMD_FUNC(undisguiseall);
  245. ACMD_FUNC(disguiseall);
  246. ACMD_FUNC(changelook);
  247. ACMD_FUNC(mobinfo); //by Lupus
  248. ACMD_FUNC(exp); // by Skotlex
  249. ACMD_FUNC(adopt); // by Veider
  250. ACMD_FUNC(version); // by Ancyker
  251. ACMD_FUNC(mutearea); // by MouseJstr
  252. ACMD_FUNC(shuffle); // by MouseJstr
  253. ACMD_FUNC(rates); // by MouseJstr
  254. ACMD_FUNC(iteminfo); // Lupus
  255. ACMD_FUNC(whodrops); //Skotlex
  256. ACMD_FUNC(mapflag); // Lupus
  257. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  258. ACMD_FUNC(monsterignore); // [Valaris]
  259. ACMD_FUNC(fakename); //[Valaris]
  260. ACMD_FUNC(size); //[Valaris]
  261. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  262. ACMD_FUNC(showzeny);
  263. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  264. ACMD_FUNC(autotrade);// durf
  265. ACMD_FUNC(changeleader);// [Skotlex]
  266. ACMD_FUNC(changegm);// durf
  267. // Duel [LuzZza]
  268. ACMD_FUNC(invite);
  269. ACMD_FUNC(duel);
  270. ACMD_FUNC(leave);
  271. ACMD_FUNC(accept);
  272. ACMD_FUNC(reject);
  273. ACMD_FUNC(away); // LuzZza
  274. ACMD_FUNC(main); // LuzZza
  275. ACMD_FUNC(clone); // [Valaris]
  276. ACMD_FUNC(tonpc); // LuzZza
  277. /*==========================================
  278. *AtCommandInfo atcommand_info[]構造体の定義
  279. *------------------------------------------
  280. */
  281. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  282. // to set default level, read atcommand_athena.conf first please.
  283. static AtCommandInfo atcommand_info[] = {
  284. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  285. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  286. { AtCommand_Where, "@where", 1, atcommand_where },
  287. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  288. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  289. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  290. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  291. { AtCommand_Who, "@who", 20, atcommand_who },
  292. { AtCommand_Who, "@whois", 20, atcommand_who },
  293. { AtCommand_Who, "@w", 20, atcommand_who },
  294. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  295. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  296. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  297. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  298. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  299. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  300. { AtCommand_Save, "@save", 40, atcommand_save },
  301. { AtCommand_Load, "@return", 40, atcommand_load },
  302. { AtCommand_Load, "@load", 40, atcommand_load },
  303. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  304. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  305. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  306. { AtCommand_Option, "@option", 40, atcommand_option },
  307. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  308. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  309. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  310. { AtCommand_Die, "@die", 1, atcommand_die },
  311. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  312. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  313. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  314. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  315. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  316. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  317. { AtCommand_Item, "@item", 60, atcommand_item },
  318. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  319. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  320. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  321. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  322. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  323. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  324. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  325. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  326. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  327. { AtCommand_H, "@h", 20, atcommand_help },
  328. { AtCommand_Help, "@help", 20, atcommand_help },
  329. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  330. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  331. { AtCommand_GM, "@gm", 100,atcommand_gm },
  332. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  333. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  334. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  335. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  336. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  337. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  338. { AtCommand_Model, "@model", 20, atcommand_model },
  339. { AtCommand_Go, "@go", 10, atcommand_go },
  340. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  341. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  342. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  343. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  344. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  345. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  346. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  347. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  348. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  349. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  350. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  351. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  352. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  353. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  354. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  355. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  356. { AtCommand_Strength, "@str", 60, atcommand_param },
  357. { AtCommand_Agility, "@agi", 60, atcommand_param },
  358. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  359. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  360. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  361. { AtCommand_Luck, "@luk", 60, atcommand_param },
  362. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  363. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  364. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  365. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  366. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  367. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  368. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  369. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  370. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  371. { AtCommand_Night, "@night", 80, atcommand_night },
  372. { AtCommand_Day, "@day", 80, atcommand_day },
  373. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  374. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  375. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  376. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  377. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  378. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  379. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  380. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  381. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  382. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  383. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  384. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  385. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  386. { AtCommand_Party, "@party", 1, atcommand_party },
  387. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  388. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  389. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  390. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  391. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  392. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  393. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  394. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  395. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  396. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  397. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  398. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  399. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  400. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  401. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  402. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  403. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  404. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  405. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  406. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  407. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  408. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  409. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  410. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  411. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  412. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  413. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  414. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  415. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  416. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  417. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  418. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  419. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  420. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  421. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  422. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  423. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  424. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  425. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  426. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  427. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  428. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  429. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  430. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  431. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  432. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  433. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  434. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  435. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  436. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  437. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  438. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  439. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  440. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  441. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  442. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  443. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  444. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  445. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  446. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  447. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  448. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  449. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  450. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  451. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  452. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  453. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  454. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  455. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  456. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  457. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  458. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  459. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  460. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  461. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  462. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  463. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  464. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  465. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  466. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  467. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  468. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  469. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  470. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  471. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  472. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  473. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  474. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  475. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  476. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  477. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  478. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  479. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  480. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  481. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  482. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  483. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  484. { AtCommand_Send, "@send", 60, atcommand_send },
  485. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  486. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  487. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  488. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  489. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken]
  490. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  491. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  492. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  493. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  494. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  495. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  496. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  497. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  498. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  499. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  500. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  501. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  502. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  503. { AtCommand_Users, "@users", 40, atcommand_users },
  504. { AtCommand_ResetState, "/reset", 40, NULL },
  505. #ifndef TXT_ONLY // sql-only commands
  506. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  507. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  508. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  509. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  510. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  511. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  512. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  513. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  514. #endif /* TXT_ONLY */
  515. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  516. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  517. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  518. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  519. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  520. #ifdef DMALLOC
  521. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  522. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  523. #endif
  524. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  525. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  526. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  527. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  528. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  529. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  530. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  531. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  532. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  533. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  534. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  535. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  536. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  537. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  538. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  539. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  540. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  541. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  542. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  543. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  544. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  545. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  546. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  547. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  548. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  549. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  550. { AtCommand_Version, "@version", 1, atcommand_version },
  551. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  552. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  553. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  554. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  555. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  556. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  557. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  558. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  559. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  560. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  561. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  562. { AtCommand_Size, "@size", 20, atcommand_size },
  563. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  564. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  565. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  566. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  567. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  568. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  569. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  570. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  571. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  572. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  573. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  574. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  575. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  576. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  577. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  578. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  579. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  580. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  581. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  582. // add new commands before this line
  583. { AtCommand_Unknown, NULL, 1, NULL }
  584. };
  585. /*=========================================
  586. * Generic variables
  587. *-----------------------------------------
  588. */
  589. char atcmd_output[200];
  590. char atcmd_player_name[100];
  591. char atcmd_temp[100];
  592. /*==========================================
  593. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  594. *------------------------------------------
  595. */
  596. char *estr_lower(char *str)
  597. {
  598. int i;
  599. for (i=0; str[i]; i++)
  600. if ((str[i] >= 65) && (str[i] <= 90))
  601. str[i] += 32;
  602. return str;
  603. }
  604. // compare function for sorting high to lowest
  605. int hightolow_compare (const void * a, const void * b)
  606. {
  607. return ( *(int*)b - *(int*)a );
  608. }
  609. // compare function for sorting lowest to highest
  610. int lowtohigh_compare (const void * a, const void * b)
  611. {
  612. return ( *(int*)a - *(int*)b );
  613. }
  614. //-----------------------------------------------------------
  615. // Return the message string of the specified number by [Yor]
  616. //-----------------------------------------------------------
  617. char * msg_txt(int msg_number) {
  618. if (msg_number >= 0 && msg_number < MAX_MSG &&
  619. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  620. return msg_table[msg_number];
  621. return "??";
  622. }
  623. //-----------------------------------------------------------
  624. // Returns Players title (from msg_athena.conf) [Lupus]
  625. //-----------------------------------------------------------
  626. char * player_title_txt(int level) {
  627. if (level < battle_config.title_lvl1)
  628. return ""; //w/o any titles
  629. if (level >= battle_config.title_lvl8)
  630. sprintf(atcmd_temp, msg_table[332], level);
  631. else
  632. if (level >= battle_config.title_lvl7)
  633. sprintf(atcmd_temp, msg_table[331], level);
  634. else
  635. if (level >= battle_config.title_lvl6)
  636. sprintf(atcmd_temp, msg_table[330], level);
  637. else
  638. if (level >= battle_config.title_lvl5)
  639. sprintf(atcmd_temp, msg_table[329], level);
  640. else
  641. if (level >= battle_config.title_lvl4)
  642. sprintf(atcmd_temp, msg_table[328], level);
  643. else
  644. if (level >= battle_config.title_lvl3)
  645. sprintf(atcmd_temp, msg_table[327], level);
  646. else
  647. if (level >= battle_config.title_lvl2)
  648. sprintf(atcmd_temp, msg_table[326], level);
  649. else
  650. sprintf(atcmd_temp, msg_table[325], level); //lvl1
  651. return atcmd_temp;
  652. }
  653. //------------------------------------------------------------
  654. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  655. //------------------------------------------------------------
  656. int e_mail_check(char *email) {
  657. char ch;
  658. char* last_arobas;
  659. // athena limits
  660. if (strlen(email) < 3 || strlen(email) > 39)
  661. return 0;
  662. // part of RFC limits (official reference of e-mail description)
  663. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  664. return 0;
  665. if (email[strlen(email)-1] == '.')
  666. return 0;
  667. last_arobas = strrchr(email, '@');
  668. if (strstr(last_arobas, "@.") != NULL ||
  669. strstr(last_arobas, "..") != NULL)
  670. return 0;
  671. for(ch = 1; ch < 32; ch++) {
  672. if (strchr(last_arobas, ch) != NULL) {
  673. return 0;
  674. break;
  675. }
  676. }
  677. if (strchr(last_arobas, ' ') != NULL ||
  678. strchr(last_arobas, ';') != NULL)
  679. return 0;
  680. // all correct
  681. return 1;
  682. }
  683. /*==========================================
  684. * get_atcommand_level @コマンドの必要レベルを取得
  685. *------------------------------------------
  686. */
  687. int get_atcommand_level(const AtCommandType type) {
  688. int i;
  689. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  690. if (atcommand_info[i].type == type)
  691. return atcommand_info[i].level;
  692. return 100; // 100: command can not be used
  693. }
  694. /*==========================================
  695. *is_atcommand @コマンドに存在するかどうか確認する
  696. *------------------------------------------
  697. */
  698. AtCommandType
  699. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  700. const char* str = message;
  701. int s_flag = 0;
  702. AtCommandInfo info;
  703. AtCommandType type;
  704. nullpo_retr(AtCommand_None, sd);
  705. if (!battle_config.allow_atcommand_when_mute &&
  706. sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1) {
  707. return AtCommand_Unknown;
  708. }
  709. if (!message || !*message)
  710. return AtCommand_None;
  711. memset(&info, 0, sizeof(info));
  712. str += strlen(sd->status.name);
  713. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  714. if (*str == ':')
  715. s_flag = 1;
  716. str++;
  717. }
  718. if (!*str)
  719. return AtCommand_None;
  720. if (map[sd->bl.m].flag.nocommand &&
  721. (gmlvl > 0? gmlvl:pc_isGM(sd)) < battle_config.gm_skilluncond)
  722. { //Command not allowed on this map.
  723. sprintf(atcmd_output, msg_table[143]);
  724. clif_displaymessage(fd, atcmd_output);
  725. return AtCommand_None;
  726. }
  727. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  728. if (type != AtCommand_None) {
  729. char command[100];
  730. const char* p = str;
  731. memset(command, '\0', sizeof(command));
  732. memset(atcmd_output, '\0', sizeof(atcmd_output));
  733. while (*p && !isspace(*p))
  734. p++;
  735. if (p - str >= sizeof(command)) // too long
  736. return AtCommand_Unknown;
  737. strncpy(command, str, p - str);
  738. while (isspace(*p))
  739. p++;
  740. if (type == AtCommand_Unknown || info.proc == NULL) {
  741. sprintf(atcmd_output, msg_table[153], command); // %s is Unknown Command.
  742. clif_displaymessage(fd, atcmd_output);
  743. } else {
  744. if (info.proc(fd, sd, command, p) != 0) {
  745. // Command can not be executed
  746. sprintf(atcmd_output, msg_table[154], command); // %s failed.
  747. clif_displaymessage(fd, atcmd_output);
  748. }
  749. }
  750. return info.type;
  751. }
  752. return AtCommand_None;
  753. }
  754. /*==========================================
  755. *
  756. *------------------------------------------
  757. */
  758. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  759. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  760. if (!info)
  761. return AtCommand_None;
  762. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  763. return AtCommand_None;
  764. if (!p || !*p) {
  765. ShowError("at command message is empty\n");
  766. return AtCommand_None;
  767. }
  768. if (*p == command_symbol) { // check first char.
  769. char command[101];
  770. int i = 0;
  771. memset(info, 0, sizeof(AtCommandInfo));
  772. sscanf(p, "%100s", command);
  773. command[sizeof(command)-1] = '\0';
  774. while (atcommand_info[i].type != AtCommand_Unknown) {
  775. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  776. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  777. break;
  778. }
  779. i++;
  780. }
  781. if (atcommand_info[i].type == AtCommand_Unknown) {
  782. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  783. if (level == 0)
  784. return AtCommand_None;
  785. else
  786. return AtCommand_Unknown;
  787. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  788. log_atcommand(sd, message);
  789. }
  790. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  791. } else {
  792. return AtCommand_None;
  793. }
  794. return info->type;
  795. }
  796. /*==========================================
  797. * Read Message Data
  798. *------------------------------------------
  799. */
  800. int msg_config_read(const char *cfgName) {
  801. int msg_number;
  802. char line[1024], w1[1024], w2[1024];
  803. FILE *fp;
  804. static int called = 1;
  805. if ((fp = fopen(cfgName, "r")) == NULL) {
  806. ShowError("Messages file not found: %s\n", cfgName);
  807. return 1;
  808. }
  809. if ((--called) == 0)
  810. memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
  811. while(fgets(line, sizeof(line)-1, fp)) {
  812. if (line[0] == '/' && line[1] == '/')
  813. continue;
  814. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  815. if (strcmpi(w1, "import") == 0) {
  816. msg_config_read(w2);
  817. } else {
  818. msg_number = atoi(w1);
  819. if (msg_number >= 0 && msg_number < MAX_MSG) {
  820. if (msg_table[msg_number] != NULL)
  821. aFree(msg_table[msg_number]);
  822. msg_table[msg_number] = (char *)aCalloc(strlen(w2) + 1, sizeof (char));
  823. strcpy(msg_table[msg_number],w2);
  824. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  825. }
  826. }
  827. }
  828. }
  829. fclose(fp);
  830. return 0;
  831. }
  832. /*==========================================
  833. * Cleanup Message Data
  834. *------------------------------------------
  835. */
  836. void do_final_msg (void) {
  837. int i;
  838. for (i = 0; i < MAX_MSG; i++)
  839. aFree(msg_table[i]);
  840. return;
  841. }
  842. /*==========================================
  843. *
  844. *------------------------------------------
  845. */
  846. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  847. int i;
  848. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  849. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  850. return &atcommand_info[i];
  851. return NULL;
  852. }
  853. /*==========================================
  854. *
  855. *------------------------------------------
  856. */
  857. int atcommand_config_read(const char *cfgName) {
  858. char line[1024], w1[1024], w2[1024];
  859. AtCommandInfo* p;
  860. FILE* fp;
  861. if ((fp = fopen(cfgName, "r")) == NULL) {
  862. ShowError("At commands configuration file not found: %s\n", cfgName);
  863. return 1;
  864. }
  865. while (fgets(line, sizeof(line)-1, fp)) {
  866. if (line[0] == '/' && line[1] == '/')
  867. continue;
  868. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  869. continue;
  870. p = get_atcommandinfo_byname(w1);
  871. if (p != NULL) {
  872. p->level = atoi(w2);
  873. if (p->level > 100)
  874. p->level = 100;
  875. else if (p->level < 0)
  876. p->level = 0;
  877. }
  878. if (strcmpi(w1, "import") == 0)
  879. atcommand_config_read(w2);
  880. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  881. w2[0] != '/' && // symbol of standard ragnarok GM commands
  882. w2[0] != '%' && // symbol of party chat speaking
  883. w2[0] != '$' && // symbol of guild chat
  884. w2[0] != '#') // symbol of charcommand
  885. command_symbol = w2[0];
  886. }
  887. fclose(fp);
  888. return 0;
  889. }
  890. /*==========================================
  891. * Duel organizing functions [LuzZza]
  892. *------------------------------------------
  893. */
  894. void duel_msg_foreach_sameduel_wos(
  895. const unsigned int did, struct map_session_data* sd, char *output)
  896. {
  897. int i;
  898. struct map_session_data* msg_sd;
  899. for(i=0; i<fd_max; i++)
  900. if(session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  901. && msg_sd->state.auth && msg_sd->duel_group == did && msg_sd != sd)
  902. clif_disp_onlyself(msg_sd, output, strlen(output));
  903. return;
  904. }
  905. void duel_savetime(struct map_session_data* sd) {
  906. time_t timer;
  907. struct tm *t;
  908. time(&timer);
  909. t = localtime(&timer);
  910. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  911. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  912. return;
  913. }
  914. int duel_checktime(struct map_session_data* sd) {
  915. int diff;
  916. time_t timer;
  917. struct tm *t;
  918. time(&timer);
  919. t = localtime(&timer);
  920. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  921. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  922. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  923. }
  924. int duel_showinfo(
  925. const unsigned int did, struct map_session_data* sd)
  926. {
  927. int i, p=0;
  928. char output[256];
  929. struct map_session_data* msg_sd;
  930. if(duel_list[did].max_players_limit > 0)
  931. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  932. did, duel_count,
  933. duel_list[did].members_count,
  934. duel_list[did].members_count + duel_list[did].invites_count,
  935. duel_list[did].max_players_limit);
  936. else
  937. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  938. did, duel_count,
  939. duel_list[did].members_count,
  940. duel_list[did].members_count + duel_list[did].invites_count);
  941. clif_disp_onlyself(sd, output, strlen(output));
  942. for(i=0; i<fd_max; i++)
  943. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  944. && msg_sd->state.auth && msg_sd->duel_group == did) {
  945. sprintf(output, " %d. %s", ++p, (unsigned char *) msg_sd->status.name);
  946. clif_disp_onlyself(sd, output, strlen(output));
  947. }
  948. return 0;
  949. }
  950. int duel_create(
  951. struct map_session_data* sd, const unsigned int maxpl)
  952. {
  953. int i=1;
  954. char output[256];
  955. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  956. if(i == MAX_DUEL) return 0;
  957. duel_count++;
  958. sd->duel_group = i;
  959. duel_list[i].members_count++;
  960. duel_list[i].invites_count = 0;
  961. duel_list[i].max_players_limit = maxpl;
  962. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  963. clif_disp_onlyself(sd, output, strlen(output));
  964. clif_set0199(sd->fd, 1);
  965. //clif_misceffect2(&sd->bl, 159);
  966. return i;
  967. }
  968. int duel_invite(
  969. const unsigned int did, struct map_session_data* sd,
  970. struct map_session_data* target_sd)
  971. {
  972. char output[256];
  973. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  974. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  975. duel_msg_foreach_sameduel_wos(did, sd, output);
  976. target_sd->duel_invite = did;
  977. duel_list[did].invites_count++;
  978. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  979. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  980. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  981. return 0;
  982. }
  983. int duel_leave(
  984. const unsigned int did, struct map_session_data* sd)
  985. {
  986. int i;
  987. char output[256];
  988. struct map_session_data* msg_sd;
  989. // " <- Player %s has left duel --"
  990. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  991. duel_msg_foreach_sameduel_wos(did, sd, output);
  992. duel_list[did].members_count--;
  993. if(duel_list[did].members_count == 0) {
  994. for (i=0; i<fd_max; i++)
  995. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  996. && msg_sd->state.auth && msg_sd->duel_invite == did && msg_sd != sd) {
  997. msg_sd->duel_invite = 0;
  998. }
  999. duel_count--;
  1000. }
  1001. sd->duel_group = 0;
  1002. duel_savetime(sd);
  1003. clif_set0199(sd->fd, 0);
  1004. return 0;
  1005. }
  1006. int duel_accept(
  1007. const unsigned int did, struct map_session_data* sd)
  1008. {
  1009. char output[256];
  1010. // " -> Player %s has accepted duel --"
  1011. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  1012. duel_msg_foreach_sameduel_wos(did, sd, output);
  1013. duel_list[did].members_count++;
  1014. sd->duel_group = sd->duel_invite;
  1015. duel_list[did].invites_count--;
  1016. sd->duel_invite = 0;
  1017. clif_set0199(sd->fd, 1);
  1018. //clif_misceffect2(&sd->bl, 159);
  1019. return 0;
  1020. }
  1021. int duel_reject(
  1022. const unsigned int did, struct map_session_data* sd)
  1023. {
  1024. char output[256];
  1025. // " -- Player %s has rejected duel --"
  1026. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1027. duel_msg_foreach_sameduel_wos(did, sd, output);
  1028. duel_list[did].invites_count--;
  1029. sd->duel_invite = 0;
  1030. return 0;
  1031. }
  1032. /*==========================================
  1033. // @ command processing functions
  1034. *------------------------------------------
  1035. */
  1036. /*==========================================
  1037. * @send (used for testing packet sends from the client)
  1038. *------------------------------------------
  1039. */
  1040. int atcommand_send(
  1041. const int fd, struct map_session_data* sd,
  1042. const char* command, const char* message)
  1043. {
  1044. int i,type=0;
  1045. int info[20];
  1046. 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) {
  1047. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1048. return -1;
  1049. }
  1050. if (type > 0 && type < MAX_PACKET_DB) {
  1051. switch (type)
  1052. {
  1053. case 0x209: {
  1054. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1055. WFIFOW(fd,0) = 0x209;
  1056. WFIFOW(fd,2) = 2;
  1057. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1058. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1059. break;
  1060. }
  1061. case 0x1b1:
  1062. case 0x1c2:
  1063. //case xxx:
  1064. // add others here
  1065. // break;
  1066. default: {
  1067. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1068. WFIFOW(fd,0) = type;
  1069. for(i=1;i<=sizeof(info);i++)
  1070. if(info[i])
  1071. WFIFOW(fd,i) = info[i];
  1072. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1073. break;
  1074. }
  1075. }
  1076. sprintf (atcmd_output, msg_table[258], type, type);
  1077. clif_displaymessage(fd, atcmd_output);
  1078. } else {
  1079. clif_displaymessage(fd, msg_table[259]);
  1080. }
  1081. return 0;
  1082. }
  1083. // @rura
  1084. /*==========================================
  1085. *
  1086. *------------------------------------------
  1087. */
  1088. int atcommand_rura(
  1089. const int fd, struct map_session_data* sd,
  1090. const char* command, const char* message)
  1091. {
  1092. char map_name[MAP_NAME_LENGTH];
  1093. unsigned short mapindex;
  1094. int x = 0, y = 0;
  1095. int m = -1;
  1096. nullpo_retr(-1, sd);
  1097. memset(map_name, '\0', sizeof(map_name));
  1098. if (!message || !*message ||
  1099. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1100. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1101. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1102. return -1;
  1103. }
  1104. if (x <= 0)
  1105. x = rand() % 399 + 1;
  1106. if (y <= 0)
  1107. y = rand() % 399 + 1;
  1108. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1109. strcat(map_name, ".gat");
  1110. mapindex = mapindex_name2id(map_name);
  1111. if (mapindex)
  1112. m = map_mapindex2mapid(mapindex);
  1113. if (!mapindex || m < 0) {
  1114. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1115. return -1;
  1116. }
  1117. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1118. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1119. clif_displaymessage(fd, msg_table[247]);
  1120. return -1;
  1121. }
  1122. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1123. clif_displaymessage(fd, msg_table[248]);
  1124. return -1;
  1125. }
  1126. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1127. clif_displaymessage(fd, msg_table[0]); // Warped.
  1128. else {
  1129. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1130. return -1;
  1131. }
  1132. } else {
  1133. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1134. return -1;
  1135. }
  1136. return 0;
  1137. }
  1138. /*==========================================
  1139. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1140. *------------------------------------------
  1141. */
  1142. int atcommand_where(
  1143. const int fd, struct map_session_data* sd,
  1144. const char* command, const char* message)
  1145. {
  1146. struct map_session_data *pl_sd = NULL;
  1147. int GM_level, pl_GM_level;
  1148. nullpo_retr(-1, sd);
  1149. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1150. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1151. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1152. return -1;
  1153. }
  1154. pl_sd = map_nick2sd(atcmd_player_name);
  1155. if (pl_sd == NULL)
  1156. return -1;
  1157. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1158. return -1;
  1159. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1160. pl_GM_level = pc_isGM(pl_sd);
  1161. if (battle_config.hide_GM_session) {
  1162. if(GM_level < pl_GM_level) {
  1163. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1164. return -1;
  1165. }
  1166. }
  1167. }
  1168. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1169. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1170. clif_displaymessage(fd, atcmd_output);
  1171. return 0;
  1172. }
  1173. /*==========================================
  1174. *
  1175. *------------------------------------------
  1176. */
  1177. int atcommand_jumpto(
  1178. const int fd, struct map_session_data* sd,
  1179. const char* command, const char* message)
  1180. {
  1181. struct map_session_data *pl_sd = NULL;
  1182. nullpo_retr(-1, sd);
  1183. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1184. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1185. return -1;
  1186. }
  1187. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1188. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1189. return -1;
  1190. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1191. return -1;
  1192. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1193. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1194. clif_displaymessage(fd, msg_table[247]);
  1195. return -1;
  1196. }
  1197. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1198. clif_displaymessage(fd, msg_table[248]);
  1199. return -1;
  1200. }
  1201. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1202. sprintf(atcmd_output, msg_table[4], atcmd_player_name); // Jump to %s
  1203. clif_displaymessage(fd, atcmd_output);
  1204. } else {
  1205. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1206. return -1;
  1207. }
  1208. return 0;
  1209. }
  1210. /*==========================================
  1211. *
  1212. *------------------------------------------
  1213. */
  1214. int atcommand_jump(
  1215. const int fd, struct map_session_data* sd,
  1216. const char* command, const char* message)
  1217. {
  1218. int x = 0, y = 0;
  1219. nullpo_retr(-1, sd);
  1220. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1221. sscanf(message, "%d %d", &x, &y);
  1222. if (x <= 0) //If coordinates are 'wrong', random jump.
  1223. x = -1;
  1224. if (y <= 0)
  1225. y = -1;
  1226. 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)) {
  1227. clif_displaymessage(fd, msg_table[248]);
  1228. return -1;
  1229. }
  1230. pc_setpos(sd, sd->mapindex, x, y, 3);
  1231. sprintf(atcmd_output, msg_table[5], sd->bl.x, sd->bl.y); // Jump to %d %d
  1232. clif_displaymessage(fd, atcmd_output);
  1233. return 0;
  1234. }
  1235. /*==========================================
  1236. * @who3 = Player name, his location
  1237. *------------------------------------------
  1238. */
  1239. int atcommand_who3(
  1240. const int fd, struct map_session_data* sd,
  1241. const char* command, const char* message)
  1242. {
  1243. char temp0[100];
  1244. struct map_session_data *pl_sd, **pl_allsd;
  1245. int i, j, count, users;
  1246. int pl_GM_level, GM_level;
  1247. char match_text[100];
  1248. char player_name[NAME_LENGTH];
  1249. nullpo_retr(-1, sd);
  1250. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1251. memset(match_text, '\0', sizeof(match_text));
  1252. memset(player_name, '\0', sizeof(player_name));
  1253. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1254. strcpy(match_text, "");
  1255. for (j = 0; match_text[j]; j++)
  1256. match_text[j] = tolower(match_text[j]);
  1257. count = 0;
  1258. GM_level = pc_isGM(sd);
  1259. pl_allsd = map_getallusers(&users);
  1260. for (i = 0; i < users; i++) {
  1261. if ((pl_sd = pl_allsd[i])) {
  1262. pl_GM_level = pc_isGM(pl_sd);
  1263. 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
  1264. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1265. for (j = 0; player_name[j]; j++)
  1266. player_name[j] = tolower(player_name[j]);
  1267. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1268. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1269. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1270. } else {
  1271. atcmd_output[0]=0;
  1272. }
  1273. //Player name
  1274. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1275. strcat(atcmd_output,temp0);
  1276. //Player title, if exists
  1277. if (pl_GM_level > 0) {
  1278. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1279. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1280. strcat(atcmd_output,temp0);
  1281. }
  1282. //Players Location: map x y
  1283. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1284. strcat(atcmd_output,temp0);
  1285. clif_displaymessage(fd, atcmd_output);
  1286. count++;
  1287. }
  1288. }
  1289. }
  1290. }
  1291. if (count == 0)
  1292. clif_displaymessage(fd, msg_table[28]); // No player found.
  1293. else if (count == 1)
  1294. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1295. else {
  1296. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1297. clif_displaymessage(fd, atcmd_output);
  1298. }
  1299. return 0;
  1300. }
  1301. /*==========================================
  1302. * Player name, BLevel, Job,
  1303. *------------------------------------------
  1304. */
  1305. int atcommand_who2(
  1306. const int fd, struct map_session_data* sd,
  1307. const char* command, const char* message)
  1308. {
  1309. char temp0[100];
  1310. struct map_session_data *pl_sd, **pl_allsd;
  1311. int i, j, count, users;
  1312. int pl_GM_level, GM_level;
  1313. char match_text[100];
  1314. char player_name[NAME_LENGTH];
  1315. nullpo_retr(-1, sd);
  1316. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1317. memset(match_text, '\0', sizeof(match_text));
  1318. memset(player_name, '\0', sizeof(player_name));
  1319. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1320. strcpy(match_text, "");
  1321. for (j = 0; match_text[j]; j++)
  1322. match_text[j] = tolower(match_text[j]);
  1323. count = 0;
  1324. GM_level = pc_isGM(sd);
  1325. pl_allsd = map_getallusers(&users);
  1326. for (i = 0; i < users; i++) {
  1327. if ((pl_sd = pl_allsd[i])) {
  1328. pl_GM_level = pc_isGM(pl_sd);
  1329. 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
  1330. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1331. for (j = 0; player_name[j]; j++)
  1332. player_name[j] = tolower(player_name[j]);
  1333. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1334. //Players Name
  1335. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1336. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1337. //Player title, if exists
  1338. if (pl_GM_level > 0) {
  1339. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1340. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1341. strcat(atcmd_output,temp0);
  1342. }
  1343. //Players Base Level / Job name
  1344. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1345. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1346. strcat(atcmd_output,temp0);
  1347. clif_displaymessage(fd, atcmd_output);
  1348. count++;
  1349. }
  1350. }
  1351. }
  1352. }
  1353. if (count == 0)
  1354. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1355. else if (count == 1)
  1356. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1357. else {
  1358. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1359. clif_displaymessage(fd, atcmd_output);
  1360. }
  1361. return 0;
  1362. }
  1363. /*==========================================
  1364. * Player name, Playrs Party / Guild name
  1365. *------------------------------------------
  1366. */
  1367. int atcommand_who(
  1368. const int fd, struct map_session_data* sd,
  1369. const char* command, const char* message)
  1370. {
  1371. char temp0[100];
  1372. struct map_session_data *pl_sd, **pl_allsd;
  1373. int i, j, count, users;
  1374. int pl_GM_level, GM_level;
  1375. char match_text[100];
  1376. char player_name[NAME_LENGTH];
  1377. struct guild *g;
  1378. struct party *p;
  1379. nullpo_retr(-1, sd);
  1380. memset(temp0, '\0', sizeof(temp0));
  1381. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1382. memset(match_text, '\0', sizeof(match_text));
  1383. memset(player_name, '\0', sizeof(player_name));
  1384. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1385. strcpy(match_text, "");
  1386. for (j = 0; match_text[j]; j++)
  1387. match_text[j] = tolower(match_text[j]);
  1388. count = 0;
  1389. GM_level = pc_isGM(sd);
  1390. pl_allsd = map_getallusers(&users);
  1391. for (i = 0; i < users; i++) {
  1392. if ((pl_sd = pl_allsd[i])) {
  1393. pl_GM_level = pc_isGM(pl_sd);
  1394. 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
  1395. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1396. for (j = 0; player_name[j]; j++)
  1397. player_name[j] = tolower(player_name[j]);
  1398. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1399. g = guild_search(pl_sd->status.guild_id);
  1400. p = party_search(pl_sd->status.party_id);
  1401. //Players Name
  1402. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1403. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1404. //Player title, if exists
  1405. if (pl_GM_level > 0) {
  1406. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1407. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1408. strcat(atcmd_output,temp0);
  1409. }
  1410. //Players Party if exists
  1411. if (p != NULL) {
  1412. //sprintf(temp0," | Party: '%s'", p->name);
  1413. sprintf(temp0, msg_txt(335), p->name);
  1414. strcat(atcmd_output,temp0);
  1415. }
  1416. //Players Guild if exists
  1417. if (g != NULL) {
  1418. //sprintf(temp0," | Guild: '%s'", g->name);
  1419. sprintf(temp0, msg_txt(336), g->name);
  1420. strcat(atcmd_output,temp0);
  1421. }
  1422. clif_displaymessage(fd, atcmd_output);
  1423. count++;
  1424. }
  1425. }
  1426. }
  1427. }
  1428. if (count == 0)
  1429. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1430. else if (count == 1)
  1431. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1432. else {
  1433. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1434. clif_displaymessage(fd, atcmd_output);
  1435. }
  1436. return 0;
  1437. }
  1438. /*==========================================
  1439. *
  1440. *------------------------------------------
  1441. */
  1442. int atcommand_whomap3(
  1443. const int fd, struct map_session_data* sd,
  1444. const char* command, const char* message)
  1445. {
  1446. struct map_session_data *pl_sd, **pl_allsd;
  1447. int i, count, users;
  1448. int pl_GM_level, GM_level;
  1449. int map_id;
  1450. char map_name[MAP_NAME_LENGTH];
  1451. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1452. memset(map_name, '\0', sizeof(map_name));
  1453. if (!message || !*message)
  1454. map_id = sd->bl.m;
  1455. else {
  1456. sscanf(message, "%15s", map_name);
  1457. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1458. strcat(map_name, ".gat");
  1459. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1460. map_id = sd->bl.m;
  1461. }
  1462. count = 0;
  1463. GM_level = pc_isGM(sd);
  1464. pl_allsd = map_getallusers(&users);
  1465. for (i = 0; i < users; i++) {
  1466. if ((pl_sd = pl_allsd[i])) {
  1467. pl_GM_level = pc_isGM(pl_sd);
  1468. 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
  1469. if (pl_sd->bl.m == map_id) {
  1470. if (pl_GM_level > 0)
  1471. 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);
  1472. else
  1473. 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);
  1474. clif_displaymessage(fd, atcmd_output);
  1475. count++;
  1476. }
  1477. }
  1478. }
  1479. }
  1480. if (count == 0)
  1481. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1482. else if (count == 1)
  1483. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1484. else {
  1485. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1486. }
  1487. clif_displaymessage(fd, atcmd_output);
  1488. return 0;
  1489. }
  1490. /*==========================================
  1491. *
  1492. *------------------------------------------
  1493. */
  1494. int atcommand_whomap2(
  1495. const int fd, struct map_session_data* sd,
  1496. const char* command, const char* message)
  1497. {
  1498. struct map_session_data *pl_sd, **pl_allsd;
  1499. int i, count, users;
  1500. int pl_GM_level, GM_level;
  1501. int map_id = 0;
  1502. char map_name[MAP_NAME_LENGTH];
  1503. nullpo_retr(-1, sd);
  1504. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1505. memset(map_name, '\0', sizeof(map_name));
  1506. if (!message || !*message)
  1507. map_id = sd->bl.m;
  1508. else {
  1509. sscanf(message, "%15s", map_name);
  1510. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1511. strcat(map_name, ".gat");
  1512. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1513. map_id = sd->bl.m;
  1514. }
  1515. count = 0;
  1516. GM_level = pc_isGM(sd);
  1517. pl_allsd = map_getallusers(&users);
  1518. for (i = 0; i < users; i++) {
  1519. if ((pl_sd = pl_allsd[i])) {
  1520. pl_GM_level = pc_isGM(pl_sd);
  1521. 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
  1522. if (pl_sd->bl.m == map_id) {
  1523. if (pl_GM_level > 0)
  1524. 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);
  1525. else
  1526. 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);
  1527. clif_displaymessage(fd, atcmd_output);
  1528. count++;
  1529. }
  1530. }
  1531. }
  1532. }
  1533. if (count == 0)
  1534. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1535. else if (count == 1)
  1536. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1537. else {
  1538. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1539. }
  1540. clif_displaymessage(fd, atcmd_output);
  1541. return 0;
  1542. }
  1543. /*==========================================
  1544. *
  1545. *------------------------------------------
  1546. */
  1547. int atcommand_whomap(
  1548. const int fd, struct map_session_data* sd,
  1549. const char* command, const char* message)
  1550. {
  1551. char temp0[100];
  1552. char temp1[100];
  1553. struct map_session_data *pl_sd, **pl_allsd;
  1554. int i, count, users;
  1555. int pl_GM_level, GM_level;
  1556. int map_id = 0;
  1557. char map_name[MAP_NAME_LENGTH];
  1558. struct guild *g;
  1559. struct party *p;
  1560. nullpo_retr(-1, sd);
  1561. memset(temp0, '\0', sizeof(temp0));
  1562. memset(temp1, '\0', sizeof(temp1));
  1563. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1564. memset(map_name, '\0', sizeof(map_name));
  1565. if (!message || !*message)
  1566. map_id = sd->bl.m;
  1567. else {
  1568. sscanf(message, "%15s", map_name);
  1569. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1570. strcat(map_name, ".gat");
  1571. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1572. map_id = sd->bl.m;
  1573. }
  1574. count = 0;
  1575. GM_level = pc_isGM(sd);
  1576. pl_allsd = map_getallusers(&users);
  1577. for (i = 0; i < users; i++) {
  1578. if ((pl_sd = pl_allsd[i])) {
  1579. pl_GM_level = pc_isGM(pl_sd);
  1580. 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
  1581. if (pl_sd->bl.m == map_id) {
  1582. g = guild_search(pl_sd->status.guild_id);
  1583. if (g == NULL)
  1584. sprintf(temp1, "None");
  1585. else
  1586. sprintf(temp1, "%s", g->name);
  1587. p = party_search(pl_sd->status.party_id);
  1588. if (p == NULL)
  1589. sprintf(temp0, "None");
  1590. else
  1591. sprintf(temp0, "%s", p->name);
  1592. if (pl_GM_level > 0)
  1593. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1594. else
  1595. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1596. clif_displaymessage(fd, atcmd_output);
  1597. count++;
  1598. }
  1599. }
  1600. }
  1601. }
  1602. if (count == 0)
  1603. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1604. else if (count == 1)
  1605. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1606. else {
  1607. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1608. }
  1609. clif_displaymessage(fd, atcmd_output);
  1610. return 0;
  1611. }
  1612. /*==========================================
  1613. *
  1614. *------------------------------------------
  1615. */
  1616. int atcommand_whogm(
  1617. const int fd, struct map_session_data* sd,
  1618. const char* command, const char* message)
  1619. {
  1620. char temp0[100];
  1621. char temp1[100];
  1622. struct map_session_data *pl_sd, **pl_allsd;
  1623. int i, j, count, users;
  1624. int pl_GM_level, GM_level;
  1625. char match_text[100];
  1626. char player_name[NAME_LENGTH];
  1627. struct guild *g;
  1628. struct party *p;
  1629. nullpo_retr(-1, sd);
  1630. memset(temp0, '\0', sizeof(temp0));
  1631. memset(temp1, '\0', sizeof(temp1));
  1632. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1633. memset(match_text, '\0', sizeof(match_text));
  1634. memset(player_name, '\0', sizeof(player_name));
  1635. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1636. strcpy(match_text, "");
  1637. for (j = 0; match_text[j]; j++)
  1638. match_text[j] = tolower(match_text[j]);
  1639. count = 0;
  1640. GM_level = pc_isGM(sd);
  1641. pl_allsd = map_getallusers(&users);
  1642. for (i = 0; i < users; i++) {
  1643. if ((pl_sd = pl_allsd[i])) {
  1644. pl_GM_level = pc_isGM(pl_sd);
  1645. if (pl_GM_level > 0) {
  1646. 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
  1647. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1648. for (j = 0; player_name[j]; j++)
  1649. player_name[j] = tolower(player_name[j]);
  1650. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1651. 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);
  1652. clif_displaymessage(fd, atcmd_output);
  1653. 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);
  1654. clif_displaymessage(fd, atcmd_output);
  1655. g = guild_search(pl_sd->status.guild_id);
  1656. if (g == NULL)
  1657. sprintf(temp1, "None");
  1658. else
  1659. sprintf(temp1, "%s", g->name);
  1660. p = party_search(pl_sd->status.party_id);
  1661. if (p == NULL)
  1662. sprintf(temp0, "None");
  1663. else
  1664. sprintf(temp0, "%s", p->name);
  1665. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1666. clif_displaymessage(fd, atcmd_output);
  1667. count++;
  1668. }
  1669. }
  1670. }
  1671. }
  1672. }
  1673. if (count == 0)
  1674. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1675. else if (count == 1)
  1676. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1677. else {
  1678. sprintf(atcmd_output, msg_table[152], count); // %d GMs found.
  1679. clif_displaymessage(fd, atcmd_output);
  1680. }
  1681. return 0;
  1682. }
  1683. int atcommand_whozeny(
  1684. const int fd, struct map_session_data* sd,
  1685. const char* command, const char* message)
  1686. {
  1687. struct map_session_data *pl_sd, **pl_allsd;
  1688. int i, j, count,c, users;
  1689. char match_text[100];
  1690. char player_name[NAME_LENGTH];
  1691. int *zeny;
  1692. int *counted;
  1693. nullpo_retr(-1, sd);
  1694. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1695. memset(match_text, '\0', sizeof(match_text));
  1696. memset(player_name, '\0', sizeof(player_name));
  1697. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1698. strcpy(match_text, "");
  1699. for (j = 0; match_text[j]; j++)
  1700. match_text[j] = tolower(match_text[j]);
  1701. count = 0;
  1702. pl_allsd = map_getallusers(&users);
  1703. if (users < 1)
  1704. {
  1705. clif_displaymessage(fd, msg_table[28]); // No player found.
  1706. return 0;
  1707. }
  1708. zeny = (int *)aCallocA(users, sizeof(int));
  1709. counted = (int *)aCallocA(users, sizeof(int));
  1710. for (i = 0; i < users; i++) {
  1711. if ((pl_sd = pl_allsd[i])) {
  1712. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1713. for (j = 0; player_name[j]; j++)
  1714. player_name[j] = tolower(player_name[j]);
  1715. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1716. zeny[count]=pl_sd->status.zeny;
  1717. counted[i]=0;
  1718. count++;
  1719. }
  1720. }
  1721. }
  1722. qsort(zeny, count, sizeof(int), hightolow_compare);
  1723. for (c = 0; c < count && c < 50; c++) {
  1724. if(!zeny[c])
  1725. continue;
  1726. for (i = 0; i < users; i++) {
  1727. if(!zeny[c])
  1728. continue;
  1729. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1730. if(pl_sd->status.zeny==zeny[c]) {
  1731. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1732. clif_displaymessage(fd, atcmd_output);
  1733. zeny[c]=0;
  1734. counted[i]=1;
  1735. }
  1736. }
  1737. }
  1738. }
  1739. if (count == 0)
  1740. clif_displaymessage(fd, msg_table[28]); // No player found.
  1741. else if (count == 1)
  1742. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1743. else {
  1744. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1745. clif_displaymessage(fd, atcmd_output);
  1746. }
  1747. aFree(zeny);
  1748. aFree(counted);
  1749. return 0;
  1750. }
  1751. // cause random emote on all online players [Valaris]
  1752. int atcommand_happyhappyjoyjoy(
  1753. const int fd, struct map_session_data* sd,
  1754. const char* command, const char* message)
  1755. {
  1756. struct map_session_data *pl_sd, **pl_allsd;
  1757. int i,e, users;
  1758. nullpo_retr(-1, sd);
  1759. pl_allsd = map_getallusers(&users);
  1760. for (i = 0; i < users; i++) {
  1761. if ((pl_sd = pl_allsd[i])) {
  1762. e=rand()%40;
  1763. if(e==34)
  1764. e = 0;
  1765. clif_emotion(&pl_sd->bl,e);
  1766. }
  1767. }
  1768. return 0;
  1769. }
  1770. /*==========================================
  1771. *
  1772. *------------------------------------------
  1773. */
  1774. int atcommand_save(
  1775. const int fd, struct map_session_data* sd,
  1776. const char* command, const char* message)
  1777. {
  1778. nullpo_retr(-1, sd);
  1779. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1780. if (sd->status.pet_id > 0 && sd->pd)
  1781. intif_save_petdata(sd->status.account_id, &sd->pet);
  1782. chrif_save(sd,0);
  1783. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1784. return 0;
  1785. }
  1786. /*==========================================
  1787. *
  1788. *------------------------------------------
  1789. */
  1790. int atcommand_load(
  1791. const int fd, struct map_session_data* sd,
  1792. const char* command, const char* message)
  1793. {
  1794. int m;
  1795. nullpo_retr(-1, sd);
  1796. m = map_mapindex2mapid(sd->status.save_point.map);
  1797. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1798. clif_displaymessage(fd, msg_table[249]);
  1799. return -1;
  1800. }
  1801. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1802. clif_displaymessage(fd, msg_table[248]);
  1803. return -1;
  1804. }
  1805. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1806. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1807. return 0;
  1808. }
  1809. /*==========================================
  1810. *
  1811. *------------------------------------------
  1812. */
  1813. int atcommand_speed(
  1814. const int fd, struct map_session_data* sd,
  1815. const char* command, const char* message)
  1816. {
  1817. int speed;
  1818. nullpo_retr(-1, sd);
  1819. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1820. if (!message || !*message) {
  1821. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1822. clif_displaymessage(fd, atcmd_output);
  1823. return -1;
  1824. }
  1825. speed = atoi(message);
  1826. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1827. sd->speed = speed;
  1828. //sd->walktimer = x;
  1829. //この文を追加 by れ�
  1830. clif_updatestatus(sd, SP_SPEED);
  1831. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1832. } else {
  1833. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1834. clif_displaymessage(fd, atcmd_output);
  1835. return -1;
  1836. }
  1837. return 0;
  1838. }
  1839. /*==========================================
  1840. *
  1841. *------------------------------------------
  1842. */
  1843. int atcommand_storage(
  1844. const int fd, struct map_session_data* sd,
  1845. const char* command, const char* message)
  1846. {
  1847. struct storage *stor; //changes from Freya/Yor
  1848. nullpo_retr(-1, sd);
  1849. if (sd->state.storage_flag) {
  1850. clif_displaymessage(fd, msg_table[250]);
  1851. return -1;
  1852. }
  1853. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1854. clif_displaymessage(fd, msg_table[250]);
  1855. return -1;
  1856. }
  1857. storage_storageopen(sd);
  1858. return 0;
  1859. }
  1860. /*==========================================
  1861. *
  1862. *------------------------------------------
  1863. */
  1864. int atcommand_guildstorage(
  1865. const int fd, struct map_session_data* sd,
  1866. const char* command, const char* message)
  1867. {
  1868. struct storage *stor; //changes from Freya/Yor
  1869. nullpo_retr(-1, sd);
  1870. if (sd->status.guild_id > 0) {
  1871. if (sd->state.storage_flag) {
  1872. clif_displaymessage(fd, msg_table[251]);
  1873. return -1;
  1874. }
  1875. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1876. clif_displaymessage(fd, msg_table[251]);
  1877. return -1;
  1878. }
  1879. storage_guild_storageopen(sd);
  1880. } else {
  1881. clif_displaymessage(fd, msg_table[252]);
  1882. return -1;
  1883. }
  1884. return 0;
  1885. }
  1886. /*==========================================
  1887. *
  1888. *------------------------------------------
  1889. */
  1890. int atcommand_option(
  1891. const int fd, struct map_session_data* sd,
  1892. const char* command, const char* message)
  1893. {
  1894. int param1 = 0, param2 = 0, param3 = 0;
  1895. nullpo_retr(-1, sd);
  1896. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1897. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1898. return -1;
  1899. }
  1900. sd->sc.opt1 = param1;
  1901. sd->sc.opt2 = param2;
  1902. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1903. if (sd->status.class_ == JOB_BABY_MERCHANT)
  1904. clif_cart_itemlist(sd);
  1905. clif_cart_equiplist(sd);
  1906. clif_updatestatus(sd, SP_CARTINFO);
  1907. }
  1908. pc_setoption(sd, param3);
  1909. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1910. return 0;
  1911. }
  1912. /*==========================================
  1913. *
  1914. *------------------------------------------
  1915. */
  1916. int atcommand_hide(
  1917. const int fd, struct map_session_data* sd,
  1918. const char* command, const char* message)
  1919. {
  1920. nullpo_retr(-1, sd);
  1921. if (sd->sc.option & OPTION_INVISIBLE) {
  1922. sd->sc.option &= ~OPTION_INVISIBLE;
  1923. if (sd->disguise)
  1924. status_set_viewdata(&sd->bl, sd->disguise);
  1925. else
  1926. status_set_viewdata(&sd->bl, sd->status.class_);
  1927. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1928. } else {
  1929. sd->sc.option |= OPTION_INVISIBLE;
  1930. sd->vd.class_ = INVISIBLE_CLASS;
  1931. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1932. }
  1933. clif_changeoption(&sd->bl);
  1934. return 0;
  1935. }
  1936. /*==========================================
  1937. * 転職する upperを指定すると転生や養子にもなれる
  1938. *------------------------------------------
  1939. */
  1940. int atcommand_jobchange(
  1941. const int fd, struct map_session_data* sd,
  1942. const char* command, const char* message)
  1943. {
  1944. int job = 0, upper = 0;
  1945. nullpo_retr(-1, sd);
  1946. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1947. int i, found = 0;
  1948. const struct { char name[16]; int id; } jobs[] = {
  1949. { "novice", 0 },
  1950. { "swordsman", 1 },
  1951. { "mage", 2 },
  1952. { "archer", 3 },
  1953. { "acolyte", 4 },
  1954. { "merchant", 5 },
  1955. { "thief", 6 },
  1956. { "knight", 7 },
  1957. { "priest", 8 },
  1958. { "priestess", 8 },
  1959. { "wizard", 9 },
  1960. { "blacksmith", 10 },
  1961. { "hunter", 11 },
  1962. { "assassin", 12 },
  1963. { "crusader", 14 },
  1964. { "monk", 15 },
  1965. { "sage", 16 },
  1966. { "rogue", 17 },
  1967. { "alchemist", 18 },
  1968. { "bard", 19 },
  1969. { "dancer", 20 },
  1970. { "super novice", 23 },
  1971. { "supernovice", 23 },
  1972. { "gunslinger", 24 },
  1973. { "gunner", 24 },
  1974. { "ninja", 25 },
  1975. { "high novice", 4001 },
  1976. { "swordsman high", 4002 },
  1977. { "mage high", 4003 },
  1978. { "archer high", 4004 },
  1979. { "acolyte high", 4005 },
  1980. { "merchant high", 4006 },
  1981. { "thief high", 4007 },
  1982. { "lord knight", 4008 },
  1983. { "high priest", 4009 },
  1984. { "high priestess", 4009 },
  1985. { "high wizard", 4010 },
  1986. { "whitesmith", 4011 },
  1987. { "sniper", 4012 },
  1988. { "assassin cross", 4013 },
  1989. { "paladin", 4015 },
  1990. { "champion", 4016 },
  1991. { "professor", 4017 },
  1992. { "stalker", 4018 },
  1993. { "creator", 4019 },
  1994. { "clown", 4020 },
  1995. { "gypsy", 4021 },
  1996. { "baby novice", 4023 },
  1997. { "baby swordsman", 4024 },
  1998. { "baby mage", 4025 },
  1999. { "baby archer", 4026 },
  2000. { "baby acolyte", 4027 },
  2001. { "baby merchant", 4028 },
  2002. { "baby thief", 4029 },
  2003. { "baby knight", 4030 },
  2004. { "baby priest", 4031 },
  2005. { "baby priestess", 4031 },
  2006. { "baby wizard", 4032 },
  2007. { "baby blacksmith",4033 },
  2008. { "baby hunter", 4034 },
  2009. { "baby assassin", 4035 },
  2010. { "baby crusader", 4037 },
  2011. { "baby monk", 4038 },
  2012. { "baby sage", 4039 },
  2013. { "baby rogue", 4040 },
  2014. { "baby alchemist", 4041 },
  2015. { "baby bard", 4042 },
  2016. { "baby dancer", 4043 },
  2017. { "super baby", 4045 },
  2018. { "taekwon", 4046 },
  2019. { "taekwon boy", 4046 },
  2020. { "taekwon girl", 4046 },
  2021. { "star gladiator", 4047 },
  2022. { "soul linker", 4049 },
  2023. };
  2024. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2025. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2026. job = jobs[i].id;
  2027. upper = 0;
  2028. found = 1;
  2029. break;
  2030. }
  2031. }
  2032. if (!found) {
  2033. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2034. return -1;
  2035. }
  2036. }
  2037. if (job == 37 ||job == 45)
  2038. return 0;
  2039. if ((job >= 0 && job < MAX_PC_CLASS))
  2040. {
  2041. int j;
  2042. for (j=0; j < MAX_INVENTORY; j++) {
  2043. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2044. pc_unequipitem(sd, j, 3);
  2045. }
  2046. if (pc_jobchange(sd, job, upper) == 0)
  2047. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  2048. else {
  2049. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  2050. return -1;
  2051. }
  2052. } else {
  2053. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2054. return -1;
  2055. }
  2056. return 0;
  2057. }
  2058. /*==========================================
  2059. *
  2060. *------------------------------------------
  2061. */
  2062. int atcommand_die(
  2063. const int fd, struct map_session_data* sd,
  2064. const char* command, const char* message)
  2065. {
  2066. nullpo_retr(-1, sd);
  2067. clif_specialeffect(&sd->bl,450,1);
  2068. pc_damage(NULL, sd, sd->status.hp);
  2069. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  2070. return 0;
  2071. }
  2072. /*==========================================
  2073. *
  2074. *------------------------------------------
  2075. */
  2076. int atcommand_kill(
  2077. const int fd, struct map_session_data* sd,
  2078. const char* command, const char* message)
  2079. {
  2080. struct map_session_data *pl_sd;
  2081. nullpo_retr(-1, sd);
  2082. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2083. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2084. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2085. return -1;
  2086. }
  2087. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2088. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2089. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  2090. clif_displaymessage(fd, msg_table[14]); // Character killed.
  2091. } else {
  2092. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  2093. return -1;
  2094. }
  2095. } else {
  2096. clif_displaymessage(fd, msg_table[3]); // Character not found.
  2097. return -1;
  2098. }
  2099. return 0;
  2100. }
  2101. /*==========================================
  2102. *
  2103. *------------------------------------------
  2104. */
  2105. int atcommand_alive(
  2106. const int fd, struct map_session_data* sd,
  2107. const char* command, const char* message)
  2108. {
  2109. nullpo_retr(-1, sd);
  2110. if (pc_isdead(sd)) {
  2111. sd->status.hp = sd->status.max_hp;
  2112. sd->status.sp = sd->status.max_sp;
  2113. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2114. pc_setstand(sd);
  2115. if (battle_config.pc_invincible_time > 0)
  2116. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  2117. clif_updatestatus(sd, SP_HP);
  2118. clif_updatestatus(sd, SP_SP);
  2119. clif_resurrection(&sd->bl, 1);
  2120. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  2121. return 0;
  2122. }
  2123. return -1;
  2124. }
  2125. /*==========================================
  2126. * +kamic [LuzZza]
  2127. *------------------------------------------
  2128. */
  2129. int atcommand_kami(
  2130. const int fd, struct map_session_data* sd,
  2131. const char* command, const char* message)
  2132. {
  2133. unsigned long color=0;
  2134. nullpo_retr(-1, sd);
  2135. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2136. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2137. if (!message || !*message) {
  2138. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2139. return -1;
  2140. }
  2141. sscanf(message, "%199[^\n]", atcmd_output);
  2142. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2143. } else {
  2144. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2145. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2146. return -1;
  2147. }
  2148. if(color < 0 || color > 0xFFFFFF) {
  2149. clif_displaymessage(fd, "Invalid color.");
  2150. return -1;
  2151. }
  2152. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2153. }
  2154. return 0;
  2155. }
  2156. /*==========================================
  2157. *
  2158. *------------------------------------------
  2159. */
  2160. int atcommand_heal(
  2161. const int fd, struct map_session_data* sd,
  2162. const char* command, const char* message)
  2163. {
  2164. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2165. nullpo_retr(-1, sd);
  2166. sscanf(message, "%d %d", &hp, &sp);
  2167. if (hp == 0 && sp == 0) {
  2168. hp = sd->status.max_hp - sd->status.hp;
  2169. sp = sd->status.max_sp - sd->status.sp;
  2170. } else {
  2171. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2172. hp = sd->status.max_hp - sd->status.hp;
  2173. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2174. hp = 1 - sd->status.hp;
  2175. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2176. sp = sd->status.max_sp - sd->status.sp;
  2177. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2178. sp = 1 - sd->status.sp;
  2179. }
  2180. if (hp > 0) // display like heal
  2181. clif_heal(fd, SP_HP, hp);
  2182. else if (hp < 0) // display like damage
  2183. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2184. if (sp > 0) // no display when we lost SP
  2185. clif_heal(fd, SP_SP, sp);
  2186. if (hp != 0 || sp != 0) {
  2187. pc_heal(sd, hp, sp);
  2188. if (hp >= 0 && sp >= 0)
  2189. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2190. else
  2191. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2192. } else {
  2193. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2194. return -1;
  2195. }
  2196. return 0;
  2197. }
  2198. /*==========================================
  2199. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2200. *------------------------------------------
  2201. */
  2202. int atcommand_item(
  2203. const int fd, struct map_session_data* sd,
  2204. const char* command, const char* message)
  2205. {
  2206. char item_name[100];
  2207. int number = 0, item_id, flag;
  2208. struct item item_tmp;
  2209. struct item_data *item_data;
  2210. int get_count, i, pet_id;
  2211. nullpo_retr(-1, sd);
  2212. memset(item_name, '\0', sizeof(item_name));
  2213. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2214. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2215. return -1;
  2216. }
  2217. if (number <= 0)
  2218. number = 1;
  2219. item_id = 0;
  2220. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2221. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2222. item_id = item_data->nameid;
  2223. if (item_id >= 500) {
  2224. get_count = number;
  2225. // check pet egg
  2226. pet_id = search_petDB_index(item_id, PET_EGG);
  2227. if (item_data->type == 4 || item_data->type == 5 ||
  2228. item_data->type == 7 || item_data->type == 8) {
  2229. get_count = 1;
  2230. }
  2231. for (i = 0; i < number; i += get_count) {
  2232. // if pet egg
  2233. if (pet_id >= 0) {
  2234. sd->catch_target_class = pet_db[pet_id].class_;
  2235. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2236. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2237. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2238. 100, 0, 1, pet_db[pet_id].jname);
  2239. // if not pet egg
  2240. } else {
  2241. memset(&item_tmp, 0, sizeof(item_tmp));
  2242. item_tmp.nameid = item_id;
  2243. item_tmp.identify = 1;
  2244. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2245. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2246. }
  2247. }
  2248. //Logs (A)dmins items [Lupus]
  2249. if(log_config.pick > 0 ) {
  2250. log_pick(sd, "A", 0, item_id, number, NULL);
  2251. }
  2252. //Logs
  2253. clif_displaymessage(fd, msg_table[18]); // Item created.
  2254. } else {
  2255. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2256. return -1;
  2257. }
  2258. return 0;
  2259. }
  2260. /*==========================================
  2261. *
  2262. *------------------------------------------
  2263. */
  2264. int atcommand_item2(
  2265. const int fd, struct map_session_data* sd,
  2266. const char* command, const char* message)
  2267. {
  2268. struct item item_tmp;
  2269. struct item_data *item_data;
  2270. char item_name[100];
  2271. int item_id, number = 0;
  2272. int identify = 0, refine = 0, attr = 0;
  2273. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2274. int flag;
  2275. int loop, get_count, i;
  2276. nullpo_retr(-1, sd);
  2277. memset(item_name, '\0', sizeof(item_name));
  2278. 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) {
  2279. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2280. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2281. return -1;
  2282. }
  2283. if (number <= 0)
  2284. number = 1;
  2285. item_id = 0;
  2286. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2287. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2288. item_id = item_data->nameid;
  2289. if (item_id > 500) {
  2290. loop = 1;
  2291. get_count = number;
  2292. if (item_data->type == 4 || item_data->type == 5 ||
  2293. item_data->type == 7 || item_data->type == 8) {
  2294. loop = number;
  2295. get_count = 1;
  2296. if (item_data->type == 7) {
  2297. identify = 1;
  2298. refine = 0;
  2299. }
  2300. if (item_data->type == 8)
  2301. refine = 0;
  2302. if (refine > 10)
  2303. refine = 10;
  2304. } else {
  2305. identify = 1;
  2306. refine = attr = 0;
  2307. }
  2308. for (i = 0; i < loop; i++) {
  2309. memset(&item_tmp, 0, sizeof(item_tmp));
  2310. item_tmp.nameid = item_id;
  2311. item_tmp.identify = identify;
  2312. item_tmp.refine = refine;
  2313. item_tmp.attribute = attr;
  2314. item_tmp.card[0] = c1;
  2315. item_tmp.card[1] = c2;
  2316. item_tmp.card[2] = c3;
  2317. item_tmp.card[3] = c4;
  2318. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2319. clif_additem(sd, 0, 0, flag);
  2320. }
  2321. //Logs (A)dmins items [Lupus]
  2322. if(log_config.pick > 0 ) {
  2323. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2324. }
  2325. //Logs
  2326. clif_displaymessage(fd, msg_table[18]); // Item created.
  2327. } else {
  2328. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2329. return -1;
  2330. }
  2331. return 0;
  2332. }
  2333. /*==========================================
  2334. *
  2335. *------------------------------------------
  2336. */
  2337. int atcommand_itemreset(
  2338. const int fd, struct map_session_data* sd,
  2339. const char* command, const char* message)
  2340. {
  2341. int i;
  2342. nullpo_retr(-1, sd);
  2343. for (i = 0; i < MAX_INVENTORY; i++) {
  2344. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2345. //Logs (A)dmins items [Lupus]
  2346. if(log_config.pick > 0 ) {
  2347. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2348. }
  2349. //Logs
  2350. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2351. }
  2352. }
  2353. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2354. return 0;
  2355. }
  2356. /*==========================================
  2357. *
  2358. *------------------------------------------
  2359. */
  2360. int atcommand_itemcheck(
  2361. const int fd, struct map_session_data* sd,
  2362. const char* command, const char* message)
  2363. {
  2364. nullpo_retr(-1, sd);
  2365. pc_checkitem(sd);
  2366. return 0;
  2367. }
  2368. /*==========================================
  2369. * Atcommand @lvlup
  2370. *------------------------------------------
  2371. */
  2372. int atcommand_baselevelup(
  2373. const int fd, struct map_session_data* sd,
  2374. const char* command, const char* message)
  2375. {
  2376. int level=0, i=0, status_point=0;
  2377. nullpo_retr(-1, sd);
  2378. level = atoi(message);
  2379. if (!message || !*message || !level) {
  2380. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2381. return -1;
  2382. }
  2383. if (level > 0) {
  2384. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2385. clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
  2386. return -1;
  2387. } /* End Addition */
  2388. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2389. level = pc_maxbaselv(sd) - sd->status.base_level;
  2390. for (i = 1; i <= level; i++)
  2391. status_point += (sd->status.base_level + i + 14) / 5;
  2392. if (sd->status.status_point > USHRT_MAX - status_point)
  2393. sd->status.status_point = USHRT_MAX;
  2394. else
  2395. sd->status.status_point += status_point;
  2396. sd->status.base_level += (unsigned int)level;
  2397. clif_updatestatus(sd, SP_BASELEVEL);
  2398. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2399. clif_updatestatus(sd, SP_STATUSPOINT);
  2400. status_calc_pc(sd, 0);
  2401. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2402. clif_misceffect(&sd->bl, 0);
  2403. clif_displaymessage(fd, msg_table[21]); /* Base level raised. */
  2404. } else {
  2405. if (sd->status.base_level == 1) {
  2406. clif_displaymessage(fd, msg_table[158]); /* Base level can't go any lower. */
  2407. return -1;
  2408. }
  2409. level*=-1;
  2410. if ((unsigned int)level >= sd->status.base_level)
  2411. level = sd->status.base_level-1;
  2412. if (sd->status.status_point > 0) {
  2413. for (i = 0; i > -level; i--)
  2414. status_point -= (sd->status.base_level + i + 14) / 5;
  2415. if (sd->status.status_point < status_point)
  2416. sd->status.status_point = 0;
  2417. else
  2418. sd->status.status_point -= status_point;
  2419. clif_updatestatus(sd, SP_STATUSPOINT);
  2420. } /* to add: remove status points from stats */
  2421. sd->status.base_level -= (unsigned int)level;
  2422. clif_updatestatus(sd, SP_BASELEVEL);
  2423. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2424. status_calc_pc(sd, 0);
  2425. clif_displaymessage(fd, msg_table[22]); /* Base level lowered. */
  2426. }
  2427. return 0;
  2428. }
  2429. /*==========================================
  2430. *
  2431. *------------------------------------------
  2432. */
  2433. int atcommand_joblevelup(
  2434. const int fd, struct map_session_data* sd,
  2435. const char* command, const char* message)
  2436. {
  2437. int level=0;
  2438. nullpo_retr(-1, sd);
  2439. level = atoi(message);
  2440. if (!message || !*message || !level) {
  2441. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2442. return -1;
  2443. }
  2444. if (level > 0) {
  2445. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2446. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2447. return -1;
  2448. }
  2449. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2450. level = pc_maxjoblv(sd) - sd->status.job_level;
  2451. sd->status.job_level += (unsigned int)level;
  2452. clif_updatestatus(sd, SP_JOBLEVEL);
  2453. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2454. if (sd->status.skill_point > USHRT_MAX - level)
  2455. sd->status.skill_point = USHRT_MAX;
  2456. else
  2457. sd->status.skill_point += level;
  2458. clif_updatestatus(sd, SP_SKILLPOINT);
  2459. status_calc_pc(sd, 0);
  2460. clif_misceffect(&sd->bl, 1);
  2461. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2462. } else {
  2463. if (sd->status.job_level == 1) {
  2464. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2465. return -1;
  2466. }
  2467. level *=-1;
  2468. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2469. level = sd->status.job_level-1;
  2470. sd->status.job_level -= (unsigned int)level;
  2471. clif_updatestatus(sd, SP_JOBLEVEL);
  2472. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2473. if (sd->status.skill_point < level)
  2474. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2475. if (sd->status.skill_point < level)
  2476. sd->status.skill_point = 0;
  2477. else
  2478. sd->status.skill_point -= level;
  2479. clif_updatestatus(sd, SP_SKILLPOINT);
  2480. status_calc_pc(sd, 0);
  2481. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2482. }
  2483. return 0;
  2484. }
  2485. /*==========================================
  2486. * @help
  2487. *------------------------------------------
  2488. */
  2489. int atcommand_help(
  2490. const int fd, struct map_session_data* sd,
  2491. const char* command, const char* message)
  2492. {
  2493. char buf[2048], w1[2048], w2[2048];
  2494. int i, gm_level;
  2495. FILE* fp;
  2496. nullpo_retr(-1, sd);
  2497. memset(buf, '\0', sizeof(buf));
  2498. if ((fp = fopen(help_txt, "r")) != NULL) {
  2499. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2500. gm_level = pc_isGM(sd);
  2501. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2502. if (buf[0] == '/' && buf[1] == '/')
  2503. continue;
  2504. for (i = 0; buf[i] != '\0'; i++) {
  2505. if (buf[i] == '\r' || buf[i] == '\n') {
  2506. buf[i] = '\0';
  2507. break;
  2508. }
  2509. }
  2510. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2511. clif_displaymessage(fd, buf);
  2512. else if (gm_level >= atoi(w1))
  2513. clif_displaymessage(fd, w2);
  2514. }
  2515. fclose(fp);
  2516. } else {
  2517. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2518. return -1;
  2519. }
  2520. return 0;
  2521. }
  2522. /*==========================================
  2523. * @help2 - Char commands [Kayla]
  2524. *------------------------------------------
  2525. */
  2526. int atcommand_help2(
  2527. const int fd, struct map_session_data* sd,
  2528. const char* command, const char* message)
  2529. {
  2530. char buf[2048], w1[2048], w2[2048];
  2531. int i, gm_level;
  2532. FILE* fp;
  2533. nullpo_retr(-1, sd);
  2534. memset(buf, '\0', sizeof(buf));
  2535. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2536. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2537. gm_level = pc_isGM(sd);
  2538. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2539. if (buf[0] == '/' && buf[1] == '/')
  2540. continue;
  2541. for (i = 0; buf[i] != '\0'; i++) {
  2542. if (buf[i] == '\r' || buf[i] == '\n') {
  2543. buf[i] = '\0';
  2544. break;
  2545. }
  2546. }
  2547. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2548. clif_displaymessage(fd, buf);
  2549. else if (gm_level >= atoi(w1))
  2550. clif_displaymessage(fd, w2);
  2551. }
  2552. fclose(fp);
  2553. } else {
  2554. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2555. return -1;
  2556. }
  2557. return 0;
  2558. }
  2559. /*==========================================
  2560. * @gm
  2561. *------------------------------------------
  2562. */
  2563. int atcommand_gm(
  2564. const int fd, struct map_session_data* sd,
  2565. const char* command, const char* message)
  2566. {
  2567. char password[100];
  2568. nullpo_retr(-1, sd);
  2569. memset(password, '\0', sizeof(password));
  2570. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2571. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2572. return -1;
  2573. }
  2574. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2575. clif_displaymessage(fd, msg_table[50]); /* You already have some GM powers. */
  2576. return -1;
  2577. } else
  2578. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2579. return 0;
  2580. }
  2581. /*==========================================
  2582. *
  2583. *------------------------------------------
  2584. */
  2585. int atcommand_pvpoff(
  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) {
  2597. map[sd->bl.m].flag.pvp = 0;
  2598. clif_send0199(sd->bl.m, 0);
  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) {
  2602. clif_pvpset(pl_sd, 0, 0, 2);
  2603. if (pl_sd->pvp_timer != -1) {
  2604. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2605. pl_sd->pvp_timer = -1;
  2606. }
  2607. }
  2608. }
  2609. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2610. } else {
  2611. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2612. return -1;
  2613. }
  2614. return 0;
  2615. }
  2616. /*==========================================
  2617. *
  2618. *------------------------------------------
  2619. */
  2620. int atcommand_pvpon(
  2621. const int fd, struct map_session_data* sd,
  2622. const char* command, const char* message)
  2623. {
  2624. struct map_session_data *pl_sd, **pl_allsd;
  2625. int i, users;
  2626. nullpo_retr(-1, sd);
  2627. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2628. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2629. return -1;
  2630. }
  2631. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2632. map[sd->bl.m].flag.pvp = 1;
  2633. clif_send0199(sd->bl.m, 1);
  2634. pl_allsd = map_getallusers(&users);
  2635. for (i = 0; i < users; i++) {
  2636. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2637. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2638. pl_sd->pvp_rank = 0;
  2639. pl_sd->pvp_lastusers = 0;
  2640. pl_sd->pvp_point = 5;
  2641. pl_sd->pvp_won = 0;
  2642. pl_sd->pvp_lost = 0;
  2643. }
  2644. }
  2645. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2646. } else {
  2647. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2648. return -1;
  2649. }
  2650. return 0;
  2651. }
  2652. /*==========================================
  2653. *
  2654. *------------------------------------------
  2655. */
  2656. int atcommand_gvgoff(
  2657. const int fd, struct map_session_data* sd,
  2658. const char* command, const char* message)
  2659. {
  2660. nullpo_retr(-1, sd);
  2661. if (map[sd->bl.m].flag.gvg) {
  2662. map[sd->bl.m].flag.gvg = 0;
  2663. clif_send0199(sd->bl.m, 0);
  2664. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2665. } else {
  2666. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2667. return -1;
  2668. }
  2669. return 0;
  2670. }
  2671. /*==========================================
  2672. *
  2673. *------------------------------------------
  2674. */
  2675. int atcommand_gvgon(
  2676. const int fd, struct map_session_data* sd,
  2677. const char* command, const char* message)
  2678. {
  2679. nullpo_retr(-1, sd);
  2680. if (!map[sd->bl.m].flag.gvg) {
  2681. map[sd->bl.m].flag.gvg = 1;
  2682. clif_send0199(sd->bl.m, 3);
  2683. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2684. } else {
  2685. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2686. return -1;
  2687. }
  2688. return 0;
  2689. }
  2690. /*==========================================
  2691. *
  2692. *------------------------------------------
  2693. */
  2694. int atcommand_model(
  2695. const int fd, struct map_session_data* sd,
  2696. const char* command, const char* message)
  2697. {
  2698. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2699. nullpo_retr(-1, sd);
  2700. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2701. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2702. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2703. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2704. clif_displaymessage(fd, atcmd_output);
  2705. return -1;
  2706. }
  2707. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2708. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2709. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2710. /* Removed because this check is TOO strange. [Skotlex]
  2711. //秒フ色変更
  2712. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2713. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2714. //秒フ色未実装職の判定
  2715. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2716. return -1;
  2717. } else {
  2718. */
  2719. pc_changelook(sd, LOOK_HAIR, hair_style);
  2720. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2721. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2722. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2723. // }
  2724. } else {
  2725. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2726. return -1;
  2727. }
  2728. return 0;
  2729. }
  2730. /*==========================================
  2731. * @dye && @ccolor
  2732. *------------------------------------------
  2733. */
  2734. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2735. {
  2736. int cloth_color = 0;
  2737. nullpo_retr(-1, sd);
  2738. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2739. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2740. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2741. clif_displaymessage(fd, atcmd_output);
  2742. return -1;
  2743. }
  2744. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2745. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2746. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2747. } else {
  2748. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2749. return -1;
  2750. }
  2751. return 0;
  2752. }
  2753. /*==========================================
  2754. * @hairstyle && @hstyle
  2755. *------------------------------------------
  2756. */
  2757. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2758. {
  2759. int hair_style = 0;
  2760. nullpo_retr(-1, sd);
  2761. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2762. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2763. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2764. clif_displaymessage(fd, atcmd_output);
  2765. return -1;
  2766. }
  2767. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2768. /* Removed because this check is TOO strange. [Skotlex]
  2769. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2770. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2771. return -1;
  2772. } else {
  2773. */
  2774. pc_changelook(sd, LOOK_HAIR, hair_style);
  2775. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2776. // }
  2777. } else {
  2778. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2779. return -1;
  2780. }
  2781. return 0;
  2782. }
  2783. /*==========================================
  2784. * @charhairstyle by [MouseJstr]
  2785. *------------------------------------------
  2786. */
  2787. int
  2788. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2789. const char* command, const char* message)
  2790. {
  2791. nullpo_retr(-1, sd);
  2792. return 0;
  2793. }
  2794. /*==========================================
  2795. * @haircolor && @hcolor
  2796. *------------------------------------------
  2797. */
  2798. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2799. {
  2800. int hair_color = 0;
  2801. nullpo_retr(-1, sd);
  2802. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2803. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2804. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2805. clif_displaymessage(fd, atcmd_output);
  2806. return -1;
  2807. }
  2808. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2809. /* Removed for being such a strange check. [Skotlex]
  2810. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2811. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2812. return -1;
  2813. } else {
  2814. */
  2815. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2816. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2817. // }
  2818. } else {
  2819. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2820. return -1;
  2821. }
  2822. return 0;
  2823. }
  2824. /*==========================================
  2825. * @go [city_number or city_name] - Updated by Harbin
  2826. *------------------------------------------
  2827. */
  2828. int atcommand_go(
  2829. const int fd, struct map_session_data* sd,
  2830. const char* command, const char* message)
  2831. {
  2832. int i;
  2833. int town;
  2834. char map_name[MAP_NAME_LENGTH];
  2835. int m;
  2836. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2837. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2838. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2839. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2840. { MAP_PAYON, 162, 233 }, // 3=Payon
  2841. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2842. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2843. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2844. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2845. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2846. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2847. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2848. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2849. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2850. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2851. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2852. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2853. { MAP_JAIL, 23, 61 }, // 16=Prison
  2854. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2855. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2856. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2857. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2858. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2859. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2860. };
  2861. nullpo_retr(-1, sd);
  2862. if(map[sd->bl.m].flag.nogo) {
  2863. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2864. return 0;
  2865. }
  2866. memset(map_name, '\0', sizeof(map_name));
  2867. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2868. // get the number
  2869. town = atoi(message);
  2870. // if no value, display all value
  2871. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2872. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2873. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2874. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2875. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2876. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2877. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2878. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2879. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2880. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2881. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2882. return -1;
  2883. } else {
  2884. // get possible name of the city and add .gat if not in the name
  2885. map_name[MAP_NAME_LENGTH-1] = '\0';
  2886. for (i = 0; map_name[i]; i++)
  2887. map_name[i] = tolower(map_name[i]);
  2888. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2889. strcat(map_name, ".gat");
  2890. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2891. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2892. town = 0;
  2893. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2894. town = 1;
  2895. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2896. town = 2;
  2897. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2898. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2899. town = 3;
  2900. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2901. town = 4;
  2902. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2903. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2904. town = 5;
  2905. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2906. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2907. town = 6;
  2908. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2909. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2910. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2911. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2912. town = 7;
  2913. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2914. town = 8;
  2915. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2916. town = 9;
  2917. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2918. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2919. town = 10;
  2920. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2921. town = 11;
  2922. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2923. town = 12;
  2924. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2925. town = 13;
  2926. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2927. town = 14;
  2928. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2929. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2930. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2931. town = 15;
  2932. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2933. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2934. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2935. town = 16;
  2936. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2937. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2938. town = 17;
  2939. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2940. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2941. town = 18;
  2942. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  2943. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  2944. town = 19;
  2945. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2946. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2947. town = 20;
  2948. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  2949. town = 21;
  2950. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2951. town = 22;
  2952. }
  2953. if (town >= -3 && town <= -1) {
  2954. if (sd->status.memo_point[-town-1].map) {
  2955. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2956. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2957. clif_displaymessage(fd, msg_table[247]);
  2958. return -1;
  2959. }
  2960. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2961. clif_displaymessage(fd, msg_table[248]);
  2962. return -1;
  2963. }
  2964. 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) {
  2965. clif_displaymessage(fd, msg_table[0]); // Warped.
  2966. } else {
  2967. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2968. return -1;
  2969. }
  2970. } else {
  2971. sprintf(atcmd_output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2972. clif_displaymessage(fd, atcmd_output);
  2973. return -1;
  2974. }
  2975. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2976. m = map_mapname2mapid((char *)data[town].map);
  2977. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2978. clif_displaymessage(fd, msg_table[247]);
  2979. return -1;
  2980. }
  2981. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2982. clif_displaymessage(fd, msg_table[248]);
  2983. return -1;
  2984. }
  2985. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2986. clif_displaymessage(fd, msg_table[0]); // Warped.
  2987. } else {
  2988. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2989. return -1;
  2990. }
  2991. } else { // if you arrive here, you have an error in town variable when reading of names
  2992. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2993. return -1;
  2994. }
  2995. }
  2996. return 0;
  2997. }
  2998. /*==========================================
  2999. *
  3000. *------------------------------------------
  3001. */
  3002. int atcommand_monster(
  3003. const int fd, struct map_session_data* sd,
  3004. const char* command, const char* message)
  3005. {
  3006. char name[NAME_LENGTH];
  3007. char monster[NAME_LENGTH];
  3008. int mob_id;
  3009. int number = 0;
  3010. int x = 0, y = 0;
  3011. int count;
  3012. int i, j, k;
  3013. int mx, my, range;
  3014. nullpo_retr(-1, sd);
  3015. memset(name, '\0', sizeof(name));
  3016. memset(monster, '\0', sizeof(monster));
  3017. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3018. if (!message || !*message) {
  3019. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3020. return -1;
  3021. }
  3022. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) > 1 ||
  3023. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) > 1) {
  3024. //All data can be left as it is.
  3025. } else if ((count=sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y)) > 1) {
  3026. //Here, it is possible name was not given and we are using monster for it.
  3027. if (count < 3) //Blank mob's name.
  3028. name[0] = '\0';
  3029. } else if (sscanf(message, "%23s %23s %d %d %d", name, monster, &number, &x, &y) > 1) {
  3030. //All data can be left as it is.
  3031. } else if (sscanf(message, "%23s", monster) > 0) {
  3032. //As before, name may be already filled.
  3033. name[0] = '\0';
  3034. } else {
  3035. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3036. return -1;
  3037. }
  3038. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3039. mob_id = mobdb_checkid(atoi(monster));
  3040. if (mob_id == 0) {
  3041. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3042. return -1;
  3043. }
  3044. if (mob_id == MOBID_EMPERIUM) {
  3045. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  3046. return -1;
  3047. }
  3048. if (number <= 0)
  3049. number = 1;
  3050. if (strlen(name) < 1)
  3051. strcpy(name, "--ja--");
  3052. // 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
  3053. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3054. number = battle_config.atc_spawn_quantity_limit;
  3055. if (battle_config.etc_log)
  3056. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  3057. count = 0;
  3058. range = (int)sqrt(number) / 2;
  3059. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  3060. for (i = 0; i < number; i++) {
  3061. j = 0;
  3062. k = 0;
  3063. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  3064. if (x <= 0)
  3065. mx = sd->bl.x + (rand() % range - (range / 2));
  3066. else
  3067. mx = x;
  3068. if (y <= 0)
  3069. my = sd->bl.y + (rand() % range - (range / 2));
  3070. else
  3071. my = y;
  3072. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  3073. }
  3074. count += (k != 0) ? 1 : 0;
  3075. }
  3076. if (count != 0)
  3077. if (number == count)
  3078. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  3079. else {
  3080. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  3081. clif_displaymessage(fd, atcmd_output);
  3082. }
  3083. else {
  3084. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3085. return -1;
  3086. }
  3087. return 0;
  3088. }
  3089. // small monster spawning [Valaris]
  3090. int atcommand_monstersmall(
  3091. const int fd, struct map_session_data* sd,
  3092. const char* command, const char* message) {
  3093. char name[NAME_LENGTH] = "";
  3094. char monster[NAME_LENGTH] = "";
  3095. int mob_id = 0;
  3096. int number = 0;
  3097. int x = 0;
  3098. int y = 0;
  3099. int count;
  3100. int i;
  3101. nullpo_retr(-1, sd);
  3102. if (!message || !*message) {
  3103. clif_displaymessage(fd, "Give a monster name/id please.");
  3104. return -1;
  3105. }
  3106. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3107. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3108. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3109. clif_displaymessage(fd, "Give a monster name/id please.");
  3110. return -1;
  3111. }
  3112. // If monster identifier/name argument is a name
  3113. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3114. mob_id = atoi(monster);
  3115. if (mob_id == 0) {
  3116. clif_displaymessage(fd, msg_table[40]);
  3117. return -1;
  3118. }
  3119. if (mob_id == MOBID_EMPERIUM) {
  3120. clif_displaymessage(fd, msg_table[83]);
  3121. return -1;
  3122. }
  3123. if (mobdb_checkid(mob_id) == 0) {
  3124. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3125. return -1;
  3126. }
  3127. if (number <= 0)
  3128. number = 1;
  3129. if (strlen(name) < 1)
  3130. strcpy(name, "--ja--");
  3131. // 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
  3132. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3133. number = battle_config.atc_spawn_quantity_limit;
  3134. count = 0;
  3135. for (i = 0; i < number; i++) {
  3136. int mx, my;
  3137. if (x <= 0)
  3138. mx = sd->bl.x + (rand() % 11 - 5);
  3139. else
  3140. mx = x;
  3141. if (y <= 0)
  3142. my = sd->bl.y + (rand() % 11 - 5);
  3143. else
  3144. my = y;
  3145. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3146. }
  3147. if (count != 0)
  3148. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3149. else
  3150. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3151. return 0;
  3152. }
  3153. // big monster spawning [Valaris]
  3154. int atcommand_monsterbig(
  3155. const int fd, struct map_session_data* sd,
  3156. const char* command, const char* message) {
  3157. char name[NAME_LENGTH] = "";
  3158. char monster[NAME_LENGTH] = "";
  3159. int mob_id = 0;
  3160. int number = 0;
  3161. int x = 0;
  3162. int y = 0;
  3163. int count;
  3164. int i;
  3165. nullpo_retr(-1, sd);
  3166. if (!message || !*message) {
  3167. clif_displaymessage(fd, "Give a monster name/id please.");
  3168. return -1;
  3169. }
  3170. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3171. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3172. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3173. clif_displaymessage(fd, "Give a monster name/id please.");
  3174. return -1;
  3175. }
  3176. // If monster identifier/name argument is a name
  3177. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3178. mob_id = atoi(monster);
  3179. if (mob_id == 0) {
  3180. clif_displaymessage(fd, msg_table[40]);
  3181. return -1;
  3182. }
  3183. if (mob_id == MOBID_EMPERIUM) {
  3184. clif_displaymessage(fd, msg_table[83]);
  3185. return -1;
  3186. }
  3187. if (mobdb_checkid(mob_id) == 0) {
  3188. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3189. return -1;
  3190. }
  3191. if (number <= 0)
  3192. number = 1;
  3193. if (strlen(name) < 1)
  3194. strcpy(name, "--ja--");
  3195. // 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
  3196. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3197. number = battle_config.atc_spawn_quantity_limit;
  3198. count = 0;
  3199. for (i = 0; i < number; i++) {
  3200. int mx, my;
  3201. if (x <= 0)
  3202. mx = sd->bl.x + (rand() % 11 - 5);
  3203. else
  3204. mx = x;
  3205. if (y <= 0)
  3206. my = sd->bl.y + (rand() % 11 - 5);
  3207. else
  3208. my = y;
  3209. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2*MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3210. }
  3211. if (count != 0)
  3212. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3213. else
  3214. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3215. return 0;
  3216. }
  3217. /*==========================================
  3218. *
  3219. *------------------------------------------
  3220. */
  3221. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3222. struct mob_data *md;
  3223. int flag;
  3224. nullpo_retr(0, ap);
  3225. nullpo_retr(0, md=(struct mob_data *)bl);
  3226. flag = va_arg(ap, int);
  3227. if (md->guardian_data)
  3228. return 0; //Do not touch WoE mobs!
  3229. if (flag)
  3230. mob_damage(NULL, md, md->hp, 2);
  3231. else
  3232. unit_remove_map(&md->bl,1);
  3233. return 1;
  3234. }
  3235. void atcommand_killmonster_sub(
  3236. const int fd, struct map_session_data* sd, const char* message,
  3237. const int drop)
  3238. {
  3239. int map_id;
  3240. char map_name[MAP_NAME_LENGTH];
  3241. if (!sd) return;
  3242. memset(map_name, '\0', sizeof(map_name));
  3243. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3244. map_id = sd->bl.m;
  3245. else {
  3246. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3247. strcat(map_name, ".gat");
  3248. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3249. map_id = sd->bl.m;
  3250. }
  3251. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3252. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3253. return;
  3254. }
  3255. /*==========================================
  3256. *
  3257. *------------------------------------------
  3258. */
  3259. int atcommand_killmonster(
  3260. const int fd, struct map_session_data* sd,
  3261. const char* command, const char* message)
  3262. {
  3263. if (!sd) return 0;
  3264. atcommand_killmonster_sub(fd, sd, message, 1);
  3265. return 0;
  3266. }
  3267. /*==========================================
  3268. *
  3269. *------------------------------------------
  3270. */
  3271. int atcommand_killmonster2(
  3272. const int fd, struct map_session_data* sd,
  3273. const char* command, const char* message)
  3274. {
  3275. if (!sd) return 0;
  3276. atcommand_killmonster_sub(fd, sd, message, 0);
  3277. return 0;
  3278. }
  3279. /*==========================================
  3280. *
  3281. *------------------------------------------
  3282. */
  3283. int atcommand_refine(
  3284. const int fd, struct map_session_data* sd,
  3285. const char* command, const char* message)
  3286. {
  3287. int i, position = 0, refine = 0, current_position, final_refine;
  3288. int count;
  3289. nullpo_retr(-1, sd);
  3290. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3291. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3292. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3293. return -1;
  3294. }
  3295. if (refine < -10)
  3296. refine = -10;
  3297. else if (refine > 10)
  3298. refine = 10;
  3299. else if (refine == 0)
  3300. refine = 1;
  3301. count = 0;
  3302. for (i = 0; i < MAX_INVENTORY; i++) {
  3303. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3304. (sd->status.inventory[i].equip & position ||
  3305. (sd->status.inventory[i].equip && !position))) {
  3306. final_refine = sd->status.inventory[i].refine + refine;
  3307. if (final_refine > 10)
  3308. final_refine = 10;
  3309. else if (final_refine < 0)
  3310. final_refine = 0;
  3311. if (sd->status.inventory[i].refine != final_refine) {
  3312. sd->status.inventory[i].refine = final_refine;
  3313. current_position = sd->status.inventory[i].equip;
  3314. pc_unequipitem(sd, i, 3);
  3315. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3316. clif_delitem(sd, i, 1);
  3317. clif_additem(sd, i, 1, 0);
  3318. pc_equipitem(sd, i, current_position);
  3319. clif_misceffect((struct block_list*)&sd->bl, 3);
  3320. count++;
  3321. }
  3322. }
  3323. }
  3324. if (count == 0)
  3325. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3326. else if (count == 1)
  3327. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3328. else {
  3329. sprintf(atcmd_output, msg_table[168], count); // %d items have been refined!
  3330. clif_displaymessage(fd, atcmd_output);
  3331. }
  3332. return 0;
  3333. }
  3334. /*==========================================
  3335. *
  3336. *------------------------------------------
  3337. */
  3338. int atcommand_produce(
  3339. const int fd, struct map_session_data* sd,
  3340. const char* command, const char* message)
  3341. {
  3342. char item_name[100];
  3343. int item_id, attribute = 0, star = 0;
  3344. int flag = 0;
  3345. struct item_data *item_data;
  3346. struct item tmp_item;
  3347. nullpo_retr(-1, sd);
  3348. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3349. memset(item_name, '\0', sizeof(item_name));
  3350. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3351. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3352. return -1;
  3353. }
  3354. item_id = 0;
  3355. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3356. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3357. item_id = item_data->nameid;
  3358. if (itemdb_exists(item_id) &&
  3359. (item_id <= 500 || item_id > 1099) &&
  3360. (item_id < 4001 || item_id > 4148) &&
  3361. (item_id < 7001 || item_id > 10019) &&
  3362. itemdb_isequip(item_id)) {
  3363. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3364. attribute = ATTRIBUTE_NORMAL;
  3365. if (star < MIN_STAR || star > MAX_STAR)
  3366. star = 0;
  3367. memset(&tmp_item, 0, sizeof tmp_item);
  3368. tmp_item.nameid = item_id;
  3369. tmp_item.amount = 1;
  3370. tmp_item.identify = 1;
  3371. tmp_item.card[0] = 0x00ff;
  3372. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3373. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3374. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3375. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3376. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3377. //Logs (A)dmins items [Lupus]
  3378. if(log_config.pick > 0 ) {
  3379. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3380. }
  3381. //Logs
  3382. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3383. clif_additem(sd, 0, 0, flag);
  3384. } else {
  3385. if (battle_config.error_log)
  3386. ShowError("@produce NOT WEAPON [%d]\n", item_id);
  3387. if (item_id != 0 && itemdb_exists(item_id))
  3388. sprintf(atcmd_output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3389. else
  3390. sprintf(atcmd_output, msg_table[170]); // This item is not an equipment.
  3391. clif_displaymessage(fd, atcmd_output);
  3392. return -1;
  3393. }
  3394. return 0;
  3395. }
  3396. /*==========================================
  3397. * Sub-function to display actual memo points
  3398. *------------------------------------------
  3399. */
  3400. void atcommand_memo_sub(struct map_session_data* sd) {
  3401. int i;
  3402. if (!sd) return;
  3403. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3404. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3405. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3406. if (sd->status.memo_point[i].map)
  3407. 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);
  3408. else
  3409. sprintf(atcmd_output, msg_table[171], i); // %d - void
  3410. clif_displaymessage(sd->fd, atcmd_output);
  3411. }
  3412. return;
  3413. }
  3414. /*==========================================
  3415. *
  3416. *------------------------------------------
  3417. */
  3418. int atcommand_memo(
  3419. const int fd, struct map_session_data* sd,
  3420. const char* command, const char* message)
  3421. {
  3422. int position = 0;
  3423. nullpo_retr(-1, sd);
  3424. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3425. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3426. atcommand_memo_sub(sd);
  3427. else {
  3428. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3429. 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)) {
  3430. clif_displaymessage(fd, msg_table[253]);
  3431. return -1;
  3432. }
  3433. if (sd->status.memo_point[position].map) {
  3434. 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).
  3435. clif_displaymessage(fd, atcmd_output);
  3436. }
  3437. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3438. sd->status.memo_point[position].x = sd->bl.x;
  3439. sd->status.memo_point[position].y = sd->bl.y;
  3440. clif_skill_memo(sd, 0);
  3441. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3442. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3443. atcommand_memo_sub(sd);
  3444. } else {
  3445. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3446. clif_displaymessage(fd, atcmd_output);
  3447. atcommand_memo_sub(sd);
  3448. return -1;
  3449. }
  3450. }
  3451. return 0;
  3452. }
  3453. /*==========================================
  3454. *
  3455. *------------------------------------------
  3456. */
  3457. int atcommand_gat(
  3458. const int fd, struct map_session_data* sd,
  3459. const char* command, const char* message)
  3460. {
  3461. int y;
  3462. nullpo_retr(-1, sd);
  3463. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3464. for (y = 2; y >= -2; y--) {
  3465. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3466. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3467. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3468. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3469. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3470. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3471. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3472. clif_displaymessage(fd, atcmd_output);
  3473. }
  3474. return 0;
  3475. }
  3476. /*==========================================
  3477. *
  3478. *------------------------------------------
  3479. */
  3480. int atcommand_packet(
  3481. const int fd, struct map_session_data* sd,
  3482. const char* command, const char* message)
  3483. {
  3484. static int packet_mode = 0;
  3485. int i, x = 0, y = 0;
  3486. nullpo_retr(-1, sd);
  3487. if (strstr(command, "packetmode")) {
  3488. packet_mode = atoi(message);
  3489. clif_displaymessage(fd, "Packet mode changed.");
  3490. return 0;
  3491. }
  3492. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3493. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3494. return -1;
  3495. }
  3496. if (i == 1) y = 1;
  3497. switch (packet_mode)
  3498. {
  3499. case 0:
  3500. clif_status_change(&sd->bl, x, y);
  3501. break;
  3502. case 1:
  3503. sd->status.skill[sd->cloneskill_id].id=0;
  3504. sd->status.skill[sd->cloneskill_id].lv=0;
  3505. sd->status.skill[sd->cloneskill_id].flag=0;
  3506. sd->cloneskill_id = x;
  3507. sd->status.skill[x].id = x;
  3508. sd->status.skill[x].lv = skill_get_max(x);
  3509. sd->status.skill[x].flag = 13;//cloneskill flag
  3510. clif_skillinfoblock(sd);
  3511. break;
  3512. case 2:
  3513. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3514. case 3:
  3515. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3516. default:
  3517. break;
  3518. //added later
  3519. }
  3520. return 0;
  3521. }
  3522. /*==========================================
  3523. * @waterlevel [Skotlex]
  3524. *------------------------------------------
  3525. */
  3526. int atcommand_waterlevel(
  3527. const int fd, struct map_session_data* sd,
  3528. const char* command, const char* message)
  3529. {
  3530. int newlevel;
  3531. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3532. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3533. clif_displaymessage(fd, atcmd_output);
  3534. return 0;
  3535. }
  3536. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3537. if (newlevel > 0)
  3538. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3539. else
  3540. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3541. clif_displaymessage(fd, atcmd_output);
  3542. } else {
  3543. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3544. clif_displaymessage(fd, atcmd_output);
  3545. }
  3546. return 0;
  3547. }
  3548. /*==========================================
  3549. * @stpoint (Rewritten by [Yor])
  3550. *------------------------------------------
  3551. */
  3552. int atcommand_statuspoint(
  3553. const int fd, struct map_session_data* sd,
  3554. const char* command, const char* message)
  3555. {
  3556. int point, new_status_point;
  3557. if (!message || !*message || (point = atoi(message)) == 0) {
  3558. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3559. return -1;
  3560. }
  3561. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3562. new_status_point = USHRT_MAX;
  3563. else
  3564. if (point < 0 && sd->status.status_point < -point)
  3565. new_status_point = 0;
  3566. else
  3567. new_status_point = sd->status.status_point + point;
  3568. if (new_status_point != (int)sd->status.status_point) {
  3569. sd->status.status_point = (unsigned short)new_status_point;
  3570. clif_updatestatus(sd, SP_STATUSPOINT);
  3571. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3572. } else {
  3573. if (point < 0)
  3574. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3575. else
  3576. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3577. return -1;
  3578. }
  3579. return 0;
  3580. }
  3581. /*==========================================
  3582. * @skpoint (Rewritten by [Yor])
  3583. *------------------------------------------
  3584. */
  3585. int atcommand_skillpoint(
  3586. const int fd, struct map_session_data* sd,
  3587. const char* command, const char* message)
  3588. {
  3589. int point, new_skill_point;
  3590. nullpo_retr(-1, sd);
  3591. if (!message || !*message || (point = atoi(message)) == 0) {
  3592. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3593. return -1;
  3594. }
  3595. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3596. new_skill_point = USHRT_MAX;
  3597. else if (point < 0 && sd->status.skill_point < -point)
  3598. new_skill_point = 0;
  3599. else
  3600. new_skill_point = sd->status.skill_point + point;
  3601. if (new_skill_point != (int)sd->status.skill_point) {
  3602. sd->status.skill_point = (unsigned short)new_skill_point;
  3603. clif_updatestatus(sd, SP_SKILLPOINT);
  3604. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3605. } else {
  3606. if (point < 0)
  3607. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3608. else
  3609. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3610. return -1;
  3611. }
  3612. return 0;
  3613. }
  3614. /*==========================================
  3615. * @zeny (Rewritten by [Yor])
  3616. *------------------------------------------
  3617. */
  3618. int atcommand_zeny(
  3619. const int fd, struct map_session_data* sd,
  3620. const char* command, const char* message)
  3621. {
  3622. int zeny, new_zeny;
  3623. nullpo_retr(-1, sd);
  3624. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3625. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3626. return -1;
  3627. }
  3628. new_zeny = sd->status.zeny + zeny;
  3629. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3630. new_zeny = MAX_ZENY;
  3631. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3632. new_zeny = 0;
  3633. if (new_zeny != sd->status.zeny) {
  3634. sd->status.zeny = new_zeny;
  3635. clif_updatestatus(sd, SP_ZENY);
  3636. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3637. } else {
  3638. if (zeny < 0)
  3639. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3640. else
  3641. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3642. return -1;
  3643. }
  3644. return 0;
  3645. }
  3646. /*==========================================
  3647. *
  3648. *------------------------------------------
  3649. */
  3650. int atcommand_param(
  3651. const int fd, struct map_session_data* sd,
  3652. const char* command, const char* message)
  3653. {
  3654. int i, index, value = 0, new_value;
  3655. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3656. short* status[] = {
  3657. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3658. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3659. };
  3660. nullpo_retr(-1, sd);
  3661. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3662. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3663. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3664. clif_displaymessage(fd, atcmd_output);
  3665. return -1;
  3666. }
  3667. index = -1;
  3668. for (i = 0; param[i] != NULL; i++) {
  3669. if (strcmpi(command, param[i]) == 0) {
  3670. index = i;
  3671. break;
  3672. }
  3673. }
  3674. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3675. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3676. clif_displaymessage(fd, atcmd_output);
  3677. return -1;
  3678. }
  3679. new_value = (int)*status[index] + value;
  3680. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3681. new_value = pc_maxparameter(sd);
  3682. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negativ overflow
  3683. new_value = 1;
  3684. if (new_value != (int)*status[index]) {
  3685. *status[index] = new_value;
  3686. clif_updatestatus(sd, SP_STR + index);
  3687. clif_updatestatus(sd, SP_USTR + index);
  3688. status_calc_pc(sd, 0);
  3689. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3690. } else {
  3691. if (value < 0)
  3692. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3693. else
  3694. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3695. return -1;
  3696. }
  3697. return 0;
  3698. }
  3699. /*==========================================
  3700. *
  3701. *------------------------------------------
  3702. */
  3703. //** Stat all by fritz (rewritten by [Yor])
  3704. int atcommand_stat_all(
  3705. const int fd, struct map_session_data* sd,
  3706. const char* command, const char* message)
  3707. {
  3708. int index, count, value = 0, max, new_value;
  3709. short* status[] = {
  3710. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3711. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3712. };
  3713. nullpo_retr(-1, sd);
  3714. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3715. value = pc_maxparameter(sd);
  3716. count = 0;
  3717. max = pc_maxparameter(sd);
  3718. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3719. if (value > 0 && *status[index] > max - value)
  3720. new_value = max;
  3721. else if (value < 0 && *status[index] <= -value)
  3722. new_value = 1;
  3723. else
  3724. new_value = *status[index] +value;
  3725. if (new_value != (int)*status[index]) {
  3726. *status[index] = new_value;
  3727. clif_updatestatus(sd, SP_STR + index);
  3728. clif_updatestatus(sd, SP_USTR + index);
  3729. status_calc_pc(sd, 0);
  3730. count++;
  3731. }
  3732. }
  3733. if (count > 0) // if at least 1 stat modified
  3734. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3735. else {
  3736. if (value < 0)
  3737. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3738. else
  3739. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3740. return -1;
  3741. }
  3742. return 0;
  3743. }
  3744. /*==========================================
  3745. *
  3746. *------------------------------------------
  3747. */
  3748. int atcommand_guildlevelup(
  3749. const int fd, struct map_session_data* sd,
  3750. const char* command, const char* message)
  3751. {
  3752. int level = 0;
  3753. short added_level;
  3754. struct guild *guild_info;
  3755. nullpo_retr(-1, sd);
  3756. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3757. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3758. return -1;
  3759. }
  3760. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3761. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3762. return -1;
  3763. }
  3764. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3765. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3766. return -1;
  3767. }
  3768. added_level = (short)level;
  3769. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3770. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3771. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3772. added_level = 1 - guild_info->guild_lv;
  3773. if (added_level != 0) {
  3774. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3775. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3776. } else {
  3777. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3778. return -1;
  3779. }
  3780. return 0;
  3781. }
  3782. /*==========================================
  3783. *
  3784. *------------------------------------------
  3785. */
  3786. int atcommand_makeegg(
  3787. const int fd, struct map_session_data* sd,
  3788. const char* command, const char* message)
  3789. {
  3790. struct item_data *item_data;
  3791. int id, pet_id;
  3792. nullpo_retr(-1, sd);
  3793. if (!message || !*message) {
  3794. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3795. return -1;
  3796. }
  3797. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3798. id = item_data->nameid;
  3799. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3800. id = atoi(message);
  3801. pet_id = search_petDB_index(id, PET_CLASS);
  3802. if (pet_id < 0)
  3803. pet_id = search_petDB_index(id, PET_EGG);
  3804. if (pet_id >= 0) {
  3805. sd->catch_target_class = pet_db[pet_id].class_;
  3806. intif_create_pet(
  3807. sd->status.account_id, sd->status.char_id,
  3808. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3809. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3810. 100, 0, 1, pet_db[pet_id].jname);
  3811. } else {
  3812. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3813. return -1;
  3814. }
  3815. return 0;
  3816. }
  3817. /*==========================================
  3818. *
  3819. *------------------------------------------
  3820. */
  3821. int atcommand_hatch(
  3822. const int fd, struct map_session_data* sd,
  3823. const char* command, const char* message)
  3824. {
  3825. nullpo_retr(-1, sd);
  3826. if (sd->status.pet_id <= 0)
  3827. clif_sendegg(sd);
  3828. else {
  3829. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3830. return -1;
  3831. }
  3832. return 0;
  3833. }
  3834. /*==========================================
  3835. *
  3836. *------------------------------------------
  3837. */
  3838. int atcommand_petfriendly(
  3839. const int fd, struct map_session_data* sd,
  3840. const char* command, const char* message)
  3841. {
  3842. int friendly;
  3843. int t;
  3844. nullpo_retr(-1, sd);
  3845. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3846. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3847. return -1;
  3848. }
  3849. if (sd->status.pet_id > 0 && sd->pd) {
  3850. if (friendly >= 0 && friendly <= 1000) {
  3851. if (friendly != sd->pet.intimate) {
  3852. t = sd->pet.intimate;
  3853. sd->pet.intimate = friendly;
  3854. clif_send_petstatus(sd);
  3855. if (battle_config.pet_status_support) {
  3856. if ((sd->pet.intimate > 0 && t <= 0) ||
  3857. (sd->pet.intimate <= 0 && t > 0)) {
  3858. if (sd->bl.prev != NULL)
  3859. status_calc_pc(sd, 0);
  3860. else
  3861. status_calc_pc(sd, 2);
  3862. }
  3863. }
  3864. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3865. } else {
  3866. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3867. return -1;
  3868. }
  3869. } else {
  3870. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3871. return -1;
  3872. }
  3873. } else {
  3874. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3875. return -1;
  3876. }
  3877. return 0;
  3878. }
  3879. /*==========================================
  3880. *
  3881. *------------------------------------------
  3882. */
  3883. int atcommand_pethungry(
  3884. const int fd, struct map_session_data* sd,
  3885. const char* command, const char* message)
  3886. {
  3887. int hungry;
  3888. nullpo_retr(-1, sd);
  3889. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3890. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3891. return -1;
  3892. }
  3893. if (sd->status.pet_id > 0 && sd->pd) {
  3894. if (hungry >= 0 && hungry <= 100) {
  3895. if (hungry != sd->pet.hungry) {
  3896. sd->pet.hungry = hungry;
  3897. clif_send_petstatus(sd);
  3898. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3899. } else {
  3900. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3901. return -1;
  3902. }
  3903. } else {
  3904. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3905. return -1;
  3906. }
  3907. } else {
  3908. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3909. return -1;
  3910. }
  3911. return 0;
  3912. }
  3913. /*==========================================
  3914. *
  3915. *------------------------------------------
  3916. */
  3917. int atcommand_petrename(
  3918. const int fd, struct map_session_data* sd,
  3919. const char* command, const char* message)
  3920. {
  3921. nullpo_retr(-1, sd);
  3922. if (sd->status.pet_id > 0 && sd->pd) {
  3923. if (sd->pet.rename_flag != 0) {
  3924. sd->pet.rename_flag = 0;
  3925. intif_save_petdata(sd->status.account_id, &sd->pet);
  3926. clif_send_petstatus(sd);
  3927. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3928. } else {
  3929. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3930. return -1;
  3931. }
  3932. } else {
  3933. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3934. return -1;
  3935. }
  3936. return 0;
  3937. }
  3938. /*==========================================
  3939. *
  3940. *------------------------------------------
  3941. */
  3942. int
  3943. atcommand_recall(
  3944. const int fd, struct map_session_data* sd,
  3945. const char* command, const char* message)
  3946. {
  3947. struct map_session_data *pl_sd = NULL;
  3948. nullpo_retr(-1, sd);
  3949. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3950. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3951. return -1;
  3952. }
  3953. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3954. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3955. return -1;
  3956. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3957. return -1;
  3958. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3959. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3960. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3961. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3962. return -1;
  3963. }
  3964. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3965. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3966. return -1;
  3967. }
  3968. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3969. sprintf(atcmd_output, msg_table[46], atcmd_player_name); // %s recalled!
  3970. clif_displaymessage(fd, atcmd_output);
  3971. } else {
  3972. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3973. return -1;
  3974. }
  3975. } else {
  3976. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3977. return -1;
  3978. }
  3979. return 0;
  3980. }
  3981. /*==========================================
  3982. *
  3983. *------------------------------------------
  3984. */
  3985. int atcommand_revive(
  3986. const int fd, struct map_session_data* sd,
  3987. const char* command, const char* message)
  3988. {
  3989. struct map_session_data *pl_sd;
  3990. nullpo_retr(-1, sd);
  3991. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3992. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3993. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3994. return -1;
  3995. }
  3996. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3997. if (pc_isdead(pl_sd)) {
  3998. pl_sd->status.hp = pl_sd->status.max_hp;
  3999. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4000. pc_setstand(pl_sd);
  4001. if (battle_config.pc_invincible_time > 0)
  4002. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  4003. clif_updatestatus(pl_sd, SP_HP);
  4004. clif_updatestatus(pl_sd, SP_SP);
  4005. clif_resurrection(&pl_sd->bl, 1);
  4006. clif_displaymessage(fd, msg_table[51]); // Character revived.
  4007. return 0;
  4008. }
  4009. return -1;
  4010. } else {
  4011. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4012. return -1;
  4013. }
  4014. return 0;
  4015. }
  4016. /*==========================================
  4017. * charblock command (usage: charblock <player_name>)
  4018. * This command do a definitiv ban on a player
  4019. *------------------------------------------
  4020. */
  4021. int atcommand_char_block(
  4022. const int fd, struct map_session_data* sd,
  4023. const char* command, const char* message)
  4024. {
  4025. nullpo_retr(-1, sd);
  4026. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4027. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4028. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4029. return -1;
  4030. }
  4031. // check player name
  4032. if (strlen(atcmd_player_name) < 4) {
  4033. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4034. return -1;
  4035. } else if (strlen(atcmd_player_name) > 23) {
  4036. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4037. return -1;
  4038. } else {
  4039. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4040. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4041. }
  4042. return 0;
  4043. }
  4044. /*==========================================
  4045. * charban command (usage: charban <time> <player_name>)
  4046. * This command do a limited ban on a player
  4047. * Time is done as follows:
  4048. * Adjustment value (-1, 1, +1, etc...)
  4049. * Modified element:
  4050. * a or y: year
  4051. * m: month
  4052. * j or d: day
  4053. * h: hour
  4054. * mn: minute
  4055. * s: second
  4056. * <example> @ban +1m-2mn1s-6y test_player
  4057. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4058. *------------------------------------------
  4059. */
  4060. int atcommand_char_ban(
  4061. const int fd, struct map_session_data* sd,
  4062. const char* command, const char* message)
  4063. {
  4064. char * modif_p;
  4065. int year, month, day, hour, minute, second, value;
  4066. nullpo_retr(-1, sd);
  4067. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4068. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4069. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4070. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4071. return -1;
  4072. }
  4073. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4074. modif_p = atcmd_output;
  4075. year = month = day = hour = minute = second = 0;
  4076. while (modif_p[0] != '\0') {
  4077. value = atoi(modif_p);
  4078. if (value == 0)
  4079. modif_p++;
  4080. else {
  4081. if (modif_p[0] == '-' || modif_p[0] == '+')
  4082. modif_p++;
  4083. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4084. modif_p++;
  4085. if (modif_p[0] == 's') {
  4086. second = value;
  4087. modif_p++;
  4088. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4089. minute = value;
  4090. modif_p = modif_p + 2;
  4091. } else if (modif_p[0] == 'h') {
  4092. hour = value;
  4093. modif_p++;
  4094. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4095. day = value;
  4096. modif_p++;
  4097. } else if (modif_p[0] == 'm') {
  4098. month = value;
  4099. modif_p++;
  4100. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4101. year = value;
  4102. modif_p++;
  4103. } else if (modif_p[0] != '\0') {
  4104. modif_p++;
  4105. }
  4106. }
  4107. }
  4108. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4109. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  4110. return -1;
  4111. }
  4112. // check player name
  4113. if (strlen(atcmd_player_name) < 4) {
  4114. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4115. return -1;
  4116. } else if (strlen(atcmd_player_name) > 23) {
  4117. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4118. return -1;
  4119. } else {
  4120. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4121. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4122. }
  4123. return 0;
  4124. }
  4125. /*==========================================
  4126. * charunblock command (usage: charunblock <player_name>)
  4127. *------------------------------------------
  4128. */
  4129. int atcommand_char_unblock(
  4130. const int fd, struct map_session_data* sd,
  4131. const char* command, const char* message)
  4132. {
  4133. nullpo_retr(-1, sd);
  4134. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4135. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4136. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4137. return -1;
  4138. }
  4139. // check player name
  4140. if (strlen(atcmd_player_name) < 4) {
  4141. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4142. return -1;
  4143. } else if (strlen(atcmd_player_name) > 23) {
  4144. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4145. return -1;
  4146. } else {
  4147. // send answer to login server via char-server
  4148. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4149. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4150. }
  4151. return 0;
  4152. }
  4153. /*==========================================
  4154. * charunban command (usage: charunban <player_name>)
  4155. *------------------------------------------
  4156. */
  4157. int atcommand_char_unban(
  4158. const int fd, struct map_session_data* sd,
  4159. const char* command, const char* message)
  4160. {
  4161. nullpo_retr(-1, sd);
  4162. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4163. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4164. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4165. return -1;
  4166. }
  4167. // check player name
  4168. if (strlen(atcmd_player_name) < 4) {
  4169. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4170. return -1;
  4171. } else if (strlen(atcmd_player_name) > 23) {
  4172. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4173. return -1;
  4174. } else {
  4175. // send answer to login server via char-server
  4176. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4177. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4178. }
  4179. return 0;
  4180. }
  4181. /*==========================================
  4182. *
  4183. *------------------------------------------
  4184. */
  4185. int atcommand_night(
  4186. const int fd, struct map_session_data* sd,
  4187. const char* command, const char* message)
  4188. {
  4189. nullpo_retr(-1, sd);
  4190. if (night_flag != 1) {
  4191. map_night_timer(night_timer_tid, 0, 0, 1);
  4192. } else {
  4193. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4194. return -1;
  4195. }
  4196. return 0;
  4197. }
  4198. /*==========================================
  4199. *
  4200. *------------------------------------------
  4201. */
  4202. int atcommand_day(
  4203. const int fd, struct map_session_data* sd,
  4204. const char* command, const char* message)
  4205. {
  4206. nullpo_retr(-1, sd);
  4207. if (night_flag != 0) {
  4208. map_day_timer(day_timer_tid, 0, 0, 1);
  4209. } else {
  4210. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4211. return -1;
  4212. }
  4213. return 0;
  4214. }
  4215. /*==========================================
  4216. *
  4217. *------------------------------------------
  4218. */
  4219. int atcommand_doom(
  4220. const int fd, struct map_session_data* sd,
  4221. const char* command, const char* message)
  4222. {
  4223. struct map_session_data *pl_sd, **pl_allsd;
  4224. int i, users;
  4225. nullpo_retr(-1, sd);
  4226. clif_specialeffect(&sd->bl,450,2);
  4227. pl_allsd = map_getallusers(&users);
  4228. for(i = 0; i < users; i++) {
  4229. 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
  4230. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4231. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4232. }
  4233. }
  4234. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4235. return 0;
  4236. }
  4237. /*==========================================
  4238. *
  4239. *------------------------------------------
  4240. */
  4241. int atcommand_doommap(
  4242. const int fd, struct map_session_data* sd,
  4243. const char* command, const char* message)
  4244. {
  4245. struct map_session_data *pl_sd, **pl_allsd;
  4246. int i, users;
  4247. nullpo_retr(-1, sd);
  4248. clif_specialeffect(&sd->bl,450,3);
  4249. pl_allsd = map_getallusers(&users);
  4250. for (i = 0; i < users; i++) {
  4251. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4252. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4253. {
  4254. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4255. // clif_specialeffect(&pl_sd->bl,450,1);
  4256. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4257. }
  4258. }
  4259. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4260. return 0;
  4261. }
  4262. /*==========================================
  4263. *
  4264. *------------------------------------------
  4265. */
  4266. static void atcommand_raise_sub(struct map_session_data* sd)
  4267. {
  4268. if (sd && sd->state.auth && pc_isdead(sd)) {
  4269. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4270. sd->status.hp = sd->status.max_hp;
  4271. sd->status.sp = sd->status.max_sp;
  4272. pc_setstand(sd);
  4273. clif_updatestatus(sd, SP_HP);
  4274. clif_updatestatus(sd, SP_SP);
  4275. clif_resurrection(&sd->bl, 1);
  4276. if (battle_config.pc_invincible_time > 0)
  4277. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4278. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4279. }
  4280. }
  4281. /*==========================================
  4282. *
  4283. *------------------------------------------
  4284. */
  4285. int atcommand_raise(
  4286. const int fd, struct map_session_data* sd,
  4287. const char* command, const char* message)
  4288. {
  4289. int i, users;
  4290. struct map_session_data **all_sd;
  4291. nullpo_retr(-1, sd);
  4292. all_sd = map_getallusers(&users);
  4293. for (i = 0; i < users; i++) {
  4294. atcommand_raise_sub(all_sd[i]);
  4295. }
  4296. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4297. return 0;
  4298. }
  4299. /*==========================================
  4300. *
  4301. *------------------------------------------
  4302. */
  4303. int atcommand_raisemap(
  4304. const int fd, struct map_session_data* sd,
  4305. const char* command, const char* message)
  4306. {
  4307. struct map_session_data **pl_allsd;
  4308. int i, users;
  4309. nullpo_retr(-1, sd);
  4310. pl_allsd = map_getallusers(&users);
  4311. for (i = 0; i < users; i++) {
  4312. if (sd->bl.m == pl_allsd[i]->bl.m)
  4313. atcommand_raise_sub(pl_allsd[i]);
  4314. }
  4315. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4316. return 0;
  4317. }
  4318. /*==========================================
  4319. *
  4320. *------------------------------------------
  4321. */
  4322. int atcommand_kick(
  4323. const int fd, struct map_session_data* sd,
  4324. const char* command, const char* message)
  4325. {
  4326. struct map_session_data *pl_sd;
  4327. nullpo_retr(-1, sd);
  4328. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4329. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4330. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4331. return -1;
  4332. }
  4333. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4334. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4335. clif_GM_kick(sd, pl_sd, 1);
  4336. else {
  4337. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4338. return -1;
  4339. }
  4340. } else {
  4341. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4342. return -1;
  4343. }
  4344. return 0;
  4345. }
  4346. /*==========================================
  4347. *
  4348. *------------------------------------------
  4349. */
  4350. int atcommand_kickall(
  4351. const int fd, struct map_session_data* sd,
  4352. const char* command, const char* message)
  4353. {
  4354. struct map_session_data *pl_sd, **pl_allsd;
  4355. int i, users;
  4356. nullpo_retr(-1, sd);
  4357. pl_allsd = map_getallusers(&users);
  4358. for (i = 0; i < users; i++) {
  4359. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4360. if (sd->status.account_id != pl_sd->status.account_id)
  4361. clif_GM_kick(sd, pl_sd, 0);
  4362. }
  4363. }
  4364. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4365. return 0;
  4366. }
  4367. /*==========================================
  4368. *
  4369. *------------------------------------------
  4370. */
  4371. int atcommand_allskill(
  4372. const int fd, struct map_session_data* sd,
  4373. const char* command, const char* message)
  4374. {
  4375. nullpo_retr(-1, sd);
  4376. pc_allskillup(sd); // all skills
  4377. sd->status.skill_point = 0; // 0 skill points
  4378. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4379. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4380. return 0;
  4381. }
  4382. /*==========================================
  4383. *
  4384. *------------------------------------------
  4385. */
  4386. int atcommand_questskill(
  4387. const int fd, struct map_session_data* sd,
  4388. const char* command, const char* message)
  4389. {
  4390. int skill_id;
  4391. nullpo_retr(-1, sd);
  4392. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4393. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4394. return -1;
  4395. }
  4396. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4397. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4398. if (pc_checkskill(sd, skill_id) == 0) {
  4399. pc_skill(sd, skill_id, 1, 0);
  4400. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4401. } else {
  4402. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4403. return -1;
  4404. }
  4405. } else {
  4406. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4407. return -1;
  4408. }
  4409. } else {
  4410. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4411. return -1;
  4412. }
  4413. return 0;
  4414. }
  4415. /*==========================================
  4416. *
  4417. *------------------------------------------
  4418. */
  4419. int atcommand_lostskill(
  4420. const int fd, struct map_session_data* sd,
  4421. const char* command, const char* message)
  4422. {
  4423. int skill_id;
  4424. nullpo_retr(-1, sd);
  4425. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4426. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4427. return -1;
  4428. }
  4429. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4430. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4431. if (pc_checkskill(sd, skill_id) > 0) {
  4432. sd->status.skill[skill_id].lv = 0;
  4433. sd->status.skill[skill_id].flag = 0;
  4434. clif_skillinfoblock(sd);
  4435. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4436. } else {
  4437. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4438. return -1;
  4439. }
  4440. } else {
  4441. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4442. return -1;
  4443. }
  4444. } else {
  4445. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4446. return -1;
  4447. }
  4448. return 0;
  4449. }
  4450. /*==========================================
  4451. *
  4452. *------------------------------------------
  4453. */
  4454. int atcommand_spiritball(
  4455. const int fd, struct map_session_data* sd,
  4456. const char* command, const char* message)
  4457. {
  4458. int number;
  4459. nullpo_retr(-1, sd);
  4460. if (!message || !*message || (number = atoi(message)) < 0) {
  4461. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4462. return -1;
  4463. }
  4464. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4465. if (number > 500)
  4466. number = 500;
  4467. if (number >= 0 && number <= 0x7FFF) {
  4468. if (sd->spiritball != number || number > 499) {
  4469. if (sd->spiritball > 0)
  4470. pc_delspiritball(sd, sd->spiritball, 1);
  4471. sd->spiritball = number;
  4472. clif_spiritball(sd);
  4473. // no message, player can look the difference
  4474. if (number > 1000)
  4475. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4476. } else {
  4477. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4478. return -1;
  4479. }
  4480. } else {
  4481. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4482. return -1;
  4483. }
  4484. return 0;
  4485. }
  4486. /*==========================================
  4487. *
  4488. *------------------------------------------
  4489. */
  4490. int atcommand_party(
  4491. const int fd, struct map_session_data* sd,
  4492. const char* command, const char* message)
  4493. {
  4494. char party[NAME_LENGTH];
  4495. nullpo_retr(-1, sd);
  4496. memset(party, '\0', sizeof(party));
  4497. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4498. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4499. return -1;
  4500. }
  4501. party_create(sd, party, 0, 0);
  4502. return 0;
  4503. }
  4504. /*==========================================
  4505. *
  4506. *------------------------------------------
  4507. */
  4508. int atcommand_guild(
  4509. const int fd, struct map_session_data* sd,
  4510. const char* command, const char* message)
  4511. {
  4512. char guild[NAME_LENGTH];
  4513. int prev;
  4514. nullpo_retr(-1, sd);
  4515. memset(guild, '\0', sizeof(guild));
  4516. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4517. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4518. return -1;
  4519. }
  4520. prev = battle_config.guild_emperium_check;
  4521. battle_config.guild_emperium_check = 0;
  4522. guild_create(sd, guild);
  4523. battle_config.guild_emperium_check = prev;
  4524. return 0;
  4525. }
  4526. /*==========================================
  4527. *
  4528. *------------------------------------------
  4529. */
  4530. int atcommand_agitstart(
  4531. const int fd, struct map_session_data* sd,
  4532. const char* command, const char* message)
  4533. {
  4534. nullpo_retr(-1, sd);
  4535. if (agit_flag == 1) {
  4536. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4537. return -1;
  4538. }
  4539. agit_flag = 1;
  4540. guild_agit_start();
  4541. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4542. return 0;
  4543. }
  4544. /*==========================================
  4545. *
  4546. *------------------------------------------
  4547. */
  4548. int atcommand_agitend(
  4549. const int fd, struct map_session_data* sd,
  4550. const char* command, const char* message)
  4551. {
  4552. nullpo_retr(-1, sd);
  4553. if (agit_flag == 0) {
  4554. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4555. return -1;
  4556. }
  4557. agit_flag = 0;
  4558. guild_agit_end();
  4559. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4560. return 0;
  4561. }
  4562. /*==========================================
  4563. * @mapexitでマップサーバーを終了させる
  4564. *------------------------------------------
  4565. */
  4566. int atcommand_mapexit(
  4567. const int fd, struct map_session_data* sd,
  4568. const char* command, const char* message)
  4569. {
  4570. struct map_session_data *pl_sd, **pl_allsd;
  4571. int i, users;
  4572. nullpo_retr(-1, sd);
  4573. pl_allsd = map_getallusers(&users);
  4574. for (i = 0; i < users; i++) {
  4575. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4576. clif_GM_kick(sd, pl_sd, 0);
  4577. }
  4578. clif_GM_kick(sd, sd, 0);
  4579. flush_fifos();
  4580. runflag = 0;
  4581. return 0;
  4582. }
  4583. /*==========================================
  4584. * idsearch <part_of_name>: revrited by [Yor]
  4585. *------------------------------------------
  4586. */
  4587. int atcommand_idsearch(
  4588. const int fd, struct map_session_data* sd,
  4589. const char* command, const char* message)
  4590. {
  4591. char item_name[100];
  4592. unsigned int i, match;
  4593. struct item_data *item_array[MAX_SEARCH];
  4594. nullpo_retr(-1, sd);
  4595. memset(item_name, '\0', sizeof(item_name));
  4596. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4597. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4598. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4599. return -1;
  4600. }
  4601. sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4602. clif_displaymessage(fd, atcmd_output);
  4603. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4604. if (match > MAX_SEARCH) {
  4605. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, match);
  4606. clif_displaymessage(fd, atcmd_output);
  4607. match = MAX_SEARCH;
  4608. }
  4609. for(i = 0; i < match; i++) {
  4610. sprintf(atcmd_output, msg_table[78], item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4611. clif_displaymessage(fd, atcmd_output);
  4612. }
  4613. sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
  4614. clif_displaymessage(fd, atcmd_output);
  4615. return 0;
  4616. }
  4617. /*==========================================
  4618. * Recall All Characters Online To Your Location
  4619. *------------------------------------------
  4620. */
  4621. int atcommand_recallall(
  4622. const int fd, struct map_session_data* sd,
  4623. const char* command, const char* message)
  4624. {
  4625. struct map_session_data *pl_sd, **pl_allsd;
  4626. int i;
  4627. int count, users;
  4628. nullpo_retr(-1, sd);
  4629. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4630. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4631. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4632. return -1;
  4633. }
  4634. count = 0;
  4635. pl_allsd = map_getallusers(&users);
  4636. for (i = 0; i < users; i++) {
  4637. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4638. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4639. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4640. count++;
  4641. else {
  4642. if (pc_isdead(pl_sd)) { //Wake them up
  4643. pc_setstand(pl_sd);
  4644. pc_setrestartvalue(pl_sd,1);
  4645. }
  4646. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4647. }
  4648. }
  4649. }
  4650. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  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. return 0;
  4656. }
  4657. /*==========================================
  4658. * Recall online characters of a guild to your location
  4659. *------------------------------------------
  4660. */
  4661. int atcommand_guildrecall(
  4662. const int fd, struct map_session_data* sd,
  4663. const char* command, const char* message)
  4664. {
  4665. struct map_session_data *pl_sd, **pl_allsd;
  4666. int i, users, count;
  4667. char guild_name[NAME_LENGTH];
  4668. struct guild *g;
  4669. nullpo_retr(-1, sd);
  4670. memset(guild_name, '\0', sizeof(guild_name));
  4671. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4672. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4673. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4674. return -1;
  4675. }
  4676. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4677. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4678. return -1;
  4679. }
  4680. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4681. (g = guild_search(atoi(message))) != NULL) {
  4682. count = 0;
  4683. pl_allsd = map_getallusers(&users);
  4684. for (i = 0; i < users; i++) {
  4685. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4686. pl_sd->status.guild_id == g->guild_id) {
  4687. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4688. continue; //Skip GMs greater than you.
  4689. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4690. count++;
  4691. else
  4692. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4693. }
  4694. }
  4695. sprintf(atcmd_output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4696. clif_displaymessage(fd, atcmd_output);
  4697. if (count) {
  4698. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4699. clif_displaymessage(fd, atcmd_output);
  4700. }
  4701. } else {
  4702. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4703. return -1;
  4704. }
  4705. return 0;
  4706. }
  4707. /*==========================================
  4708. * Recall online characters of a party to your location
  4709. *------------------------------------------
  4710. */
  4711. int atcommand_partyrecall(
  4712. const int fd, struct map_session_data* sd,
  4713. const char* command, const char* message)
  4714. {
  4715. int i;
  4716. struct map_session_data *pl_sd, **pl_allsd;
  4717. char party_name[NAME_LENGTH];
  4718. struct party *p;
  4719. int count, users;
  4720. nullpo_retr(-1, sd);
  4721. memset(party_name, '\0', sizeof(party_name));
  4722. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4723. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4724. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4725. return -1;
  4726. }
  4727. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4728. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4729. return -1;
  4730. }
  4731. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4732. (p = party_search(atoi(message))) != NULL) {
  4733. count = 0;
  4734. pl_allsd = map_getallusers(&users);
  4735. for (i = 0; i < users; i++) {
  4736. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4737. pl_sd->status.party_id == p->party_id) {
  4738. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4739. continue; //Skip GMs greater than you.
  4740. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4741. count++;
  4742. else
  4743. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4744. }
  4745. }
  4746. sprintf(atcmd_output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4747. clif_displaymessage(fd, atcmd_output);
  4748. if (count) {
  4749. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4750. clif_displaymessage(fd, atcmd_output);
  4751. }
  4752. } else {
  4753. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4754. return -1;
  4755. }
  4756. return 0;
  4757. }
  4758. /*==========================================
  4759. *
  4760. *------------------------------------------
  4761. */
  4762. int atcommand_reloaditemdb(
  4763. const int fd, struct map_session_data* sd,
  4764. const char* command, const char* message)
  4765. {
  4766. nullpo_retr(-1, sd);
  4767. itemdb_reload();
  4768. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4769. return 0;
  4770. }
  4771. /*==========================================
  4772. *
  4773. *------------------------------------------
  4774. */
  4775. int atcommand_reloadmobdb(
  4776. const int fd, struct map_session_data* sd,
  4777. const char* command, const char* message)
  4778. {
  4779. nullpo_retr(-1, sd);
  4780. mob_reload();
  4781. do_final_pet();
  4782. read_petdb();
  4783. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4784. return 0;
  4785. }
  4786. /*==========================================
  4787. *
  4788. *------------------------------------------
  4789. */
  4790. int atcommand_reloadskilldb(
  4791. const int fd, struct map_session_data* sd,
  4792. const char* command, const char* message)
  4793. {
  4794. nullpo_retr(-1, sd);
  4795. skill_reload();
  4796. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4797. return 0;
  4798. }
  4799. /*==========================================
  4800. * @reloadatcommand
  4801. * atcommand_athena.conf のリロード
  4802. *------------------------------------------
  4803. */
  4804. int
  4805. atcommand_reloadatcommand(
  4806. const int fd, struct map_session_data* sd,
  4807. const char* command, const char* message)
  4808. {
  4809. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4810. clif_displaymessage(fd, msg_table[254]);
  4811. return 0;
  4812. }
  4813. /*==========================================
  4814. * @reloadbattleconf
  4815. * battle_athena.conf のリロード
  4816. *------------------------------------------
  4817. */
  4818. int
  4819. atcommand_reloadbattleconf(
  4820. const int fd, struct map_session_data* sd,
  4821. const char* command, const char* message)
  4822. {
  4823. battle_config_read(BATTLE_CONF_FILENAME);
  4824. mob_reload(); //Needed as well so rate changes take effect.
  4825. clif_displaymessage(fd, msg_table[255]);
  4826. return 0;
  4827. }
  4828. /*==========================================
  4829. * @reloadstatusdb
  4830. * job_db1.txt job_db2.txt job_db2-2.txt
  4831. * refine_db.txt size_fix.txt
  4832. * のリロード
  4833. *------------------------------------------
  4834. */
  4835. int
  4836. atcommand_reloadstatusdb(
  4837. const int fd, struct map_session_data* sd,
  4838. const char* command, const char* message)
  4839. {
  4840. status_readdb();
  4841. clif_displaymessage(fd, msg_table[256]);
  4842. return 0;
  4843. }
  4844. /*==========================================
  4845. * @reloadpcdb
  4846. * exp.txt skill_tree.txt attr_fix.txt
  4847. * のリロード
  4848. *------------------------------------------
  4849. */
  4850. int
  4851. atcommand_reloadpcdb(
  4852. const int fd, struct map_session_data* sd,
  4853. const char* command, const char* message)
  4854. {
  4855. pc_readdb();
  4856. clif_displaymessage(fd, msg_table[257]);
  4857. return 0;
  4858. }
  4859. /*==========================================
  4860. * @reloadmotd [Valaris]
  4861. * Reloads motd.txt
  4862. *------------------------------------------
  4863. */
  4864. int
  4865. atcommand_reloadmotd(
  4866. const int fd, struct map_session_data* sd,
  4867. const char* command, const char* message)
  4868. {
  4869. pc_read_motd();
  4870. clif_displaymessage(fd, msg_table[268]);
  4871. return 0;
  4872. }
  4873. /*==========================================
  4874. *
  4875. *------------------------------------------
  4876. */
  4877. int atcommand_reloadscript(
  4878. const int fd, struct map_session_data* sd,
  4879. const char* command, const char* message)
  4880. {
  4881. nullpo_retr(-1, sd);
  4882. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4883. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4884. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4885. flush_fifos();
  4886. //do_init_npc();
  4887. script_reload();
  4888. npc_reload();
  4889. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4890. return 0;
  4891. }
  4892. /*==========================================
  4893. *
  4894. *------------------------------------------
  4895. */
  4896. int atcommand_reloadgmdb( // by [Yor]
  4897. const int fd, struct map_session_data* sd,
  4898. const char* command, const char* message)
  4899. {
  4900. nullpo_retr(-1, sd);
  4901. chrif_reloadGMdb();
  4902. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4903. return 0;
  4904. }
  4905. /*==========================================
  4906. * @mapinfo <map name> [0-3] by MC_Cameri
  4907. * => Shows information about the map [map name]
  4908. * 0 = no additional information
  4909. * 1 = Show users in that map and their location
  4910. * 2 = Shows NPCs in that map
  4911. * 3 = Shows the shops/chats in that map (not implemented)
  4912. *------------------------------------------
  4913. */
  4914. int atcommand_mapinfo(
  4915. const int fd, struct map_session_data* sd,
  4916. const char* command, const char* message)
  4917. {
  4918. struct map_session_data *pl_sd, **pl_allsd;
  4919. struct npc_data *nd = NULL;
  4920. struct chat_data *cd = NULL;
  4921. char direction[12];
  4922. int m_id, i, chat_num, users, list = 0;
  4923. unsigned short m_index;
  4924. nullpo_retr(-1, sd);
  4925. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4926. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4927. memset(direction, '\0', sizeof(direction));
  4928. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4929. if (list < 0 || list > 3) {
  4930. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4931. return -1;
  4932. }
  4933. if (atcmd_player_name[0] == '\0') {
  4934. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4935. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4936. m_id = map_mapindex2mapid(sd->mapindex);
  4937. } else {
  4938. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4939. strcat(atcmd_player_name, ".gat");
  4940. m_id = map_mapname2mapid(atcmd_player_name);
  4941. }
  4942. if (m_id < 0) {
  4943. clif_displaymessage(fd, msg_table[1]); // Map not found.
  4944. return -1;
  4945. }
  4946. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4947. clif_displaymessage(fd, "------ Map Info ------");
  4948. chat_num = 0;
  4949. pl_allsd = map_getallusers(&users);
  4950. for (i = 0; i < users; i++) {
  4951. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4952. chat_num++;
  4953. }
  4954. }
  4955. 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);
  4956. clif_displaymessage(fd, atcmd_output);
  4957. if (map[m_id].flag.alias)
  4958. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4959. clif_displaymessage(fd, "------ Map Flags ------");
  4960. strcpy(atcmd_output,"PvP Flags: ");
  4961. if (map[m_id].flag.pvp)
  4962. strcat(atcmd_output, "Pvp ON | ");
  4963. if (map[m_id].flag.nopvp)
  4964. strcat(atcmd_output, "NoPvp | ");
  4965. if (map[m_id].flag.pvp_noguild)
  4966. strcat(atcmd_output, "NoGuild | ");
  4967. if (map[m_id].flag.pvp_noparty)
  4968. strcat(atcmd_output, "NoParty | ");
  4969. if (map[m_id].flag.pvp_nightmaredrop)
  4970. strcat(atcmd_output, "NightmareDrop | ");
  4971. if (map[m_id].flag.pvp_nocalcrank)
  4972. strcat(atcmd_output, "NoCalcRank | ");
  4973. clif_displaymessage(fd, atcmd_output);
  4974. strcpy(atcmd_output,"GvG Flags: ");
  4975. if (map[m_id].flag.gvg)
  4976. strcat(atcmd_output, "GvG ON | ");
  4977. if (map[m_id].flag.gvg_dungeon)
  4978. strcat(atcmd_output, "GvG Dungeon | ");
  4979. if (map[m_id].flag.gvg_castle)
  4980. strcat(atcmd_output, "GvG Castle | ");
  4981. if (map[m_id].flag.gvg_noparty)
  4982. strcat(atcmd_output, "NoParty | ");
  4983. clif_displaymessage(fd, atcmd_output);
  4984. strcpy(atcmd_output,"Teleport Flags: ");
  4985. if (map[m_id].flag.noteleport)
  4986. strcat(atcmd_output, "NoTeleport | ");
  4987. if (map[m_id].flag.monster_noteleport)
  4988. strcat(atcmd_output, "Monster NoTeleport | ");
  4989. if (map[m_id].flag.nowarp)
  4990. strcat(atcmd_output, "NoWarp | ");
  4991. if (map[m_id].flag.nowarpto)
  4992. strcat(atcmd_output, "NoWarpTo | ");
  4993. if (map[m_id].flag.noreturn)
  4994. strcat(atcmd_output, "NoReturn | ");
  4995. if (map[m_id].flag.nogo)
  4996. strcat(atcmd_output, "NoGo | ");
  4997. if (map[m_id].flag.nomemo)
  4998. strcat(atcmd_output, "NoMemo | ");
  4999. clif_displaymessage(fd, atcmd_output);
  5000. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  5001. clif_displaymessage(fd, atcmd_output);
  5002. if (map[m_id].flag.nosave) {
  5003. if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  5004. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  5005. else
  5006. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  5007. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  5008. clif_displaymessage(fd, atcmd_output);
  5009. }
  5010. strcpy(atcmd_output,"Weather Flags: ");
  5011. if (map[m_id].flag.snow)
  5012. strcat(atcmd_output, "Snow | ");
  5013. if (map[m_id].flag.fog)
  5014. strcat(atcmd_output, "Fog | ");
  5015. if (map[m_id].flag.sakura)
  5016. strcat(atcmd_output, "Sakura | ");
  5017. if (map[m_id].flag.clouds)
  5018. strcat(atcmd_output, "Clouds | ");
  5019. if (map[m_id].flag.clouds2)
  5020. strcat(atcmd_output, "Clouds2 | ");
  5021. if (map[m_id].flag.fireworks)
  5022. strcat(atcmd_output, "Fireworks | ");
  5023. if (map[m_id].flag.leaves)
  5024. strcat(atcmd_output, "Leaves | ");
  5025. if (map[m_id].flag.rain)
  5026. strcat(atcmd_output, "Rain | ");
  5027. if (map[m_id].flag.indoors)
  5028. strcat(atcmd_output, "Indoors | ");
  5029. if (map[m_id].flag.nightenabled)
  5030. strcat(atcmd_output, "Displays Night | ");
  5031. clif_displaymessage(fd, atcmd_output);
  5032. strcpy(atcmd_output,"Other Flags: ");
  5033. if (map[m_id].flag.nobranch)
  5034. strcat(atcmd_output, "NoBranch | ");
  5035. if (map[m_id].flag.notrade)
  5036. strcat(atcmd_output, "NoTrade | ");
  5037. if (map[m_id].flag.nodrop)
  5038. strcat(atcmd_output, "NoDrop | ");
  5039. if (map[m_id].flag.noskill)
  5040. strcat(atcmd_output, "NoSkill | ");
  5041. if (map[m_id].flag.noicewall)
  5042. strcat(atcmd_output, "NoIcewall | ");
  5043. if (map[m_id].flag.nocommand)
  5044. strcat(atcmd_output, "NoCommand | ");
  5045. clif_displaymessage(fd, atcmd_output);
  5046. strcpy(atcmd_output,"Other Flags: ");
  5047. if (map[m_id].flag.nobaseexp)
  5048. strcat(atcmd_output, "NoBaseEXP | ");
  5049. if (map[m_id].flag.nojobexp)
  5050. strcat(atcmd_output, "NoJobEXP | ");
  5051. if (map[m_id].flag.nomobloot)
  5052. strcat(atcmd_output, "NoMobLoot | ");
  5053. if (map[m_id].flag.nomvploot)
  5054. strcat(atcmd_output, "NoMVPLoot | ");
  5055. clif_displaymessage(fd, atcmd_output);
  5056. switch (list) {
  5057. case 0:
  5058. // Do nothing. It's list 0, no additional display.
  5059. break;
  5060. case 1:
  5061. clif_displaymessage(fd, "----- Players in Map -----");
  5062. for (i = 0; i < users; i++) {
  5063. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5064. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5065. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5066. clif_displaymessage(fd, atcmd_output);
  5067. }
  5068. }
  5069. break;
  5070. case 2:
  5071. clif_displaymessage(fd, "----- NPCs in Map -----");
  5072. for (i = 0; i < map[m_id].npc_num;) {
  5073. nd = map[m_id].npc[i];
  5074. switch(nd->ud.dir) {
  5075. case 0: strcpy(direction, "North"); break;
  5076. case 1: strcpy(direction, "North West"); break;
  5077. case 2: strcpy(direction, "West"); break;
  5078. case 3: strcpy(direction, "South West"); break;
  5079. case 4: strcpy(direction, "South"); break;
  5080. case 5: strcpy(direction, "South East"); break;
  5081. case 6: strcpy(direction, "East"); break;
  5082. case 7: strcpy(direction, "North East"); break;
  5083. case 9: strcpy(direction, "North"); break;
  5084. default: strcpy(direction, "Unknown"); break;
  5085. }
  5086. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5087. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5088. clif_displaymessage(fd, atcmd_output);
  5089. }
  5090. break;
  5091. case 3:
  5092. clif_displaymessage(fd, "----- Chats in Map -----");
  5093. for (i = 0; i < users; i++) {
  5094. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5095. pl_sd->mapindex == m_index &&
  5096. cd->usersd[0] == pl_sd) {
  5097. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5098. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5099. clif_displaymessage(fd, atcmd_output);
  5100. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5101. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5102. clif_displaymessage(fd, atcmd_output);
  5103. }
  5104. }
  5105. break;
  5106. default: // normally impossible to arrive here
  5107. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5108. return -1;
  5109. break;
  5110. }
  5111. return 0;
  5112. }
  5113. /*==========================================
  5114. *
  5115. *------------------------------------------
  5116. */
  5117. int atcommand_mount_peco(
  5118. const int fd, struct map_session_data* sd,
  5119. const char* command, const char* message)
  5120. {
  5121. nullpo_retr(-1, sd);
  5122. if (!pc_isriding(sd)) { // if actually no peco
  5123. if (pc_checkskill(sd, KN_RIDING)) {
  5124. pc_setoption(sd, sd->sc.option | 0x0020);
  5125. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5126. } else {
  5127. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5128. return -1;
  5129. }
  5130. } else { //Dismount
  5131. pc_setoption(sd, sd->sc.option & ~0x0020);
  5132. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5133. }
  5134. return 0;
  5135. }
  5136. /*==========================================
  5137. *
  5138. *------------------------------------------
  5139. */
  5140. int atcommand_char_mount_peco(
  5141. const int fd, struct map_session_data* sd,
  5142. const char* command, const char* message)
  5143. {
  5144. struct map_session_data *pl_sd;
  5145. nullpo_retr(-1, sd);
  5146. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5147. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5148. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5149. return -1;
  5150. }
  5151. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5152. if (!pc_isriding(pl_sd)) { // if actually no peco
  5153. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5154. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5155. clif_displaymessage(fd, msg_table[216]); // Mounted Peco.
  5156. } else {
  5157. clif_displaymessage(fd, msg_table[217]); // You can not mount a peco with your job.
  5158. return -1;
  5159. }
  5160. } else { //Dismount
  5161. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5162. clif_displaymessage(fd, msg_table[218]); // Unmounted Peco.
  5163. }
  5164. } else {
  5165. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5166. return -1;
  5167. }
  5168. return 0;
  5169. }
  5170. /*==========================================
  5171. *Spy Commands by Syrus22
  5172. *------------------------------------------
  5173. */
  5174. int atcommand_guildspy(
  5175. const int fd, struct map_session_data* sd,
  5176. const char* command, const char* message)
  5177. {
  5178. char guild_name[NAME_LENGTH];
  5179. struct guild *g;
  5180. nullpo_retr(-1, sd);
  5181. memset(guild_name, '\0', sizeof(guild_name));
  5182. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5183. if (!enable_spy)
  5184. {
  5185. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5186. return -1;
  5187. }
  5188. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5189. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5190. return -1;
  5191. }
  5192. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5193. (g = guild_search(atoi(message))) != NULL) {
  5194. if (sd->guildspy == g->guild_id) {
  5195. sd->guildspy = 0;
  5196. sprintf(atcmd_output, msg_table[103], g->name); // No longer spying on the %s guild.
  5197. clif_displaymessage(fd, atcmd_output);
  5198. } else {
  5199. sd->guildspy = g->guild_id;
  5200. sprintf(atcmd_output, msg_table[104], g->name); // Spying on the %s guild.
  5201. clif_displaymessage(fd, atcmd_output);
  5202. }
  5203. } else {
  5204. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5205. return -1;
  5206. }
  5207. return 0;
  5208. }
  5209. /*==========================================
  5210. *
  5211. *------------------------------------------
  5212. */
  5213. int atcommand_partyspy(
  5214. const int fd, struct map_session_data* sd,
  5215. const char* command, const char* message)
  5216. {
  5217. char party_name[NAME_LENGTH];
  5218. struct party *p;
  5219. nullpo_retr(-1, sd);
  5220. memset(party_name, '\0', sizeof(party_name));
  5221. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5222. if (!enable_spy)
  5223. {
  5224. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5225. return -1;
  5226. }
  5227. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5228. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5229. return -1;
  5230. }
  5231. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5232. (p = party_search(atoi(message))) != NULL) {
  5233. if (sd->partyspy == p->party_id) {
  5234. sd->partyspy = 0;
  5235. sprintf(atcmd_output, msg_table[105], p->name); // No longer spying on the %s party.
  5236. clif_displaymessage(fd, atcmd_output);
  5237. } else {
  5238. sd->partyspy = p->party_id;
  5239. sprintf(atcmd_output, msg_table[106], p->name); // Spying on the %s party.
  5240. clif_displaymessage(fd, atcmd_output);
  5241. }
  5242. } else {
  5243. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5244. return -1;
  5245. }
  5246. return 0;
  5247. }
  5248. /*==========================================
  5249. * @repairall [Valaris]
  5250. *------------------------------------------
  5251. */
  5252. int atcommand_repairall(
  5253. const int fd, struct map_session_data* sd,
  5254. const char* command, const char* message)
  5255. {
  5256. int count, i;
  5257. nullpo_retr(-1, sd);
  5258. count = 0;
  5259. for (i = 0; i < MAX_INVENTORY; i++) {
  5260. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5261. sd->status.inventory[i].attribute = 0;
  5262. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5263. count++;
  5264. }
  5265. }
  5266. if (count > 0) {
  5267. clif_misceffect(&sd->bl, 3);
  5268. clif_equiplist(sd);
  5269. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5270. } else {
  5271. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5272. return -1;
  5273. }
  5274. return 0;
  5275. }
  5276. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5277. int atcommand_nuke(
  5278. const int fd, struct map_session_data* sd,
  5279. const char* command, const char* message)
  5280. {
  5281. struct map_session_data *pl_sd;
  5282. nullpo_retr(-1, sd);
  5283. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5284. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5285. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5286. return -1;
  5287. }
  5288. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5289. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5290. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5291. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5292. } else {
  5293. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5294. return -1;
  5295. }
  5296. } else {
  5297. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5298. return -1;
  5299. }
  5300. return 0;
  5301. }
  5302. /*==========================================
  5303. * @tonpc
  5304. *------------------------------------------
  5305. */
  5306. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5307. const char* command, const char* message)
  5308. {
  5309. char npcname[NAME_LENGTH];
  5310. struct npc_data *nd;
  5311. nullpo_retr(-1, sd);
  5312. memset(npcname, 0, sizeof(npcname));
  5313. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5314. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5315. return -1;
  5316. }
  5317. if ((nd = npc_name2id(npcname)) != NULL) {
  5318. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5319. clif_displaymessage(fd, msg_table[0]); // Warped.
  5320. else
  5321. return -1;
  5322. } else {
  5323. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5324. return -1;
  5325. }
  5326. return 0;
  5327. }
  5328. /*==========================================
  5329. *
  5330. *------------------------------------------
  5331. */
  5332. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5333. const char* command, const char* message)
  5334. {
  5335. char NPCname[NAME_LENGTH];
  5336. nullpo_retr(-1, sd);
  5337. memset(NPCname, '\0', sizeof(NPCname));
  5338. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5339. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5340. return -1;
  5341. }
  5342. if (npc_name2id(NPCname) != NULL) {
  5343. npc_enable(NPCname, 1);
  5344. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5345. } else {
  5346. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5347. return -1;
  5348. }
  5349. return 0;
  5350. }
  5351. /*==========================================
  5352. *
  5353. *------------------------------------------
  5354. */
  5355. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5356. const char* command, const char* message)
  5357. {
  5358. char NPCname[NAME_LENGTH];
  5359. nullpo_retr(-1, sd);
  5360. memset(NPCname, '\0', sizeof(NPCname));
  5361. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5362. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5363. return -1;
  5364. }
  5365. if (npc_name2id(NPCname) != NULL) {
  5366. npc_enable(NPCname, 0);
  5367. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5368. } else {
  5369. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5370. return -1;
  5371. }
  5372. return 0;
  5373. }
  5374. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5375. const char* command, const char* message)
  5376. {
  5377. FILE *fp;
  5378. if (!message || !*message) {
  5379. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5380. return -1;
  5381. }
  5382. // check if script file exists
  5383. if ((fp = fopen(message, "r")) == NULL) {
  5384. clif_displaymessage(fd, msg_table[261]);
  5385. return -1;
  5386. }
  5387. fclose(fp);
  5388. // add to list of script sources and run it
  5389. npc_addsrcfile((char *)message);
  5390. npc_parsesrcfile((char *)message);
  5391. clif_displaymessage(fd, msg_table[262]);
  5392. return 0;
  5393. }
  5394. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5395. const char* command, const char* message)
  5396. {
  5397. struct npc_data *nd;
  5398. char NPCname[NAME_LENGTH];
  5399. nullpo_retr(-1, sd);
  5400. memset(NPCname, '\0', sizeof(NPCname));
  5401. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5402. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5403. return -1;
  5404. }
  5405. if ((nd = npc_name2id(NPCname)) != NULL) {
  5406. npc_unload(nd);
  5407. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5408. } else {
  5409. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5410. return -1;
  5411. }
  5412. return 0;
  5413. }
  5414. /*==========================================
  5415. * time in txt for time command (by [Yor])
  5416. *------------------------------------------
  5417. */
  5418. char * txt_time(unsigned int duration) {
  5419. int days, hours, minutes, seconds;
  5420. char temp[256];
  5421. static char temp1[256];
  5422. memset(temp, '\0', sizeof(temp));
  5423. memset(temp1, '\0', sizeof(temp1));
  5424. if (duration < 0)
  5425. duration = 0;
  5426. days = duration / (60 * 60 * 24);
  5427. duration = duration - (60 * 60 * 24 * days);
  5428. hours = duration / (60 * 60);
  5429. duration = duration - (60 * 60 * hours);
  5430. minutes = duration / 60;
  5431. seconds = duration - (60 * minutes);
  5432. if (days < 2)
  5433. sprintf(temp, msg_table[219], days); // %d day
  5434. else
  5435. sprintf(temp, msg_table[220], days); // %d days
  5436. if (hours < 2)
  5437. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5438. else
  5439. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5440. if (minutes < 2)
  5441. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5442. else
  5443. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5444. if (seconds < 2)
  5445. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5446. else
  5447. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5448. return temp1;
  5449. }
  5450. /*==========================================
  5451. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5452. * Calculation management of GM modification (@day/@night GM commands) is done
  5453. *------------------------------------------
  5454. */
  5455. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5456. const char* command, const char* message)
  5457. {
  5458. struct TimerData * timer_data;
  5459. struct TimerData * timer_data2;
  5460. time_t time_server; // variable for number of seconds (used with time() function)
  5461. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5462. char temp[256];
  5463. nullpo_retr(-1, sd);
  5464. memset(temp, '\0', sizeof(temp));
  5465. time(&time_server); // get time in seconds since 1/1/1970
  5466. datetime = localtime(&time_server); // convert seconds in structure
  5467. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5468. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5469. clif_displaymessage(fd, temp);
  5470. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5471. if (night_flag == 0)
  5472. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5473. else
  5474. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5475. } else if (battle_config.night_duration == 0)
  5476. if (night_flag == 1) { // we start with night
  5477. timer_data = get_timer(day_timer_tid);
  5478. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5479. clif_displaymessage(fd, temp);
  5480. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5481. } else
  5482. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5483. else if (battle_config.day_duration == 0)
  5484. if (night_flag == 0) { // we start with day
  5485. timer_data = get_timer(night_timer_tid);
  5486. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5487. clif_displaymessage(fd, temp);
  5488. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5489. } else
  5490. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5491. else {
  5492. if (night_flag == 0) {
  5493. timer_data = get_timer(night_timer_tid);
  5494. timer_data2 = get_timer(day_timer_tid);
  5495. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5496. clif_displaymessage(fd, temp);
  5497. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5498. 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.
  5499. else
  5500. 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.
  5501. clif_displaymessage(fd, temp);
  5502. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5503. clif_displaymessage(fd, temp);
  5504. } else {
  5505. timer_data = get_timer(day_timer_tid);
  5506. timer_data2 = get_timer(night_timer_tid);
  5507. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5508. clif_displaymessage(fd, temp);
  5509. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5510. 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.
  5511. else
  5512. 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.
  5513. clif_displaymessage(fd, temp);
  5514. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5515. clif_displaymessage(fd, temp);
  5516. }
  5517. }
  5518. return 0;
  5519. }
  5520. /*==========================================
  5521. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5522. * removes <quantity> item from a character
  5523. * item can be equiped or not.
  5524. * Inspired from a old command created by RoVeRT
  5525. *------------------------------------------
  5526. */
  5527. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5528. const char* command, const char* message)
  5529. {
  5530. struct map_session_data *pl_sd;
  5531. char item_name[100];
  5532. int i, number = 0, item_id, item_position, count;
  5533. struct item_data *item_data;
  5534. nullpo_retr(-1, sd);
  5535. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5536. memset(item_name, '\0', sizeof(item_name));
  5537. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5538. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5539. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5540. return -1;
  5541. }
  5542. item_id = 0;
  5543. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5544. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5545. item_id = item_data->nameid;
  5546. if (item_id > 500) {
  5547. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5548. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5549. item_position = pc_search_inventory(pl_sd, item_id);
  5550. if (item_position >= 0) {
  5551. count = 0;
  5552. for(i = 0; i < number && item_position >= 0; i++) {
  5553. //Logs (A)dmins items [Lupus]
  5554. if(log_config.pick > 0 ) {
  5555. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5556. }
  5557. //Logs
  5558. pc_delitem(pl_sd, item_position, 1, 0);
  5559. count++;
  5560. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5561. }
  5562. sprintf(atcmd_output, msg_table[113], count); // %d item(s) removed by a GM.
  5563. clif_displaymessage(pl_sd->fd, atcmd_output);
  5564. if (number == count)
  5565. sprintf(atcmd_output, msg_table[114], count); // %d item(s) removed from the player.
  5566. else
  5567. sprintf(atcmd_output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5568. clif_displaymessage(fd, atcmd_output);
  5569. } else {
  5570. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5571. return -1;
  5572. }
  5573. } else {
  5574. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5575. return -1;
  5576. }
  5577. } else {
  5578. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5579. return -1;
  5580. }
  5581. } else {
  5582. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5583. return -1;
  5584. }
  5585. return 0;
  5586. }
  5587. /*==========================================
  5588. * @jail <char_name> by [Yor]
  5589. * Special warp! No check with nowarp and nowarpto flag
  5590. *------------------------------------------
  5591. */
  5592. int atcommand_jail(
  5593. const int fd, struct map_session_data* sd,
  5594. const char* command, const char* message)
  5595. {
  5596. struct map_session_data *pl_sd;
  5597. int x, y;
  5598. unsigned short m_index;
  5599. nullpo_retr(-1, sd);
  5600. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5601. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5602. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5603. return -1;
  5604. }
  5605. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5606. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5607. switch(rand() % 2) {
  5608. case 0:
  5609. x = 24;
  5610. y = 75;
  5611. break;
  5612. default:
  5613. x = 49;
  5614. y = 75;
  5615. break;
  5616. }
  5617. m_index = mapindex_name2id(MAP_JAIL);
  5618. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0) {
  5619. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5620. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5621. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5622. } else {
  5623. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5624. return -1;
  5625. }
  5626. } else {
  5627. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5628. return -1;
  5629. }
  5630. } else {
  5631. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5632. return -1;
  5633. }
  5634. return 0;
  5635. }
  5636. /*==========================================
  5637. * @unjail/@discharge <char_name> by [Yor]
  5638. * Special warp! No check with nowarp and nowarpto flag
  5639. *------------------------------------------
  5640. */
  5641. int atcommand_unjail(
  5642. const int fd, struct map_session_data* sd,
  5643. const char* command, const char* message)
  5644. {
  5645. struct map_session_data *pl_sd;
  5646. unsigned short m_index;
  5647. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5648. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5649. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5650. return -1;
  5651. }
  5652. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5653. m_index = mapindex_name2id(MAP_PRONTERA);
  5654. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5655. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5656. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5657. return -1;
  5658. } else if (pc_setpos(pl_sd, m_index, 0, 0, 3) == 0) { //old coords: 156,191
  5659. pc_setsavepoint(pl_sd, m_index, 0, 0); // Save char respawn point in Prontera
  5660. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5661. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5662. } else {
  5663. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5664. return -1;
  5665. }
  5666. } else {
  5667. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5668. return -1;
  5669. }
  5670. } else {
  5671. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5672. return -1;
  5673. }
  5674. return 0;
  5675. }
  5676. /*==========================================
  5677. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5678. *------------------------------------------
  5679. */
  5680. int atcommand_disguise(
  5681. const int fd, struct map_session_data* sd,
  5682. const char* command, const char* message)
  5683. {
  5684. int id = 0;
  5685. nullpo_retr(-1, sd);
  5686. if (!message || !*message) {
  5687. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5688. return -1;
  5689. }
  5690. if ((id = atoi(message)) > 0)
  5691. { //Acquired an ID
  5692. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5693. id = 0; //Invalid id for either mobs or npcs.
  5694. } else { //Acquired a Name
  5695. if ((id = mobdb_searchname(message)) == 0)
  5696. {
  5697. struct npc_data* nd = npc_name2id(message);
  5698. if (nd != NULL)
  5699. id = nd->n;
  5700. }
  5701. }
  5702. if (id == 0)
  5703. { // Monster/NPC name/id hasn't been found.
  5704. clif_displaymessage(fd, msg_table[123]);
  5705. return -1;
  5706. }
  5707. pc_disguise(sd, id);
  5708. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5709. return 0;
  5710. }
  5711. /*==========================================
  5712. * DisguiseAll
  5713. *------------------------------------------
  5714. */
  5715. int atcommand_disguiseall(
  5716. const int fd, struct map_session_data* sd,
  5717. const char* command, const char* message)
  5718. {
  5719. int mob_id=0, i=0, users;
  5720. struct map_session_data *pl_sd, **pl_allsd;
  5721. nullpo_retr(-1, sd);
  5722. if (!message || !*message) {
  5723. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5724. return -1;
  5725. }
  5726. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5727. mob_id = atoi(message);
  5728. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5729. pl_allsd = map_getallusers(&users);
  5730. for(i=0; i < users; i++) {
  5731. if((pl_sd = pl_allsd[i]))
  5732. pc_disguise(pl_sd, mob_id);
  5733. }
  5734. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5735. } else {
  5736. return -1;
  5737. }
  5738. return 0;
  5739. }
  5740. /*==========================================
  5741. * @undisguise by [Yor]
  5742. *------------------------------------------
  5743. */
  5744. int atcommand_undisguise(
  5745. const int fd, struct map_session_data* sd,
  5746. const char* command, const char* message)
  5747. {
  5748. nullpo_retr(-1, sd);
  5749. if (sd->disguise) {
  5750. pc_disguise(sd, 0);
  5751. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5752. } else {
  5753. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5754. return -1;
  5755. }
  5756. return 0;
  5757. }
  5758. /*==========================================
  5759. * UndisguiseAll
  5760. *------------------------------------------
  5761. */
  5762. int atcommand_undisguiseall(
  5763. const int fd, struct map_session_data* sd,
  5764. const char* command, const char* message)
  5765. {
  5766. struct map_session_data *pl_sd, **pl_allsd;
  5767. int i, users;
  5768. nullpo_retr(-1, sd);
  5769. pl_allsd = map_getallusers(&users);
  5770. for(i=0; i < users; i++) {
  5771. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5772. pc_disguise(pl_sd, 0);
  5773. }
  5774. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5775. return 0;
  5776. }
  5777. /*==========================================
  5778. * @exp by [Skotlex]
  5779. *------------------------------------------
  5780. */
  5781. int atcommand_exp(
  5782. const int fd, struct map_session_data* sd,
  5783. const char* command, const char* message)
  5784. {
  5785. char output[200];
  5786. double nextb, nextj;
  5787. nullpo_retr(-1, sd);
  5788. memset(output, '\0', sizeof(output));
  5789. nextb = pc_nextbaseexp(sd);
  5790. if (nextb)
  5791. nextb = sd->status.base_exp*100.0/nextb;
  5792. nextj = pc_nextjobexp(sd);
  5793. if (nextj)
  5794. nextj = sd->status.job_exp*100.0/nextj;
  5795. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5796. clif_displaymessage(fd, output);
  5797. return 0;
  5798. }
  5799. /*==========================================
  5800. * @broadcast by [Valaris]
  5801. *------------------------------------------
  5802. */
  5803. int atcommand_broadcast(
  5804. const int fd, struct map_session_data* sd,
  5805. const char* command, const char* message)
  5806. {
  5807. nullpo_retr(-1, sd);
  5808. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5809. if (!message || !*message) {
  5810. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5811. return -1;
  5812. }
  5813. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5814. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5815. return 0;
  5816. }
  5817. /*==========================================
  5818. * @localbroadcast by [Valaris]
  5819. *------------------------------------------
  5820. */
  5821. int atcommand_localbroadcast(
  5822. const int fd, struct map_session_data* sd,
  5823. const char* command, const char* message)
  5824. {
  5825. nullpo_retr(-1, sd);
  5826. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5827. if (!message || !*message) {
  5828. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5829. return -1;
  5830. }
  5831. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5832. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5833. return 0;
  5834. }
  5835. /*==========================================
  5836. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5837. *------------------------------------------
  5838. */
  5839. int atcommand_chardisguise(
  5840. const int fd, struct map_session_data* sd,
  5841. const char* command, const char* message)
  5842. {
  5843. int mob_id;
  5844. char mob_name[NAME_LENGTH];
  5845. struct map_session_data* pl_sd;
  5846. nullpo_retr(-1, sd);
  5847. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5848. memset(mob_name, '\0', sizeof(mob_name));
  5849. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5850. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5851. return -1;
  5852. }
  5853. if ((mob_id = atoi(mob_name)) > 0)
  5854. { //Acquired an ID
  5855. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5856. mob_id = 0; //Invalid id for either mobs or npcs.
  5857. } else { //Acquired a Name
  5858. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5859. {
  5860. struct npc_data* nd = npc_name2id(mob_name);
  5861. if (nd != NULL)
  5862. mob_id = nd->n;
  5863. }
  5864. }
  5865. if (mob_id == 0)
  5866. {
  5867. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5868. return -1;
  5869. }
  5870. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5871. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5872. pc_disguise(pl_sd, mob_id);
  5873. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5874. } else {
  5875. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5876. return -1;
  5877. }
  5878. } else {
  5879. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5880. return -1;
  5881. }
  5882. return 0;
  5883. }
  5884. /*==========================================
  5885. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5886. *------------------------------------------
  5887. */
  5888. int atcommand_charundisguise(
  5889. const int fd, struct map_session_data* sd,
  5890. const char* command, const char* message)
  5891. {
  5892. struct map_session_data* pl_sd;
  5893. nullpo_retr(-1, sd);
  5894. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5895. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5896. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5897. return -1;
  5898. }
  5899. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5900. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5901. if (pl_sd->disguise)
  5902. pc_disguise(pl_sd, 0);
  5903. else {
  5904. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5905. return -1;
  5906. }
  5907. } else {
  5908. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5909. return -1;
  5910. }
  5911. } else {
  5912. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5913. return -1;
  5914. }
  5915. return 0;
  5916. }
  5917. /*==========================================
  5918. * @email <actual@email> <new@email> by [Yor]
  5919. *------------------------------------------
  5920. */
  5921. int atcommand_email(
  5922. const int fd, struct map_session_data* sd,
  5923. const char* command, const char* message)
  5924. {
  5925. char actual_email[100];
  5926. char new_email[100];
  5927. nullpo_retr(-1, sd);
  5928. memset(actual_email, '\0', sizeof(actual_email));
  5929. memset(new_email, '\0', sizeof(new_email));
  5930. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5931. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5932. return -1;
  5933. }
  5934. if (e_mail_check(actual_email) == 0) {
  5935. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5936. return -1;
  5937. } else if (e_mail_check(new_email) == 0) {
  5938. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5939. return -1;
  5940. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5941. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5942. return -1;
  5943. } else if (strcmpi(actual_email, new_email) == 0) {
  5944. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5945. return -1;
  5946. } else {
  5947. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5948. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5949. }
  5950. return 0;
  5951. }
  5952. /*==========================================
  5953. *@effect
  5954. *------------------------------------------
  5955. */
  5956. int atcommand_effect(
  5957. const int fd, struct map_session_data* sd,
  5958. const char* command, const char* message)
  5959. {
  5960. struct map_session_data *pl_sd, **pl_allsd;
  5961. int type = 0, flag = 0, i, users;
  5962. nullpo_retr(-1, sd);
  5963. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5964. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5965. return -1;
  5966. }
  5967. if(flag <=0){
  5968. clif_specialeffect(&sd->bl, type, flag);
  5969. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5970. }
  5971. else{
  5972. pl_allsd = map_getallusers(&users);
  5973. for (i = 0; i < users; i++) {
  5974. if ((pl_sd = pl_allsd[i])) {
  5975. clif_specialeffect(&pl_sd->bl, type, flag);
  5976. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5977. }
  5978. }
  5979. }
  5980. return 0;
  5981. }
  5982. /*==========================================
  5983. * @charcartlist <character>: Displays the items list of a player's cart.
  5984. *------------------------------------------
  5985. */
  5986. int
  5987. atcommand_character_cart_list(
  5988. const int fd, struct map_session_data* sd,
  5989. const char* command, const char* message)
  5990. {
  5991. char outputtmp[200];
  5992. struct map_session_data *pl_sd;
  5993. struct item_data *item_data, *item_temp;
  5994. int i, j, count, counter, counter2;
  5995. nullpo_retr(-1, sd);
  5996. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5997. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5998. memset(outputtmp, '\0', sizeof(outputtmp));
  5999. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6000. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6001. return -1;
  6002. }
  6003. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6004. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6005. counter = 0;
  6006. count = 0;
  6007. for (i = 0; i < MAX_CART; i++) {
  6008. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6009. counter = counter + pl_sd->status.cart[i].amount;
  6010. count++;
  6011. if (count == 1) {
  6012. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6013. clif_displaymessage(fd, atcmd_output);
  6014. }
  6015. if (pl_sd->status.cart[i].refine)
  6016. 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);
  6017. else
  6018. 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);
  6019. clif_displaymessage(fd, atcmd_output);
  6020. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6021. counter2 = 0;
  6022. for (j = 0; j < item_data->slot; j++) {
  6023. if (pl_sd->status.cart[i].card[j]) {
  6024. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6025. if (atcmd_output[0] == '\0')
  6026. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6027. else
  6028. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6029. strcat(atcmd_output, outputtmp);
  6030. }
  6031. }
  6032. }
  6033. if (atcmd_output[0] != '\0') {
  6034. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6035. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6036. clif_displaymessage(fd, atcmd_output);
  6037. }
  6038. }
  6039. }
  6040. if (count == 0)
  6041. clif_displaymessage(fd, "No item found in the cart of this player.");
  6042. else {
  6043. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6044. clif_displaymessage(fd, atcmd_output);
  6045. }
  6046. } else {
  6047. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6048. return -1;
  6049. }
  6050. } else {
  6051. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6052. return -1;
  6053. }
  6054. return 0;
  6055. }
  6056. /*==========================================
  6057. * @killer by MouseJstr
  6058. * enable killing players even when not in pvp
  6059. *------------------------------------------
  6060. */
  6061. int
  6062. atcommand_killer(
  6063. const int fd, struct map_session_data* sd,
  6064. const char* command, const char* message)
  6065. {
  6066. nullpo_retr(-1, sd);
  6067. sd->special_state.killer = !sd->special_state.killer;
  6068. if(sd->special_state.killer)
  6069. clif_displaymessage(fd, msg_table[241]);
  6070. else
  6071. clif_displaymessage(fd, msg_table[242]);
  6072. return 0;
  6073. }
  6074. /*==========================================
  6075. * @killable by MouseJstr
  6076. * enable other people killing you
  6077. *------------------------------------------
  6078. */
  6079. int
  6080. atcommand_killable(
  6081. const int fd, struct map_session_data* sd,
  6082. const char* command, const char* message)
  6083. {
  6084. nullpo_retr(-1, sd);
  6085. sd->special_state.killable = !sd->special_state.killable;
  6086. if(sd->special_state.killable)
  6087. clif_displaymessage(fd, msg_table[242]);
  6088. else
  6089. clif_displaymessage(fd, msg_table[241]);
  6090. return 0;
  6091. }
  6092. /*==========================================
  6093. * @charkillable by MouseJstr
  6094. * enable another player to be killed
  6095. *------------------------------------------
  6096. */
  6097. int
  6098. atcommand_charkillable(
  6099. const int fd, struct map_session_data* sd,
  6100. const char* command, const char* message)
  6101. {
  6102. struct map_session_data *pl_sd = NULL;
  6103. nullpo_retr(-1, sd);
  6104. if (!message || !*message)
  6105. return -1;
  6106. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6107. return -1;
  6108. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6109. if(pl_sd->special_state.killable)
  6110. clif_displaymessage(fd, "The player is now killable");
  6111. else
  6112. clif_displaymessage(fd, "The player is no longer killable");
  6113. return 0;
  6114. }
  6115. /*==========================================
  6116. * @skillon by MouseJstr
  6117. * turn skills on for the map
  6118. *------------------------------------------
  6119. */
  6120. int
  6121. atcommand_skillon(
  6122. const int fd, struct map_session_data* sd,
  6123. const char* command, const char* message)
  6124. {
  6125. nullpo_retr(-1, sd);
  6126. map[sd->bl.m].flag.noskill = 0;
  6127. clif_displaymessage(fd, msg_table[244]);
  6128. return 0;
  6129. }
  6130. /*==========================================
  6131. * @skilloff by MouseJstr
  6132. * Turn skills off on the map
  6133. *------------------------------------------
  6134. */
  6135. int
  6136. atcommand_skilloff(
  6137. const int fd, struct map_session_data* sd,
  6138. const char* command, const char* message)
  6139. {
  6140. nullpo_retr(-1, sd);
  6141. map[sd->bl.m].flag.noskill = 1;
  6142. clif_displaymessage(fd, msg_table[243]);
  6143. return 0;
  6144. }
  6145. /*==========================================
  6146. * @npcmove by MouseJstr
  6147. *
  6148. * move a npc
  6149. *------------------------------------------
  6150. */
  6151. int
  6152. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6153. const char* command, const char* message)
  6154. {
  6155. int x = 0, y = 0, m;
  6156. struct npc_data *nd = 0;
  6157. nullpo_retr(-1, sd);
  6158. if (!message || !*message)
  6159. return -1;
  6160. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6161. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6162. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6163. return -1;
  6164. }
  6165. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6166. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6167. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6168. return -1;
  6169. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6170. return -1; //Not on a map.
  6171. npc_enable(atcmd_player_name, 0);
  6172. if (x < 0) x = 0;
  6173. else if (x >= map[m].xs) x = map[m].xs-1;
  6174. if (y < 0) y = 0;
  6175. else if (y >= map[m].ys) y = map[m].ys-1;
  6176. map_moveblock(&nd->bl, x, y, gettick());
  6177. npc_enable(atcmd_player_name, 1);
  6178. return 0;
  6179. }
  6180. /*==========================================
  6181. * @addwarp by MouseJstr
  6182. *
  6183. * Create a new static warp point.
  6184. *------------------------------------------
  6185. */
  6186. int
  6187. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6188. const char* command, const char* message)
  6189. {
  6190. char w1[64], w3[64], w4[64];
  6191. int x,y,ret;
  6192. nullpo_retr(-1, sd);
  6193. if (!message || !*message)
  6194. return -1;
  6195. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6196. return -1;
  6197. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6198. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6199. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6200. ret = npc_parse_warp(w1, "warp", w3, w4);
  6201. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6202. clif_displaymessage(fd, atcmd_output);
  6203. return ret;
  6204. }
  6205. /*==========================================
  6206. * @follow by [MouseJstr]
  6207. *
  6208. * Follow a player .. staying no more then 5 spaces away
  6209. *------------------------------------------
  6210. */
  6211. int
  6212. atcommand_follow(const int fd, struct map_session_data* sd,
  6213. const char* command, const char* message)
  6214. {
  6215. struct map_session_data *pl_sd = NULL;
  6216. nullpo_retr(-1, sd);
  6217. if (!message || !*message) {
  6218. if (sd->followtarget == -1)
  6219. return -1;
  6220. pc_stop_following (sd);
  6221. clif_displaymessage(fd, "Stop following");
  6222. return 0;
  6223. }
  6224. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6225. if (sd->followtarget == pl_sd->bl.id)
  6226. pc_stop_following (sd);
  6227. else
  6228. pc_follow(sd, pl_sd->bl.id);
  6229. return 0;
  6230. }
  6231. return 1;
  6232. }
  6233. /*==========================================
  6234. * @dropall by [MouseJstr]
  6235. *
  6236. * Drop all your possession on the ground
  6237. *------------------------------------------
  6238. */
  6239. int
  6240. atcommand_dropall(const int fd, struct map_session_data* sd,
  6241. const char* command, const char* message)
  6242. {
  6243. int i;
  6244. nullpo_retr(-1, sd);
  6245. for (i = 0; i < MAX_INVENTORY; i++) {
  6246. if (sd->status.inventory[i].amount) {
  6247. if(sd->status.inventory[i].equip != 0)
  6248. pc_unequipitem(sd, i, 3);
  6249. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6250. }
  6251. }
  6252. return 0;
  6253. }
  6254. /*==========================================
  6255. * @chardropall by [MouseJstr]
  6256. *
  6257. * Throw all the characters possessions on the ground. Normally
  6258. * done in response to them being disrespectful of a GM
  6259. *------------------------------------------
  6260. */
  6261. int
  6262. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6263. const char* command, const char* message)
  6264. {
  6265. int i;
  6266. struct map_session_data *pl_sd = NULL;
  6267. nullpo_retr(-1, sd);
  6268. if (!message || !*message)
  6269. return -1;
  6270. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6271. return -1;
  6272. for (i = 0; i < MAX_INVENTORY; i++) {
  6273. if (pl_sd->status.inventory[i].amount) {
  6274. if(pl_sd->status.inventory[i].equip != 0)
  6275. pc_unequipitem(pl_sd, i, 3);
  6276. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6277. }
  6278. }
  6279. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6280. clif_displaymessage(fd, "It is done");
  6281. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6282. return 0;
  6283. }
  6284. /*==========================================
  6285. * @storeall by [MouseJstr]
  6286. *
  6287. * Put everything into storage to simplify your inventory to make
  6288. * debugging easie
  6289. *------------------------------------------
  6290. */
  6291. int
  6292. atcommand_storeall(const int fd, struct map_session_data* sd,
  6293. const char* command, const char* message)
  6294. {
  6295. int i;
  6296. nullpo_retr(-1, sd);
  6297. if (storage_storageopen(sd) == 1) {
  6298. clif_displaymessage(fd, "run this command again..");
  6299. return 0;
  6300. }
  6301. for (i = 0; i < MAX_INVENTORY; i++) {
  6302. if (sd->status.inventory[i].amount) {
  6303. if(sd->status.inventory[i].equip != 0)
  6304. pc_unequipitem(sd, i, 3);
  6305. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6306. }
  6307. }
  6308. storage_storageclose(sd);
  6309. clif_displaymessage(fd, "It is done");
  6310. return 0;
  6311. }
  6312. /*==========================================
  6313. * @charstoreall by [MouseJstr]
  6314. *
  6315. * A way to screw with players who piss you off
  6316. *------------------------------------------
  6317. */
  6318. int
  6319. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6320. const char* command, const char* message)
  6321. {
  6322. int i;
  6323. struct map_session_data *pl_sd = NULL;
  6324. nullpo_retr(-1, sd);
  6325. if (!message || !*message)
  6326. return -1;
  6327. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6328. return -1;
  6329. if (storage_storageopen(pl_sd) == 1) {
  6330. clif_displaymessage(fd, "Had to open the characters storage window...");
  6331. clif_displaymessage(fd, "run this command again..");
  6332. return 0;
  6333. }
  6334. for (i = 0; i < MAX_INVENTORY; i++) {
  6335. if (pl_sd->status.inventory[i].amount) {
  6336. if(pl_sd->status.inventory[i].equip != 0)
  6337. pc_unequipitem(pl_sd, i, 3);
  6338. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6339. }
  6340. }
  6341. storage_storageclose(pl_sd);
  6342. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6343. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6344. clif_displaymessage(pl_sd->fd, " -- the management");
  6345. clif_displaymessage(fd, "It is done");
  6346. return 0;
  6347. }
  6348. /*==========================================
  6349. * @skillid by [MouseJstr]
  6350. *
  6351. * lookup a skill by name
  6352. *------------------------------------------
  6353. */
  6354. int
  6355. atcommand_skillid(const int fd, struct map_session_data* sd,
  6356. const char* command, const char* message)
  6357. {
  6358. int skillen, idx;
  6359. nullpo_retr(-1, sd);
  6360. if (!message || !*message)
  6361. return -1;
  6362. skillen = strlen(message);
  6363. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6364. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6365. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6366. {
  6367. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6368. clif_displaymessage(fd, atcmd_output);
  6369. }
  6370. }
  6371. return 0;
  6372. }
  6373. /*==========================================
  6374. * @useskill by [MouseJstr]
  6375. *
  6376. * A way of using skills without having to find them in the skills menu
  6377. *------------------------------------------
  6378. */
  6379. int
  6380. atcommand_useskill(const int fd, struct map_session_data* sd,
  6381. const char* command, const char* message)
  6382. {
  6383. struct map_session_data *pl_sd = NULL;
  6384. int skillnum;
  6385. int skilllv;
  6386. char target[255];
  6387. nullpo_retr(-1, sd);
  6388. if (!message || !*message)
  6389. return -1;
  6390. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6391. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6392. return -1;
  6393. }
  6394. if((pl_sd=map_nick2sd(target)) == NULL) {
  6395. return -1;
  6396. }
  6397. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6398. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6399. else
  6400. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, skilllv);
  6401. return 0;
  6402. }
  6403. /*==========================================
  6404. * @skilltree by [MouseJstr]
  6405. *
  6406. * prints the skill tree for a player required to get to a skill
  6407. *------------------------------------------
  6408. */
  6409. int
  6410. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6411. const char* command, const char* message)
  6412. {
  6413. struct map_session_data *pl_sd = NULL;
  6414. int skillnum, skillidx = -1;
  6415. int meets = 1, j, c=0;
  6416. char target[NAME_LENGTH], *tbl;
  6417. struct skill_tree_entry *ent;
  6418. nullpo_retr(-1, sd);
  6419. if (!message || !*message)
  6420. return -1;
  6421. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6422. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6423. return -1;
  6424. }
  6425. if((pl_sd=map_nick2sd(target)) == NULL)
  6426. return -1;
  6427. c = pc_calc_skilltree_normalize_job(pl_sd);
  6428. tbl = job_name(c);
  6429. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6430. tbl, pc_checkskill(pl_sd, 1));
  6431. clif_displaymessage(fd, atcmd_output);
  6432. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6433. if (skill_tree[c][j].id == skillnum) {
  6434. skillidx = j;
  6435. break;
  6436. }
  6437. }
  6438. if (skillidx == -1) {
  6439. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6440. clif_displaymessage(fd, atcmd_output);
  6441. return 0;
  6442. }
  6443. ent = &skill_tree[c][skillidx];
  6444. for(j=0;j<5;j++)
  6445. if( ent->need[j].id &&
  6446. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6447. {
  6448. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6449. sprintf(atcmd_output, "player requires level %d of skill %s",
  6450. ent->need[j].lv, desc);
  6451. clif_displaymessage(fd, atcmd_output);
  6452. meets = 0;
  6453. }
  6454. if (meets == 1) {
  6455. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6456. clif_displaymessage(fd, atcmd_output);
  6457. }
  6458. return 0;
  6459. }
  6460. // Hand a ring with partners name on it to this char
  6461. void getring (struct map_session_data *sd)
  6462. {
  6463. int flag,item_id = 0;
  6464. struct item item_tmp;
  6465. if(sd->status.sex==0)
  6466. item_id = 2635;
  6467. else
  6468. item_id = 2634;
  6469. memset(&item_tmp,0,sizeof(item_tmp));
  6470. item_tmp.nameid=item_id;
  6471. item_tmp.identify=1;
  6472. item_tmp.card[0]=255;
  6473. item_tmp.card[2]=sd->status.partner_id;
  6474. item_tmp.card[3]=sd->status.partner_id >> 16;
  6475. //Logs (A)dmins items [Lupus]
  6476. if(log_config.pick > 0 ) {
  6477. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6478. }
  6479. //Logs
  6480. if((flag = pc_additem(sd,&item_tmp,1))) {
  6481. clif_additem(sd,0,0,flag);
  6482. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6483. }
  6484. }
  6485. /*==========================================
  6486. * @marry by [MouseJstr], fixed by Lupus
  6487. *
  6488. * Marry two players
  6489. *------------------------------------------
  6490. */
  6491. int
  6492. atcommand_marry(const int fd, struct map_session_data* sd,
  6493. const char* command, const char* message)
  6494. {
  6495. struct map_session_data *pl_sd1 = NULL;
  6496. struct map_session_data *pl_sd2 = NULL;
  6497. char player1[128], player2[128]; //Length used for return error msgs
  6498. nullpo_retr(-1, sd);
  6499. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6500. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6501. return -1;
  6502. }
  6503. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6504. sprintf(player2, "Cannot find player '%s' online", player1);
  6505. clif_displaymessage(fd, player2);
  6506. return -1;
  6507. }
  6508. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6509. sprintf(player1, "Cannot find player '%s' online", player2);
  6510. clif_displaymessage(fd, player1);
  6511. return -1;
  6512. }
  6513. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6514. clif_displaymessage(fd, "They are married.. wish them well");
  6515. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6516. // Auto-give named rings (Aru)
  6517. getring (pl_sd1);
  6518. getring (pl_sd2);
  6519. return 0;
  6520. }
  6521. return -1;
  6522. }
  6523. /*==========================================
  6524. * @divorce by [MouseJstr], fixed by [Lupus]
  6525. *
  6526. * divorce two players
  6527. *------------------------------------------
  6528. */
  6529. int
  6530. atcommand_divorce(const int fd, struct map_session_data* sd,
  6531. const char* command, const char* message)
  6532. {
  6533. struct map_session_data *pl_sd = NULL;
  6534. nullpo_retr(-1, sd);
  6535. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6536. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6537. return -1;
  6538. }
  6539. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6540. if (pc_divorce(pl_sd) != 0) {
  6541. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6542. clif_displaymessage(fd, atcmd_output);
  6543. return -1;
  6544. } else {
  6545. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6546. clif_displaymessage(fd, atcmd_output);
  6547. return 0;
  6548. }
  6549. }
  6550. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6551. clif_displaymessage(fd, atcmd_output);
  6552. return -1;
  6553. }
  6554. #ifdef DMALLOC
  6555. unsigned long dmark_;
  6556. int
  6557. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6558. const char* command, const char* message)
  6559. {
  6560. dmark_ = dmalloc_mark();
  6561. clif_displaymessage(fd, "debug mark set");
  6562. return 0;
  6563. }
  6564. int
  6565. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6566. const char* command, const char* message)
  6567. {
  6568. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6569. dmark_ = dmalloc_mark();
  6570. clif_displaymessage(fd, "malloc changes logged");
  6571. return 0;
  6572. }
  6573. #endif
  6574. /*==========================================
  6575. * @grind by [MouseJstr]
  6576. *------------------------------------------
  6577. */
  6578. int
  6579. atcommand_grind(const int fd, struct map_session_data* sd,
  6580. const char* command, const char* message)
  6581. {
  6582. struct map_session_data *pl_sd = NULL;
  6583. int skillnum;
  6584. int inf;
  6585. char target[NAME_LENGTH];
  6586. nullpo_retr(-1, sd);
  6587. if (!message || !*message)
  6588. return -1;
  6589. if(sscanf(message, "%23s", target) != 1) {
  6590. clif_displaymessage(fd, "Usage: @grind <target>");
  6591. return -1;
  6592. }
  6593. if((pl_sd=map_nick2sd(target)) == NULL)
  6594. return -1;
  6595. for (skillnum = 1; skillnum < 500; skillnum++) {
  6596. sd->status.sp = sd->status.max_sp;
  6597. atcommand_alive(fd, sd, command, message);
  6598. inf = skill_get_inf(skillnum);
  6599. if (inf & INF_GROUND_SKILL)
  6600. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6601. else if (!(inf & INF_SUPPORT_SKILL))
  6602. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6603. }
  6604. return 0;
  6605. }
  6606. /*==========================================
  6607. * @grind2 by [MouseJstr]
  6608. *------------------------------------------
  6609. */
  6610. int
  6611. atcommand_grind2(const int fd, struct map_session_data* sd,
  6612. const char* command, const char* message)
  6613. {
  6614. int i, x, y, id;
  6615. for (i = 1000; i <2000; i++) {
  6616. x = sd->bl.x + (rand() % 10 - 5);
  6617. y = sd->bl.y + (rand() % 10 - 5);
  6618. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6619. }
  6620. return 0;
  6621. }
  6622. /*==========================================
  6623. * @changelook by [Celest]
  6624. *------------------------------------------
  6625. */
  6626. int
  6627. atcommand_changelook(const int fd, struct map_session_data* sd,
  6628. const char* command, const char* message)
  6629. {
  6630. int i, j = 0, k = 0;
  6631. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6632. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6633. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6634. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6635. return -1;
  6636. } else if (i == 2) {
  6637. if (j < 1) j = 1;
  6638. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6639. j = pos[j - 1];
  6640. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6641. k = j; // swap
  6642. j = LOOK_HEAD_TOP;
  6643. }
  6644. clif_changelook(&sd->bl,j,k);
  6645. return 0;
  6646. }
  6647. /*==========================================
  6648. *Turns on/off Autotrade for a specific player
  6649. *------------------------------------------
  6650. *by durf (changed by Lupus)
  6651. */
  6652. int
  6653. atcommand_autotrade(
  6654. const int fd, struct map_session_data* sd,
  6655. const char* command, const char* message)
  6656. {
  6657. nullpo_retr(-1, sd);
  6658. if (sd->vender_id) //check if player's vending
  6659. {
  6660. sd->state.autotrade = 1;
  6661. clif_authfail_fd(fd, 15);
  6662. }
  6663. else
  6664. {
  6665. //"You should be vending to use @Autotrade."
  6666. clif_displaymessage(fd, msg_txt(549));
  6667. }
  6668. return 0;
  6669. }
  6670. /*==========================================
  6671. * Changes Master of your Guild to a specified guild member
  6672. *------------------------------------------
  6673. *by durf (changed by Lupus)
  6674. */
  6675. int
  6676. atcommand_changegm(
  6677. const int fd, struct map_session_data* sd,
  6678. const char* command, const char* message)
  6679. {
  6680. struct guild *g;
  6681. struct map_session_data *pl_sd;
  6682. nullpo_retr(-1, sd);
  6683. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6684. {
  6685. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6686. return -1;
  6687. }
  6688. if (strlen(message)==0)
  6689. {
  6690. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6691. return -1;
  6692. }
  6693. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6694. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6695. return -1;
  6696. }
  6697. guild_gm_change(sd->status.guild_id, pl_sd);
  6698. return 0;
  6699. }
  6700. /*==========================================
  6701. *Changes the leader of a party.
  6702. *------------------------------------------
  6703. *by Skotlex
  6704. */
  6705. int
  6706. atcommand_changeleader(
  6707. const int fd, struct map_session_data* sd,
  6708. const char* command, const char* message)
  6709. {
  6710. struct party *p;
  6711. struct map_session_data *pl_sd;
  6712. int mi, pl_mi;
  6713. nullpo_retr(-1, sd);
  6714. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6715. {
  6716. clif_displaymessage(fd, "You need to be a party's leader to use this command.");
  6717. return -1;
  6718. }
  6719. for (mi = 0; mi < MAX_PARTY && p->member[mi].sd != sd; mi++);
  6720. if (mi == MAX_PARTY)
  6721. return -1; //Shouldn't happen
  6722. if (!p->member[mi].leader)
  6723. {
  6724. clif_displaymessage(fd, "You need to be the party's leader to use this command.");
  6725. return -1;
  6726. }
  6727. if (strlen(message)==0)
  6728. {
  6729. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6730. return -1;
  6731. }
  6732. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6733. clif_displaymessage(fd, "Target character must be online and be in your party.");
  6734. return -1;
  6735. }
  6736. for (pl_mi = 0; pl_mi < MAX_PARTY && p->member[pl_mi].sd != pl_sd; pl_mi++);
  6737. if (pl_mi == MAX_PARTY)
  6738. return -1; //Shouldn't happen
  6739. //Change leadership.
  6740. p->member[mi].leader = 0;
  6741. if (p->member[mi].sd->fd)
  6742. clif_displaymessage(p->member[mi].sd->fd, "Leadership transferred.");
  6743. p->member[pl_mi].leader = 1;
  6744. if (p->member[pl_mi].sd->fd)
  6745. clif_displaymessage(p->member[pl_mi].sd->fd, "You've become the party leader.");
  6746. intif_party_leaderchange(p->party_id,p->member[pl_mi].account_id,p->member[pl_mi].char_id);
  6747. //Update info.
  6748. clif_party_main_info(p,-1);
  6749. clif_party_info(p,-1);
  6750. return 0;
  6751. }
  6752. /*==========================================
  6753. *Turns on/off AutoLoot for a specific player
  6754. *------------------------------------------
  6755. *by Upa-Kun
  6756. */
  6757. int
  6758. atcommand_autoloot(
  6759. const int fd, struct map_session_data* sd,
  6760. const char* command, const char* message)
  6761. {
  6762. int rate;
  6763. double drate;
  6764. nullpo_retr(-1, sd);
  6765. if (!message || !*message) {
  6766. if (sd->state.autoloot)
  6767. rate = 0;
  6768. else
  6769. rate = 10000;
  6770. } else {
  6771. drate = atof(message);
  6772. rate = (int)(drate*100);
  6773. }
  6774. if (rate > 10000) rate = 10000;
  6775. else if (rate < 0) rate = 0;
  6776. sd->state.autoloot = rate;
  6777. if (sd->state.autoloot) {
  6778. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6779. clif_displaymessage(fd, atcmd_output);
  6780. }else
  6781. clif_displaymessage(fd, "Autoloot is now off.");
  6782. return 0;
  6783. }
  6784. /*==========================================
  6785. * It is made to rain.
  6786. *------------------------------------------
  6787. */
  6788. int
  6789. atcommand_rain(
  6790. const int fd, struct map_session_data* sd,
  6791. const char* command, const char* message)
  6792. {
  6793. nullpo_retr(-1, sd);
  6794. if (map[sd->bl.m].flag.rain) {
  6795. map[sd->bl.m].flag.rain=0;
  6796. clif_weather(sd->bl.m);
  6797. clif_displaymessage(fd, "The rain has stopped.");
  6798. } else {
  6799. map[sd->bl.m].flag.rain=1;
  6800. clif_weather(sd->bl.m);
  6801. clif_displaymessage(fd, "It is made to rain.");
  6802. }
  6803. return 0;
  6804. }
  6805. /*==========================================
  6806. * It is made to snow.
  6807. *------------------------------------------
  6808. */
  6809. int
  6810. atcommand_snow(
  6811. const int fd, struct map_session_data* sd,
  6812. const char* command, const char* message)
  6813. {
  6814. nullpo_retr(-1, sd);
  6815. if (map[sd->bl.m].flag.snow) {
  6816. map[sd->bl.m].flag.snow=0;
  6817. clif_weather(sd->bl.m);
  6818. clif_displaymessage(fd, "Snow has stopped falling.");
  6819. } else {
  6820. map[sd->bl.m].flag.snow=1;
  6821. clif_weather(sd->bl.m);
  6822. clif_displaymessage(fd, "It is made to snow.");
  6823. }
  6824. return 0;
  6825. }
  6826. /*==========================================
  6827. * Cherry tree snowstorm is made to fall. (Sakura)
  6828. *------------------------------------------
  6829. */
  6830. int
  6831. atcommand_sakura(
  6832. const int fd, struct map_session_data* sd,
  6833. const char* command, const char* message)
  6834. {
  6835. nullpo_retr(-1, sd);
  6836. if (map[sd->bl.m].flag.sakura) {
  6837. map[sd->bl.m].flag.sakura=0;
  6838. clif_weather(sd->bl.m);
  6839. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6840. } else {
  6841. map[sd->bl.m].flag.sakura=1;
  6842. clif_weather(sd->bl.m);
  6843. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6844. }
  6845. return 0;
  6846. }
  6847. /*==========================================
  6848. * Clouds appear.
  6849. *------------------------------------------
  6850. */
  6851. int
  6852. atcommand_clouds(
  6853. const int fd, struct map_session_data* sd,
  6854. const char* command, const char* message)
  6855. {
  6856. nullpo_retr(-1, sd);
  6857. if (map[sd->bl.m].flag.clouds) {
  6858. map[sd->bl.m].flag.clouds=0;
  6859. clif_weather(sd->bl.m);
  6860. clif_displaymessage(fd, "The clouds has disappear.");
  6861. } else {
  6862. map[sd->bl.m].flag.clouds=1;
  6863. clif_weather(sd->bl.m);
  6864. clif_displaymessage(fd, "Clouds appear.");
  6865. }
  6866. return 0;
  6867. }
  6868. /*==========================================
  6869. * Different type of clouds using effect 516
  6870. *------------------------------------------
  6871. */
  6872. int
  6873. atcommand_clouds2(
  6874. const int fd, struct map_session_data* sd,
  6875. const char* command, const char* message)
  6876. {
  6877. nullpo_retr(-1, sd);
  6878. if (map[sd->bl.m].flag.clouds2) {
  6879. map[sd->bl.m].flag.clouds2=0;
  6880. clif_weather(sd->bl.m);
  6881. clif_displaymessage(fd, "The alternative clouds disappear.");
  6882. } else {
  6883. map[sd->bl.m].flag.clouds2=1;
  6884. clif_weather(sd->bl.m);
  6885. clif_displaymessage(fd, "Alternative clouds appear.");
  6886. }
  6887. return 0;
  6888. }
  6889. /*==========================================
  6890. * Fog hangs over.
  6891. *------------------------------------------
  6892. */
  6893. int
  6894. atcommand_fog(
  6895. const int fd, struct map_session_data* sd,
  6896. const char* command, const char* message)
  6897. {
  6898. nullpo_retr(-1, sd);
  6899. if (map[sd->bl.m].flag.fog) {
  6900. map[sd->bl.m].flag.fog=0;
  6901. clif_weather(sd->bl.m);
  6902. clif_displaymessage(fd, "The fog has gone.");
  6903. } else {
  6904. map[sd->bl.m].flag.fog=1;
  6905. clif_weather(sd->bl.m);
  6906. clif_displaymessage(fd, "Fog hangs over.");
  6907. }
  6908. return 0;
  6909. }
  6910. /*==========================================
  6911. * Fallen leaves fall.
  6912. *------------------------------------------
  6913. */
  6914. int
  6915. atcommand_leaves(
  6916. const int fd, struct map_session_data* sd,
  6917. const char* command, const char* message)
  6918. {
  6919. nullpo_retr(-1, sd);
  6920. if (map[sd->bl.m].flag.leaves) {
  6921. map[sd->bl.m].flag.leaves=0;
  6922. clif_weather(sd->bl.m);
  6923. clif_displaymessage(fd, "Leaves no longer fall.");
  6924. } else {
  6925. map[sd->bl.m].flag.leaves=1;
  6926. clif_weather(sd->bl.m);
  6927. clif_displaymessage(fd, "Fallen leaves fall.");
  6928. }
  6929. return 0;
  6930. }
  6931. /*==========================================
  6932. * Fireworks appear.
  6933. *------------------------------------------
  6934. */
  6935. int
  6936. atcommand_fireworks(
  6937. const int fd, struct map_session_data* sd,
  6938. const char* command, const char* message)
  6939. {
  6940. nullpo_retr(-1, sd);
  6941. if (map[sd->bl.m].flag.fireworks) {
  6942. map[sd->bl.m].flag.fireworks=0;
  6943. clif_weather(sd->bl.m);
  6944. clif_displaymessage(fd, "Fireworks are ended.");
  6945. } else {
  6946. map[sd->bl.m].flag.fireworks=1;
  6947. clif_weather(sd->bl.m);
  6948. clif_displaymessage(fd, "Fireworks are launched.");
  6949. }
  6950. return 0;
  6951. }
  6952. /*==========================================
  6953. * Clearing Weather Effects by Dexity
  6954. *------------------------------------------
  6955. */
  6956. int
  6957. atcommand_clearweather(
  6958. const int fd, struct map_session_data* sd,
  6959. const char* command, const char* message)
  6960. {
  6961. nullpo_retr(-1, sd);
  6962. map[sd->bl.m].flag.rain=0;
  6963. map[sd->bl.m].flag.snow=0;
  6964. map[sd->bl.m].flag.sakura=0;
  6965. map[sd->bl.m].flag.clouds=0;
  6966. map[sd->bl.m].flag.clouds2=0;
  6967. map[sd->bl.m].flag.fog=0;
  6968. map[sd->bl.m].flag.fireworks=0;
  6969. map[sd->bl.m].flag.leaves=0;
  6970. clif_weather(sd->bl.m);
  6971. return 0;
  6972. }
  6973. /*===============================================================
  6974. * Sound Command - plays a sound for everyone! [Codemaster]
  6975. *---------------------------------------------------------------
  6976. */
  6977. int
  6978. atcommand_sound(
  6979. const int fd, struct map_session_data *sd,
  6980. const char *command, const char *message)
  6981. {
  6982. char sound_file[100];
  6983. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6984. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6985. return -1;
  6986. }
  6987. memset(sound_file, '\0', sizeof(sound_file));
  6988. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6989. return -1;
  6990. if(strstr(sound_file, ".wav") == NULL)
  6991. strcat(sound_file, ".wav");
  6992. clif_soundeffectall(&sd->bl, sound_file,0,2);
  6993. return 0;
  6994. }
  6995. /*==========================================
  6996. * MOB Search
  6997. *------------------------------------------
  6998. */
  6999. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  7000. {
  7001. int mob_id,fd;
  7002. static int number=0;
  7003. struct mob_data *md;
  7004. nullpo_retr(0, bl);
  7005. if(!ap){
  7006. number=0;
  7007. return 0;
  7008. }
  7009. mob_id = va_arg(ap,int);
  7010. fd = va_arg(ap,int);
  7011. md = (struct mob_data *)bl;
  7012. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7013. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7014. ++number,bl->x, bl->y,md->name);
  7015. clif_displaymessage(fd, atcmd_output);
  7016. }
  7017. return 0;
  7018. }
  7019. int atcommand_mobsearch(
  7020. const int fd, struct map_session_data* sd,
  7021. const char* command, const char* message)
  7022. {
  7023. char mob_name[100];
  7024. int mob_id,map_id = 0;
  7025. nullpo_retr(-1, sd);
  7026. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7027. return -1;
  7028. if ((mob_id = atoi(mob_name)) == 0)
  7029. mob_id = mobdb_searchname(mob_name);
  7030. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7031. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7032. clif_displaymessage(fd, atcmd_output);
  7033. return 0;
  7034. }
  7035. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7036. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7037. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7038. map_id = sd->bl.m;
  7039. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7040. mob_name, mapindex_id2name(sd->mapindex));
  7041. clif_displaymessage(fd, atcmd_output);
  7042. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7043. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7044. return 0;
  7045. }
  7046. /*==========================================
  7047. * ドロップアイテムの掃除
  7048. *------------------------------------------
  7049. */
  7050. /*==========================================
  7051. * cleanmap
  7052. *------------------------------------------
  7053. */
  7054. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7055. {
  7056. nullpo_retr(0, bl);
  7057. map_clearflooritem(bl->id);
  7058. return 0;
  7059. }
  7060. int
  7061. atcommand_cleanmap(
  7062. const int fd, struct map_session_data* sd,
  7063. const char* command, const char* message)
  7064. {
  7065. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7066. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7067. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7068. BL_ITEM);
  7069. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7070. return 0;
  7071. }
  7072. /*==========================================
  7073. * NPC/PETに話させる
  7074. *------------------------------------------
  7075. */
  7076. int
  7077. atcommand_npctalk(
  7078. const int fd, struct map_session_data* sd,
  7079. const char* command, const char* message)
  7080. {
  7081. char name[NAME_LENGTH],mes[100],temp[100];
  7082. struct npc_data *nd;
  7083. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7084. return -1;
  7085. if (!(nd = npc_name2id(name)))
  7086. return -1;
  7087. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7088. clif_message(&nd->bl, temp);
  7089. return 0;
  7090. }
  7091. int
  7092. atcommand_pettalk(
  7093. const int fd, struct map_session_data* sd,
  7094. const char* command, const char* message)
  7095. {
  7096. char mes[100],temp[100];
  7097. struct pet_data *pd;
  7098. nullpo_retr(-1, sd);
  7099. if(!sd->status.pet_id || !(pd=sd->pd))
  7100. return -1;
  7101. if (sscanf(message, "%99[^\n]", mes) < 1)
  7102. return -1;
  7103. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  7104. clif_message(&pd->bl, temp);
  7105. return 0;
  7106. }
  7107. /*==========================================
  7108. * @users
  7109. * サーバー内の人数マップを表示させる
  7110. * 手抜きのため汚くなっているのは仕様です。
  7111. *------------------------------------------
  7112. */
  7113. static struct dbt *users_db = NULL;
  7114. static int users_all;
  7115. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7116. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7117. users_all++;
  7118. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7119. return 0;
  7120. }
  7121. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7122. char buf[256];
  7123. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7124. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7125. clif_displaymessage(sd->fd,buf);
  7126. return 0;
  7127. }
  7128. int
  7129. atcommand_users(
  7130. const int fd, struct map_session_data* sd,
  7131. const char* command, const char* message)
  7132. {
  7133. char buf[256];
  7134. users_all = 0;
  7135. users_db->clear(users_db, NULL);
  7136. clif_foreachclient(atcommand_users_sub1);
  7137. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7138. sprintf(buf,"all : %d",users_all);
  7139. clif_displaymessage(fd,buf);
  7140. return 0;
  7141. }
  7142. /*==========================================
  7143. *
  7144. *------------------------------------------
  7145. */
  7146. int
  7147. atcommand_summon(
  7148. const int fd, struct map_session_data* sd,
  7149. const char* command, const char* message)
  7150. {
  7151. char name[NAME_LENGTH];
  7152. int mob_id = 0;
  7153. int x = 0;
  7154. int y = 0;
  7155. int id = 0;
  7156. int duration = 0;
  7157. struct mob_data *md;
  7158. unsigned int tick=gettick();
  7159. nullpo_retr(-1, sd);
  7160. if (!message || !*message)
  7161. return -1;
  7162. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7163. return -1;
  7164. if (duration < 1)
  7165. duration =1;
  7166. else if (duration > 60)
  7167. duration =60;
  7168. if ((mob_id = atoi(name)) == 0)
  7169. mob_id = mobdb_searchname(name);
  7170. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7171. return -1;
  7172. x = sd->bl.x + (rand() % 10 - 5);
  7173. y = sd->bl.y + (rand() % 10 - 5);
  7174. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  7175. if((md=(struct mob_data *)map_id2bl(id))){
  7176. md->master_id=sd->bl.id;
  7177. md->special_state.ai=1;
  7178. md->mode=md->db->mode|MD_AGGRESSIVE;
  7179. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7180. clif_misceffect2(&md->bl,344);
  7181. }
  7182. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  7183. return 0;
  7184. }
  7185. /*==========================================
  7186. * @adjcmdlvl by [MouseJstr]
  7187. *
  7188. * Temp adjust the GM level required to use a GM command
  7189. *
  7190. * Used during beta testing to allow players to use GM commands
  7191. * for short periods of time
  7192. *------------------------------------------
  7193. */
  7194. int
  7195. atcommand_adjcmdlvl(
  7196. const int fd, struct map_session_data* sd,
  7197. const char* command, const char* message)
  7198. {
  7199. int i, newlev;
  7200. char cmd[100];
  7201. nullpo_retr(-1, sd);
  7202. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7203. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7204. return -1;
  7205. }
  7206. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7207. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7208. atcommand_info[i].level = newlev;
  7209. clif_displaymessage(fd, "@command level changed.");
  7210. return 0;
  7211. }
  7212. clif_displaymessage(fd, "@command not found.");
  7213. return -1;
  7214. }
  7215. /*==========================================
  7216. * @adjgmlvl by [MouseJstr]
  7217. *
  7218. * Create a temp GM
  7219. *
  7220. * Used during beta testing to allow players to use GM commands
  7221. * for short periods of time
  7222. *------------------------------------------
  7223. */
  7224. int
  7225. atcommand_adjgmlvl(
  7226. const int fd, struct map_session_data* sd,
  7227. const char* command, const char* message)
  7228. {
  7229. int newlev;
  7230. char user[NAME_LENGTH];
  7231. struct map_session_data *pl_sd;
  7232. nullpo_retr(-1, sd);
  7233. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7234. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7235. return -1;
  7236. }
  7237. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7238. return -1;
  7239. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7240. return 0;
  7241. }
  7242. /*==========================================
  7243. * @trade by [MouseJstr]
  7244. *
  7245. * Open a trade window with a remote player
  7246. *
  7247. * If I have to jump to a remote player one more time, I am
  7248. * gonna scream!
  7249. *------------------------------------------
  7250. */
  7251. int
  7252. atcommand_trade(
  7253. const int fd, struct map_session_data* sd,
  7254. const char* command, const char* message)
  7255. {
  7256. struct map_session_data *pl_sd = NULL;
  7257. nullpo_retr(-1, sd);
  7258. if (!message || !*message)
  7259. return -1;
  7260. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7261. trade_traderequest(sd, pl_sd->bl.id);
  7262. return 0;
  7263. }
  7264. return -1;
  7265. }
  7266. /*==========================================
  7267. * @setbattleflag by [MouseJstr]
  7268. *
  7269. * set a battle_config flag without having to reboot
  7270. */
  7271. int
  7272. atcommand_setbattleflag(
  7273. const int fd, struct map_session_data* sd,
  7274. const char* command, const char* message)
  7275. {
  7276. char flag[128], value[128];
  7277. nullpo_retr(-1, sd);
  7278. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7279. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7280. return -1;
  7281. }
  7282. if (battle_set_value(flag, value) == 0)
  7283. clif_displaymessage(fd, "unknown battle_config flag");
  7284. else
  7285. clif_displaymessage(fd, "battle_config set as requested");
  7286. return 0;
  7287. }
  7288. /*===========================
  7289. * @unmute [Valaris]
  7290. *===========================
  7291. */
  7292. int atcommand_unmute(
  7293. const int fd, struct map_session_data* sd,
  7294. const char* command, const char* message)
  7295. {
  7296. struct map_session_data *pl_sd = NULL;
  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)
  7303. return -1;
  7304. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7305. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7306. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7307. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7308. clif_displaymessage(sd->fd,"Player unmuted");
  7309. }
  7310. else
  7311. clif_displaymessage(sd->fd,"Player is not muted");
  7312. }
  7313. return 0;
  7314. }
  7315. /*==========================================
  7316. * @uptime by MC Cameri
  7317. *------------------------------------------
  7318. */
  7319. int
  7320. atcommand_uptime(
  7321. const int fd, struct map_session_data* sd,
  7322. const char* command, const char* message)
  7323. {
  7324. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7325. minute = 60, days = 0, hours = 0, minutes = 0;
  7326. nullpo_retr(-1, sd);
  7327. seconds = get_uptime();
  7328. days = seconds/day;
  7329. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7330. hours = seconds/hour;
  7331. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7332. minutes = seconds/minute;
  7333. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7334. snprintf(atcmd_output, sizeof(atcmd_output), msg_table[245], days, hours, minutes, seconds);
  7335. clif_displaymessage(fd, atcmd_output);
  7336. return 0;
  7337. }
  7338. /*==========================================
  7339. * @changesex <sex>
  7340. * => Changes one's sex. Argument sex can be
  7341. * 0 or 1, m or f, male or female.
  7342. *------------------------------------------
  7343. */
  7344. int
  7345. atcommand_changesex(
  7346. const int fd, struct map_session_data* sd,
  7347. const char* command, const char* message)
  7348. {
  7349. nullpo_retr(-1, sd);
  7350. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7351. return 0;
  7352. }
  7353. /*================================================
  7354. * @mute - Mutes a player for a set amount of time
  7355. *------------------------------------------------
  7356. */
  7357. int atcommand_mute(
  7358. const int fd, struct map_session_data* sd,
  7359. const char* command, const char* message)
  7360. {
  7361. struct map_session_data *pl_sd = NULL;
  7362. int manner;
  7363. nullpo_retr(-1, sd);
  7364. if(!battle_config.muting_players) {
  7365. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7366. return 0;
  7367. }
  7368. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7369. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7370. return -1;
  7371. }
  7372. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7373. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7374. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7375. return -1;
  7376. }
  7377. clif_GM_silence(sd, pl_sd, 0);
  7378. pl_sd->status.manner -= manner;
  7379. if(pl_sd->status.manner < 0)
  7380. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7381. }
  7382. else {
  7383. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7384. return -1;
  7385. }
  7386. return 0;
  7387. }
  7388. /*==========================================
  7389. * @refresh (like @jumpto <<yourself>>)
  7390. *------------------------------------------
  7391. */
  7392. int atcommand_refresh(
  7393. const int fd, struct map_session_data* sd,
  7394. const char* command, const char* message)
  7395. {
  7396. nullpo_retr(-1, sd);
  7397. clif_refresh(sd);
  7398. return 0;
  7399. }
  7400. /*==========================================
  7401. * @petid <part of pet name>
  7402. * => Displays a list of matching pets.
  7403. *------------------------------------------
  7404. */
  7405. int
  7406. atcommand_petid(const int fd, struct map_session_data* sd,
  7407. const char* command, const char* message)
  7408. {
  7409. char searchtext[100];
  7410. char temp0[100];
  7411. char temp1[100];
  7412. int cnt = 0, i = 0;
  7413. nullpo_retr(-1, sd);
  7414. if (!message || !*message)
  7415. return -1;
  7416. if (sscanf(message, "%99s", searchtext) < 1)
  7417. return -1;
  7418. estr_lower(searchtext);
  7419. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7420. clif_displaymessage(fd,temp0);
  7421. while (i < MAX_PET_DB) {
  7422. strcpy(temp1,pet_db[i].name);
  7423. strcpy(temp1, estr_lower(temp1));
  7424. strcpy(temp0,pet_db[i].jname);
  7425. strcpy(temp0, estr_lower(temp1));
  7426. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7427. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7428. pet_db[i].jname);
  7429. if (cnt >= 100) { // Only if there are custom pets
  7430. clif_displaymessage(fd, "Be more specific, can't send more than"
  7431. " 100 results.");
  7432. } else {
  7433. clif_displaymessage(fd, temp0);
  7434. }
  7435. cnt++;
  7436. }
  7437. i++;
  7438. }
  7439. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7440. clif_displaymessage(fd, temp0);
  7441. return 0;
  7442. }
  7443. /*==========================================
  7444. * @identify
  7445. * => GM's magnifier.
  7446. *------------------------------------------
  7447. */
  7448. int
  7449. atcommand_identify(
  7450. const int fd, struct map_session_data* sd,
  7451. const char* command, const char* message)
  7452. {
  7453. int i,num;
  7454. nullpo_retr(-1, sd);
  7455. for(i=num=0;i<MAX_INVENTORY;i++){
  7456. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7457. num++;
  7458. }
  7459. }
  7460. if (num > 0) {
  7461. clif_item_identify_list(sd);
  7462. } else {
  7463. clif_displaymessage(fd,"There are no items to appraise.");
  7464. }
  7465. return 0;
  7466. }
  7467. /*==========================================
  7468. * @gmotd (Global MOTD)
  7469. * by davidsiaw :P
  7470. *------------------------------------------
  7471. */
  7472. int
  7473. atcommand_gmotd(
  7474. const int fd, struct map_session_data* sd,
  7475. const char* command, const char* message)
  7476. {
  7477. char buf[256];
  7478. FILE *fp;
  7479. nullpo_retr(-1, sd);
  7480. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7481. while (fgets(buf, 250, fp) != NULL){
  7482. int i;
  7483. for( i=0; buf[i]; i++){
  7484. if( buf[i]=='\r' || buf[i]=='\n'){
  7485. buf[i]=0;
  7486. break;
  7487. }
  7488. }
  7489. intif_GMmessage(buf,strlen(buf)+1,8);
  7490. }
  7491. fclose(fp);
  7492. }
  7493. return 0;
  7494. }
  7495. int atcommand_misceffect(
  7496. const int fd, struct map_session_data* sd,
  7497. const char* command, const char* message)
  7498. {
  7499. int effect = 0;
  7500. nullpo_retr(-1, sd);
  7501. if (!message || !*message)
  7502. return -1;
  7503. if (sscanf(message, "%d", &effect) < 1)
  7504. return -1;
  7505. clif_misceffect(&sd->bl,effect);
  7506. return 0;
  7507. }
  7508. int charid2sessionid(int charid)
  7509. {
  7510. struct map_session_data *pl_sd = NULL;
  7511. pl_sd = map_charid2sd(charid);
  7512. if (pl_sd) return pl_sd->fd;
  7513. return 0;
  7514. }
  7515. int accountid2sessionid(int accountid)
  7516. {
  7517. struct map_session_data *pl_sd = NULL;
  7518. pl_sd = map_id2sd(accountid);
  7519. if (pl_sd) return pl_sd->fd;
  7520. return 0;
  7521. }
  7522. /*==========================================
  7523. * Jump to a player by PID number
  7524. * Original by Dino9021
  7525. * Added in by nsstrunks
  7526. *------------------------------------------
  7527. */
  7528. int atcommand_jumptoid(
  7529. const int fd, struct map_session_data* sd,
  7530. const char* command, const char* message)
  7531. {
  7532. int cid=0;
  7533. int session_id=0;
  7534. struct map_session_data *pl_sd;
  7535. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7536. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7537. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7538. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7539. return -1;
  7540. }
  7541. cid=atoi(message);
  7542. if ((session_id=charid2sessionid(cid))!=0)
  7543. {
  7544. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7545. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7546. clif_displaymessage(fd, msg_table[247]);
  7547. return -1;
  7548. }
  7549. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7550. clif_displaymessage(fd, msg_table[248]);
  7551. return -1;
  7552. }
  7553. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7554. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7555. clif_displaymessage(fd, atcmd_output);
  7556. } else {
  7557. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7558. return -1;
  7559. }
  7560. }
  7561. else
  7562. {
  7563. clif_displaymessage(fd,msg_table[3]);
  7564. }
  7565. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7566. return 0;
  7567. }
  7568. /*==========================================
  7569. * Jump to a player by PID number
  7570. * Original by Dino9021
  7571. * Added in by nsstrunks
  7572. *------------------------------------------
  7573. */
  7574. int atcommand_jumptoid2(
  7575. const int fd, struct map_session_data* sd,
  7576. const char* command, const char* message)
  7577. {
  7578. int aid=0;
  7579. int session_id=0;
  7580. struct map_session_data *pl_sd;
  7581. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7582. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7583. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7584. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7585. return -1;
  7586. }
  7587. aid=atoi(message);
  7588. if ((session_id=accountid2sessionid(aid))!=0)
  7589. {
  7590. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7591. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7592. clif_displaymessage(fd, msg_table[247]);
  7593. return -1;
  7594. }
  7595. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7596. clif_displaymessage(fd, msg_table[248]);
  7597. return -1;
  7598. }
  7599. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7600. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7601. clif_displaymessage(fd, atcmd_output);
  7602. } else {
  7603. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7604. return -1;
  7605. }
  7606. }
  7607. else
  7608. {
  7609. clif_displaymessage(fd,msg_table[3]);
  7610. }
  7611. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7612. return 0;
  7613. }
  7614. /*==========================================
  7615. * Recall a player by PID number
  7616. * Original by Dino9021
  7617. * Added in by nsstrunks
  7618. *------------------------------------------
  7619. */
  7620. int atcommand_recallid(
  7621. const int fd, struct map_session_data* sd,
  7622. const char* command, const char* message)
  7623. {
  7624. int cid=0;
  7625. int session_id=0;
  7626. struct map_session_data *pl_sd;
  7627. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7628. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7629. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7630. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7631. return -1;
  7632. }
  7633. cid=atoi(message);
  7634. if ((session_id=charid2sessionid(cid))!=0)
  7635. {
  7636. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7637. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7638. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7639. clif_displaymessage(fd, msg_table[247]);
  7640. return -1;
  7641. }
  7642. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7643. clif_displaymessage(fd, msg_table[248]);
  7644. return -1;
  7645. }
  7646. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7647. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7648. clif_displaymessage(fd, atcmd_output);
  7649. } else {
  7650. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7651. return -1;
  7652. }
  7653. } else {
  7654. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7655. return -1;
  7656. }
  7657. }
  7658. else
  7659. {
  7660. clif_displaymessage(fd,msg_table[3]);
  7661. }
  7662. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7663. return 0;
  7664. }
  7665. /*==========================================
  7666. * Recall a player by PID number
  7667. * Original by Dino9021
  7668. * Added in by nsstrunks
  7669. *------------------------------------------
  7670. */
  7671. int atcommand_recallid2(
  7672. const int fd, struct map_session_data* sd,
  7673. const char* command, const char* message)
  7674. {
  7675. int aid=0;
  7676. int session_id=0;
  7677. struct map_session_data *pl_sd;
  7678. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7679. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7680. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7681. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7682. return -1;
  7683. }
  7684. aid=atoi(message);
  7685. if ((session_id=accountid2sessionid(aid))!=0)
  7686. {
  7687. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7688. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7689. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7690. clif_displaymessage(fd, msg_table[247]);
  7691. return -1;
  7692. }
  7693. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7694. clif_displaymessage(fd, msg_table[248]);
  7695. return -1;
  7696. }
  7697. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7698. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7699. clif_displaymessage(fd, atcmd_output);
  7700. } else {
  7701. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7702. return -1;
  7703. }
  7704. } else {
  7705. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7706. return -1;
  7707. }
  7708. }
  7709. else
  7710. {
  7711. clif_displaymessage(fd,msg_table[3]);
  7712. }
  7713. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7714. return 0;
  7715. }
  7716. /*==========================================
  7717. * Kick a player by PID number
  7718. * Original by Dino9021
  7719. * Added in by nsstrunks
  7720. *------------------------------------------
  7721. */
  7722. int atcommand_kickid(
  7723. const int fd, struct map_session_data* sd,
  7724. const char* command, const char* message)
  7725. {
  7726. struct map_session_data *pl_sd;
  7727. int cid=0;
  7728. int session_id=0;
  7729. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7730. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7731. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7732. return -1;
  7733. }
  7734. cid=atoi(message);
  7735. if ((session_id=charid2sessionid(cid))!=0)
  7736. {
  7737. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7738. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7739. clif_GM_kick(sd, pl_sd, 1);
  7740. else {
  7741. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7742. return -1;
  7743. }
  7744. } else {
  7745. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7746. return -1;
  7747. }
  7748. }
  7749. else
  7750. {
  7751. clif_displaymessage(fd,msg_table[3]);
  7752. }
  7753. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7754. return 0;
  7755. }
  7756. /*==========================================
  7757. * Kick a player by PID number
  7758. * Original by Dino9021
  7759. * Added in by nsstrunks
  7760. *------------------------------------------
  7761. */
  7762. int atcommand_kickid2(
  7763. const int fd, struct map_session_data* sd,
  7764. const char* command, const char* message)
  7765. {
  7766. struct map_session_data *pl_sd;
  7767. int aid=0;
  7768. int session_id=0;
  7769. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7770. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7771. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7772. return -1;
  7773. }
  7774. aid=atoi(message);
  7775. if ((session_id=accountid2sessionid(aid))!=0)
  7776. {
  7777. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7778. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7779. clif_GM_kick(sd, pl_sd, 1);
  7780. else {
  7781. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7782. return -1;
  7783. }
  7784. } else {
  7785. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7786. return -1;
  7787. }
  7788. }
  7789. else
  7790. {
  7791. clif_displaymessage(fd,msg_table[3]);
  7792. }
  7793. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7794. return 0;
  7795. }
  7796. /*==========================================
  7797. * Revive a player by PID number
  7798. * Original by Dino9021
  7799. * Added in by nsstrunks
  7800. *------------------------------------------
  7801. */
  7802. int atcommand_reviveid(
  7803. const int fd, struct map_session_data* sd,
  7804. const char* command, const char* message)
  7805. {
  7806. int cid=0;
  7807. int session_id=0;
  7808. struct map_session_data *pl_sd;
  7809. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7810. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7811. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7812. return -1;
  7813. }
  7814. cid=atoi(message);
  7815. if ((session_id=charid2sessionid(cid))!=0)
  7816. {
  7817. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7818. pl_sd->status.hp = pl_sd->status.max_hp;
  7819. pc_setstand(pl_sd);
  7820. if (battle_config.pc_invincible_time > 0)
  7821. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7822. clif_updatestatus(pl_sd, SP_HP);
  7823. clif_updatestatus(pl_sd, SP_SP);
  7824. clif_resurrection(&pl_sd->bl, 1);
  7825. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7826. } else {
  7827. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7828. return -1;
  7829. }
  7830. }
  7831. else
  7832. {
  7833. clif_displaymessage(fd,msg_table[3]);
  7834. }
  7835. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7836. return 0;
  7837. }
  7838. /*==========================================
  7839. * Revive a player by PID number
  7840. * Original by Dino9021
  7841. * Added in by nsstrunks
  7842. *------------------------------------------
  7843. */
  7844. int atcommand_reviveid2(
  7845. const int fd, struct map_session_data* sd,
  7846. const char* command, const char* message)
  7847. {
  7848. int aid=0;
  7849. int session_id=0;
  7850. struct map_session_data *pl_sd;
  7851. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7852. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7853. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7854. return -1;
  7855. }
  7856. aid=atoi(message);
  7857. if ((session_id=accountid2sessionid(aid))!=0)
  7858. {
  7859. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7860. pl_sd->status.hp = pl_sd->status.max_hp;
  7861. pc_setstand(pl_sd);
  7862. if (battle_config.pc_invincible_time > 0)
  7863. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7864. clif_updatestatus(pl_sd, SP_HP);
  7865. clif_updatestatus(pl_sd, SP_SP);
  7866. clif_resurrection(&pl_sd->bl, 1);
  7867. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7868. } else {
  7869. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7870. return -1;
  7871. }
  7872. }
  7873. else
  7874. {
  7875. clif_displaymessage(fd,msg_table[3]);
  7876. }
  7877. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7878. return 0;
  7879. }
  7880. /*==========================================
  7881. * Kill a player by PID number
  7882. * Original by Dino9021
  7883. * Added in by nsstrunks
  7884. *------------------------------------------
  7885. */
  7886. int atcommand_killid(
  7887. const int fd, struct map_session_data* sd,
  7888. const char* command, const char* message)
  7889. {
  7890. int cid=0;
  7891. int session_id=0;
  7892. struct map_session_data *pl_sd;
  7893. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7894. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7895. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7896. return -1;
  7897. }
  7898. cid=atoi(message);
  7899. if ((session_id=charid2sessionid(cid))!=0)
  7900. {
  7901. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7902. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7903. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7904. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7905. } else {
  7906. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7907. return -1;
  7908. }
  7909. } else {
  7910. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7911. return -1;
  7912. }
  7913. }
  7914. else
  7915. {
  7916. clif_displaymessage(fd,msg_table[3]);
  7917. }
  7918. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7919. return 0;
  7920. }
  7921. /*==========================================
  7922. * Kill a player by PID number
  7923. * Original by Dino9021
  7924. * Added in by nsstrunks
  7925. *------------------------------------------
  7926. */
  7927. int atcommand_killid2(
  7928. const int fd, struct map_session_data* sd,
  7929. const char* command, const char* message)
  7930. {
  7931. int aid=0;
  7932. int session_id=0;
  7933. struct map_session_data *pl_sd;
  7934. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7935. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7936. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7937. return -1;
  7938. }
  7939. aid=atoi(message);
  7940. if ((session_id=accountid2sessionid(aid))!=0)
  7941. {
  7942. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7943. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7944. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7945. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7946. } else {
  7947. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7948. return -1;
  7949. }
  7950. } else {
  7951. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7952. return -1;
  7953. }
  7954. }
  7955. else
  7956. {
  7957. clif_displaymessage(fd,msg_table[3]);
  7958. }
  7959. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7960. return 0;
  7961. }
  7962. /*==========================================
  7963. * Make a player killable, by PID
  7964. * Original by Dino9021
  7965. * Added in by nsstrunks
  7966. *------------------------------------------
  7967. */
  7968. int
  7969. atcommand_charkillableid(
  7970. const int fd, struct map_session_data* sd,
  7971. const char* command, const char* message)
  7972. {
  7973. struct map_session_data *pl_sd = NULL;
  7974. int cid=0;
  7975. int session_id=0;
  7976. if (!message || (cid = atoi(message)) == 0 || !*message)
  7977. return -1;
  7978. cid=atoi(message);
  7979. if ((session_id=charid2sessionid(cid))!=0)
  7980. {
  7981. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7982. return -1;
  7983. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7984. if(pl_sd->special_state.killable)
  7985. clif_displaymessage(fd, "The player is now killable");
  7986. else
  7987. clif_displaymessage(fd, "The player is no longer killable");
  7988. }
  7989. else
  7990. {
  7991. clif_displaymessage(fd,msg_table[3]);
  7992. }
  7993. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7994. return 0;
  7995. }
  7996. /*==========================================
  7997. * Make a player killable, by PID
  7998. * Original by Dino9021
  7999. * Added in by nsstrunks
  8000. *------------------------------------------
  8001. */
  8002. int
  8003. atcommand_charkillableid2(
  8004. const int fd, struct map_session_data* sd,
  8005. const char* command, const char* message)
  8006. {
  8007. struct map_session_data *pl_sd = NULL;
  8008. int aid=0;
  8009. int session_id=0;
  8010. if (!message || (aid = atoi(message)) == 0 || !*message)
  8011. return -1;
  8012. aid=atoi(message);
  8013. if ((session_id=accountid2sessionid(aid))!=0)
  8014. {
  8015. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8016. return -1;
  8017. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  8018. if(pl_sd->special_state.killable)
  8019. clif_displaymessage(fd, "The player is now killable");
  8020. else
  8021. clif_displaymessage(fd, "The player is no longer killable");
  8022. }
  8023. else
  8024. {
  8025. clif_displaymessage(fd,msg_table[3]);
  8026. }
  8027. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8028. return 0;
  8029. }
  8030. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8031. /*==========================================
  8032. * Mail System commands by [Valaris]
  8033. *------------------------------------------
  8034. */
  8035. int atcommand_listmail(
  8036. const int fd, struct map_session_data* sd,
  8037. const char* command, const char* message)
  8038. {
  8039. if(!mail_server_enable)
  8040. return 0;
  8041. nullpo_retr(-1, sd);
  8042. if(strlen(command)==12)
  8043. mail_check(sd,3);
  8044. else if(strlen(command)==9)
  8045. mail_check(sd,2);
  8046. else
  8047. mail_check(sd,1);
  8048. return 0;
  8049. }
  8050. int atcommand_readmail(
  8051. const int fd, struct map_session_data* sd,
  8052. const char* command, const char* message)
  8053. {
  8054. int index;
  8055. if(!mail_server_enable)
  8056. return 0;
  8057. nullpo_retr(-1, sd);
  8058. if (!message || !*message) {
  8059. clif_displaymessage(sd->fd,"You must specify a message number.");
  8060. return 0;
  8061. }
  8062. index = atoi(message);
  8063. if (index < 1) {
  8064. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8065. return 0;
  8066. }
  8067. if(strlen(command)==11)
  8068. mail_delete(sd,index);
  8069. else
  8070. mail_read(sd,index);
  8071. return 0;
  8072. }
  8073. int atcommand_sendmail(
  8074. const int fd, struct map_session_data* sd,
  8075. const char* command, const char* message)
  8076. {
  8077. char name[NAME_LENGTH],text[80];
  8078. if(!mail_server_enable)
  8079. return 0;
  8080. nullpo_retr(-1, sd);
  8081. if (!message || !*message) {
  8082. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8083. return 0;
  8084. }
  8085. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8086. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8087. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8088. return 0;
  8089. }
  8090. if(strlen(command)==17)
  8091. mail_send(sd,name,text,1);
  8092. else
  8093. mail_send(sd,name,text,0);
  8094. return 0;
  8095. }
  8096. /*==========================================
  8097. * Refresh online command for SQL [Valaris]
  8098. * Will refresh and check online column of
  8099. * players and set correctly.
  8100. *------------------------------------------
  8101. */
  8102. int atcommand_refreshonline(
  8103. const int fd, struct map_session_data* sd,
  8104. const char* command, const char* message)
  8105. {
  8106. send_users_tochar(-1, gettick(), 0, 0);
  8107. return 0;
  8108. }
  8109. #endif /* end sql only */
  8110. /*==========================================
  8111. * Show Monster DB Info v 1.0
  8112. * originally by [Lupus] eAthena
  8113. *------------------------------------------
  8114. */
  8115. int atcommand_mobinfo(
  8116. const int fd, struct map_session_data* sd,
  8117. const char* command, const char* message)
  8118. {
  8119. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8120. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8121. unsigned char melement[11][8] = {"None", "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8122. char atcmd_output2[200];
  8123. struct item_data *item_data;
  8124. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8125. int mob_id, count;
  8126. int i, j, k;
  8127. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8128. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8129. if (!message || !*message) {
  8130. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8131. return -1;
  8132. }
  8133. // If monster identifier/name argument is a name
  8134. if ((mob_id = mobdb_checkid(atoi(message))))
  8135. {
  8136. mob_array[0] = mob_db(mob_id);
  8137. count = 1;
  8138. } else
  8139. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8140. if (!count) {
  8141. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8142. return -1;
  8143. }
  8144. if (count > MAX_SEARCH) {
  8145. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8146. clif_displaymessage(fd, atcmd_output);
  8147. count = MAX_SEARCH;
  8148. }
  8149. for (k = 0; k < count; k++) {
  8150. mob = mob_array[k];
  8151. // stats
  8152. if (mob->mexp)
  8153. sprintf(atcmd_output, "MVP Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8154. else
  8155. sprintf(atcmd_output, "Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8156. clif_displaymessage(fd, atcmd_output);
  8157. 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);
  8158. clif_displaymessage(fd, atcmd_output);
  8159. 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);
  8160. clif_displaymessage(fd, atcmd_output);
  8161. if (mob->element < 20) {
  8162. //Element - None, Level 0
  8163. i = 0;
  8164. j = 0;
  8165. } else {
  8166. i = mob->element % 20 + 1;
  8167. j = mob->element / 20;
  8168. }
  8169. 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);
  8170. clif_displaymessage(fd, atcmd_output);
  8171. // drops
  8172. clif_displaymessage(fd, " Drops:");
  8173. strcpy(atcmd_output, " ");
  8174. j = 0;
  8175. for (i = 0; i < 10; i++) {
  8176. if (mob->dropitem[i].nameid <= 0 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8177. continue;
  8178. if (mob->dropitem[i].p > 0) {
  8179. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->dropitem[i].p / 100);
  8180. strcat(atcmd_output, atcmd_output2);
  8181. if (++j % 3 == 0) {
  8182. clif_displaymessage(fd, atcmd_output);
  8183. strcpy(atcmd_output, " ");
  8184. }
  8185. }
  8186. }
  8187. if (j == 0)
  8188. clif_displaymessage(fd, "This monster has no drops.");
  8189. else if (j % 3 != 0)
  8190. clif_displaymessage(fd, atcmd_output);
  8191. // mvp
  8192. if (mob->mexp) {
  8193. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8194. clif_displaymessage(fd, atcmd_output);
  8195. strcpy(atcmd_output, " MVP Items:");
  8196. j = 0;
  8197. for (i = 0; i < 3; i++) {
  8198. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8199. continue;
  8200. if (mob->mvpitem[i].p > 0) {
  8201. j++;
  8202. if (j == 1)
  8203. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8204. else
  8205. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8206. strcat(atcmd_output, atcmd_output2);
  8207. }
  8208. }
  8209. if (j == 0)
  8210. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8211. else
  8212. clif_displaymessage(fd, atcmd_output);
  8213. }
  8214. }
  8215. return 0;
  8216. }
  8217. /*==========================================
  8218. * Show Items DB Info v 1.0
  8219. * originally by [Lupus] eAthena
  8220. *------------------------------------------
  8221. */
  8222. int atcommand_iteminfo(
  8223. const int fd, struct map_session_data* sd,
  8224. const char* command, const char* message)
  8225. {
  8226. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8227. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8228. struct item_data *item_data, *item_array[MAX_SEARCH];
  8229. int i, item_id=0, count = 1;
  8230. if (!message || !*message) {
  8231. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8232. return -1;
  8233. }
  8234. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8235. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8236. if (!count) {
  8237. clif_displaymessage(fd, "Item not found.");
  8238. return -1;
  8239. }
  8240. if (count > MAX_SEARCH) {
  8241. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8242. clif_displaymessage(fd, atcmd_output);
  8243. count = MAX_SEARCH;
  8244. }
  8245. for (i = 0; i < count; i++) {
  8246. item_data = item_array[i];
  8247. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8248. item_data->name,item_data->jname,item_data->slot,item_id,
  8249. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8250. (item_data->script==NULL)? "None" : "With script"
  8251. );
  8252. clif_displaymessage(fd, atcmd_output);
  8253. 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 );
  8254. clif_displaymessage(fd, atcmd_output);
  8255. if (item_data->maxchance == 10000)
  8256. strcpy(atcmd_output, " - Available in the shops only");
  8257. else if (item_data->maxchance)
  8258. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8259. else
  8260. strcpy(atcmd_output, " - Monsters don't drop this item");
  8261. clif_displaymessage(fd, atcmd_output);
  8262. }
  8263. return 0;
  8264. }
  8265. /*==========================================
  8266. * Show who drops the item.
  8267. *------------------------------------------
  8268. */
  8269. int atcommand_whodrops(
  8270. const int fd, struct map_session_data* sd,
  8271. const char* command, const char* message)
  8272. {
  8273. struct item_data *item_data, *item_array[MAX_SEARCH];
  8274. int i,j, count = 1;
  8275. if (!message || !*message) {
  8276. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8277. return -1;
  8278. }
  8279. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8280. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8281. if (!count) {
  8282. clif_displaymessage(fd, "Item not found.");
  8283. return -1;
  8284. }
  8285. if (count > MAX_SEARCH) {
  8286. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8287. clif_displaymessage(fd, atcmd_output);
  8288. count = MAX_SEARCH;
  8289. }
  8290. for (i = 0; i < count; i++) {
  8291. item_data = item_array[i];
  8292. sprintf(atcmd_output, "Item: '%s'[%d]",
  8293. item_data->jname,item_data->slot);
  8294. clif_displaymessage(fd, atcmd_output);
  8295. if (item_data->mob[0].chance == 0) {
  8296. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8297. clif_displaymessage(fd, atcmd_output);
  8298. } else {
  8299. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8300. clif_displaymessage(fd, atcmd_output);
  8301. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8302. {
  8303. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8304. clif_displaymessage(fd, atcmd_output);
  8305. }
  8306. }
  8307. }
  8308. return 0;
  8309. }
  8310. /*==========================================
  8311. * @adopt by [Veider]
  8312. *
  8313. * adopt a novice
  8314. *------------------------------------------
  8315. */
  8316. int
  8317. atcommand_adopt(const int fd, struct map_session_data* sd,
  8318. const char* command, const char* message)
  8319. {
  8320. struct map_session_data *pl_sd1 = NULL;
  8321. struct map_session_data *pl_sd2 = NULL;
  8322. struct map_session_data *pl_sd3 = NULL;
  8323. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8324. nullpo_retr(-1, sd);
  8325. if (!message || !*message)
  8326. return -1;
  8327. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8328. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8329. return -1;
  8330. }
  8331. if (battle_config.etc_log)
  8332. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8333. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8334. sprintf(player2, "Cannot find player %s online", player1);
  8335. clif_displaymessage(fd, player2);
  8336. return -1;
  8337. }
  8338. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8339. sprintf(player1, "Cannot find player %s online", player2);
  8340. clif_displaymessage(fd, player1);
  8341. return -1;
  8342. }
  8343. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8344. sprintf(player1, "Cannot find player %s online", player3);
  8345. clif_displaymessage(fd, player1);
  8346. return -1;
  8347. }
  8348. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8349. clif_displaymessage(fd, "They are too young to be parents!");
  8350. return -1;
  8351. }
  8352. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8353. clif_displaymessage(fd, "They are family.. wish them luck");
  8354. return 0;
  8355. }
  8356. else
  8357. return -1;
  8358. }
  8359. int atcommand_version(
  8360. const int fd, struct map_session_data* sd,
  8361. const char* command, const char* message)
  8362. {
  8363. const char * revision;
  8364. if ((revision = get_svn_revision()) != 0) {
  8365. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8366. clif_displaymessage(fd,atcmd_output);
  8367. } else
  8368. clif_displaymessage(fd,"Cannot determine SVN revision");
  8369. return 0;
  8370. }
  8371. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8372. {
  8373. int time, id;
  8374. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8375. if (pl_sd == NULL)
  8376. return 0;
  8377. id = va_arg(ap, int);
  8378. time = va_arg(ap, int);
  8379. if (id != bl->id && !pc_isGM(pl_sd)) {
  8380. pl_sd->status.manner -= time;
  8381. if (pl_sd->status.manner < 0)
  8382. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8383. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8384. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8385. }
  8386. return 0;
  8387. }
  8388. /*==========================================
  8389. * @mutearea by MouseJstr
  8390. *------------------------------------------
  8391. */
  8392. int atcommand_mutearea(
  8393. const int fd, struct map_session_data* sd,
  8394. const char* command, const char* message)
  8395. {
  8396. int time;
  8397. nullpo_retr(0, sd);
  8398. if(!battle_config.muting_players) {
  8399. clif_displaymessage(fd, "Please enable the muting system before using it.");
  8400. return 0;
  8401. }
  8402. time = atoi(message);
  8403. if (!time)
  8404. time = 15; // 15 minutes default
  8405. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8406. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8407. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8408. return 0;
  8409. }
  8410. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8411. {
  8412. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8413. if (bl == NULL)
  8414. return 0;
  8415. if (!pc_isGM(pl_sd))
  8416. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8417. return 0;
  8418. }
  8419. /*==========================================
  8420. * @shuffle by MouseJstr
  8421. *------------------------------------------
  8422. */
  8423. int atcommand_shuffle(
  8424. const int fd, struct map_session_data* sd,
  8425. const char* command, const char* message)
  8426. {
  8427. nullpo_retr(0, sd);
  8428. if (strcmp(message, "area")== 0) {
  8429. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8430. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8431. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8432. } else if (strcmp(message, "map")== 0) {
  8433. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8434. } else if (strcmp(message, "world") == 0) {
  8435. struct map_session_data **pl_allsd;
  8436. int i, users;
  8437. pl_allsd = map_getallusers(&users);
  8438. for (i = 0; i < users; i++)
  8439. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8440. } else
  8441. clif_displaymessage(fd, "options are area, map, or world");
  8442. return 0;
  8443. }
  8444. int atcommand_rates(
  8445. const int fd, struct map_session_data* sd,
  8446. const char* command, const char* message)
  8447. {
  8448. char buf[255];
  8449. nullpo_retr(0, sd);
  8450. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8451. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8452. clif_displaymessage(fd, buf);
  8453. return 0;
  8454. }
  8455. /*==========================================
  8456. * @me by lordalfa
  8457. * => Displays the OUTPUT string on top of
  8458. * the Visible players Heads.
  8459. *------------------------------------------
  8460. */
  8461. int atcommand_me(
  8462. const int fd, struct map_session_data* sd,
  8463. const char* command, const char* message)
  8464. {
  8465. char tempmes[200];
  8466. nullpo_retr(-1, sd);
  8467. memset(tempmes, '\0', sizeof(tempmes));
  8468. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8469. if (!message || !*message) {
  8470. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8471. return -1;
  8472. }
  8473. sscanf(message, "%199[^\n]", tempmes);
  8474. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8475. clif_disp_overhead(sd, atcmd_output);
  8476. return 0;
  8477. }
  8478. /*==========================================
  8479. * @size
  8480. * => Resize your character sprite. [Valaris]
  8481. *------------------------------------------
  8482. */
  8483. int atcommand_size(
  8484. const int fd, struct map_session_data* sd,
  8485. const char* command, const char* message)
  8486. {
  8487. int size=0;
  8488. nullpo_retr(-1, sd);
  8489. if (!message || !*message)
  8490. return -1;
  8491. if (sscanf(message,"%d", &size) < 1)
  8492. return -1;
  8493. if(sd->state.size) {
  8494. sd->state.size=0;
  8495. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8496. }
  8497. if(size==1) {
  8498. sd->state.size=1;
  8499. clif_specialeffect(&sd->bl,420,0);
  8500. } else if(size==2) {
  8501. sd->state.size=2;
  8502. clif_specialeffect(&sd->bl,422,0);
  8503. }
  8504. return 0;
  8505. }
  8506. /*==========================================
  8507. * @monsterignore
  8508. * => Makes monsters ignore you. [Valaris]
  8509. *------------------------------------------
  8510. */
  8511. int atcommand_monsterignore(
  8512. const int fd, struct map_session_data* sd,
  8513. const char* command, const char* message)
  8514. {
  8515. nullpo_retr(-1, sd);
  8516. if (!sd->state.monster_ignore) {
  8517. sd->state.monster_ignore = 1;
  8518. clif_displaymessage(sd->fd, "Monsters will now ignore you.");
  8519. } else {
  8520. sd->state.monster_ignore = 0;
  8521. clif_displaymessage(sd->fd, "Monsters are no longer ignoring you.");
  8522. }
  8523. return 0;
  8524. }
  8525. /*==========================================
  8526. * @fakename
  8527. * => Gives your character a fake name. [Valaris]
  8528. *------------------------------------------
  8529. */
  8530. int atcommand_fakename(
  8531. const int fd, struct map_session_data* sd,
  8532. const char* command, const char* message)
  8533. {
  8534. char name[NAME_LENGTH];
  8535. nullpo_retr(-1, sd);
  8536. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8537. sd->fakename[0]='\0';
  8538. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8539. clif_displaymessage(sd->fd,"Returned to real name.");
  8540. return 0;
  8541. }
  8542. if (!message || !*message) {
  8543. clif_displaymessage(sd->fd,"You must enter a name.");
  8544. return 0;
  8545. }
  8546. if (sscanf(message, "%23[^\n]", name) < 1) {
  8547. return 0;
  8548. }
  8549. if(strlen(name) < 2) {
  8550. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8551. return 0;
  8552. }
  8553. memcpy(sd->fakename,name,NAME_LENGTH-1);
  8554. clif_charnameack(0, &sd->bl);
  8555. clif_displaymessage(sd->fd,"Fake name enabled.");
  8556. return 0;
  8557. }
  8558. /*==========================================
  8559. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  8560. * => Shows information about the map flags [map name]
  8561. * Also set flags
  8562. *------------------------------------------
  8563. */
  8564. int atcommand_mapflag(
  8565. const int fd, struct map_session_data* sd,
  8566. const char* command, const char* message)
  8567. {
  8568. // WIP
  8569. return 0;
  8570. }
  8571. /*===================================
  8572. * Remove some messages
  8573. *-----------------------------------
  8574. */
  8575. int atcommand_showexp(
  8576. const int fd, struct map_session_data* sd,
  8577. const char* command, const char* message)
  8578. {
  8579. if (sd->state.showexp) {
  8580. sd->state.showexp = 0;
  8581. clif_displaymessage(fd, "Gained exp will not be shown.");
  8582. return 0;
  8583. }
  8584. sd->state.showexp = 1;
  8585. clif_displaymessage(fd, "Gained exp is now shown");
  8586. return 0;
  8587. }
  8588. int atcommand_showzeny(
  8589. const int fd, struct map_session_data* sd,
  8590. const char* command, const char* message)
  8591. {
  8592. if (sd->state.showzeny) {
  8593. sd->state.showzeny = 0;
  8594. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8595. return 0;
  8596. }
  8597. sd->state.showzeny = 1;
  8598. clif_displaymessage(fd, "Gained zeny is now shown");
  8599. return 0;
  8600. }
  8601. int atcommand_showdelay(
  8602. const int fd, struct map_session_data* sd,
  8603. const char* command, const char* message)
  8604. {
  8605. if (sd->state.showdelay) {
  8606. sd->state.showdelay = 0;
  8607. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8608. return 0;
  8609. }
  8610. sd->state.showdelay = 1;
  8611. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8612. return 0;
  8613. }
  8614. /*==========================================
  8615. * Duel organizing functions [LuzZza]
  8616. *
  8617. * @duel [limit|nick] - create a duel
  8618. * @invite <nick> - invite player
  8619. * @accept - accept invitation
  8620. * @reject - reject invitation
  8621. * @leave - leave duel
  8622. *------------------------------------------
  8623. */
  8624. int atcommand_invite(
  8625. const int fd, struct map_session_data* sd,
  8626. const char* command, const char* message)
  8627. {
  8628. unsigned int did = sd->duel_group;
  8629. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8630. if(did <= 0) {
  8631. // "Duel: @invite without @duel."
  8632. clif_displaymessage(fd, msg_txt(350));
  8633. return 0;
  8634. }
  8635. if(duel_list[did].max_players_limit > 0 &&
  8636. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8637. // "Duel: Limit of players is reached."
  8638. clif_displaymessage(fd, msg_txt(351));
  8639. return 0;
  8640. }
  8641. if(target_sd == NULL) {
  8642. // "Duel: Player not found."
  8643. clif_displaymessage(fd, msg_txt(352));
  8644. return 0;
  8645. }
  8646. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8647. // "Duel: Player already in duel."
  8648. clif_displaymessage(fd, msg_txt(353));
  8649. return 0;
  8650. }
  8651. duel_invite(did, sd, target_sd);
  8652. // "Duel: Invitation has been sent."
  8653. clif_displaymessage(fd, msg_txt(354));
  8654. return 0;
  8655. }
  8656. int atcommand_duel(
  8657. const int fd, struct map_session_data* sd,
  8658. const char* command, const char* message)
  8659. {
  8660. char output[256];
  8661. unsigned int maxpl=0, newduel;
  8662. struct map_session_data *target_sd;
  8663. /* // Commnted because it can be disabled in at-comms conf.
  8664. if(!battle_config.duel_enable) {
  8665. clif_displaymessage(fd, "Duel: duel is disable.");
  8666. return 0;
  8667. }
  8668. */
  8669. if(sd->duel_group > 0) {
  8670. duel_showinfo(sd->duel_group, sd);
  8671. return 0;
  8672. }
  8673. if(sd->duel_invite > 0) {
  8674. // "Duel: @duel without @reject."
  8675. clif_displaymessage(fd, msg_txt(355));
  8676. return 0;
  8677. }
  8678. if(!duel_checktime(sd)) {
  8679. // "Duel: You can take part in duel only one time per %d minutes."
  8680. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8681. clif_displaymessage(fd, output);
  8682. return 0;
  8683. }
  8684. if(strlen(message) > 0) {
  8685. if(sscanf(message, "%d", &maxpl) >= 1) {
  8686. if(maxpl < 2 || maxpl > 65535) {
  8687. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8688. return 0;
  8689. }
  8690. duel_create(sd, maxpl);
  8691. } else {
  8692. target_sd = map_nick2sd((char *)message);
  8693. if(target_sd != NULL) {
  8694. if((newduel = duel_create(sd, 2)) != -1) {
  8695. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8696. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8697. return 0;
  8698. }
  8699. duel_invite(newduel, sd, target_sd);
  8700. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8701. }
  8702. } else {
  8703. // "Duel: Player not found."
  8704. clif_displaymessage(fd, msg_txt(352));
  8705. return 0;
  8706. }
  8707. }
  8708. } else
  8709. duel_create(sd, 0);
  8710. return 0;
  8711. }
  8712. int atcommand_leave(
  8713. const int fd, struct map_session_data* sd,
  8714. const char* command, const char* message)
  8715. {
  8716. if(sd->duel_group <= 0) {
  8717. // "Duel: @leave without @duel."
  8718. clif_displaymessage(fd, msg_txt(358));
  8719. return 0;
  8720. }
  8721. duel_leave(sd->duel_group, sd);
  8722. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8723. return 0;
  8724. }
  8725. int atcommand_accept(
  8726. const int fd, struct map_session_data* sd,
  8727. const char* command, const char* message)
  8728. {
  8729. char output[256];
  8730. if(!duel_checktime(sd)) {
  8731. // "Duel: You can take part in duel only one time per %d minutes."
  8732. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8733. clif_displaymessage(fd, output);
  8734. return 0;
  8735. }
  8736. if(sd->duel_invite <= 0) {
  8737. // "Duel: @accept without invititation."
  8738. clif_displaymessage(fd, msg_txt(360));
  8739. return 0;
  8740. }
  8741. duel_accept(sd->duel_invite, sd);
  8742. // "Duel: Invitation has been accepted."
  8743. clif_displaymessage(fd, msg_txt(361));
  8744. return 0;
  8745. }
  8746. int atcommand_reject(
  8747. const int fd, struct map_session_data* sd,
  8748. const char* command, const char* message)
  8749. {
  8750. if(sd->duel_invite <= 0) {
  8751. // "Duel: @reject without invititation."
  8752. clif_displaymessage(fd, msg_txt(362));
  8753. return 0;
  8754. }
  8755. duel_reject(sd->duel_invite, sd);
  8756. // "Duel: Invitation has been rejected."
  8757. clif_displaymessage(fd, msg_txt(363));
  8758. return 0;
  8759. }
  8760. /*===================================
  8761. * Away message (@away, @aw) [LuzZza]
  8762. *-----------------------------------
  8763. */
  8764. int atcommand_away(
  8765. const int fd, struct map_session_data* sd,
  8766. const char* command, const char* message)
  8767. {
  8768. if(strlen(message) > 0) {
  8769. if(strlen(message) > 128)
  8770. return -1;
  8771. strcpy(sd->away_message, message);
  8772. //"Away automessage has been activated."
  8773. clif_displaymessage(fd, msg_txt(546));
  8774. } else {
  8775. if(strlen(sd->away_message) > 0) {
  8776. sd->away_message[0] = 0;
  8777. //"Away automessage has been disabled."
  8778. clif_displaymessage(fd, msg_txt(547));
  8779. return 0;
  8780. }
  8781. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8782. clif_displaymessage(fd, msg_txt(548));
  8783. }
  8784. return 0;
  8785. }
  8786. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8787. int atcommand_clone(
  8788. const int fd, struct map_session_data* sd,
  8789. const char* command, const char* message)
  8790. {
  8791. int x=0,y=0,flag=0,master=0,i=0;
  8792. struct map_session_data *pl_sd=NULL;
  8793. if (!message || !*message) {
  8794. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8795. return 0;
  8796. }
  8797. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8798. clif_displaymessage(fd, msg_txt(3));
  8799. return 0;
  8800. }
  8801. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8802. clif_displaymessage(fd, msg_txt(126));
  8803. return 0;
  8804. }
  8805. if (strcmpi(command, "@clone") == 0)
  8806. flag = 1;
  8807. else if (strcmpi(command, "@slaveclone") == 0) {
  8808. flag = 2;
  8809. master = sd->bl.id;
  8810. if (battle_config.atc_slave_clone_limit
  8811. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8812. clif_displaymessage(fd, msg_txt(127));
  8813. return 0;
  8814. }
  8815. }
  8816. do {
  8817. x = sd->bl.x + (rand() % 10 - 5);
  8818. y = sd->bl.y + (rand() % 10 - 5);
  8819. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8820. if (i >= 10) {
  8821. x = sd->bl.x;
  8822. y = sd->bl.y;
  8823. }
  8824. if((x = mob_clone_spawn(pl_sd, (char*)mapindex_id2name(sd->mapindex), x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8825. clif_displaymessage(fd, msg_txt(128+flag*2));
  8826. return 0;
  8827. }
  8828. clif_displaymessage(fd, msg_txt(129+flag*2));
  8829. return 0;
  8830. }
  8831. /*===================================
  8832. * Main chat [LuzZza]
  8833. * Usage: @main <on|off|message>
  8834. *-----------------------------------
  8835. */
  8836. int atcommand_main(
  8837. const int fd, struct map_session_data* sd,
  8838. const char* command, const char* message)
  8839. {
  8840. if(strlen(message) > 0) {
  8841. if(strlen(message) > 128)
  8842. return -1;
  8843. if(strcmpi(message, "on") == 0) {
  8844. if(!sd->state.mainchat) {
  8845. sd->state.mainchat = 1;
  8846. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8847. } else {
  8848. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8849. }
  8850. } else if(strcmpi(message, "off") == 0) {
  8851. if(sd->state.mainchat) {
  8852. sd->state.mainchat = 0;
  8853. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8854. } else {
  8855. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8856. }
  8857. } else {
  8858. if(!sd->state.mainchat) {
  8859. sd->state.mainchat = 1;
  8860. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8861. }
  8862. if (sd->sc.data[SC_NOCHAT].timer != -1) {
  8863. clif_displaymessage(fd, msg_txt(387));
  8864. return -1;
  8865. }
  8866. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8867. // I use 0xFE000000 color for signalizing that this message is
  8868. // main chat message. 0xFE000000 is invalid color, same using
  8869. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8870. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8871. }
  8872. } else {
  8873. if(sd->state.mainchat)
  8874. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8875. clif_displaymessage(fd, msg_txt(384));
  8876. else
  8877. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8878. clif_displaymessage(fd, msg_txt(385));
  8879. }
  8880. return 0;
  8881. }
  8882. void do_init_atcommand() {
  8883. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8884. duel_count = 0;
  8885. memset(&duel_list[0], 0, sizeof(duel_list));
  8886. return;
  8887. }
  8888. void do_final_atcommand() {
  8889. users_db->destroy(users_db,NULL);
  8890. }