atcommand.c 330 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910
  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 "atcommand.h"
  16. #include "log.h"
  17. #include "clif.h"
  18. #include "chrif.h"
  19. #include "intif.h"
  20. #include "itemdb.h"
  21. #include "map.h"
  22. #include "pc.h"
  23. #include "status.h"
  24. #include "skill.h"
  25. #include "mob.h"
  26. #include "pet.h"
  27. #include "mercenary.h" //[orn]
  28. #include "battle.h"
  29. #include "party.h"
  30. #include "guild.h"
  31. #include "script.h"
  32. #include "npc.h"
  33. #include "trade.h"
  34. #include "unit.h"
  35. #ifndef TXT_ONLY
  36. #include "mail.h"
  37. #endif
  38. static char command_symbol = '@'; // first char of the commands (by [Yor])
  39. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  40. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  41. ACMD_FUNC(broadcast);
  42. ACMD_FUNC(localbroadcast);
  43. ACMD_FUNC(rura);
  44. ACMD_FUNC(where);
  45. ACMD_FUNC(jumpto);
  46. ACMD_FUNC(jump);
  47. ACMD_FUNC(who);
  48. ACMD_FUNC(who2);
  49. ACMD_FUNC(who3);
  50. ACMD_FUNC(whomap);
  51. ACMD_FUNC(whomap2);
  52. ACMD_FUNC(whomap3);
  53. ACMD_FUNC(whogm); // by Yor
  54. ACMD_FUNC(whozeny); // [Valaris]
  55. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  56. ACMD_FUNC(save);
  57. ACMD_FUNC(load);
  58. ACMD_FUNC(speed);
  59. ACMD_FUNC(charspeed);
  60. ACMD_FUNC(storage);
  61. ACMD_FUNC(guildstorage);
  62. ACMD_FUNC(option);
  63. ACMD_FUNC(hide);
  64. ACMD_FUNC(jobchange);
  65. ACMD_FUNC(die);
  66. ACMD_FUNC(kill);
  67. ACMD_FUNC(alive);
  68. ACMD_FUNC(kami);
  69. ACMD_FUNC(heal);
  70. ACMD_FUNC(item);
  71. ACMD_FUNC(item2);
  72. ACMD_FUNC(itemreset);
  73. ACMD_FUNC(baselevelup);
  74. ACMD_FUNC(joblevelup);
  75. ACMD_FUNC(help);
  76. ACMD_FUNC(help2);
  77. ACMD_FUNC(gm);
  78. ACMD_FUNC(pvpoff);
  79. ACMD_FUNC(pvpon);
  80. ACMD_FUNC(gvgoff);
  81. ACMD_FUNC(gvgon);
  82. ACMD_FUNC(model);
  83. ACMD_FUNC(go);
  84. ACMD_FUNC(monster);
  85. ACMD_FUNC(monstersmall);
  86. ACMD_FUNC(monsterbig);
  87. ACMD_FUNC(spawn);
  88. ACMD_FUNC(killmonster);
  89. ACMD_FUNC(killmonster2);
  90. ACMD_FUNC(refine);
  91. ACMD_FUNC(produce);
  92. ACMD_FUNC(memo);
  93. ACMD_FUNC(gat);
  94. ACMD_FUNC(packet);
  95. ACMD_FUNC(waterlevel);
  96. ACMD_FUNC(statuspoint);
  97. ACMD_FUNC(skillpoint);
  98. ACMD_FUNC(zeny);
  99. ACMD_FUNC(param);
  100. ACMD_FUNC(guildlevelup);
  101. ACMD_FUNC(makeegg);
  102. ACMD_FUNC(hatch);
  103. ACMD_FUNC(petfriendly);
  104. ACMD_FUNC(pethungry);
  105. ACMD_FUNC(petrename);
  106. ACMD_FUNC(recall);
  107. ACMD_FUNC(recallall);
  108. ACMD_FUNC(revive);
  109. ACMD_FUNC(night);
  110. ACMD_FUNC(day);
  111. ACMD_FUNC(doom);
  112. ACMD_FUNC(doommap);
  113. ACMD_FUNC(raise);
  114. ACMD_FUNC(raisemap);
  115. ACMD_FUNC(kick);
  116. ACMD_FUNC(kickall);
  117. ACMD_FUNC(allskill);
  118. ACMD_FUNC(questskill);
  119. ACMD_FUNC(lostskill);
  120. ACMD_FUNC(spiritball);
  121. ACMD_FUNC(party);
  122. ACMD_FUNC(guild);
  123. ACMD_FUNC(agitstart);
  124. ACMD_FUNC(agitend);
  125. ACMD_FUNC(reloaditemdb);
  126. ACMD_FUNC(reloadmobdb);
  127. ACMD_FUNC(reloadskilldb);
  128. ACMD_FUNC(reloadscript);
  129. ACMD_FUNC(reloadgmdb); // by Yor
  130. ACMD_FUNC(reloadatcommand);
  131. ACMD_FUNC(reloadbattleconf);
  132. ACMD_FUNC(reloadstatusdb);
  133. ACMD_FUNC(reloadpcdb);
  134. ACMD_FUNC(reloadmotd); // [Valaris]
  135. ACMD_FUNC(mapexit);
  136. ACMD_FUNC(idsearch);
  137. ACMD_FUNC(mapinfo);
  138. ACMD_FUNC(dye); //** by fritz
  139. ACMD_FUNC(hair_style); //** by fritz
  140. ACMD_FUNC(hair_color); //** by fritz
  141. ACMD_FUNC(stat_all); //** by fritz
  142. ACMD_FUNC(char_block); // by Yor
  143. ACMD_FUNC(char_ban); // by Yor
  144. ACMD_FUNC(char_unblock); // by Yor
  145. ACMD_FUNC(char_unban); // by Yor
  146. ACMD_FUNC(mount_peco); // by Valaris
  147. ACMD_FUNC(char_mount_peco); // by Yor
  148. ACMD_FUNC(guildspy); // [Syrus22]
  149. ACMD_FUNC(partyspy); // [Syrus22]
  150. ACMD_FUNC(repairall); // [Valaris]
  151. ACMD_FUNC(guildrecall); // by Yor
  152. ACMD_FUNC(partyrecall); // by Yor
  153. ACMD_FUNC(nuke); // [Valaris]
  154. ACMD_FUNC(shownpc);
  155. ACMD_FUNC(hidenpc);
  156. ACMD_FUNC(loadnpc);
  157. ACMD_FUNC(unloadnpc);
  158. ACMD_FUNC(servertime); // by Yor
  159. ACMD_FUNC(chardelitem); // by Yor
  160. ACMD_FUNC(jail); // by Yor
  161. ACMD_FUNC(unjail); // by Yor
  162. ACMD_FUNC(jailfor); // Alias Meruru
  163. ACMD_FUNC(jailtime); // Coltaro
  164. ACMD_FUNC(charjailtime); // Coltaro
  165. ACMD_FUNC(disguise); // [Valaris]
  166. ACMD_FUNC(undisguise); // by Yor
  167. ACMD_FUNC(chardisguise); // Kalaspuff
  168. ACMD_FUNC(charundisguise); // Kalaspuff
  169. ACMD_FUNC(email); // by Yor
  170. ACMD_FUNC(effect);//by Apple
  171. ACMD_FUNC(character_cart_list); // by Yor
  172. ACMD_FUNC(addwarp); // by MouseJstr
  173. ACMD_FUNC(follow); // by MouseJstr
  174. ACMD_FUNC(skillon); // by MouseJstr
  175. ACMD_FUNC(skilloff); // by MouseJstr
  176. ACMD_FUNC(killer); // by MouseJstr
  177. ACMD_FUNC(npcmove); // by MouseJstr
  178. ACMD_FUNC(killable); // by MouseJstr
  179. ACMD_FUNC(charkillable); // by MouseJstr
  180. ACMD_FUNC(dropall); // by MouseJstr
  181. ACMD_FUNC(chardropall); // by MouseJstr
  182. ACMD_FUNC(storeall); // by MouseJstr
  183. ACMD_FUNC(charstoreall); // by MouseJstr
  184. ACMD_FUNC(skillid); // by MouseJstr
  185. ACMD_FUNC(useskill); // by MouseJstr
  186. ACMD_FUNC(summon);
  187. ACMD_FUNC(rain);
  188. ACMD_FUNC(snow);
  189. ACMD_FUNC(sakura);
  190. ACMD_FUNC(clouds);
  191. ACMD_FUNC(clouds2); // [Valaris]
  192. ACMD_FUNC(fog);
  193. ACMD_FUNC(fireworks);
  194. ACMD_FUNC(leaves);
  195. ACMD_FUNC(adjgmlvl); // by MouseJstr
  196. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  197. ACMD_FUNC(trade); // by MouseJstr
  198. ACMD_FUNC(send); // by davidsiaw
  199. ACMD_FUNC(setbattleflag); // by MouseJstr
  200. ACMD_FUNC(unmute); // [Valaris]
  201. ACMD_FUNC(clearweather); // Dexity
  202. ACMD_FUNC(uptime); // by MC Cameri
  203. ACMD_FUNC(changesex); // by MC Cameri
  204. ACMD_FUNC(mute); // celest
  205. ACMD_FUNC(refresh); // by MC Cameri
  206. ACMD_FUNC(petid); // by MC Cameri
  207. ACMD_FUNC(identify); // by MC Cameri
  208. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  209. ACMD_FUNC(misceffect); // by MC Cameri
  210. ACMD_FUNC(mobsearch);
  211. ACMD_FUNC(cleanmap);
  212. ACMD_FUNC(npctalk);
  213. ACMD_FUNC(pettalk);
  214. ACMD_FUNC(users);
  215. ACMD_FUNC(reset);
  216. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  217. #ifndef TXT_ONLY
  218. ACMD_FUNC(checkmail); // [Valaris]
  219. ACMD_FUNC(listmail); // [Valaris]
  220. ACMD_FUNC(listnewmail); // [Valaris]
  221. ACMD_FUNC(readmail); // [Valaris]
  222. ACMD_FUNC(sendmail); // [Valaris]
  223. ACMD_FUNC(sendprioritymail); // [Valaris]
  224. ACMD_FUNC(deletemail); // [Valaris]
  225. ACMD_FUNC(refreshonline); // [Valaris]
  226. #endif /* TXT_ONLY */
  227. ACMD_FUNC(skilltree); // by MouseJstr
  228. ACMD_FUNC(marry); // by MouseJstr
  229. ACMD_FUNC(divorce); // by MouseJstr
  230. ACMD_FUNC(grind); // by MouseJstr
  231. ACMD_FUNC(grind2); // by MouseJstr
  232. #ifdef DMALLOC
  233. ACMD_FUNC(dmstart); // by MouseJstr
  234. ACMD_FUNC(dmtick); // by MouseJstr
  235. #endif
  236. ACMD_FUNC(jumptoid); // by Dino9021
  237. ACMD_FUNC(jumptoid2); // by Dino9021
  238. ACMD_FUNC(recallid); // by Dino9021
  239. ACMD_FUNC(recallid2); // by Dino9021
  240. ACMD_FUNC(kickid); // by Dino9021
  241. ACMD_FUNC(kickid2); // by Dino9021
  242. ACMD_FUNC(reviveid); // by Dino9021
  243. ACMD_FUNC(reviveid2); // by Dino9021
  244. ACMD_FUNC(killid); // by Dino9021
  245. ACMD_FUNC(killid2); // by Dino9021
  246. ACMD_FUNC(charkillableid); // by Dino9021
  247. ACMD_FUNC(charkillableid2); // by Dino9021
  248. ACMD_FUNC(sound);
  249. ACMD_FUNC(undisguiseall);
  250. ACMD_FUNC(disguiseall);
  251. ACMD_FUNC(changelook);
  252. ACMD_FUNC(mobinfo); //by Lupus
  253. ACMD_FUNC(exp); // by Skotlex
  254. ACMD_FUNC(adopt); // by Veider
  255. ACMD_FUNC(version); // by Ancyker
  256. ACMD_FUNC(mutearea); // by MouseJstr
  257. ACMD_FUNC(shuffle); // by MouseJstr
  258. ACMD_FUNC(rates); // by MouseJstr
  259. ACMD_FUNC(iteminfo); // Lupus
  260. ACMD_FUNC(whodrops); //Skotlex
  261. ACMD_FUNC(mapflag); // Lupus
  262. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  263. ACMD_FUNC(monsterignore); // [Valaris]
  264. ACMD_FUNC(fakename); //[Valaris]
  265. ACMD_FUNC(size); //[Valaris]
  266. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  267. ACMD_FUNC(showzeny);
  268. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  269. ACMD_FUNC(autotrade);// durf
  270. ACMD_FUNC(changeleader);// [Skotlex]
  271. ACMD_FUNC(partyoption);// [Skotlex]
  272. ACMD_FUNC(changegm);// durf
  273. // Duel [LuzZza]
  274. ACMD_FUNC(invite);
  275. ACMD_FUNC(duel);
  276. ACMD_FUNC(leave);
  277. ACMD_FUNC(accept);
  278. ACMD_FUNC(reject);
  279. ACMD_FUNC(away); // LuzZza
  280. ACMD_FUNC(main); // LuzZza
  281. ACMD_FUNC(clone); // [Valaris]
  282. ACMD_FUNC(tonpc); // LuzZza
  283. ACMD_FUNC(commands); // [Skotlex]
  284. ACMD_FUNC(noask); //LuzZza
  285. ACMD_FUNC(request); //[Skotlex]
  286. ACMD_FUNC(homlevel); //[orn]
  287. ACMD_FUNC(homevolution); //[orn]
  288. ACMD_FUNC(makehomun); //[orn]
  289. ACMD_FUNC(homfriendly); //[orn]
  290. ACMD_FUNC(homhungry); //[orn]
  291. ACMD_FUNC(homtalk); //[orn]
  292. ACMD_FUNC(hominfo); //[Toms]
  293. ACMD_FUNC(showmobs); //KarLaeda
  294. /*==========================================
  295. *AtCommandInfo atcommand_info[]構造体の定義
  296. *------------------------------------------
  297. */
  298. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  299. // to set default level, read atcommand_athena.conf first please.
  300. static AtCommandInfo atcommand_info[] = {
  301. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  302. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  303. { AtCommand_Where, "@where", 1, atcommand_where },
  304. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  305. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  306. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  307. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  308. { AtCommand_Who, "@who", 20, atcommand_who },
  309. { AtCommand_Who, "@whois", 20, atcommand_who },
  310. { AtCommand_Who, "@w", 20, atcommand_who },
  311. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  312. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  313. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  314. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  315. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  316. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  317. { AtCommand_Save, "@save", 40, atcommand_save },
  318. { AtCommand_Load, "@return", 40, atcommand_load },
  319. { AtCommand_Load, "@load", 40, atcommand_load },
  320. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  321. { AtCommand_CharSpeed, "@charspeed", 40, atcommand_charspeed },
  322. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  323. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  324. { AtCommand_Option, "@option", 40, atcommand_option },
  325. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  326. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  327. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  328. { AtCommand_Die, "@die", 1, atcommand_die },
  329. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  330. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  331. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  332. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  333. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  334. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  335. { AtCommand_Item, "@item", 60, atcommand_item },
  336. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  337. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  338. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  339. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  340. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  341. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  342. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  343. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  344. { AtCommand_H, "@h", 20, atcommand_help },
  345. { AtCommand_Help, "@help", 20, atcommand_help },
  346. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  347. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  348. { AtCommand_GM, "@gm", 100,atcommand_gm },
  349. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  350. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  351. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  352. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  353. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  354. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  355. { AtCommand_Model, "@model", 20, atcommand_model },
  356. { AtCommand_Go, "@go", 10, atcommand_go },
  357. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  358. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  359. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  360. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  361. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  362. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  363. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  364. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  365. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  366. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  367. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  368. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  369. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  370. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  371. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  372. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  373. { AtCommand_Strength, "@str", 60, atcommand_param },
  374. { AtCommand_Agility, "@agi", 60, atcommand_param },
  375. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  376. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  377. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  378. { AtCommand_Luck, "@luk", 60, atcommand_param },
  379. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  380. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  381. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  382. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  383. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  384. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  385. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  386. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  387. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  388. { AtCommand_Night, "@night", 80, atcommand_night },
  389. { AtCommand_Day, "@day", 80, atcommand_day },
  390. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  391. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  392. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  393. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  394. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  395. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  396. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  397. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  398. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  399. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  400. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  401. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  402. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  403. { AtCommand_Party, "@party", 1, atcommand_party },
  404. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  405. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  406. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  407. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  408. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  409. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  410. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  411. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  412. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  413. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  414. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  415. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  416. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  417. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  418. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  419. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  420. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  421. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  422. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  423. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  424. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  425. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  426. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  427. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  428. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  429. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  430. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  431. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  432. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  433. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  434. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  435. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  436. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  437. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  438. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  439. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  440. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  441. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  442. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  443. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  444. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  445. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  446. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  447. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  448. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  449. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  450. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  451. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  452. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  453. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  454. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  455. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  456. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  457. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  458. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  459. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  460. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  461. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  462. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  463. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  464. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  465. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  466. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  467. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  468. { AtCommand_JailFor, "@jailfor", 20, atcommand_jailfor }, //Meruru
  469. { AtCommand_JailTime, "@jailtime", 1, atcommand_jailtime }, //Change this to 0 in atcommand_conf.txt if you want it accessible to players (you most likely will ;))
  470. { AtCommand_CharJailTime, "@charjailtime", 20, atcommand_charjailtime },
  471. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  472. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  473. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  474. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  475. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  476. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  477. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  478. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  479. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  480. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  481. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  482. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  483. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  484. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  485. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  486. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  487. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  488. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  489. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  490. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  491. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  492. // { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
  493. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  494. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  495. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  496. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  497. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  498. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  499. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  500. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  501. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  502. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  503. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  504. { AtCommand_Send, "@send", 60, atcommand_send },
  505. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  506. { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
  507. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  508. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  509. { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken] <- why not? [Skotlex]
  510. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  511. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  512. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  513. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  514. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  515. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  516. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  517. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  518. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  519. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  520. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  521. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  522. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  523. { AtCommand_Users, "@users", 40, atcommand_users },
  524. { AtCommand_ResetState, "@reset", 40, atcommand_reset },
  525. #ifndef TXT_ONLY // sql-only commands
  526. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  527. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  528. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  529. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  530. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  531. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  532. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  533. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  534. #endif /* TXT_ONLY */
  535. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  536. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  537. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  538. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  539. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  540. #ifdef DMALLOC
  541. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  542. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  543. #endif
  544. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  545. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  546. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  547. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  548. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  549. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  550. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  551. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  552. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  553. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  554. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  555. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  556. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  557. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  558. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  559. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  560. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  561. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  562. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  563. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  564. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  565. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  566. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  567. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  568. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  569. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  570. { AtCommand_Version, "@version", 1, atcommand_version },
  571. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  572. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  573. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  574. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  575. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  576. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  577. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  578. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  579. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  580. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  581. { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
  582. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  583. { AtCommand_Size, "@size", 20, atcommand_size },
  584. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  585. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  586. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  587. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  588. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  589. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  590. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  591. { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
  592. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  593. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  594. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  595. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  596. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  597. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  598. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  599. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  600. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  601. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  602. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  603. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  604. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  605. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  606. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  607. { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
  608. { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
  609. { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
  610. { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
  611. { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
  612. { AtCommand_HomTalk, "@homtalk", 0, atcommand_homtalk },
  613. { AtCommand_HomInfo, "@hominfo", 0, atcommand_hominfo },
  614. { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
  615. // add new commands before this line
  616. { AtCommand_Unknown, NULL, 1, NULL }
  617. };
  618. /*=========================================
  619. * Generic variables
  620. *-----------------------------------------
  621. */
  622. char atcmd_output[200];
  623. char atcmd_player_name[100];
  624. char atcmd_temp[100];
  625. /*==========================================
  626. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  627. *------------------------------------------
  628. */
  629. char *estr_lower(char *str)
  630. {
  631. int i;
  632. for (i=0; str[i]; i++)
  633. if ((str[i] >= 65) && (str[i] <= 90))
  634. str[i] += 32;
  635. return str;
  636. }
  637. // compare function for sorting high to lowest
  638. int hightolow_compare (const void * a, const void * b)
  639. {
  640. return ( *(int*)b - *(int*)a );
  641. }
  642. // compare function for sorting lowest to highest
  643. int lowtohigh_compare (const void * a, const void * b)
  644. {
  645. return ( *(int*)a - *(int*)b );
  646. }
  647. //-----------------------------------------------------------
  648. // Return the message string of the specified number by [Yor]
  649. //-----------------------------------------------------------
  650. char * msg_txt(int msg_number) {
  651. if (msg_number >= 0 && msg_number < MAX_MSG &&
  652. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  653. return msg_table[msg_number];
  654. return "??";
  655. }
  656. //-----------------------------------------------------------
  657. // Returns Players title (from msg_athena.conf) [Lupus]
  658. //-----------------------------------------------------------
  659. char * player_title_txt(int level) {
  660. if (level < battle_config.title_lvl1)
  661. return ""; //w/o any titles
  662. if (level >= battle_config.title_lvl8)
  663. sprintf(atcmd_temp, msg_txt(332), level);
  664. else
  665. if (level >= battle_config.title_lvl7)
  666. sprintf(atcmd_temp, msg_txt(331), level);
  667. else
  668. if (level >= battle_config.title_lvl6)
  669. sprintf(atcmd_temp, msg_txt(330), level);
  670. else
  671. if (level >= battle_config.title_lvl5)
  672. sprintf(atcmd_temp, msg_txt(329), level);
  673. else
  674. if (level >= battle_config.title_lvl4)
  675. sprintf(atcmd_temp, msg_txt(328), level);
  676. else
  677. if (level >= battle_config.title_lvl3)
  678. sprintf(atcmd_temp, msg_txt(327), level);
  679. else
  680. if (level >= battle_config.title_lvl2)
  681. sprintf(atcmd_temp, msg_txt(326), level);
  682. else
  683. sprintf(atcmd_temp, msg_txt(325), level); //lvl1
  684. return atcmd_temp;
  685. }
  686. //------------------------------------------------------------
  687. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  688. //------------------------------------------------------------
  689. int e_mail_check(char *email) {
  690. char ch;
  691. char* last_arobas;
  692. // athena limits
  693. if (strlen(email) < 3 || strlen(email) > 39)
  694. return 0;
  695. // part of RFC limits (official reference of e-mail description)
  696. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  697. return 0;
  698. if (email[strlen(email)-1] == '.')
  699. return 0;
  700. last_arobas = strrchr(email, '@');
  701. if (strstr(last_arobas, "@.") != NULL ||
  702. strstr(last_arobas, "..") != NULL)
  703. return 0;
  704. for(ch = 1; ch < 32; ch++) {
  705. if (strchr(last_arobas, ch) != NULL) {
  706. return 0;
  707. break;
  708. }
  709. }
  710. if (strchr(last_arobas, ' ') != NULL ||
  711. strchr(last_arobas, ';') != NULL)
  712. return 0;
  713. // all correct
  714. return 1;
  715. }
  716. /*==========================================
  717. * get_atcommand_level @コマンドの必要レベルを取得
  718. *------------------------------------------
  719. */
  720. int get_atcommand_level(const AtCommandType type) {
  721. int i;
  722. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  723. if (atcommand_info[i].type == type)
  724. return atcommand_info[i].level;
  725. return 100; // 100: command can not be used
  726. }
  727. /*==========================================
  728. *is_atcommand @コマンドに存在するかどうか確認する
  729. *------------------------------------------
  730. */
  731. AtCommandType
  732. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  733. const char* str = message;
  734. int s_flag = 0;
  735. AtCommandInfo info;
  736. AtCommandType type;
  737. nullpo_retr(AtCommand_None, sd);
  738. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
  739. return AtCommand_Unknown;
  740. }
  741. if (!message || !*message)
  742. return AtCommand_None;
  743. malloc_set(&info, 0, sizeof(info));
  744. str += strlen(sd->status.name);
  745. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  746. if (*str == ':')
  747. s_flag = 1;
  748. str++;
  749. }
  750. if (!*str)
  751. return AtCommand_None;
  752. if (!gmlvl) gmlvl = pc_isGM(sd);
  753. type = atcommand(sd, gmlvl, str, &info);
  754. if (type != AtCommand_None) {
  755. char command[100];
  756. const char* p = str;
  757. if (map[sd->bl.m].nocommand &&
  758. gmlvl < map[sd->bl.m].nocommand)
  759. { //Command not allowed on this map.
  760. sprintf(atcmd_output, msg_txt(143));
  761. clif_displaymessage(fd, atcmd_output);
  762. return AtCommand_None;
  763. }
  764. malloc_tsetdword(command, '\0', sizeof(command));
  765. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  766. while (*p && !isspace(*p))
  767. p++;
  768. if (p - str >= sizeof(command)) // too long
  769. return AtCommand_Unknown;
  770. strncpy(command, str, p - str);
  771. while (isspace(*p))
  772. p++;
  773. if (type == AtCommand_Unknown || info.proc == NULL) {
  774. sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
  775. clif_displaymessage(fd, atcmd_output);
  776. } else {
  777. if (info.proc(fd, sd, command, p) != 0) {
  778. // Command can not be executed
  779. sprintf(atcmd_output, msg_txt(154), command); // %s failed.
  780. clif_displaymessage(fd, atcmd_output);
  781. }
  782. }
  783. return info.type;
  784. }
  785. return AtCommand_None;
  786. }
  787. /*==========================================
  788. *
  789. *------------------------------------------
  790. */
  791. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  792. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  793. if (!info)
  794. return AtCommand_None;
  795. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  796. return AtCommand_None;
  797. if (!p || !*p) {
  798. ShowError("at command message is empty\n");
  799. return AtCommand_None;
  800. }
  801. if (*p == command_symbol) { // check first char.
  802. char command[101];
  803. int i = 0;
  804. malloc_set(info, 0, sizeof(AtCommandInfo));
  805. sscanf(p, "%100s", command);
  806. command[sizeof(command)-1] = '\0';
  807. while (atcommand_info[i].type != AtCommand_Unknown) {
  808. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  809. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  810. break;
  811. }
  812. i++;
  813. }
  814. if (atcommand_info[i].type == AtCommand_Unknown) {
  815. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  816. if (level == 0)
  817. return AtCommand_None;
  818. else
  819. return AtCommand_Unknown;
  820. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  821. log_atcommand(sd, message);
  822. }
  823. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  824. } else {
  825. return AtCommand_None;
  826. }
  827. return info->type;
  828. }
  829. /*==========================================
  830. * Read Message Data
  831. *------------------------------------------
  832. */
  833. int msg_config_read(const char *cfgName) {
  834. int msg_number;
  835. char line[1024], w1[1024], w2[1024];
  836. FILE *fp;
  837. static int called = 1;
  838. if ((fp = fopen(cfgName, "r")) == NULL) {
  839. ShowError("Messages file not found: %s\n", cfgName);
  840. return 1;
  841. }
  842. if ((--called) == 0)
  843. malloc_tsetdword(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  844. while(fgets(line, sizeof(line)-1, fp)) {
  845. if (line[0] == '/' && line[1] == '/')
  846. continue;
  847. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  848. if (strcmpi(w1, "import") == 0) {
  849. msg_config_read(w2);
  850. } else {
  851. msg_number = atoi(w1);
  852. if (msg_number >= 0 && msg_number < MAX_MSG) {
  853. if (msg_table[msg_number] != NULL)
  854. aFree(msg_table[msg_number]);
  855. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  856. strcpy(msg_table[msg_number],w2);
  857. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  858. }
  859. }
  860. }
  861. }
  862. fclose(fp);
  863. return 0;
  864. }
  865. /*==========================================
  866. * Cleanup Message Data
  867. *------------------------------------------
  868. */
  869. void do_final_msg (void) {
  870. int i;
  871. for (i = 0; i < MAX_MSG; i++)
  872. aFree(msg_table[i]);
  873. return;
  874. }
  875. /*==========================================
  876. *
  877. *------------------------------------------
  878. */
  879. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  880. int i;
  881. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  882. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  883. return &atcommand_info[i];
  884. return NULL;
  885. }
  886. /*==========================================
  887. *
  888. *------------------------------------------
  889. */
  890. int atcommand_config_read(const char *cfgName) {
  891. char line[1024], w1[1024], w2[1024];
  892. AtCommandInfo* p;
  893. FILE* fp;
  894. if ((fp = fopen(cfgName, "r")) == NULL) {
  895. ShowError("At commands configuration file not found: %s\n", cfgName);
  896. return 1;
  897. }
  898. while (fgets(line, sizeof(line)-1, fp)) {
  899. if (line[0] == '/' && line[1] == '/')
  900. continue;
  901. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  902. continue;
  903. p = get_atcommandinfo_byname(w1);
  904. if (p != NULL) {
  905. p->level = atoi(w2);
  906. if (p->level > 100)
  907. p->level = 100;
  908. else if (p->level < 0)
  909. p->level = 0;
  910. }
  911. if (strcmpi(w1, "import") == 0)
  912. atcommand_config_read(w2);
  913. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  914. w2[0] != '/' && // symbol of standard ragnarok GM commands
  915. w2[0] != '%' && // symbol of party chat speaking
  916. w2[0] != '$' && // symbol of guild chat
  917. w2[0] != '#') // symbol of charcommand
  918. command_symbol = w2[0];
  919. }
  920. fclose(fp);
  921. return 0;
  922. }
  923. /*==========================================
  924. * Duel organizing functions [LuzZza]
  925. *------------------------------------------
  926. */
  927. void duel_savetime(struct map_session_data* sd) {
  928. time_t timer;
  929. struct tm *t;
  930. time(&timer);
  931. t = localtime(&timer);
  932. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  933. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  934. return;
  935. }
  936. int duel_checktime(struct map_session_data* sd) {
  937. int diff;
  938. time_t timer;
  939. struct tm *t;
  940. time(&timer);
  941. t = localtime(&timer);
  942. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  943. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  944. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  945. }
  946. static int duel_showinfo_sub(struct map_session_data* sd,va_list va) {
  947. struct map_session_data *ssd = va_arg(va, struct map_session_data*);
  948. int *p = va_arg(va, int*);
  949. char output[256];
  950. if (sd->duel_group != ssd->duel_group) return 0;
  951. sprintf(output, " %d. %s", ++(*p), (unsigned char *)sd->status.name);
  952. clif_disp_onlyself(ssd, output, strlen(output));
  953. return 1;
  954. }
  955. int duel_showinfo(
  956. const unsigned int did, struct map_session_data* sd)
  957. {
  958. int p=0;
  959. char output[256];
  960. if(duel_list[did].max_players_limit > 0)
  961. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  962. did, duel_count,
  963. duel_list[did].members_count,
  964. duel_list[did].members_count + duel_list[did].invites_count,
  965. duel_list[did].max_players_limit);
  966. else
  967. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  968. did, duel_count,
  969. duel_list[did].members_count,
  970. duel_list[did].members_count + duel_list[did].invites_count);
  971. clif_disp_onlyself(sd, output, strlen(output));
  972. clif_foreachclient(duel_showinfo_sub, sd, &p);
  973. return 0;
  974. }
  975. int duel_create(
  976. struct map_session_data* sd, const unsigned int maxpl)
  977. {
  978. int i=1;
  979. char output[256];
  980. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  981. if(i == MAX_DUEL) return 0;
  982. duel_count++;
  983. sd->duel_group = i;
  984. duel_list[i].members_count++;
  985. duel_list[i].invites_count = 0;
  986. duel_list[i].max_players_limit = maxpl;
  987. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  988. clif_disp_onlyself(sd, output, strlen(output));
  989. clif_set0199(sd->fd, 1);
  990. //clif_misceffect2(&sd->bl, 159);
  991. return i;
  992. }
  993. int duel_invite(
  994. const unsigned int did, struct map_session_data* sd,
  995. struct map_session_data* target_sd)
  996. {
  997. char output[256];
  998. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  999. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  1000. clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
  1001. target_sd->duel_invite = did;
  1002. duel_list[did].invites_count++;
  1003. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  1004. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  1005. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  1006. return 0;
  1007. }
  1008. static int duel_leave_sub(struct map_session_data* sd,va_list va) {
  1009. int did = va_arg(va, int);
  1010. if (sd->duel_invite == did)
  1011. sd->duel_invite = 0;
  1012. return 0;
  1013. }
  1014. int duel_leave(
  1015. const unsigned int did, struct map_session_data* sd)
  1016. {
  1017. char output[256];
  1018. // " <- Player %s has left duel --"
  1019. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  1020. clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
  1021. duel_list[did].members_count--;
  1022. if(duel_list[did].members_count == 0) {
  1023. clif_foreachclient(duel_leave_sub, did);
  1024. duel_count--;
  1025. }
  1026. sd->duel_group = 0;
  1027. duel_savetime(sd);
  1028. clif_set0199(sd->fd, 0);
  1029. return 0;
  1030. }
  1031. int duel_accept(
  1032. const unsigned int did, struct map_session_data* sd)
  1033. {
  1034. char output[256];
  1035. duel_list[did].members_count++;
  1036. sd->duel_group = sd->duel_invite;
  1037. duel_list[did].invites_count--;
  1038. sd->duel_invite = 0;
  1039. // " -> Player %s has accepted duel --"
  1040. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  1041. clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
  1042. clif_set0199(sd->fd, 1);
  1043. //clif_misceffect2(&sd->bl, 159);
  1044. return 0;
  1045. }
  1046. int duel_reject(
  1047. const unsigned int did, struct map_session_data* sd)
  1048. {
  1049. char output[256];
  1050. // " -- Player %s has rejected duel --"
  1051. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1052. clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
  1053. duel_list[did].invites_count--;
  1054. sd->duel_invite = 0;
  1055. return 0;
  1056. }
  1057. /*==========================================
  1058. // @ command processing functions
  1059. *------------------------------------------
  1060. */
  1061. /*==========================================
  1062. * @commands Lists available @ commands to you (code 98% from Meruru)
  1063. *------------------------------------------
  1064. */
  1065. int atcommand_commands(
  1066. const int fd, struct map_session_data* sd,
  1067. const char* command, const char* message)
  1068. {
  1069. char cz_line_buff[MESSAGE_SIZE+1];
  1070. register char *lpcz_cur = cz_line_buff;
  1071. register unsigned int ui_slen;
  1072. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  1073. malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
  1074. cz_line_buff[MESSAGE_SIZE] = 0;
  1075. clif_displaymessage(fd, msg_txt(273));
  1076. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  1077. {
  1078. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  1079. continue;
  1080. count++;
  1081. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  1082. //rember not <= bc we need null terminator
  1083. if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  1084. {
  1085. clif_displaymessage(fd,(char*)cz_line_buff);
  1086. lpcz_cur = cz_line_buff;
  1087. malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
  1088. cz_line_buff[MESSAGE_SIZE] = 0;
  1089. }
  1090. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  1091. lpcz_cur += ui_slen+(10-ui_slen%10);
  1092. }
  1093. clif_displaymessage(fd,(char*)cz_line_buff);
  1094. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  1095. clif_displaymessage(fd, atcmd_output);
  1096. return 0;
  1097. }
  1098. /*==========================================
  1099. * @send (used for testing packet sends from the client)
  1100. *------------------------------------------
  1101. */
  1102. int atcommand_send(
  1103. const int fd, struct map_session_data* sd,
  1104. const char* command, const char* message)
  1105. {
  1106. int i,type=0;
  1107. int info[20];
  1108. 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) {
  1109. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1110. return -1;
  1111. }
  1112. if (type > 0 && type < MAX_PACKET_DB) {
  1113. switch (type)
  1114. {
  1115. case 0x209: {
  1116. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1117. WFIFOW(fd,0) = 0x209;
  1118. WFIFOW(fd,2) = 2;
  1119. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1120. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1121. break;
  1122. }
  1123. case 0x1b1:
  1124. case 0x1c2:
  1125. //case xxx:
  1126. // add others here
  1127. // break;
  1128. default: {
  1129. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1130. WFIFOW(fd,0) = type;
  1131. for(i=1;i<=sizeof(info);i++)
  1132. if(info[i])
  1133. WFIFOW(fd,i) = info[i];
  1134. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1135. break;
  1136. }
  1137. }
  1138. sprintf (atcmd_output, msg_txt(258), type, type);
  1139. clif_displaymessage(fd, atcmd_output);
  1140. } else {
  1141. clif_displaymessage(fd, msg_txt(259));
  1142. }
  1143. return 0;
  1144. }
  1145. // @rura
  1146. /*==========================================
  1147. *
  1148. *------------------------------------------
  1149. */
  1150. int atcommand_rura(
  1151. const int fd, struct map_session_data* sd,
  1152. const char* command, const char* message)
  1153. {
  1154. char map_name[MAP_NAME_LENGTH];
  1155. unsigned short mapindex;
  1156. int x = 0, y = 0;
  1157. int m = -1;
  1158. nullpo_retr(-1, sd);
  1159. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  1160. if (!message || !*message ||
  1161. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1162. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1163. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1164. return -1;
  1165. }
  1166. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1167. strcat(map_name, ".gat");
  1168. mapindex = mapindex_name2id(map_name);
  1169. if (mapindex)
  1170. m = map_mapindex2mapid(mapindex);
  1171. if (!mapindex || m < 0) {
  1172. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1173. return -1;
  1174. }
  1175. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) {
  1176. clif_displaymessage(fd, msg_txt(2));
  1177. x = y = 0; //Invalid cell, use random spot.
  1178. }
  1179. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1180. clif_displaymessage(fd, msg_txt(247));
  1181. return -1;
  1182. }
  1183. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1184. clif_displaymessage(fd, msg_txt(248));
  1185. return -1;
  1186. }
  1187. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1188. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1189. else {
  1190. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1191. return -1;
  1192. }
  1193. return 0;
  1194. }
  1195. /*==========================================
  1196. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1197. *------------------------------------------
  1198. */
  1199. int atcommand_where(
  1200. const int fd, struct map_session_data* sd,
  1201. const char* command, const char* message)
  1202. {
  1203. struct map_session_data *pl_sd = NULL;
  1204. int GM_level, pl_GM_level;
  1205. nullpo_retr(-1, sd);
  1206. malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1207. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1208. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1209. return -1;
  1210. }
  1211. pl_sd = map_nick2sd(atcmd_player_name);
  1212. if (pl_sd == NULL)
  1213. return -1;
  1214. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1215. return -1;
  1216. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1217. pl_GM_level = pc_isGM(pl_sd);
  1218. if (battle_config.hide_GM_session) {
  1219. if(GM_level < pl_GM_level) {
  1220. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1221. return -1;
  1222. }
  1223. }
  1224. }
  1225. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1226. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1227. clif_displaymessage(fd, atcmd_output);
  1228. return 0;
  1229. }
  1230. /*==========================================
  1231. *
  1232. *------------------------------------------
  1233. */
  1234. int atcommand_jumpto(
  1235. const int fd, struct map_session_data* sd,
  1236. const char* command, const char* message)
  1237. {
  1238. struct map_session_data *pl_sd = NULL;
  1239. nullpo_retr(-1, sd);
  1240. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1241. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1242. return -1;
  1243. }
  1244. malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1245. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1246. return -1;
  1247. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1248. return -1;
  1249. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1250. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1251. clif_displaymessage(fd, msg_txt(247));
  1252. return -1;
  1253. }
  1254. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1255. clif_displaymessage(fd, msg_txt(248));
  1256. return -1;
  1257. }
  1258. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1259. sprintf(atcmd_output, msg_txt(4), atcmd_player_name); // Jump to %s
  1260. clif_displaymessage(fd, atcmd_output);
  1261. } else {
  1262. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1263. return -1;
  1264. }
  1265. return 0;
  1266. }
  1267. /*==========================================
  1268. *
  1269. *------------------------------------------
  1270. */
  1271. int atcommand_jump(
  1272. const int fd, struct map_session_data* sd,
  1273. const char* command, const char* message)
  1274. {
  1275. int x = 0, y = 0;
  1276. nullpo_retr(-1, sd);
  1277. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1278. sscanf(message, "%d %d", &x, &y);
  1279. if (x <= 0) //If coordinates are 'wrong', random jump.
  1280. x = -1;
  1281. if (y <= 0)
  1282. y = -1;
  1283. 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)) {
  1284. clif_displaymessage(fd, msg_txt(248));
  1285. return -1;
  1286. }
  1287. pc_setpos(sd, sd->mapindex, x, y, 3);
  1288. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
  1289. clif_displaymessage(fd, atcmd_output);
  1290. return 0;
  1291. }
  1292. /*==========================================
  1293. * @who3 = Player name, his location
  1294. *------------------------------------------
  1295. */
  1296. int atcommand_who3(
  1297. const int fd, struct map_session_data* sd,
  1298. const char* command, const char* message)
  1299. {
  1300. char temp0[100];
  1301. struct map_session_data *pl_sd, **pl_allsd;
  1302. int i, j, count, users;
  1303. int pl_GM_level, GM_level;
  1304. char match_text[100];
  1305. char player_name[NAME_LENGTH];
  1306. nullpo_retr(-1, sd);
  1307. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1308. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1309. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1310. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1311. strcpy(match_text, "");
  1312. for (j = 0; match_text[j]; j++)
  1313. match_text[j] = tolower(match_text[j]);
  1314. count = 0;
  1315. GM_level = pc_isGM(sd);
  1316. pl_allsd = map_getallusers(&users);
  1317. for (i = 0; i < users; i++) {
  1318. if ((pl_sd = pl_allsd[i])) {
  1319. pl_GM_level = pc_isGM(pl_sd);
  1320. 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
  1321. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1322. for (j = 0; player_name[j]; j++)
  1323. player_name[j] = tolower(player_name[j]);
  1324. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1325. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1326. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1327. } else {
  1328. atcmd_output[0]=0;
  1329. }
  1330. //Player name
  1331. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1332. strcat(atcmd_output,temp0);
  1333. //Player title, if exists
  1334. if (pl_GM_level > 0) {
  1335. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1336. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1337. strcat(atcmd_output,temp0);
  1338. }
  1339. //Players Location: map x y
  1340. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1341. strcat(atcmd_output,temp0);
  1342. clif_displaymessage(fd, atcmd_output);
  1343. count++;
  1344. }
  1345. }
  1346. }
  1347. }
  1348. if (count == 0)
  1349. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1350. else if (count == 1)
  1351. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1352. else {
  1353. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1354. clif_displaymessage(fd, atcmd_output);
  1355. }
  1356. return 0;
  1357. }
  1358. /*==========================================
  1359. * Player name, BLevel, Job,
  1360. *------------------------------------------
  1361. */
  1362. int atcommand_who2(
  1363. const int fd, struct map_session_data* sd,
  1364. const char* command, const char* message)
  1365. {
  1366. char temp0[100];
  1367. struct map_session_data *pl_sd, **pl_allsd;
  1368. int i, j, count, users;
  1369. int pl_GM_level, GM_level;
  1370. char match_text[100];
  1371. char player_name[NAME_LENGTH];
  1372. nullpo_retr(-1, sd);
  1373. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1374. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1375. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1376. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1377. strcpy(match_text, "");
  1378. for (j = 0; match_text[j]; j++)
  1379. match_text[j] = tolower(match_text[j]);
  1380. count = 0;
  1381. GM_level = pc_isGM(sd);
  1382. pl_allsd = map_getallusers(&users);
  1383. for (i = 0; i < users; i++) {
  1384. if ((pl_sd = pl_allsd[i])) {
  1385. pl_GM_level = pc_isGM(pl_sd);
  1386. 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
  1387. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1388. for (j = 0; player_name[j]; j++)
  1389. player_name[j] = tolower(player_name[j]);
  1390. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1391. //Players Name
  1392. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1393. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1394. //Player title, if exists
  1395. if (pl_GM_level > 0) {
  1396. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1397. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1398. strcat(atcmd_output,temp0);
  1399. }
  1400. //Players Base Level / Job name
  1401. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1402. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1403. strcat(atcmd_output,temp0);
  1404. clif_displaymessage(fd, atcmd_output);
  1405. count++;
  1406. }
  1407. }
  1408. }
  1409. }
  1410. if (count == 0)
  1411. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1412. else if (count == 1)
  1413. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1414. else {
  1415. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1416. clif_displaymessage(fd, atcmd_output);
  1417. }
  1418. return 0;
  1419. }
  1420. /*==========================================
  1421. * Player name, Playrs Party / Guild name
  1422. *------------------------------------------
  1423. */
  1424. int atcommand_who(
  1425. const int fd, struct map_session_data* sd,
  1426. const char* command, const char* message)
  1427. {
  1428. char temp0[100];
  1429. struct map_session_data *pl_sd, **pl_allsd;
  1430. int i, j, count, users;
  1431. int pl_GM_level, GM_level;
  1432. char match_text[100];
  1433. char player_name[NAME_LENGTH];
  1434. struct guild *g;
  1435. struct party_data *p;
  1436. nullpo_retr(-1, sd);
  1437. malloc_tsetdword(temp0, '\0', sizeof(temp0));
  1438. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1439. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1440. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1441. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1442. strcpy(match_text, "");
  1443. for (j = 0; match_text[j]; j++)
  1444. match_text[j] = tolower(match_text[j]);
  1445. count = 0;
  1446. GM_level = pc_isGM(sd);
  1447. pl_allsd = map_getallusers(&users);
  1448. for (i = 0; i < users; i++) {
  1449. if ((pl_sd = pl_allsd[i])) {
  1450. pl_GM_level = pc_isGM(pl_sd);
  1451. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1452. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1453. for (j = 0; player_name[j]; j++)
  1454. player_name[j] = tolower(player_name[j]);
  1455. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1456. g = guild_search(pl_sd->status.guild_id);
  1457. p = party_search(pl_sd->status.party_id);
  1458. //Players Name
  1459. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1460. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1461. //Player title, if exists
  1462. if (pl_GM_level > 0) {
  1463. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1464. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1465. strcat(atcmd_output,temp0);
  1466. }
  1467. //Players Party if exists
  1468. if (p != NULL) {
  1469. //sprintf(temp0," | Party: '%s'", p->name);
  1470. sprintf(temp0, msg_txt(335), p->party.name);
  1471. strcat(atcmd_output,temp0);
  1472. }
  1473. //Players Guild if exists
  1474. if (g != NULL) {
  1475. //sprintf(temp0," | Guild: '%s'", g->name);
  1476. sprintf(temp0, msg_txt(336), g->name);
  1477. strcat(atcmd_output,temp0);
  1478. }
  1479. clif_displaymessage(fd, atcmd_output);
  1480. count++;
  1481. }
  1482. }
  1483. }
  1484. }
  1485. if (count == 0)
  1486. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1487. else if (count == 1)
  1488. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1489. else {
  1490. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1491. clif_displaymessage(fd, atcmd_output);
  1492. }
  1493. return 0;
  1494. }
  1495. /*==========================================
  1496. *
  1497. *------------------------------------------
  1498. */
  1499. int atcommand_whomap3(
  1500. const int fd, struct map_session_data* sd,
  1501. const char* command, const char* message)
  1502. {
  1503. struct map_session_data *pl_sd, **pl_allsd;
  1504. int i, count, users;
  1505. int pl_GM_level, GM_level;
  1506. int map_id;
  1507. char map_name[MAP_NAME_LENGTH];
  1508. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1509. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  1510. if (!message || !*message)
  1511. map_id = sd->bl.m;
  1512. else {
  1513. sscanf(message, "%15s", map_name);
  1514. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1515. strcat(map_name, ".gat");
  1516. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1517. map_id = sd->bl.m;
  1518. }
  1519. count = 0;
  1520. GM_level = pc_isGM(sd);
  1521. pl_allsd = map_getallusers(&users);
  1522. for (i = 0; i < users; i++) {
  1523. if ((pl_sd = pl_allsd[i])) {
  1524. pl_GM_level = pc_isGM(pl_sd);
  1525. 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
  1526. if (pl_sd->bl.m == map_id) {
  1527. if (pl_GM_level > 0)
  1528. 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);
  1529. else
  1530. 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);
  1531. clif_displaymessage(fd, atcmd_output);
  1532. count++;
  1533. }
  1534. }
  1535. }
  1536. }
  1537. if (count == 0)
  1538. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1539. else if (count == 1)
  1540. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1541. else {
  1542. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1543. }
  1544. clif_displaymessage(fd, atcmd_output);
  1545. return 0;
  1546. }
  1547. /*==========================================
  1548. *
  1549. *------------------------------------------
  1550. */
  1551. int atcommand_whomap2(
  1552. const int fd, struct map_session_data* sd,
  1553. const char* command, const char* message)
  1554. {
  1555. struct map_session_data *pl_sd, **pl_allsd;
  1556. int i, count, users;
  1557. int pl_GM_level, GM_level;
  1558. int map_id = 0;
  1559. char map_name[MAP_NAME_LENGTH];
  1560. nullpo_retr(-1, sd);
  1561. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1562. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  1563. if (!message || !*message)
  1564. map_id = sd->bl.m;
  1565. else {
  1566. sscanf(message, "%15s", map_name);
  1567. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1568. strcat(map_name, ".gat");
  1569. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1570. map_id = sd->bl.m;
  1571. }
  1572. count = 0;
  1573. GM_level = pc_isGM(sd);
  1574. pl_allsd = map_getallusers(&users);
  1575. for (i = 0; i < users; i++) {
  1576. if ((pl_sd = pl_allsd[i])) {
  1577. pl_GM_level = pc_isGM(pl_sd);
  1578. 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
  1579. if (pl_sd->bl.m == map_id) {
  1580. if (pl_GM_level > 0)
  1581. 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);
  1582. else
  1583. 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);
  1584. clif_displaymessage(fd, atcmd_output);
  1585. count++;
  1586. }
  1587. }
  1588. }
  1589. }
  1590. if (count == 0)
  1591. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1592. else if (count == 1)
  1593. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1594. else {
  1595. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1596. }
  1597. clif_displaymessage(fd, atcmd_output);
  1598. return 0;
  1599. }
  1600. /*==========================================
  1601. *
  1602. *------------------------------------------
  1603. */
  1604. int atcommand_whomap(
  1605. const int fd, struct map_session_data* sd,
  1606. const char* command, const char* message)
  1607. {
  1608. char temp0[100];
  1609. char temp1[100];
  1610. struct map_session_data *pl_sd, **pl_allsd;
  1611. int i, count, users;
  1612. int pl_GM_level, GM_level;
  1613. int map_id = 0;
  1614. char map_name[MAP_NAME_LENGTH];
  1615. struct guild *g;
  1616. struct party_data *p;
  1617. nullpo_retr(-1, sd);
  1618. malloc_tsetdword(temp0, '\0', sizeof(temp0));
  1619. malloc_tsetdword(temp1, '\0', sizeof(temp1));
  1620. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1621. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  1622. if (!message || !*message)
  1623. map_id = sd->bl.m;
  1624. else {
  1625. sscanf(message, "%15s", map_name);
  1626. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1627. strcat(map_name, ".gat");
  1628. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1629. map_id = sd->bl.m;
  1630. }
  1631. count = 0;
  1632. GM_level = pc_isGM(sd);
  1633. pl_allsd = map_getallusers(&users);
  1634. for (i = 0; i < users; i++) {
  1635. if ((pl_sd = pl_allsd[i])) {
  1636. pl_GM_level = pc_isGM(pl_sd);
  1637. 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
  1638. if (pl_sd->bl.m == map_id) {
  1639. g = guild_search(pl_sd->status.guild_id);
  1640. if (g == NULL)
  1641. sprintf(temp1, "None");
  1642. else
  1643. sprintf(temp1, "%s", g->name);
  1644. p = party_search(pl_sd->status.party_id);
  1645. if (p == NULL)
  1646. sprintf(temp0, "None");
  1647. else
  1648. sprintf(temp0, "%s", p->party.name);
  1649. if (pl_GM_level > 0)
  1650. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1651. else
  1652. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1653. clif_displaymessage(fd, atcmd_output);
  1654. count++;
  1655. }
  1656. }
  1657. }
  1658. }
  1659. if (count == 0)
  1660. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1661. else if (count == 1)
  1662. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1663. else {
  1664. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1665. }
  1666. clif_displaymessage(fd, atcmd_output);
  1667. return 0;
  1668. }
  1669. /*==========================================
  1670. *
  1671. *------------------------------------------
  1672. */
  1673. int atcommand_whogm(
  1674. const int fd, struct map_session_data* sd,
  1675. const char* command, const char* message)
  1676. {
  1677. char temp0[100];
  1678. char temp1[100];
  1679. struct map_session_data *pl_sd, **pl_allsd;
  1680. int i, j, count, users;
  1681. int pl_GM_level, GM_level;
  1682. char match_text[100];
  1683. char player_name[NAME_LENGTH];
  1684. struct guild *g;
  1685. struct party_data *p;
  1686. nullpo_retr(-1, sd);
  1687. malloc_tsetdword(temp0, '\0', sizeof(temp0));
  1688. malloc_tsetdword(temp1, '\0', sizeof(temp1));
  1689. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1690. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1691. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1692. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1693. strcpy(match_text, "");
  1694. for (j = 0; match_text[j]; j++)
  1695. match_text[j] = tolower(match_text[j]);
  1696. count = 0;
  1697. GM_level = pc_isGM(sd);
  1698. pl_allsd = map_getallusers(&users);
  1699. for (i = 0; i < users; i++) {
  1700. if ((pl_sd = pl_allsd[i])) {
  1701. pl_GM_level = pc_isGM(pl_sd);
  1702. if (pl_GM_level > 0) {
  1703. 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
  1704. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1705. for (j = 0; player_name[j]; j++)
  1706. player_name[j] = tolower(player_name[j]);
  1707. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1708. 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);
  1709. clif_displaymessage(fd, atcmd_output);
  1710. 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);
  1711. clif_displaymessage(fd, atcmd_output);
  1712. g = guild_search(pl_sd->status.guild_id);
  1713. if (g == NULL)
  1714. sprintf(temp1, "None");
  1715. else
  1716. sprintf(temp1, "%s", g->name);
  1717. p = party_search(pl_sd->status.party_id);
  1718. if (p == NULL)
  1719. sprintf(temp0, "None");
  1720. else
  1721. sprintf(temp0, "%s", p->party.name);
  1722. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1723. clif_displaymessage(fd, atcmd_output);
  1724. count++;
  1725. }
  1726. }
  1727. }
  1728. }
  1729. }
  1730. if (count == 0)
  1731. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1732. else if (count == 1)
  1733. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1734. else {
  1735. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1736. clif_displaymessage(fd, atcmd_output);
  1737. }
  1738. return 0;
  1739. }
  1740. int atcommand_whozeny(
  1741. const int fd, struct map_session_data* sd,
  1742. const char* command, const char* message)
  1743. {
  1744. struct map_session_data *pl_sd, **pl_allsd;
  1745. int i, j, count,c, users;
  1746. char match_text[100];
  1747. char player_name[NAME_LENGTH];
  1748. int *zeny;
  1749. int *counted;
  1750. nullpo_retr(-1, sd);
  1751. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1752. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1753. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1754. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1755. strcpy(match_text, "");
  1756. for (j = 0; match_text[j]; j++)
  1757. match_text[j] = tolower(match_text[j]);
  1758. count = 0;
  1759. pl_allsd = map_getallusers(&users);
  1760. if (users < 1)
  1761. {
  1762. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1763. return 0;
  1764. }
  1765. zeny = (int *)aMallocA(users*sizeof(int));
  1766. counted = (int *)aMallocA(users*sizeof(int));
  1767. for (i = 0; i < users; i++) {
  1768. if ((pl_sd = pl_allsd[i])) {
  1769. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1770. for (j = 0; player_name[j]; j++)
  1771. player_name[j] = tolower(player_name[j]);
  1772. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1773. zeny[count]=pl_sd->status.zeny;
  1774. counted[i]=0;
  1775. count++;
  1776. }
  1777. }
  1778. }
  1779. qsort(zeny, count, sizeof(int), hightolow_compare);
  1780. for (c = 0; c < count && c < 50; c++) {
  1781. if(!zeny[c])
  1782. continue;
  1783. for (i = 0; i < users; i++) {
  1784. if(!zeny[c])
  1785. continue;
  1786. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1787. if(pl_sd->status.zeny==zeny[c]) {
  1788. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1789. clif_displaymessage(fd, atcmd_output);
  1790. zeny[c]=0;
  1791. counted[i]=1;
  1792. }
  1793. }
  1794. }
  1795. }
  1796. if (count == 0)
  1797. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1798. else if (count == 1)
  1799. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1800. else {
  1801. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1802. clif_displaymessage(fd, atcmd_output);
  1803. }
  1804. aFree(zeny);
  1805. aFree(counted);
  1806. return 0;
  1807. }
  1808. // cause random emote on all online players [Valaris]
  1809. int atcommand_happyhappyjoyjoy(
  1810. const int fd, struct map_session_data* sd,
  1811. const char* command, const char* message)
  1812. {
  1813. struct map_session_data *pl_sd, **pl_allsd;
  1814. int i,e, users;
  1815. nullpo_retr(-1, sd);
  1816. pl_allsd = map_getallusers(&users);
  1817. for (i = 0; i < users; i++) {
  1818. if ((pl_sd = pl_allsd[i])) {
  1819. e=rand()%40;
  1820. if(e==34)
  1821. e = 0;
  1822. clif_emotion(&pl_sd->bl,e);
  1823. }
  1824. }
  1825. return 0;
  1826. }
  1827. /*==========================================
  1828. *
  1829. *------------------------------------------
  1830. */
  1831. int atcommand_save(
  1832. const int fd, struct map_session_data* sd,
  1833. const char* command, const char* message)
  1834. {
  1835. nullpo_retr(-1, sd);
  1836. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1837. if (sd->status.pet_id > 0 && sd->pd)
  1838. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1839. chrif_save(sd,0);
  1840. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  1841. return 0;
  1842. }
  1843. /*==========================================
  1844. *
  1845. *------------------------------------------
  1846. */
  1847. int atcommand_load(
  1848. const int fd, struct map_session_data* sd,
  1849. const char* command, const char* message)
  1850. {
  1851. int m;
  1852. nullpo_retr(-1, sd);
  1853. m = map_mapindex2mapid(sd->status.save_point.map);
  1854. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1855. clif_displaymessage(fd, msg_txt(249));
  1856. return -1;
  1857. }
  1858. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1859. clif_displaymessage(fd, msg_txt(248));
  1860. return -1;
  1861. }
  1862. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1863. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1864. return 0;
  1865. }
  1866. /*==========================================
  1867. *
  1868. *------------------------------------------
  1869. */
  1870. int atcommand_speed(
  1871. const int fd, struct map_session_data* sd,
  1872. const char* command, const char* message)
  1873. {
  1874. int speed;
  1875. nullpo_retr(-1, sd);
  1876. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1877. if (!message || !*message) {
  1878. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1879. clif_displaymessage(fd, atcmd_output);
  1880. return -1;
  1881. }
  1882. speed = atoi(message);
  1883. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1884. sd->base_status.speed = speed;
  1885. status_calc_bl(&sd->bl, SCB_SPEED);
  1886. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1887. } else {
  1888. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1889. clif_displaymessage(fd, atcmd_output);
  1890. return -1;
  1891. }
  1892. return 0;
  1893. }
  1894. /*==========================================
  1895. *
  1896. *------------------------------------------
  1897. */
  1898. int atcommand_charspeed(
  1899. const int fd, struct map_session_data* sd,
  1900. const char* command, const char* message)
  1901. {
  1902. struct map_session_data *pl_sd;
  1903. int speed;
  1904. nullpo_retr(-1, sd);
  1905. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1906. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1907. if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
  1908. sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1909. clif_displaymessage(fd, atcmd_output);
  1910. return -1;
  1911. }
  1912. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  1913. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1914. return -1;
  1915. }
  1916. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1917. { //GM level check
  1918. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1919. return -1;
  1920. }
  1921. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1922. pl_sd->base_status.speed = speed;
  1923. status_calc_bl(&pl_sd->bl, SCB_SPEED);
  1924. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1925. if(pl_sd->fd)
  1926. clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
  1927. } else {
  1928. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1929. clif_displaymessage(fd, atcmd_output);
  1930. return -1;
  1931. }
  1932. return 0;
  1933. }
  1934. /*==========================================
  1935. *
  1936. *------------------------------------------
  1937. */
  1938. int atcommand_storage(
  1939. const int fd, struct map_session_data* sd,
  1940. const char* command, const char* message)
  1941. {
  1942. nullpo_retr(-1, sd);
  1943. if (storage_storageopen(sd) == 1)
  1944. { //Already open.
  1945. clif_displaymessage(fd, msg_txt(250));
  1946. return -1;
  1947. }
  1948. return 0;
  1949. }
  1950. /*==========================================
  1951. *
  1952. *------------------------------------------
  1953. */
  1954. int atcommand_guildstorage(
  1955. const int fd, struct map_session_data* sd,
  1956. const char* command, const char* message)
  1957. {
  1958. struct storage *stor; //changes from Freya/Yor
  1959. nullpo_retr(-1, sd);
  1960. if (sd->status.guild_id > 0) {
  1961. if (sd->state.storage_flag) {
  1962. clif_displaymessage(fd, msg_txt(251));
  1963. return -1;
  1964. }
  1965. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1966. clif_displaymessage(fd, msg_txt(251));
  1967. return -1;
  1968. }
  1969. storage_guild_storageopen(sd);
  1970. } else {
  1971. clif_displaymessage(fd, msg_txt(252));
  1972. return -1;
  1973. }
  1974. return 0;
  1975. }
  1976. /*==========================================
  1977. *
  1978. *------------------------------------------
  1979. */
  1980. int atcommand_option(
  1981. const int fd, struct map_session_data* sd,
  1982. const char* command, const char* message)
  1983. {
  1984. int param1 = 0, param2 = 0, param3 = 0;
  1985. nullpo_retr(-1, sd);
  1986. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1987. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1988. return -1;
  1989. }
  1990. sd->sc.opt1 = param1;
  1991. sd->sc.opt2 = param2;
  1992. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1993. clif_cartlist(sd);
  1994. clif_updatestatus(sd, SP_CARTINFO);
  1995. }
  1996. pc_setoption(sd, param3);
  1997. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1998. return 0;
  1999. }
  2000. /*==========================================
  2001. *
  2002. *------------------------------------------
  2003. */
  2004. int atcommand_hide(
  2005. const int fd, struct map_session_data* sd,
  2006. const char* command, const char* message)
  2007. {
  2008. nullpo_retr(-1, sd);
  2009. if (sd->sc.option & OPTION_INVISIBLE) {
  2010. sd->sc.option &= ~OPTION_INVISIBLE;
  2011. if (sd->disguise)
  2012. status_set_viewdata(&sd->bl, sd->disguise);
  2013. else
  2014. status_set_viewdata(&sd->bl, sd->status.class_);
  2015. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  2016. } else {
  2017. sd->sc.option |= OPTION_INVISIBLE;
  2018. sd->vd.class_ = INVISIBLE_CLASS;
  2019. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  2020. }
  2021. clif_changeoption(&sd->bl);
  2022. return 0;
  2023. }
  2024. /*==========================================
  2025. * 転職する upperを指定すると転生や養子にもなれる
  2026. *------------------------------------------
  2027. */
  2028. int atcommand_jobchange(
  2029. const int fd, struct map_session_data* sd,
  2030. const char* command, const char* message)
  2031. {
  2032. int job = 0, upper = 0;
  2033. nullpo_retr(-1, sd);
  2034. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  2035. int i, found = 0;
  2036. const struct { char name[16]; int id; } jobs[] = {
  2037. { "novice", 0 },
  2038. { "swordsman", 1 },
  2039. { "mage", 2 },
  2040. { "archer", 3 },
  2041. { "acolyte", 4 },
  2042. { "merchant", 5 },
  2043. { "thief", 6 },
  2044. { "knight", 7 },
  2045. { "priest", 8 },
  2046. { "priestess", 8 },
  2047. { "wizard", 9 },
  2048. { "blacksmith", 10 },
  2049. { "hunter", 11 },
  2050. { "assassin", 12 },
  2051. { "crusader", 14 },
  2052. { "monk", 15 },
  2053. { "sage", 16 },
  2054. { "rogue", 17 },
  2055. { "alchemist", 18 },
  2056. { "bard", 19 },
  2057. { "dancer", 20 },
  2058. { "super novice", 23 },
  2059. { "supernovice", 23 },
  2060. { "gunslinger", 24 },
  2061. { "gunner", 24 },
  2062. { "ninja", 25 },
  2063. { "high novice", 4001 },
  2064. { "swordsman high", 4002 },
  2065. { "mage high", 4003 },
  2066. { "archer high", 4004 },
  2067. { "acolyte high", 4005 },
  2068. { "merchant high", 4006 },
  2069. { "thief high", 4007 },
  2070. { "lord knight", 4008 },
  2071. { "high priest", 4009 },
  2072. { "high priestess", 4009 },
  2073. { "high wizard", 4010 },
  2074. { "whitesmith", 4011 },
  2075. { "sniper", 4012 },
  2076. { "assassin cross", 4013 },
  2077. { "paladin", 4015 },
  2078. { "champion", 4016 },
  2079. { "professor", 4017 },
  2080. { "stalker", 4018 },
  2081. { "creator", 4019 },
  2082. { "clown", 4020 },
  2083. { "gypsy", 4021 },
  2084. { "baby novice", 4023 },
  2085. { "baby swordsman", 4024 },
  2086. { "baby mage", 4025 },
  2087. { "baby archer", 4026 },
  2088. { "baby acolyte", 4027 },
  2089. { "baby merchant", 4028 },
  2090. { "baby thief", 4029 },
  2091. { "baby knight", 4030 },
  2092. { "baby priest", 4031 },
  2093. { "baby priestess", 4031 },
  2094. { "baby wizard", 4032 },
  2095. { "baby blacksmith",4033 },
  2096. { "baby hunter", 4034 },
  2097. { "baby assassin", 4035 },
  2098. { "baby crusader", 4037 },
  2099. { "baby monk", 4038 },
  2100. { "baby sage", 4039 },
  2101. { "baby rogue", 4040 },
  2102. { "baby alchemist", 4041 },
  2103. { "baby bard", 4042 },
  2104. { "baby dancer", 4043 },
  2105. { "super baby", 4045 },
  2106. { "taekwon", 4046 },
  2107. { "taekwon boy", 4046 },
  2108. { "taekwon girl", 4046 },
  2109. { "star gladiator", 4047 },
  2110. { "soul linker", 4049 },
  2111. };
  2112. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2113. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2114. job = jobs[i].id;
  2115. upper = 0;
  2116. found = 1;
  2117. break;
  2118. }
  2119. }
  2120. if (!found) {
  2121. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2122. return -1;
  2123. }
  2124. }
  2125. if (job == 37 ||job == 45)
  2126. return 0;
  2127. if ((job >= 0 && job < MAX_PC_CLASS))
  2128. {
  2129. int j;
  2130. for (j=0; j < MAX_INVENTORY; j++) {
  2131. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2132. pc_unequipitem(sd, j, 3);
  2133. }
  2134. if (pc_jobchange(sd, job, upper) == 0)
  2135. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  2136. else {
  2137. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  2138. return -1;
  2139. }
  2140. } else {
  2141. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2142. return -1;
  2143. }
  2144. return 0;
  2145. }
  2146. /*==========================================
  2147. *
  2148. *------------------------------------------
  2149. */
  2150. int atcommand_die(
  2151. const int fd, struct map_session_data* sd,
  2152. const char* command, const char* message)
  2153. {
  2154. nullpo_retr(-1, sd);
  2155. clif_specialeffect(&sd->bl,450,SELF);
  2156. status_kill(&sd->bl);
  2157. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  2158. return 0;
  2159. }
  2160. /*==========================================
  2161. *
  2162. *------------------------------------------
  2163. */
  2164. int atcommand_kill(
  2165. const int fd, struct map_session_data* sd,
  2166. const char* command, const char* message)
  2167. {
  2168. struct map_session_data *pl_sd;
  2169. nullpo_retr(-1, sd);
  2170. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2171. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2172. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2173. return -1;
  2174. }
  2175. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2176. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2177. status_kill(&pl_sd->bl);
  2178. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  2179. } else {
  2180. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2181. return -1;
  2182. }
  2183. } else {
  2184. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2185. return -1;
  2186. }
  2187. return 0;
  2188. }
  2189. /*==========================================
  2190. *
  2191. *------------------------------------------
  2192. */
  2193. int atcommand_alive(
  2194. const int fd, struct map_session_data* sd,
  2195. const char* command, const char* message)
  2196. {
  2197. nullpo_retr(-1, sd);
  2198. if (!status_revive(&sd->bl, 100, 100))
  2199. return -1;
  2200. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2201. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  2202. return 0;
  2203. }
  2204. /*==========================================
  2205. * +kamic [LuzZza]
  2206. *------------------------------------------
  2207. */
  2208. int atcommand_kami(
  2209. const int fd, struct map_session_data* sd,
  2210. const char* command, const char* message)
  2211. {
  2212. unsigned long color=0;
  2213. nullpo_retr(-1, sd);
  2214. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2215. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2216. if (!message || !*message) {
  2217. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2218. return -1;
  2219. }
  2220. sscanf(message, "%199[^\n]", atcmd_output);
  2221. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2222. } else {
  2223. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2224. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2225. return -1;
  2226. }
  2227. if(color > 0xFFFFFF) {
  2228. clif_displaymessage(fd, "Invalid color.");
  2229. return -1;
  2230. }
  2231. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2232. }
  2233. return 0;
  2234. }
  2235. /*==========================================
  2236. *
  2237. *------------------------------------------
  2238. */
  2239. int atcommand_heal(
  2240. const int fd, struct map_session_data* sd,
  2241. const char* command, const char* message)
  2242. {
  2243. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2244. nullpo_retr(-1, sd);
  2245. sscanf(message, "%d %d", &hp, &sp);
  2246. if (hp == 0 && sp == 0) {
  2247. if (!status_percent_heal(&sd->bl, 100, 100))
  2248. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2249. else
  2250. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2251. return 0;
  2252. }
  2253. if(hp > 0 && sp >= 0) {
  2254. if(!status_heal(&sd->bl, hp, sp, 0))
  2255. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2256. else
  2257. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2258. return 0;
  2259. }
  2260. if(hp < 0 && sp <= 0) {
  2261. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2262. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2263. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2264. return 0;
  2265. }
  2266. //Opposing signs.
  2267. if (hp) {
  2268. if (hp > 0)
  2269. status_heal(&sd->bl, hp, 0, 0);
  2270. else {
  2271. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2272. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2273. }
  2274. }
  2275. if (sp) {
  2276. if (sp > 0)
  2277. status_heal(&sd->bl, 0, sp, 0);
  2278. else
  2279. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2280. }
  2281. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2282. return 0;
  2283. }
  2284. /*==========================================
  2285. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2286. *------------------------------------------
  2287. */
  2288. int atcommand_item(
  2289. const int fd, struct map_session_data* sd,
  2290. const char* command, const char* message)
  2291. {
  2292. char item_name[100];
  2293. int number = 0, item_id, flag;
  2294. struct item item_tmp;
  2295. struct item_data *item_data;
  2296. int get_count, i;
  2297. nullpo_retr(-1, sd);
  2298. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  2299. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2300. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2301. return -1;
  2302. }
  2303. if (number <= 0)
  2304. number = 1;
  2305. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2306. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2307. {
  2308. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2309. return -1;
  2310. }
  2311. item_id = item_data->nameid;
  2312. get_count = number;
  2313. //Check if it's stackable.
  2314. if (!itemdb_isstackable2(item_data))
  2315. get_count = 1;
  2316. for (i = 0; i < number; i += get_count) {
  2317. // if not pet egg
  2318. if (!pet_create_egg(sd, item_id)) {
  2319. malloc_set(&item_tmp, 0, sizeof(item_tmp));
  2320. item_tmp.nameid = item_id;
  2321. item_tmp.identify = 1;
  2322. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2323. clif_additem(sd, 0, 0, flag);
  2324. }
  2325. }
  2326. //Logs (A)dmins items [Lupus]
  2327. if(log_config.enable_logs&0x400)
  2328. log_pick(sd, "A", 0, item_id, number, NULL);
  2329. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2330. return 0;
  2331. }
  2332. /*==========================================
  2333. *
  2334. *------------------------------------------
  2335. */
  2336. int atcommand_item2(
  2337. const int fd, struct map_session_data* sd,
  2338. const char* command, const char* message)
  2339. {
  2340. struct item item_tmp;
  2341. struct item_data *item_data;
  2342. char item_name[100];
  2343. int item_id, number = 0;
  2344. int identify = 0, refine = 0, attr = 0;
  2345. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2346. int flag;
  2347. int loop, get_count, i;
  2348. nullpo_retr(-1, sd);
  2349. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  2350. 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) {
  2351. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2352. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2353. return -1;
  2354. }
  2355. if (number <= 0)
  2356. number = 1;
  2357. item_id = 0;
  2358. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2359. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2360. item_id = item_data->nameid;
  2361. if (item_id > 500) {
  2362. loop = 1;
  2363. get_count = number;
  2364. if (item_data->type == 4 || item_data->type == 5 ||
  2365. item_data->type == 7 || item_data->type == 8) {
  2366. loop = number;
  2367. get_count = 1;
  2368. if (item_data->type == 7) {
  2369. identify = 1;
  2370. refine = 0;
  2371. }
  2372. if (item_data->type == 8)
  2373. refine = 0;
  2374. if (refine > 10)
  2375. refine = 10;
  2376. } else {
  2377. identify = 1;
  2378. refine = attr = 0;
  2379. }
  2380. for (i = 0; i < loop; i++) {
  2381. malloc_set(&item_tmp, 0, sizeof(item_tmp));
  2382. item_tmp.nameid = item_id;
  2383. item_tmp.identify = identify;
  2384. item_tmp.refine = refine;
  2385. item_tmp.attribute = attr;
  2386. item_tmp.card[0] = c1;
  2387. item_tmp.card[1] = c2;
  2388. item_tmp.card[2] = c3;
  2389. item_tmp.card[3] = c4;
  2390. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2391. clif_additem(sd, 0, 0, flag);
  2392. }
  2393. //Logs (A)dmins items [Lupus]
  2394. if(log_config.enable_logs&0x400)
  2395. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2396. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2397. } else {
  2398. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2399. return -1;
  2400. }
  2401. return 0;
  2402. }
  2403. /*==========================================
  2404. *
  2405. *------------------------------------------
  2406. */
  2407. int atcommand_itemreset(
  2408. const int fd, struct map_session_data* sd,
  2409. const char* command, const char* message)
  2410. {
  2411. int i;
  2412. nullpo_retr(-1, sd);
  2413. for (i = 0; i < MAX_INVENTORY; i++) {
  2414. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2415. //Logs (A)dmins items [Lupus]
  2416. if(log_config.enable_logs&0x400)
  2417. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2418. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2419. }
  2420. }
  2421. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  2422. return 0;
  2423. }
  2424. /*==========================================
  2425. * Atcommand @lvlup
  2426. *------------------------------------------
  2427. */
  2428. int atcommand_baselevelup(
  2429. const int fd, struct map_session_data* sd,
  2430. const char* command, const char* message)
  2431. {
  2432. int level=0, i=0, status_point=0;
  2433. nullpo_retr(-1, sd);
  2434. level = atoi(message);
  2435. if (!message || !*message || !level) {
  2436. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2437. return -1;
  2438. }
  2439. if (level > 0) {
  2440. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2441. clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
  2442. return -1;
  2443. } /* End Addition */
  2444. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2445. level = pc_maxbaselv(sd) - sd->status.base_level;
  2446. for (i = 1; i <= level; i++)
  2447. status_point += (sd->status.base_level + i + 14) / 5;
  2448. if (sd->status.status_point > USHRT_MAX - status_point)
  2449. sd->status.status_point = USHRT_MAX;
  2450. else
  2451. sd->status.status_point += status_point;
  2452. sd->status.base_level += (unsigned int)level;
  2453. clif_updatestatus(sd, SP_BASELEVEL);
  2454. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2455. clif_updatestatus(sd, SP_STATUSPOINT);
  2456. status_calc_pc(sd, 0);
  2457. status_percent_heal(&sd->bl, 100, 100);
  2458. clif_misceffect(&sd->bl, 0);
  2459. clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
  2460. } else {
  2461. if (sd->status.base_level == 1) {
  2462. clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
  2463. return -1;
  2464. }
  2465. level*=-1;
  2466. if ((unsigned int)level >= sd->status.base_level)
  2467. level = sd->status.base_level-1;
  2468. if (sd->status.status_point > 0) {
  2469. for (i = 0; i > -level; i--)
  2470. status_point += (sd->status.base_level + i + 14) / 5;
  2471. if (sd->status.status_point < status_point)
  2472. pc_resetstate(sd);
  2473. if (sd->status.status_point < status_point)
  2474. sd->status.status_point = 0;
  2475. else
  2476. sd->status.status_point -= status_point;
  2477. clif_updatestatus(sd, SP_STATUSPOINT);
  2478. } /* to add: remove status points from stats */
  2479. sd->status.base_level -= (unsigned int)level;
  2480. clif_updatestatus(sd, SP_BASELEVEL);
  2481. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2482. status_calc_pc(sd, 0);
  2483. clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
  2484. }
  2485. return 0;
  2486. }
  2487. /*==========================================
  2488. *
  2489. *------------------------------------------
  2490. */
  2491. int atcommand_joblevelup(
  2492. const int fd, struct map_session_data* sd,
  2493. const char* command, const char* message)
  2494. {
  2495. int level=0;
  2496. nullpo_retr(-1, sd);
  2497. level = atoi(message);
  2498. if (!message || !*message || !level) {
  2499. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2500. return -1;
  2501. }
  2502. if (level > 0) {
  2503. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2504. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  2505. return -1;
  2506. }
  2507. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2508. level = pc_maxjoblv(sd) - sd->status.job_level;
  2509. sd->status.job_level += (unsigned int)level;
  2510. clif_updatestatus(sd, SP_JOBLEVEL);
  2511. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2512. if (sd->status.skill_point > USHRT_MAX - level)
  2513. sd->status.skill_point = USHRT_MAX;
  2514. else
  2515. sd->status.skill_point += level;
  2516. clif_updatestatus(sd, SP_SKILLPOINT);
  2517. status_calc_pc(sd, 0);
  2518. clif_misceffect(&sd->bl, 1);
  2519. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  2520. } else {
  2521. if (sd->status.job_level == 1) {
  2522. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  2523. return -1;
  2524. }
  2525. level *=-1;
  2526. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2527. level = sd->status.job_level-1;
  2528. sd->status.job_level -= (unsigned int)level;
  2529. clif_updatestatus(sd, SP_JOBLEVEL);
  2530. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2531. if (sd->status.skill_point < level)
  2532. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2533. if (sd->status.skill_point < level)
  2534. sd->status.skill_point = 0;
  2535. else
  2536. sd->status.skill_point -= level;
  2537. clif_updatestatus(sd, SP_SKILLPOINT);
  2538. status_calc_pc(sd, 0);
  2539. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  2540. }
  2541. return 0;
  2542. }
  2543. /*==========================================
  2544. * @help
  2545. *------------------------------------------
  2546. */
  2547. int atcommand_help(
  2548. const int fd, struct map_session_data* sd,
  2549. const char* command, const char* message)
  2550. {
  2551. char buf[2048], w1[2048], w2[2048];
  2552. int i, gm_level;
  2553. FILE* fp;
  2554. nullpo_retr(-1, sd);
  2555. malloc_tsetdword(buf, '\0', sizeof(buf));
  2556. if ((fp = fopen(help_txt, "r")) != NULL) {
  2557. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2558. gm_level = pc_isGM(sd);
  2559. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2560. if (buf[0] == '/' && buf[1] == '/')
  2561. continue;
  2562. for (i = 0; buf[i] != '\0'; i++) {
  2563. if (buf[i] == '\r' || buf[i] == '\n') {
  2564. buf[i] = '\0';
  2565. break;
  2566. }
  2567. }
  2568. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2569. clif_displaymessage(fd, buf);
  2570. else if (gm_level >= atoi(w1))
  2571. clif_displaymessage(fd, w2);
  2572. }
  2573. fclose(fp);
  2574. } else {
  2575. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2576. return -1;
  2577. }
  2578. return 0;
  2579. }
  2580. /*==========================================
  2581. * @help2 - Char commands [Kayla]
  2582. *------------------------------------------
  2583. */
  2584. int atcommand_help2(
  2585. const int fd, struct map_session_data* sd,
  2586. const char* command, const char* message)
  2587. {
  2588. char buf[2048], w1[2048], w2[2048];
  2589. int i, gm_level;
  2590. FILE* fp;
  2591. nullpo_retr(-1, sd);
  2592. malloc_tsetdword(buf, '\0', sizeof(buf));
  2593. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2594. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2595. gm_level = pc_isGM(sd);
  2596. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2597. if (buf[0] == '/' && buf[1] == '/')
  2598. continue;
  2599. for (i = 0; buf[i] != '\0'; i++) {
  2600. if (buf[i] == '\r' || buf[i] == '\n') {
  2601. buf[i] = '\0';
  2602. break;
  2603. }
  2604. }
  2605. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2606. clif_displaymessage(fd, buf);
  2607. else if (gm_level >= atoi(w1))
  2608. clif_displaymessage(fd, w2);
  2609. }
  2610. fclose(fp);
  2611. } else {
  2612. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2613. return -1;
  2614. }
  2615. return 0;
  2616. }
  2617. /*==========================================
  2618. * @gm
  2619. *------------------------------------------
  2620. */
  2621. int atcommand_gm(
  2622. const int fd, struct map_session_data* sd,
  2623. const char* command, const char* message)
  2624. {
  2625. char password[100];
  2626. nullpo_retr(-1, sd);
  2627. malloc_tsetdword(password, '\0', sizeof(password));
  2628. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2629. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2630. return -1;
  2631. }
  2632. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2633. clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
  2634. return -1;
  2635. } else
  2636. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2637. return 0;
  2638. }
  2639. /*==========================================
  2640. *
  2641. *------------------------------------------
  2642. */
  2643. int atcommand_pvpoff(
  2644. const int fd, struct map_session_data* sd,
  2645. const char* command, const char* message)
  2646. {
  2647. struct map_session_data *pl_sd, **pl_allsd;
  2648. int i, users;
  2649. nullpo_retr(-1, sd);
  2650. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2651. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2652. return -1;
  2653. }
  2654. if (map[sd->bl.m].flag.pvp) {
  2655. map[sd->bl.m].flag.pvp = 0;
  2656. clif_send0199(sd->bl.m, 0);
  2657. pl_allsd = map_getallusers(&users);
  2658. for (i = 0; i < users; i++) { //人数分ループ
  2659. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2660. clif_pvpset(pl_sd, 0, 0, 2);
  2661. if (pl_sd->pvp_timer != -1) {
  2662. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2663. pl_sd->pvp_timer = -1;
  2664. }
  2665. }
  2666. }
  2667. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2668. } else {
  2669. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2670. return -1;
  2671. }
  2672. return 0;
  2673. }
  2674. /*==========================================
  2675. *
  2676. *------------------------------------------
  2677. */
  2678. int atcommand_pvpon(
  2679. const int fd, struct map_session_data* sd,
  2680. const char* command, const char* message)
  2681. {
  2682. struct map_session_data *pl_sd, **pl_allsd;
  2683. int i, users;
  2684. nullpo_retr(-1, sd);
  2685. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2686. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2687. return -1;
  2688. }
  2689. if (!map[sd->bl.m].flag.pvp) {
  2690. map[sd->bl.m].flag.pvp = 1;
  2691. clif_send0199(sd->bl.m, 1);
  2692. pl_allsd = map_getallusers(&users);
  2693. for (i = 0; i < users; i++) {
  2694. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2695. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2696. pl_sd->pvp_rank = 0;
  2697. pl_sd->pvp_lastusers = 0;
  2698. pl_sd->pvp_point = 5;
  2699. pl_sd->pvp_won = 0;
  2700. pl_sd->pvp_lost = 0;
  2701. }
  2702. }
  2703. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2704. } else {
  2705. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2706. return -1;
  2707. }
  2708. return 0;
  2709. }
  2710. /*==========================================
  2711. *
  2712. *------------------------------------------
  2713. */
  2714. int atcommand_gvgoff(
  2715. const int fd, struct map_session_data* sd,
  2716. const char* command, const char* message)
  2717. {
  2718. nullpo_retr(-1, sd);
  2719. if (map[sd->bl.m].flag.gvg) {
  2720. map[sd->bl.m].flag.gvg = 0;
  2721. clif_send0199(sd->bl.m, 0);
  2722. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2723. } else {
  2724. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2725. return -1;
  2726. }
  2727. return 0;
  2728. }
  2729. /*==========================================
  2730. *
  2731. *------------------------------------------
  2732. */
  2733. int atcommand_gvgon(
  2734. const int fd, struct map_session_data* sd,
  2735. const char* command, const char* message)
  2736. {
  2737. nullpo_retr(-1, sd);
  2738. if (!map[sd->bl.m].flag.gvg) {
  2739. map[sd->bl.m].flag.gvg = 1;
  2740. clif_send0199(sd->bl.m, 3);
  2741. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2742. } else {
  2743. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2744. return -1;
  2745. }
  2746. return 0;
  2747. }
  2748. /*==========================================
  2749. *
  2750. *------------------------------------------
  2751. */
  2752. int atcommand_model(
  2753. const int fd, struct map_session_data* sd,
  2754. const char* command, const char* message)
  2755. {
  2756. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2757. nullpo_retr(-1, sd);
  2758. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2759. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2760. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2761. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2762. clif_displaymessage(fd, atcmd_output);
  2763. return -1;
  2764. }
  2765. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2766. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2767. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2768. /* Removed because this check is TOO strange. [Skotlex]
  2769. //秒フ色変更
  2770. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2771. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2772. //秒フ色未実装職の判定
  2773. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2774. return -1;
  2775. } else {
  2776. */
  2777. pc_changelook(sd, LOOK_HAIR, hair_style);
  2778. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2779. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2780. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2781. // }
  2782. } else {
  2783. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2784. return -1;
  2785. }
  2786. return 0;
  2787. }
  2788. /*==========================================
  2789. * @dye && @ccolor
  2790. *------------------------------------------
  2791. */
  2792. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2793. {
  2794. int cloth_color = 0;
  2795. nullpo_retr(-1, sd);
  2796. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2797. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2798. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2799. clif_displaymessage(fd, atcmd_output);
  2800. return -1;
  2801. }
  2802. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2803. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2804. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2805. } else {
  2806. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2807. return -1;
  2808. }
  2809. return 0;
  2810. }
  2811. /*==========================================
  2812. * @hairstyle && @hstyle
  2813. *------------------------------------------
  2814. */
  2815. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2816. {
  2817. int hair_style = 0;
  2818. nullpo_retr(-1, sd);
  2819. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2820. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2821. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2822. clif_displaymessage(fd, atcmd_output);
  2823. return -1;
  2824. }
  2825. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2826. /* Removed because this check is TOO strange. [Skotlex]
  2827. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2828. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2829. return -1;
  2830. } else {
  2831. */
  2832. pc_changelook(sd, LOOK_HAIR, hair_style);
  2833. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2834. // }
  2835. } else {
  2836. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2837. return -1;
  2838. }
  2839. return 0;
  2840. }
  2841. /*==========================================
  2842. * @charhairstyle by [MouseJstr]
  2843. *------------------------------------------
  2844. */
  2845. int
  2846. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2847. const char* command, const char* message)
  2848. {
  2849. nullpo_retr(-1, sd);
  2850. return 0;
  2851. }
  2852. /*==========================================
  2853. * @haircolor && @hcolor
  2854. *------------------------------------------
  2855. */
  2856. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2857. {
  2858. int hair_color = 0;
  2859. nullpo_retr(-1, sd);
  2860. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2861. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2862. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2863. clif_displaymessage(fd, atcmd_output);
  2864. return -1;
  2865. }
  2866. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2867. /* Removed for being such a strange check. [Skotlex]
  2868. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2869. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2870. return -1;
  2871. } else {
  2872. */
  2873. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2874. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2875. // }
  2876. } else {
  2877. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2878. return -1;
  2879. }
  2880. return 0;
  2881. }
  2882. /*==========================================
  2883. * @go [city_number or city_name] - Updated by Harbin
  2884. *------------------------------------------
  2885. */
  2886. int atcommand_go(
  2887. const int fd, struct map_session_data* sd,
  2888. const char* command, const char* message)
  2889. {
  2890. int i;
  2891. int town;
  2892. char map_name[MAP_NAME_LENGTH];
  2893. int m;
  2894. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2895. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2896. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2897. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2898. { MAP_PAYON, 162, 233 }, // 3=Payon
  2899. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2900. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2901. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2902. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2903. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2904. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2905. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2906. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2907. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2908. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2909. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2910. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2911. { MAP_JAIL, 23, 61 }, // 16=Prison
  2912. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2913. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2914. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2915. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2916. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2917. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2918. };
  2919. nullpo_retr(-1, sd);
  2920. if(map[sd->bl.m].flag.nogo) {
  2921. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2922. return 0;
  2923. }
  2924. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  2925. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2926. // get the number
  2927. town = atoi(message);
  2928. // if no value, display all value
  2929. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2930. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2931. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  2932. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2933. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2934. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2935. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2936. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2937. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2938. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2939. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2940. return -1;
  2941. } else {
  2942. // get possible name of the city and add .gat if not in the name
  2943. map_name[MAP_NAME_LENGTH-1] = '\0';
  2944. for (i = 0; map_name[i]; i++)
  2945. map_name[i] = tolower(map_name[i]);
  2946. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2947. strcat(map_name, ".gat");
  2948. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2949. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2950. town = 0;
  2951. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2952. town = 1;
  2953. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2954. town = 2;
  2955. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2956. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2957. town = 3;
  2958. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2959. town = 4;
  2960. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2961. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2962. town = 5;
  2963. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2964. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2965. town = 6;
  2966. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2967. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2968. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2969. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2970. town = 7;
  2971. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2972. town = 8;
  2973. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2974. town = 9;
  2975. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2976. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2977. town = 10;
  2978. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2979. town = 11;
  2980. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2981. town = 12;
  2982. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2983. town = 13;
  2984. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2985. town = 14;
  2986. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2987. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2988. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2989. town = 15;
  2990. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2991. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2992. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2993. town = 16;
  2994. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2995. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2996. town = 17;
  2997. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2998. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2999. town = 18;
  3000. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  3001. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  3002. town = 19;
  3003. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  3004. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  3005. town = 20;
  3006. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  3007. town = 21;
  3008. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  3009. town = 22;
  3010. }
  3011. if (town >= -3 && town <= -1) {
  3012. if (sd->status.memo_point[-town-1].map) {
  3013. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  3014. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3015. clif_displaymessage(fd, msg_txt(247));
  3016. return -1;
  3017. }
  3018. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3019. clif_displaymessage(fd, msg_txt(248));
  3020. return -1;
  3021. }
  3022. 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) {
  3023. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3024. } else {
  3025. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3026. return -1;
  3027. }
  3028. } else {
  3029. sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
  3030. clif_displaymessage(fd, atcmd_output);
  3031. return -1;
  3032. }
  3033. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  3034. m = map_mapname2mapid((char *)data[town].map);
  3035. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3036. clif_displaymessage(fd, msg_txt(247));
  3037. return -1;
  3038. }
  3039. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3040. clif_displaymessage(fd, msg_txt(248));
  3041. return -1;
  3042. }
  3043. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  3044. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3045. } else {
  3046. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3047. return -1;
  3048. }
  3049. } else { // if you arrive here, you have an error in town variable when reading of names
  3050. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  3051. return -1;
  3052. }
  3053. }
  3054. return 0;
  3055. }
  3056. /*==========================================
  3057. *
  3058. *------------------------------------------
  3059. */
  3060. int atcommand_monster(
  3061. const int fd, struct map_session_data* sd,
  3062. const char* command, const char* message)
  3063. {
  3064. char name[NAME_LENGTH];
  3065. char monster[NAME_LENGTH];
  3066. int mob_id;
  3067. int number = 0;
  3068. int count;
  3069. int i, k, range;
  3070. short mx, my;
  3071. nullpo_retr(-1, sd);
  3072. malloc_tsetdword(name, '\0', sizeof(name));
  3073. malloc_tsetdword(monster, '\0', sizeof(monster));
  3074. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3075. if (!message || !*message) {
  3076. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3077. return -1;
  3078. }
  3079. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3080. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3081. //All data can be left as it is.
  3082. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3083. //Here, it is possible name was not given and we are using monster for it.
  3084. if (count < 3) //Blank mob's name.
  3085. name[0] = '\0';
  3086. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3087. //All data can be left as it is.
  3088. } else if (sscanf(message, "%23s", monster) > 0) {
  3089. //As before, name may be already filled.
  3090. name[0] = '\0';
  3091. } else {
  3092. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3093. return -1;
  3094. }
  3095. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3096. mob_id = mobdb_checkid(atoi(monster));
  3097. if (mob_id == 0) {
  3098. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3099. return -1;
  3100. }
  3101. if (mob_id == MOBID_EMPERIUM) {
  3102. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  3103. return -1;
  3104. }
  3105. if (number <= 0)
  3106. number = 1;
  3107. if (strlen(name) < 1)
  3108. strcpy(name, "--ja--");
  3109. // 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
  3110. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3111. number = battle_config.atc_spawn_quantity_limit;
  3112. if (battle_config.etc_log)
  3113. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
  3114. count = 0;
  3115. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3116. for (i = 0; i < number; i++) {
  3117. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3118. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3119. count += (k != 0) ? 1 : 0;
  3120. }
  3121. if (count != 0)
  3122. if (number == count)
  3123. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  3124. else {
  3125. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  3126. clif_displaymessage(fd, atcmd_output);
  3127. }
  3128. else {
  3129. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3130. return -1;
  3131. }
  3132. return 0;
  3133. }
  3134. // small monster spawning [Valaris]
  3135. int atcommand_monstersmall(
  3136. const int fd, struct map_session_data* sd,
  3137. const char* command, const char* message) {
  3138. char name[NAME_LENGTH] = "";
  3139. char monster[NAME_LENGTH] = "";
  3140. int mob_id = 0;
  3141. int number = 0;
  3142. int x = 0;
  3143. int y = 0;
  3144. int count;
  3145. int i;
  3146. nullpo_retr(-1, sd);
  3147. if (!message || !*message) {
  3148. clif_displaymessage(fd, "Give a monster name/id please.");
  3149. return -1;
  3150. }
  3151. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3152. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3153. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3154. clif_displaymessage(fd, "Give a monster name/id please.");
  3155. return -1;
  3156. }
  3157. // If monster identifier/name argument is a name
  3158. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3159. mob_id = atoi(monster);
  3160. if (mob_id == 0) {
  3161. clif_displaymessage(fd, msg_txt(40));
  3162. return -1;
  3163. }
  3164. if (mob_id == MOBID_EMPERIUM) {
  3165. clif_displaymessage(fd, msg_txt(83));
  3166. return -1;
  3167. }
  3168. if (mobdb_checkid(mob_id) == 0) {
  3169. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3170. return -1;
  3171. }
  3172. if (number <= 0)
  3173. number = 1;
  3174. if (strlen(name) < 1)
  3175. strcpy(name, "--ja--");
  3176. // 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
  3177. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3178. number = battle_config.atc_spawn_quantity_limit;
  3179. count = 0;
  3180. for (i = 0; i < number; i++) {
  3181. int mx, my;
  3182. if (x <= 0)
  3183. mx = sd->bl.x + (rand() % 11 - 5);
  3184. else
  3185. mx = x;
  3186. if (y <= 0)
  3187. my = sd->bl.y + (rand() % 11 - 5);
  3188. else
  3189. my = y;
  3190. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3191. }
  3192. if (count != 0)
  3193. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3194. else
  3195. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3196. return 0;
  3197. }
  3198. // big monster spawning [Valaris]
  3199. int atcommand_monsterbig(
  3200. const int fd, struct map_session_data* sd,
  3201. const char* command, const char* message) {
  3202. char name[NAME_LENGTH] = "";
  3203. char monster[NAME_LENGTH] = "";
  3204. int mob_id = 0;
  3205. int number = 0;
  3206. int x = 0;
  3207. int y = 0;
  3208. int count;
  3209. int i;
  3210. nullpo_retr(-1, sd);
  3211. if (!message || !*message) {
  3212. clif_displaymessage(fd, "Give a monster name/id please.");
  3213. return -1;
  3214. }
  3215. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3216. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3217. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3218. clif_displaymessage(fd, "Give a monster name/id please.");
  3219. return -1;
  3220. }
  3221. // If monster identifier/name argument is a name
  3222. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3223. mob_id = atoi(monster);
  3224. if (mob_id == 0) {
  3225. clif_displaymessage(fd, msg_txt(40));
  3226. return -1;
  3227. }
  3228. if (mob_id == MOBID_EMPERIUM) {
  3229. clif_displaymessage(fd, msg_txt(83));
  3230. return -1;
  3231. }
  3232. if (mobdb_checkid(mob_id) == 0) {
  3233. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3234. return -1;
  3235. }
  3236. if (number <= 0)
  3237. number = 1;
  3238. if (strlen(name) < 1)
  3239. strcpy(name, "--ja--");
  3240. // 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
  3241. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3242. number = battle_config.atc_spawn_quantity_limit;
  3243. count = 0;
  3244. for (i = 0; i < number; i++) {
  3245. int mx, my;
  3246. if (x <= 0)
  3247. mx = sd->bl.x + (rand() % 11 - 5);
  3248. else
  3249. mx = x;
  3250. if (y <= 0)
  3251. my = sd->bl.y + (rand() % 11 - 5);
  3252. else
  3253. my = y;
  3254. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3255. }
  3256. if (count != 0)
  3257. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3258. else
  3259. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3260. return 0;
  3261. }
  3262. /*==========================================
  3263. *
  3264. *------------------------------------------
  3265. */
  3266. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3267. struct mob_data *md;
  3268. int flag;
  3269. nullpo_retr(0, ap);
  3270. nullpo_retr(0, md=(struct mob_data *)bl);
  3271. flag = va_arg(ap, int);
  3272. if (md->guardian_data)
  3273. return 0; //Do not touch WoE mobs!
  3274. if (flag)
  3275. status_zap(bl,md->status.hp, 0);
  3276. else
  3277. status_kill(bl);
  3278. return 1;
  3279. }
  3280. void atcommand_killmonster_sub(
  3281. const int fd, struct map_session_data* sd, const char* message,
  3282. const int drop)
  3283. {
  3284. int map_id;
  3285. char map_name[MAP_NAME_LENGTH];
  3286. if (!sd) return;
  3287. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  3288. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3289. map_id = sd->bl.m;
  3290. else {
  3291. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3292. strcat(map_name, ".gat");
  3293. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3294. map_id = sd->bl.m;
  3295. }
  3296. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3297. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  3298. return;
  3299. }
  3300. /*==========================================
  3301. *
  3302. *------------------------------------------
  3303. */
  3304. int atcommand_killmonster(
  3305. const int fd, struct map_session_data* sd,
  3306. const char* command, const char* message)
  3307. {
  3308. if (!sd) return 0;
  3309. atcommand_killmonster_sub(fd, sd, message, 1);
  3310. return 0;
  3311. }
  3312. /*==========================================
  3313. *
  3314. *------------------------------------------
  3315. */
  3316. int atcommand_killmonster2(
  3317. const int fd, struct map_session_data* sd,
  3318. const char* command, const char* message)
  3319. {
  3320. if (!sd) return 0;
  3321. atcommand_killmonster_sub(fd, sd, message, 0);
  3322. return 0;
  3323. }
  3324. /*==========================================
  3325. *
  3326. *------------------------------------------
  3327. */
  3328. int atcommand_refine(
  3329. const int fd, struct map_session_data* sd,
  3330. const char* command, const char* message)
  3331. {
  3332. int i,j, position = 0, refine = 0, current_position, final_refine;
  3333. int count;
  3334. nullpo_retr(-1, sd);
  3335. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3336. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3337. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3338. return -1;
  3339. }
  3340. if (refine < -MAX_REFINE)
  3341. refine = -MAX_REFINE;
  3342. else if (refine > MAX_REFINE)
  3343. refine = MAX_REFINE;
  3344. else if (refine == 0)
  3345. refine = 1;
  3346. count = 0;
  3347. for (j = 0; j < EQI_MAX-1; j++) {
  3348. if ((i = sd->equip_index[j]) < 0)
  3349. continue;
  3350. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  3351. continue;
  3352. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  3353. continue;
  3354. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  3355. continue;
  3356. if(position && !(sd->status.inventory[i].equip & position))
  3357. continue;
  3358. final_refine = sd->status.inventory[i].refine + refine;
  3359. if (final_refine > MAX_REFINE)
  3360. final_refine = MAX_REFINE;
  3361. else if (final_refine < 0)
  3362. final_refine = 0;
  3363. if (sd->status.inventory[i].refine != final_refine) {
  3364. sd->status.inventory[i].refine = final_refine;
  3365. current_position = sd->status.inventory[i].equip;
  3366. pc_unequipitem(sd, i, 3);
  3367. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3368. clif_delitem(sd, i, 1);
  3369. clif_additem(sd, i, 1, 0);
  3370. pc_equipitem(sd, i, current_position);
  3371. clif_misceffect(&sd->bl, 3);
  3372. count++;
  3373. }
  3374. }
  3375. if (count == 0)
  3376. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  3377. else if (count == 1)
  3378. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  3379. else {
  3380. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  3381. clif_displaymessage(fd, atcmd_output);
  3382. }
  3383. return 0;
  3384. }
  3385. /*==========================================
  3386. *
  3387. *------------------------------------------
  3388. */
  3389. int atcommand_produce(
  3390. const int fd, struct map_session_data* sd,
  3391. const char* command, const char* message)
  3392. {
  3393. char item_name[100];
  3394. int item_id, attribute = 0, star = 0;
  3395. int flag = 0;
  3396. struct item_data *item_data;
  3397. struct item tmp_item;
  3398. nullpo_retr(-1, sd);
  3399. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3400. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  3401. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3402. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3403. return -1;
  3404. }
  3405. item_id = 0;
  3406. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  3407. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  3408. {
  3409. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  3410. clif_displaymessage(fd, atcmd_output);
  3411. return -1;
  3412. }
  3413. item_id = item_data->nameid;
  3414. if (itemdb_isequip2(item_data)) {
  3415. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3416. attribute = ATTRIBUTE_NORMAL;
  3417. if (star < MIN_STAR || star > MAX_STAR)
  3418. star = 0;
  3419. malloc_set(&tmp_item, 0, sizeof tmp_item);
  3420. tmp_item.nameid = item_id;
  3421. tmp_item.amount = 1;
  3422. tmp_item.identify = 1;
  3423. tmp_item.card[0] = CARD0_FORGE;
  3424. tmp_item.card[1] = item_data->type==IT_WEAPON?
  3425. ((star*5) << 8) + attribute:0;
  3426. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3427. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3428. clif_produceeffect(sd, 0, item_id);
  3429. clif_misceffect(&sd->bl, 3);
  3430. //Logs (A)dmins items [Lupus]
  3431. if(log_config.enable_logs&0x400)
  3432. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3433. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3434. clif_additem(sd, 0, 0, flag);
  3435. } else {
  3436. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3437. clif_displaymessage(fd, atcmd_output);
  3438. return -1;
  3439. }
  3440. return 0;
  3441. }
  3442. /*==========================================
  3443. * Sub-function to display actual memo points
  3444. *------------------------------------------
  3445. */
  3446. void atcommand_memo_sub(struct map_session_data* sd) {
  3447. int i;
  3448. if (!sd) return;
  3449. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3450. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3451. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3452. if (sd->status.memo_point[i].map)
  3453. 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);
  3454. else
  3455. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  3456. clif_displaymessage(sd->fd, atcmd_output);
  3457. }
  3458. return;
  3459. }
  3460. /*==========================================
  3461. *
  3462. *------------------------------------------
  3463. */
  3464. int atcommand_memo(
  3465. const int fd, struct map_session_data* sd,
  3466. const char* command, const char* message)
  3467. {
  3468. int position = 0;
  3469. nullpo_retr(-1, sd);
  3470. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3471. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3472. atcommand_memo_sub(sd);
  3473. else {
  3474. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3475. 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)) {
  3476. clif_displaymessage(fd, msg_txt(253));
  3477. return -1;
  3478. }
  3479. if (sd->status.memo_point[position].map) {
  3480. sprintf(atcmd_output, msg_txt(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).
  3481. clif_displaymessage(fd, atcmd_output);
  3482. }
  3483. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3484. sd->status.memo_point[position].x = sd->bl.x;
  3485. sd->status.memo_point[position].y = sd->bl.y;
  3486. clif_skill_memo(sd, 0);
  3487. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3488. clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
  3489. atcommand_memo_sub(sd);
  3490. } else {
  3491. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3492. clif_displaymessage(fd, atcmd_output);
  3493. atcommand_memo_sub(sd);
  3494. return -1;
  3495. }
  3496. }
  3497. return 0;
  3498. }
  3499. /*==========================================
  3500. *
  3501. *------------------------------------------
  3502. */
  3503. int atcommand_gat(
  3504. const int fd, struct map_session_data* sd,
  3505. const char* command, const char* message)
  3506. {
  3507. int y;
  3508. nullpo_retr(-1, sd);
  3509. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3510. for (y = 2; y >= -2; y--) {
  3511. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3512. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3513. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3514. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3515. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3516. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3517. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3518. clif_displaymessage(fd, atcmd_output);
  3519. }
  3520. return 0;
  3521. }
  3522. /*==========================================
  3523. *
  3524. *------------------------------------------
  3525. */
  3526. int atcommand_packet(
  3527. const int fd, struct map_session_data* sd,
  3528. const char* command, const char* message)
  3529. {
  3530. static int packet_mode = 0;
  3531. int i, x = 0, y = 0;
  3532. nullpo_retr(-1, sd);
  3533. if (strstr(command, "packetmode")) {
  3534. packet_mode = atoi(message);
  3535. clif_displaymessage(fd, "Packet mode changed.");
  3536. return 0;
  3537. }
  3538. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3539. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3540. return -1;
  3541. }
  3542. if (i == 1) y = 1;
  3543. switch (packet_mode)
  3544. {
  3545. case 0:
  3546. clif_status_change(&sd->bl, x, y);
  3547. break;
  3548. case 1:
  3549. sd->status.skill[sd->cloneskill_id].id=0;
  3550. sd->status.skill[sd->cloneskill_id].lv=0;
  3551. sd->status.skill[sd->cloneskill_id].flag=0;
  3552. sd->cloneskill_id = x;
  3553. sd->status.skill[x].id = x;
  3554. sd->status.skill[x].lv = skill_get_max(x);
  3555. sd->status.skill[x].flag = 13;//cloneskill flag
  3556. clif_skillinfoblock(sd);
  3557. break;
  3558. case 2:
  3559. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3560. case 3:
  3561. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3562. default:
  3563. break;
  3564. //added later
  3565. }
  3566. return 0;
  3567. }
  3568. /*==========================================
  3569. * @waterlevel [Skotlex]
  3570. *------------------------------------------
  3571. */
  3572. int atcommand_waterlevel(
  3573. const int fd, struct map_session_data* sd,
  3574. const char* command, const char* message)
  3575. {
  3576. int newlevel;
  3577. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3578. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3579. clif_displaymessage(fd, atcmd_output);
  3580. return 0;
  3581. }
  3582. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3583. if (newlevel > 0)
  3584. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3585. else
  3586. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3587. clif_displaymessage(fd, atcmd_output);
  3588. } else {
  3589. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3590. clif_displaymessage(fd, atcmd_output);
  3591. }
  3592. return 0;
  3593. }
  3594. /*==========================================
  3595. * @stpoint (Rewritten by [Yor])
  3596. *------------------------------------------
  3597. */
  3598. int atcommand_statuspoint(
  3599. const int fd, struct map_session_data* sd,
  3600. const char* command, const char* message)
  3601. {
  3602. int point, new_status_point;
  3603. if (!message || !*message || (point = atoi(message)) == 0) {
  3604. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3605. return -1;
  3606. }
  3607. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3608. new_status_point = USHRT_MAX;
  3609. else
  3610. if (point < 0 && sd->status.status_point < -point)
  3611. new_status_point = 0;
  3612. else
  3613. new_status_point = sd->status.status_point + point;
  3614. if (new_status_point != (int)sd->status.status_point) {
  3615. sd->status.status_point = (unsigned short)new_status_point;
  3616. clif_updatestatus(sd, SP_STATUSPOINT);
  3617. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  3618. } else {
  3619. if (point < 0)
  3620. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3621. else
  3622. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3623. return -1;
  3624. }
  3625. return 0;
  3626. }
  3627. /*==========================================
  3628. * @skpoint (Rewritten by [Yor])
  3629. *------------------------------------------
  3630. */
  3631. int atcommand_skillpoint(
  3632. const int fd, struct map_session_data* sd,
  3633. const char* command, const char* message)
  3634. {
  3635. int point, new_skill_point;
  3636. nullpo_retr(-1, sd);
  3637. if (!message || !*message || (point = atoi(message)) == 0) {
  3638. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3639. return -1;
  3640. }
  3641. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3642. new_skill_point = USHRT_MAX;
  3643. else if (point < 0 && sd->status.skill_point < -point)
  3644. new_skill_point = 0;
  3645. else
  3646. new_skill_point = sd->status.skill_point + point;
  3647. if (new_skill_point != (int)sd->status.skill_point) {
  3648. sd->status.skill_point = (unsigned short)new_skill_point;
  3649. clif_updatestatus(sd, SP_SKILLPOINT);
  3650. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  3651. } else {
  3652. if (point < 0)
  3653. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3654. else
  3655. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3656. return -1;
  3657. }
  3658. return 0;
  3659. }
  3660. /*==========================================
  3661. * @zeny (Rewritten by [Yor])
  3662. *------------------------------------------
  3663. */
  3664. int atcommand_zeny(
  3665. const int fd, struct map_session_data* sd,
  3666. const char* command, const char* message)
  3667. {
  3668. int zeny, new_zeny;
  3669. nullpo_retr(-1, sd);
  3670. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3671. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3672. return -1;
  3673. }
  3674. new_zeny = sd->status.zeny + zeny;
  3675. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3676. new_zeny = MAX_ZENY;
  3677. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3678. new_zeny = 0;
  3679. if (new_zeny != sd->status.zeny) {
  3680. sd->status.zeny = new_zeny;
  3681. clif_updatestatus(sd, SP_ZENY);
  3682. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  3683. } else {
  3684. if (zeny < 0)
  3685. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3686. else
  3687. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3688. return -1;
  3689. }
  3690. return 0;
  3691. }
  3692. /*==========================================
  3693. *
  3694. *------------------------------------------
  3695. */
  3696. int atcommand_param(
  3697. const int fd, struct map_session_data* sd,
  3698. const char* command, const char* message)
  3699. {
  3700. int index, value = 0, new_value, max;
  3701. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3702. short* status[6];
  3703. //we don't use direct initialization because it isn't part of the c standard.
  3704. nullpo_retr(-1, sd);
  3705. status[0] = &sd->status.str;
  3706. status[1] = &sd->status.agi;
  3707. status[2] = &sd->status.vit;
  3708. status[3] = &sd->status.int_;
  3709. status[4] = &sd->status.dex;
  3710. status[5] = &sd->status.luk;
  3711. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3712. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3713. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3714. clif_displaymessage(fd, atcmd_output);
  3715. return -1;
  3716. }
  3717. index = -1;
  3718. for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
  3719. if (strcmpi(command, param[index]) == 0)
  3720. break;
  3721. }
  3722. if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
  3723. // normaly impossible...
  3724. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3725. clif_displaymessage(fd, atcmd_output);
  3726. return -1;
  3727. }
  3728. max = pc_maxparameter(sd);
  3729. if (value > 0 && *status[index] > max - value)
  3730. new_value = max;
  3731. else if (value < 0 && *status[index] <= -value)
  3732. new_value = 1;
  3733. else
  3734. new_value = *status[index] + value;
  3735. if (new_value != (int)*status[index]) {
  3736. *status[index] = new_value;
  3737. clif_updatestatus(sd, SP_STR + index);
  3738. clif_updatestatus(sd, SP_USTR + index);
  3739. status_calc_pc(sd, 0);
  3740. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3741. } else {
  3742. if (value < 0)
  3743. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3744. else
  3745. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3746. return -1;
  3747. }
  3748. return 0;
  3749. }
  3750. /*==========================================
  3751. *
  3752. *------------------------------------------
  3753. */
  3754. //** Stat all by fritz (rewritten by [Yor])
  3755. int atcommand_stat_all(
  3756. const int fd, struct map_session_data* sd,
  3757. const char* command, const char* message)
  3758. {
  3759. int index, count, value = 0, max, new_value;
  3760. short* status[6];
  3761. //we don't use direct initialization because it isn't part of the c standard.
  3762. nullpo_retr(-1, sd);
  3763. status[0] = &sd->status.str;
  3764. status[1] = &sd->status.agi;
  3765. status[2] = &sd->status.vit;
  3766. status[3] = &sd->status.int_;
  3767. status[4] = &sd->status.dex;
  3768. status[5] = &sd->status.luk;
  3769. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3770. value = pc_maxparameter(sd);
  3771. count = 0;
  3772. max = pc_maxparameter(sd);
  3773. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3774. if (value > 0 && *status[index] > max - value)
  3775. new_value = max;
  3776. else if (value < 0 && *status[index] <= -value)
  3777. new_value = 1;
  3778. else
  3779. new_value = *status[index] +value;
  3780. if (new_value != (int)*status[index]) {
  3781. *status[index] = new_value;
  3782. clif_updatestatus(sd, SP_STR + index);
  3783. clif_updatestatus(sd, SP_USTR + index);
  3784. status_calc_pc(sd, 0);
  3785. count++;
  3786. }
  3787. }
  3788. if (count > 0) // if at least 1 stat modified
  3789. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3790. else {
  3791. if (value < 0)
  3792. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  3793. else
  3794. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  3795. return -1;
  3796. }
  3797. return 0;
  3798. }
  3799. /*==========================================
  3800. *
  3801. *------------------------------------------
  3802. */
  3803. int atcommand_guildlevelup(
  3804. const int fd, struct map_session_data* sd,
  3805. const char* command, const char* message)
  3806. {
  3807. int level = 0;
  3808. short added_level;
  3809. struct guild *guild_info;
  3810. nullpo_retr(-1, sd);
  3811. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3812. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3813. return -1;
  3814. }
  3815. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3816. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3817. return -1;
  3818. }
  3819. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3820. clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3821. return -1;
  3822. }
  3823. added_level = (short)level;
  3824. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3825. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3826. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3827. added_level = 1 - guild_info->guild_lv;
  3828. if (added_level != 0) {
  3829. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3830. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3831. } else {
  3832. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3833. return -1;
  3834. }
  3835. return 0;
  3836. }
  3837. /*==========================================
  3838. *
  3839. *------------------------------------------
  3840. */
  3841. int atcommand_makeegg(
  3842. const int fd, struct map_session_data* sd,
  3843. const char* command, const char* message)
  3844. {
  3845. struct item_data *item_data;
  3846. int id, pet_id;
  3847. nullpo_retr(-1, sd);
  3848. if (!message || !*message) {
  3849. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3850. return -1;
  3851. }
  3852. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3853. id = item_data->nameid;
  3854. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3855. id = atoi(message);
  3856. pet_id = search_petDB_index(id, PET_CLASS);
  3857. if (pet_id < 0)
  3858. pet_id = search_petDB_index(id, PET_EGG);
  3859. if (pet_id >= 0) {
  3860. sd->catch_target_class = pet_db[pet_id].class_;
  3861. intif_create_pet(
  3862. sd->status.account_id, sd->status.char_id,
  3863. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3864. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3865. 100, 0, 1, pet_db[pet_id].jname);
  3866. } else {
  3867. clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
  3868. return -1;
  3869. }
  3870. return 0;
  3871. }
  3872. /*==========================================
  3873. *
  3874. *------------------------------------------
  3875. */
  3876. int atcommand_hatch(
  3877. const int fd, struct map_session_data* sd,
  3878. const char* command, const char* message)
  3879. {
  3880. nullpo_retr(-1, sd);
  3881. if (sd->status.pet_id <= 0)
  3882. clif_sendegg(sd);
  3883. else {
  3884. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3885. return -1;
  3886. }
  3887. return 0;
  3888. }
  3889. /*==========================================
  3890. *
  3891. *------------------------------------------
  3892. */
  3893. int atcommand_petfriendly(
  3894. const int fd, struct map_session_data* sd,
  3895. const char* command, const char* message)
  3896. {
  3897. int friendly;
  3898. struct pet_data *pd;
  3899. nullpo_retr(-1, sd);
  3900. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3901. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3902. return -1;
  3903. }
  3904. pd = sd->pd;
  3905. if (!pd) {
  3906. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3907. return -1;
  3908. }
  3909. if (friendly < 0 || friendly > 1000)
  3910. {
  3911. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3912. return -1;
  3913. }
  3914. if (friendly == pd->pet.intimate) {
  3915. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  3916. return -1;
  3917. }
  3918. pd->pet.intimate = friendly;
  3919. clif_send_petstatus(sd);
  3920. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  3921. return 0;
  3922. }
  3923. /*==========================================
  3924. *
  3925. *------------------------------------------
  3926. */
  3927. int atcommand_pethungry(
  3928. const int fd, struct map_session_data* sd,
  3929. const char* command, const char* message)
  3930. {
  3931. int hungry;
  3932. struct pet_data *pd;
  3933. nullpo_retr(-1, sd);
  3934. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3935. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3936. return -1;
  3937. }
  3938. pd = sd->pd;
  3939. if (!sd->status.pet_id || !pd) {
  3940. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3941. return -1;
  3942. }
  3943. if (hungry < 0 || hungry > 100) {
  3944. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3945. return -1;
  3946. }
  3947. if (hungry == pd->pet.hungry) {
  3948. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  3949. return -1;
  3950. }
  3951. pd->pet.hungry = hungry;
  3952. clif_send_petstatus(sd);
  3953. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  3954. return 0;
  3955. }
  3956. /*==========================================
  3957. *
  3958. *------------------------------------------
  3959. */
  3960. int atcommand_petrename(
  3961. const int fd, struct map_session_data* sd,
  3962. const char* command, const char* message)
  3963. {
  3964. struct pet_data *pd;
  3965. nullpo_retr(-1, sd);
  3966. if (!sd->status.pet_id || !sd->pd) {
  3967. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3968. return -1;
  3969. }
  3970. pd = sd->pd;
  3971. if (pd->pet.rename_flag) {
  3972. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  3973. return -1;
  3974. }
  3975. pd->pet.rename_flag = 0;
  3976. intif_save_petdata(sd->status.account_id, &pd->pet);
  3977. clif_send_petstatus(sd);
  3978. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  3979. return 0;
  3980. }
  3981. /*==========================================
  3982. *
  3983. *------------------------------------------
  3984. */
  3985. int
  3986. atcommand_recall(
  3987. const int fd, struct map_session_data* sd,
  3988. const char* command, const char* message)
  3989. {
  3990. struct map_session_data *pl_sd = NULL;
  3991. nullpo_retr(-1, sd);
  3992. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3993. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3994. return -1;
  3995. }
  3996. malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3997. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3998. return -1;
  3999. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  4000. return -1;
  4001. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4002. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4003. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4004. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4005. return -1;
  4006. }
  4007. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4008. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  4009. return -1;
  4010. }
  4011. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4012. sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
  4013. clif_displaymessage(fd, atcmd_output);
  4014. } else {
  4015. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4016. return -1;
  4017. }
  4018. } else {
  4019. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4020. return -1;
  4021. }
  4022. return 0;
  4023. }
  4024. /*==========================================
  4025. *
  4026. *------------------------------------------
  4027. */
  4028. int atcommand_revive(
  4029. const int fd, struct map_session_data* sd,
  4030. const char* command, const char* message)
  4031. {
  4032. struct map_session_data *pl_sd;
  4033. nullpo_retr(-1, sd);
  4034. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4035. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4036. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  4037. return -1;
  4038. }
  4039. pl_sd = map_nick2sd(atcmd_player_name);
  4040. if (!pl_sd) {
  4041. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4042. return -1;
  4043. }
  4044. if (!status_revive(&sd->bl, 100, 0))
  4045. return -1;
  4046. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4047. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  4048. return 0;
  4049. }
  4050. /*==========================================
  4051. * charblock command (usage: charblock <player_name>)
  4052. * This command do a definitiv ban on a player
  4053. *------------------------------------------
  4054. */
  4055. int atcommand_char_block(
  4056. const int fd, struct map_session_data* sd,
  4057. const char* command, const char* message)
  4058. {
  4059. nullpo_retr(-1, sd);
  4060. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4061. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4062. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4063. return -1;
  4064. }
  4065. // check player name
  4066. if (strlen(atcmd_player_name) < 4) {
  4067. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4068. return -1;
  4069. } else if (strlen(atcmd_player_name) > 23) {
  4070. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4071. return -1;
  4072. } else {
  4073. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4074. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4075. }
  4076. return 0;
  4077. }
  4078. /*==========================================
  4079. * charban command (usage: charban <time> <player_name>)
  4080. * This command do a limited ban on a player
  4081. * Time is done as follows:
  4082. * Adjustment value (-1, 1, +1, etc...)
  4083. * Modified element:
  4084. * a or y: year
  4085. * m: month
  4086. * j or d: day
  4087. * h: hour
  4088. * mn: minute
  4089. * s: second
  4090. * <example> @ban +1m-2mn1s-6y test_player
  4091. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4092. *------------------------------------------
  4093. */
  4094. int atcommand_char_ban(
  4095. const int fd, struct map_session_data* sd,
  4096. const char* command, const char* message)
  4097. {
  4098. char * modif_p;
  4099. int year, month, day, hour, minute, second, value;
  4100. nullpo_retr(-1, sd);
  4101. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4102. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4103. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4104. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4105. return -1;
  4106. }
  4107. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4108. modif_p = atcmd_output;
  4109. year = month = day = hour = minute = second = 0;
  4110. while (modif_p[0] != '\0') {
  4111. value = atoi(modif_p);
  4112. if (value == 0)
  4113. modif_p++;
  4114. else {
  4115. if (modif_p[0] == '-' || modif_p[0] == '+')
  4116. modif_p++;
  4117. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4118. modif_p++;
  4119. if (modif_p[0] == 's') {
  4120. second = value;
  4121. modif_p++;
  4122. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4123. minute = value;
  4124. modif_p = modif_p + 2;
  4125. } else if (modif_p[0] == 'h') {
  4126. hour = value;
  4127. modif_p++;
  4128. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4129. day = value;
  4130. modif_p++;
  4131. } else if (modif_p[0] == 'm') {
  4132. month = value;
  4133. modif_p++;
  4134. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4135. year = value;
  4136. modif_p++;
  4137. } else if (modif_p[0] != '\0') {
  4138. modif_p++;
  4139. }
  4140. }
  4141. }
  4142. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4143. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  4144. return -1;
  4145. }
  4146. // check player name
  4147. if (strlen(atcmd_player_name) < 4) {
  4148. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4149. return -1;
  4150. } else if (strlen(atcmd_player_name) > 23) {
  4151. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4152. return -1;
  4153. } else {
  4154. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4155. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4156. }
  4157. return 0;
  4158. }
  4159. /*==========================================
  4160. * charunblock command (usage: charunblock <player_name>)
  4161. *------------------------------------------
  4162. */
  4163. int atcommand_char_unblock(
  4164. const int fd, struct map_session_data* sd,
  4165. const char* command, const char* message)
  4166. {
  4167. nullpo_retr(-1, sd);
  4168. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4169. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4170. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4171. return -1;
  4172. }
  4173. // check player name
  4174. if (strlen(atcmd_player_name) < 4) {
  4175. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4176. return -1;
  4177. } else if (strlen(atcmd_player_name) > 23) {
  4178. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4179. return -1;
  4180. } else {
  4181. // send answer to login server via char-server
  4182. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4183. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4184. }
  4185. return 0;
  4186. }
  4187. /*==========================================
  4188. * charunban command (usage: charunban <player_name>)
  4189. *------------------------------------------
  4190. */
  4191. int atcommand_char_unban(
  4192. const int fd, struct map_session_data* sd,
  4193. const char* command, const char* message)
  4194. {
  4195. nullpo_retr(-1, sd);
  4196. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4197. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4198. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4199. return -1;
  4200. }
  4201. // check player name
  4202. if (strlen(atcmd_player_name) < 4) {
  4203. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4204. return -1;
  4205. } else if (strlen(atcmd_player_name) > 23) {
  4206. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4207. return -1;
  4208. } else {
  4209. // send answer to login server via char-server
  4210. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4211. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4212. }
  4213. return 0;
  4214. }
  4215. /*==========================================
  4216. *
  4217. *------------------------------------------
  4218. */
  4219. int atcommand_night(
  4220. const int fd, struct map_session_data* sd,
  4221. const char* command, const char* message)
  4222. {
  4223. nullpo_retr(-1, sd);
  4224. if (night_flag != 1) {
  4225. map_night_timer(night_timer_tid, 0, 0, 1);
  4226. } else {
  4227. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  4228. return -1;
  4229. }
  4230. return 0;
  4231. }
  4232. /*==========================================
  4233. *
  4234. *------------------------------------------
  4235. */
  4236. int atcommand_day(
  4237. const int fd, struct map_session_data* sd,
  4238. const char* command, const char* message)
  4239. {
  4240. nullpo_retr(-1, sd);
  4241. if (night_flag != 0) {
  4242. map_day_timer(day_timer_tid, 0, 0, 1);
  4243. } else {
  4244. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  4245. return -1;
  4246. }
  4247. return 0;
  4248. }
  4249. /*==========================================
  4250. *
  4251. *------------------------------------------
  4252. */
  4253. int atcommand_doom(
  4254. const int fd, struct map_session_data* sd,
  4255. const char* command, const char* message)
  4256. {
  4257. struct map_session_data *pl_sd, **pl_allsd;
  4258. int i, users;
  4259. nullpo_retr(-1, sd);
  4260. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4261. pl_allsd = map_getallusers(&users);
  4262. for(i = 0; i < users; i++) {
  4263. 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
  4264. status_kill(&pl_sd->bl);
  4265. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4266. }
  4267. }
  4268. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4269. return 0;
  4270. }
  4271. /*==========================================
  4272. *
  4273. *------------------------------------------
  4274. */
  4275. int atcommand_doommap(
  4276. const int fd, struct map_session_data* sd,
  4277. const char* command, const char* message)
  4278. {
  4279. struct map_session_data *pl_sd, **pl_allsd;
  4280. int i, users;
  4281. nullpo_retr(-1, sd);
  4282. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4283. pl_allsd = map_getallusers(&users);
  4284. for (i = 0; i < users; i++) {
  4285. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4286. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4287. {
  4288. status_kill(&pl_sd->bl);
  4289. // clif_specialeffect(&pl_sd->bl,450,1);
  4290. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4291. }
  4292. }
  4293. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4294. return 0;
  4295. }
  4296. /*==========================================
  4297. *
  4298. *------------------------------------------
  4299. */
  4300. static void atcommand_raise_sub(struct map_session_data* sd)
  4301. {
  4302. if (!sd->state.auth || !status_isdead(&sd->bl))
  4303. return;
  4304. if(!status_revive(&sd->bl, 100, 100))
  4305. return;
  4306. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4307. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  4308. }
  4309. /*==========================================
  4310. *
  4311. *------------------------------------------
  4312. */
  4313. int atcommand_raise(
  4314. const int fd, struct map_session_data* sd,
  4315. const char* command, const char* message)
  4316. {
  4317. int i, users;
  4318. struct map_session_data **all_sd;
  4319. nullpo_retr(-1, sd);
  4320. all_sd = map_getallusers(&users);
  4321. for (i = 0; i < users; i++) {
  4322. atcommand_raise_sub(all_sd[i]);
  4323. }
  4324. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4325. return 0;
  4326. }
  4327. /*==========================================
  4328. *
  4329. *------------------------------------------
  4330. */
  4331. int atcommand_raisemap(
  4332. const int fd, struct map_session_data* sd,
  4333. const char* command, const char* message)
  4334. {
  4335. struct map_session_data **pl_allsd;
  4336. int i, users;
  4337. nullpo_retr(-1, sd);
  4338. pl_allsd = map_getallusers(&users);
  4339. for (i = 0; i < users; i++) {
  4340. if (sd->bl.m == pl_allsd[i]->bl.m)
  4341. atcommand_raise_sub(pl_allsd[i]);
  4342. }
  4343. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4344. return 0;
  4345. }
  4346. /*==========================================
  4347. *
  4348. *------------------------------------------
  4349. */
  4350. int atcommand_kick(
  4351. const int fd, struct map_session_data* sd,
  4352. const char* command, const char* message)
  4353. {
  4354. struct map_session_data *pl_sd;
  4355. nullpo_retr(-1, sd);
  4356. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4357. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4358. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4359. return -1;
  4360. }
  4361. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4362. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4363. clif_GM_kick(sd, pl_sd, 1);
  4364. else {
  4365. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4366. return -1;
  4367. }
  4368. } else {
  4369. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4370. return -1;
  4371. }
  4372. return 0;
  4373. }
  4374. /*==========================================
  4375. *
  4376. *------------------------------------------
  4377. */
  4378. int atcommand_kickall(
  4379. const int fd, struct map_session_data* sd,
  4380. const char* command, const char* message)
  4381. {
  4382. struct map_session_data *pl_sd, **pl_allsd;
  4383. int i, users;
  4384. nullpo_retr(-1, sd);
  4385. pl_allsd = map_getallusers(&users);
  4386. for (i = 0; i < users; i++) {
  4387. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4388. if (sd->status.account_id != pl_sd->status.account_id)
  4389. clif_GM_kick(sd, pl_sd, 0);
  4390. }
  4391. }
  4392. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  4393. return 0;
  4394. }
  4395. /*==========================================
  4396. *
  4397. *------------------------------------------
  4398. */
  4399. int atcommand_allskill(
  4400. const int fd, struct map_session_data* sd,
  4401. const char* command, const char* message)
  4402. {
  4403. nullpo_retr(-1, sd);
  4404. pc_allskillup(sd); // all skills
  4405. sd->status.skill_point = 0; // 0 skill points
  4406. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4407. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  4408. return 0;
  4409. }
  4410. /*==========================================
  4411. *
  4412. *------------------------------------------
  4413. */
  4414. int atcommand_questskill(
  4415. const int fd, struct map_session_data* sd,
  4416. const char* command, const char* message)
  4417. {
  4418. int skill_id;
  4419. nullpo_retr(-1, sd);
  4420. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4421. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4422. return -1;
  4423. }
  4424. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4425. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4426. if (pc_checkskill(sd, skill_id) == 0) {
  4427. pc_skill(sd, skill_id, 1, 0);
  4428. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  4429. } else {
  4430. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  4431. return -1;
  4432. }
  4433. } else {
  4434. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4435. return -1;
  4436. }
  4437. } else {
  4438. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4439. return -1;
  4440. }
  4441. return 0;
  4442. }
  4443. /*==========================================
  4444. *
  4445. *------------------------------------------
  4446. */
  4447. int atcommand_lostskill(
  4448. const int fd, struct map_session_data* sd,
  4449. const char* command, const char* message)
  4450. {
  4451. int skill_id;
  4452. nullpo_retr(-1, sd);
  4453. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4454. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4455. return -1;
  4456. }
  4457. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4458. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4459. if (pc_checkskill(sd, skill_id) > 0) {
  4460. sd->status.skill[skill_id].lv = 0;
  4461. sd->status.skill[skill_id].flag = 0;
  4462. clif_skillinfoblock(sd);
  4463. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  4464. } else {
  4465. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  4466. return -1;
  4467. }
  4468. } else {
  4469. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4470. return -1;
  4471. }
  4472. } else {
  4473. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4474. return -1;
  4475. }
  4476. return 0;
  4477. }
  4478. /*==========================================
  4479. *
  4480. *------------------------------------------
  4481. */
  4482. int atcommand_spiritball(
  4483. const int fd, struct map_session_data* sd,
  4484. const char* command, const char* message)
  4485. {
  4486. int number;
  4487. nullpo_retr(-1, sd);
  4488. if (!message || !*message || (number = atoi(message)) < 0) {
  4489. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4490. return -1;
  4491. }
  4492. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4493. if (number > 500)
  4494. number = 500;
  4495. if (number >= 0 && number <= 0x7FFF) {
  4496. if (sd->spiritball != number || number > 499) {
  4497. if (sd->spiritball > 0)
  4498. pc_delspiritball(sd, sd->spiritball, 1);
  4499. sd->spiritball = number;
  4500. clif_spiritball(sd);
  4501. // no message, player can look the difference
  4502. if (number > 1000)
  4503. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4504. } else {
  4505. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  4506. return -1;
  4507. }
  4508. } else {
  4509. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4510. return -1;
  4511. }
  4512. return 0;
  4513. }
  4514. /*==========================================
  4515. *
  4516. *------------------------------------------
  4517. */
  4518. int atcommand_party(
  4519. const int fd, struct map_session_data* sd,
  4520. const char* command, const char* message)
  4521. {
  4522. char party[NAME_LENGTH];
  4523. nullpo_retr(-1, sd);
  4524. malloc_tsetdword(party, '\0', sizeof(party));
  4525. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4526. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4527. return -1;
  4528. }
  4529. party_create(sd, party, 0, 0);
  4530. return 0;
  4531. }
  4532. /*==========================================
  4533. *
  4534. *------------------------------------------
  4535. */
  4536. int atcommand_guild(
  4537. const int fd, struct map_session_data* sd,
  4538. const char* command, const char* message)
  4539. {
  4540. char guild[NAME_LENGTH];
  4541. int prev;
  4542. nullpo_retr(-1, sd);
  4543. malloc_tsetdword(guild, '\0', sizeof(guild));
  4544. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4545. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4546. return -1;
  4547. }
  4548. prev = battle_config.guild_emperium_check;
  4549. battle_config.guild_emperium_check = 0;
  4550. guild_create(sd, guild);
  4551. battle_config.guild_emperium_check = prev;
  4552. return 0;
  4553. }
  4554. /*==========================================
  4555. *
  4556. *------------------------------------------
  4557. */
  4558. int atcommand_agitstart(
  4559. const int fd, struct map_session_data* sd,
  4560. const char* command, const char* message)
  4561. {
  4562. nullpo_retr(-1, sd);
  4563. if (agit_flag == 1) {
  4564. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  4565. return -1;
  4566. }
  4567. agit_flag = 1;
  4568. guild_agit_start();
  4569. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  4570. return 0;
  4571. }
  4572. /*==========================================
  4573. *
  4574. *------------------------------------------
  4575. */
  4576. int atcommand_agitend(
  4577. const int fd, struct map_session_data* sd,
  4578. const char* command, const char* message)
  4579. {
  4580. nullpo_retr(-1, sd);
  4581. if (agit_flag == 0) {
  4582. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  4583. return -1;
  4584. }
  4585. agit_flag = 0;
  4586. guild_agit_end();
  4587. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  4588. return 0;
  4589. }
  4590. /*==========================================
  4591. * @mapexitでマップサーバーを終了させる
  4592. *------------------------------------------
  4593. */
  4594. int atcommand_mapexit(
  4595. const int fd, struct map_session_data* sd,
  4596. const char* command, const char* message)
  4597. {
  4598. struct map_session_data *pl_sd, **pl_allsd;
  4599. int i, users;
  4600. nullpo_retr(-1, sd);
  4601. pl_allsd = map_getallusers(&users);
  4602. for (i = 0; i < users; i++) {
  4603. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4604. clif_GM_kick(sd, pl_sd, 0);
  4605. }
  4606. clif_GM_kick(sd, sd, 0);
  4607. flush_fifos();
  4608. runflag = 0;
  4609. return 0;
  4610. }
  4611. /*==========================================
  4612. * idsearch <part_of_name>: revrited by [Yor]
  4613. *------------------------------------------
  4614. */
  4615. int atcommand_idsearch(
  4616. const int fd, struct map_session_data* sd,
  4617. const char* command, const char* message)
  4618. {
  4619. char item_name[100];
  4620. unsigned int i, match;
  4621. struct item_data *item_array[MAX_SEARCH];
  4622. nullpo_retr(-1, sd);
  4623. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  4624. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4625. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4626. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4627. return -1;
  4628. }
  4629. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  4630. clif_displaymessage(fd, atcmd_output);
  4631. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4632. if (match > MAX_SEARCH) {
  4633. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  4634. clif_displaymessage(fd, atcmd_output);
  4635. match = MAX_SEARCH;
  4636. }
  4637. for(i = 0; i < match; i++) {
  4638. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4639. clif_displaymessage(fd, atcmd_output);
  4640. }
  4641. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  4642. clif_displaymessage(fd, atcmd_output);
  4643. return 0;
  4644. }
  4645. /*==========================================
  4646. * Recall All Characters Online To Your Location
  4647. *------------------------------------------
  4648. */
  4649. int atcommand_recallall(
  4650. const int fd, struct map_session_data* sd,
  4651. const char* command, const char* message)
  4652. {
  4653. struct map_session_data *pl_sd, **pl_allsd;
  4654. int i;
  4655. int count, users;
  4656. nullpo_retr(-1, sd);
  4657. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4658. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4659. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4660. return -1;
  4661. }
  4662. count = 0;
  4663. pl_allsd = map_getallusers(&users);
  4664. for (i = 0; i < users; i++) {
  4665. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4666. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4667. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4668. count++;
  4669. else {
  4670. if (pc_isdead(pl_sd)) { //Wake them up
  4671. pc_setstand(pl_sd);
  4672. pc_setrestartvalue(pl_sd,1);
  4673. }
  4674. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4675. }
  4676. }
  4677. }
  4678. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4679. if (count) {
  4680. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4681. clif_displaymessage(fd, atcmd_output);
  4682. }
  4683. return 0;
  4684. }
  4685. /*==========================================
  4686. * Recall online characters of a guild to your location
  4687. *------------------------------------------
  4688. */
  4689. int atcommand_guildrecall(
  4690. const int fd, struct map_session_data* sd,
  4691. const char* command, const char* message)
  4692. {
  4693. struct map_session_data *pl_sd, **pl_allsd;
  4694. int i, users, count;
  4695. char guild_name[NAME_LENGTH];
  4696. struct guild *g;
  4697. nullpo_retr(-1, sd);
  4698. malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
  4699. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4700. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4701. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4702. return -1;
  4703. }
  4704. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4705. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4706. return -1;
  4707. }
  4708. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4709. (g = guild_search(atoi(message))) != NULL) {
  4710. count = 0;
  4711. pl_allsd = map_getallusers(&users);
  4712. for (i = 0; i < users; i++) {
  4713. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4714. pl_sd->status.guild_id == g->guild_id) {
  4715. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4716. continue; //Skip GMs greater than you.
  4717. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4718. count++;
  4719. else
  4720. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4721. }
  4722. }
  4723. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  4724. clif_displaymessage(fd, atcmd_output);
  4725. if (count) {
  4726. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4727. clif_displaymessage(fd, atcmd_output);
  4728. }
  4729. } else {
  4730. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4731. return -1;
  4732. }
  4733. return 0;
  4734. }
  4735. /*==========================================
  4736. * Recall online characters of a party to your location
  4737. *------------------------------------------
  4738. */
  4739. int atcommand_partyrecall(
  4740. const int fd, struct map_session_data* sd,
  4741. const char* command, const char* message)
  4742. {
  4743. int i;
  4744. struct map_session_data *pl_sd, **pl_allsd;
  4745. char party_name[NAME_LENGTH];
  4746. struct party_data *p;
  4747. int count, users;
  4748. nullpo_retr(-1, sd);
  4749. malloc_tsetdword(party_name, '\0', sizeof(party_name));
  4750. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4751. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4752. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4753. return -1;
  4754. }
  4755. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4756. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4757. return -1;
  4758. }
  4759. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4760. (p = party_search(atoi(message))) != NULL) {
  4761. count = 0;
  4762. pl_allsd = map_getallusers(&users);
  4763. for (i = 0; i < users; i++) {
  4764. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4765. pl_sd->status.party_id == p->party.party_id) {
  4766. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4767. continue; //Skip GMs greater than you.
  4768. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4769. count++;
  4770. else
  4771. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4772. }
  4773. }
  4774. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  4775. clif_displaymessage(fd, atcmd_output);
  4776. if (count) {
  4777. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4778. clif_displaymessage(fd, atcmd_output);
  4779. }
  4780. } else {
  4781. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4782. return -1;
  4783. }
  4784. return 0;
  4785. }
  4786. /*==========================================
  4787. *
  4788. *------------------------------------------
  4789. */
  4790. int atcommand_reloaditemdb(
  4791. const int fd, struct map_session_data* sd,
  4792. const char* command, const char* message)
  4793. {
  4794. nullpo_retr(-1, sd);
  4795. itemdb_reload();
  4796. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  4797. return 0;
  4798. }
  4799. /*==========================================
  4800. *
  4801. *------------------------------------------
  4802. */
  4803. int atcommand_reloadmobdb(
  4804. const int fd, struct map_session_data* sd,
  4805. const char* command, const char* message)
  4806. {
  4807. nullpo_retr(-1, sd);
  4808. mob_reload();
  4809. read_petdb();
  4810. merc_reload();
  4811. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  4812. return 0;
  4813. }
  4814. /*==========================================
  4815. *
  4816. *------------------------------------------
  4817. */
  4818. int atcommand_reloadskilldb(
  4819. const int fd, struct map_session_data* sd,
  4820. const char* command, const char* message)
  4821. {
  4822. nullpo_retr(-1, sd);
  4823. skill_reload();
  4824. merc_skill_reload();
  4825. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  4826. return 0;
  4827. }
  4828. /*==========================================
  4829. * @reloadatcommand
  4830. * atcommand_athena.conf のリロード
  4831. *------------------------------------------
  4832. */
  4833. int
  4834. atcommand_reloadatcommand(
  4835. const int fd, struct map_session_data* sd,
  4836. const char* command, const char* message)
  4837. {
  4838. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4839. clif_displaymessage(fd, msg_txt(254));
  4840. return 0;
  4841. }
  4842. /*==========================================
  4843. * @reloadbattleconf
  4844. * battle_athena.conf のリロード
  4845. *------------------------------------------
  4846. */
  4847. int
  4848. atcommand_reloadbattleconf(
  4849. const int fd, struct map_session_data* sd,
  4850. const char* command, const char* message)
  4851. {
  4852. struct Battle_Config prev_config;
  4853. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4854. battle_config_read(BATTLE_CONF_FILENAME);
  4855. if (memcmp(&prev_config.item_rate_mvp,
  4856. &battle_config.item_rate_mvp,
  4857. sizeof(battle_config.item_rate_mvp)+
  4858. sizeof(battle_config.item_rate_common)+
  4859. sizeof(battle_config.item_rate_common_boss)+
  4860. sizeof(battle_config.item_rate_card)+
  4861. sizeof(battle_config.item_rate_card_boss)+
  4862. sizeof(battle_config.item_rate_equip)+
  4863. sizeof(battle_config.item_rate_equip_boss)+
  4864. sizeof(battle_config.item_rate_heal)+
  4865. sizeof(battle_config.item_rate_heal_boss)+
  4866. sizeof(battle_config.item_rate_use)+
  4867. sizeof(battle_config.item_rate_use_boss)+
  4868. sizeof(battle_config.item_rate_treasure)+
  4869. sizeof(battle_config.item_rate_adddrop)+
  4870. sizeof(battle_config.logarithmic_drops)+
  4871. sizeof(battle_config.item_drop_common_min)+
  4872. sizeof(battle_config.item_drop_common_max)+
  4873. sizeof(battle_config.item_drop_card_min)+
  4874. sizeof(battle_config.item_drop_card_max)+
  4875. sizeof(battle_config.item_drop_equip_min)+
  4876. sizeof(battle_config.item_drop_equip_max)+
  4877. sizeof(battle_config.item_drop_mvp_min)+
  4878. sizeof(battle_config.item_drop_mvp_max)+
  4879. sizeof(battle_config.item_drop_heal_min)+
  4880. sizeof(battle_config.item_drop_heal_max)+
  4881. sizeof(battle_config.item_drop_use_min)+
  4882. sizeof(battle_config.item_drop_use_max)+
  4883. sizeof(battle_config.item_drop_treasure_min)+
  4884. sizeof(battle_config.item_drop_treasure_max)
  4885. ) != 0)
  4886. { //Drop rates changed.
  4887. mob_reload(); //Needed as well so rate changes take effect.
  4888. #ifndef TXT_ONLY
  4889. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4890. #endif
  4891. }
  4892. clif_displaymessage(fd, msg_txt(255));
  4893. return 0;
  4894. }
  4895. /*==========================================
  4896. * @reloadstatusdb
  4897. * job_db1.txt job_db2.txt job_db2-2.txt
  4898. * refine_db.txt size_fix.txt
  4899. * のリロード
  4900. *------------------------------------------
  4901. */
  4902. int
  4903. atcommand_reloadstatusdb(
  4904. const int fd, struct map_session_data* sd,
  4905. const char* command, const char* message)
  4906. {
  4907. status_readdb();
  4908. clif_displaymessage(fd, msg_txt(256));
  4909. return 0;
  4910. }
  4911. /*==========================================
  4912. * @reloadpcdb
  4913. * exp.txt skill_tree.txt attr_fix.txt
  4914. * のリロード
  4915. *------------------------------------------
  4916. */
  4917. int
  4918. atcommand_reloadpcdb(
  4919. const int fd, struct map_session_data* sd,
  4920. const char* command, const char* message)
  4921. {
  4922. pc_readdb();
  4923. clif_displaymessage(fd, msg_txt(257));
  4924. return 0;
  4925. }
  4926. /*==========================================
  4927. * @reloadmotd [Valaris]
  4928. * Reloads motd.txt
  4929. *------------------------------------------
  4930. */
  4931. int
  4932. atcommand_reloadmotd(
  4933. const int fd, struct map_session_data* sd,
  4934. const char* command, const char* message)
  4935. {
  4936. pc_read_motd();
  4937. clif_displaymessage(fd, msg_txt(268));
  4938. return 0;
  4939. }
  4940. /*==========================================
  4941. *
  4942. *------------------------------------------
  4943. */
  4944. int atcommand_reloadscript(
  4945. const int fd, struct map_session_data* sd,
  4946. const char* command, const char* message)
  4947. {
  4948. nullpo_retr(-1, sd);
  4949. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4950. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4951. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4952. flush_fifos();
  4953. //do_init_npc();
  4954. script_reload();
  4955. npc_reload();
  4956. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  4957. return 0;
  4958. }
  4959. /*==========================================
  4960. *
  4961. *------------------------------------------
  4962. */
  4963. int atcommand_reloadgmdb( // by [Yor]
  4964. const int fd, struct map_session_data* sd,
  4965. const char* command, const char* message)
  4966. {
  4967. nullpo_retr(-1, sd);
  4968. chrif_reloadGMdb();
  4969. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  4970. return 0;
  4971. }
  4972. /*==========================================
  4973. * @mapinfo <map name> [0-3] by MC_Cameri
  4974. * => Shows information about the map [map name]
  4975. * 0 = no additional information
  4976. * 1 = Show users in that map and their location
  4977. * 2 = Shows NPCs in that map
  4978. * 3 = Shows the shops/chats in that map (not implemented)
  4979. *------------------------------------------
  4980. */
  4981. int atcommand_mapinfo(
  4982. const int fd, struct map_session_data* sd,
  4983. const char* command, const char* message)
  4984. {
  4985. struct map_session_data *pl_sd, **pl_allsd;
  4986. struct npc_data *nd = NULL;
  4987. struct chat_data *cd = NULL;
  4988. char direction[12];
  4989. int m_id, i, chat_num, users, list = 0;
  4990. unsigned short m_index;
  4991. nullpo_retr(-1, sd);
  4992. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4993. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4994. malloc_tsetdword(direction, '\0', sizeof(direction));
  4995. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4996. if (list < 0 || list > 3) {
  4997. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4998. return -1;
  4999. }
  5000. if (atcmd_player_name[0] == '\0') {
  5001. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  5002. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  5003. m_id = map_mapindex2mapid(sd->mapindex);
  5004. } else {
  5005. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  5006. strcat(atcmd_player_name, ".gat");
  5007. m_id = map_mapname2mapid(atcmd_player_name);
  5008. }
  5009. if (m_id < 0) {
  5010. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5011. return -1;
  5012. }
  5013. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  5014. clif_displaymessage(fd, "------ Map Info ------");
  5015. chat_num = 0;
  5016. pl_allsd = map_getallusers(&users);
  5017. for (i = 0; i < users; i++) {
  5018. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5019. chat_num++;
  5020. }
  5021. }
  5022. 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);
  5023. clif_displaymessage(fd, atcmd_output);
  5024. if (map[m_id].flag.alias)
  5025. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  5026. clif_displaymessage(fd, "------ Map Flags ------");
  5027. strcpy(atcmd_output,"PvP Flags: ");
  5028. if (map[m_id].flag.pvp)
  5029. strcat(atcmd_output, "Pvp ON | ");
  5030. if (map[m_id].flag.pvp_noguild)
  5031. strcat(atcmd_output, "NoGuild | ");
  5032. if (map[m_id].flag.pvp_noparty)
  5033. strcat(atcmd_output, "NoParty | ");
  5034. if (map[m_id].flag.pvp_nightmaredrop)
  5035. strcat(atcmd_output, "NightmareDrop | ");
  5036. if (map[m_id].flag.pvp_nocalcrank)
  5037. strcat(atcmd_output, "NoCalcRank | ");
  5038. clif_displaymessage(fd, atcmd_output);
  5039. strcpy(atcmd_output,"GvG Flags: ");
  5040. if (map[m_id].flag.gvg)
  5041. strcat(atcmd_output, "GvG ON | ");
  5042. if (map[m_id].flag.gvg_dungeon)
  5043. strcat(atcmd_output, "GvG Dungeon | ");
  5044. if (map[m_id].flag.gvg_castle)
  5045. strcat(atcmd_output, "GvG Castle | ");
  5046. if (map[m_id].flag.gvg_noparty)
  5047. strcat(atcmd_output, "NoParty | ");
  5048. clif_displaymessage(fd, atcmd_output);
  5049. strcpy(atcmd_output,"Teleport Flags: ");
  5050. if (map[m_id].flag.noteleport)
  5051. strcat(atcmd_output, "NoTeleport | ");
  5052. if (map[m_id].flag.monster_noteleport)
  5053. strcat(atcmd_output, "Monster NoTeleport | ");
  5054. if (map[m_id].flag.nowarp)
  5055. strcat(atcmd_output, "NoWarp | ");
  5056. if (map[m_id].flag.nowarpto)
  5057. strcat(atcmd_output, "NoWarpTo | ");
  5058. if (map[m_id].flag.noreturn)
  5059. strcat(atcmd_output, "NoReturn | ");
  5060. if (map[m_id].flag.nogo)
  5061. strcat(atcmd_output, "NoGo | ");
  5062. if (map[m_id].flag.nomemo)
  5063. strcat(atcmd_output, "NoMemo | ");
  5064. clif_displaymessage(fd, atcmd_output);
  5065. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  5066. clif_displaymessage(fd, atcmd_output);
  5067. if (map[m_id].flag.nosave) {
  5068. if (!map[m_id].save.map)
  5069. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  5070. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  5071. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  5072. else
  5073. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  5074. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  5075. clif_displaymessage(fd, atcmd_output);
  5076. }
  5077. strcpy(atcmd_output,"Weather Flags: ");
  5078. if (map[m_id].flag.snow)
  5079. strcat(atcmd_output, "Snow | ");
  5080. if (map[m_id].flag.fog)
  5081. strcat(atcmd_output, "Fog | ");
  5082. if (map[m_id].flag.sakura)
  5083. strcat(atcmd_output, "Sakura | ");
  5084. if (map[m_id].flag.clouds)
  5085. strcat(atcmd_output, "Clouds | ");
  5086. if (map[m_id].flag.clouds2)
  5087. strcat(atcmd_output, "Clouds2 | ");
  5088. if (map[m_id].flag.fireworks)
  5089. strcat(atcmd_output, "Fireworks | ");
  5090. if (map[m_id].flag.leaves)
  5091. strcat(atcmd_output, "Leaves | ");
  5092. if (map[m_id].flag.rain)
  5093. strcat(atcmd_output, "Rain | ");
  5094. if (map[m_id].flag.indoors)
  5095. strcat(atcmd_output, "Indoors | ");
  5096. if (map[m_id].flag.nightenabled)
  5097. strcat(atcmd_output, "Displays Night | ");
  5098. clif_displaymessage(fd, atcmd_output);
  5099. strcpy(atcmd_output,"Other Flags: ");
  5100. if (map[m_id].flag.nobranch)
  5101. strcat(atcmd_output, "NoBranch | ");
  5102. if (map[m_id].flag.notrade)
  5103. strcat(atcmd_output, "NoTrade | ");
  5104. if (map[m_id].flag.novending)
  5105. strcat(atcmd_output, "NoVending | ");
  5106. if (map[m_id].flag.nodrop)
  5107. strcat(atcmd_output, "NoDrop | ");
  5108. if (map[m_id].flag.noskill)
  5109. strcat(atcmd_output, "NoSkill | ");
  5110. if (map[m_id].flag.noicewall)
  5111. strcat(atcmd_output, "NoIcewall | ");
  5112. clif_displaymessage(fd, atcmd_output);
  5113. strcpy(atcmd_output,"Other Flags: ");
  5114. if (map[m_id].nocommand)
  5115. strcat(atcmd_output, "NoCommand | ");
  5116. if (map[m_id].flag.nobaseexp)
  5117. strcat(atcmd_output, "NoBaseEXP | ");
  5118. if (map[m_id].flag.nojobexp)
  5119. strcat(atcmd_output, "NoJobEXP | ");
  5120. if (map[m_id].flag.nomobloot)
  5121. strcat(atcmd_output, "NoMobLoot | ");
  5122. if (map[m_id].flag.nomvploot)
  5123. strcat(atcmd_output, "NoMVPLoot | ");
  5124. clif_displaymessage(fd, atcmd_output);
  5125. switch (list) {
  5126. case 0:
  5127. // Do nothing. It's list 0, no additional display.
  5128. break;
  5129. case 1:
  5130. clif_displaymessage(fd, "----- Players in Map -----");
  5131. for (i = 0; i < users; i++) {
  5132. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5133. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5134. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5135. clif_displaymessage(fd, atcmd_output);
  5136. }
  5137. }
  5138. break;
  5139. case 2:
  5140. clif_displaymessage(fd, "----- NPCs in Map -----");
  5141. for (i = 0; i < map[m_id].npc_num;) {
  5142. nd = map[m_id].npc[i];
  5143. switch(nd->ud.dir) {
  5144. case 0: strcpy(direction, "North"); break;
  5145. case 1: strcpy(direction, "North West"); break;
  5146. case 2: strcpy(direction, "West"); break;
  5147. case 3: strcpy(direction, "South West"); break;
  5148. case 4: strcpy(direction, "South"); break;
  5149. case 5: strcpy(direction, "South East"); break;
  5150. case 6: strcpy(direction, "East"); break;
  5151. case 7: strcpy(direction, "North East"); break;
  5152. case 9: strcpy(direction, "North"); break;
  5153. default: strcpy(direction, "Unknown"); break;
  5154. }
  5155. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5156. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5157. clif_displaymessage(fd, atcmd_output);
  5158. }
  5159. break;
  5160. case 3:
  5161. clif_displaymessage(fd, "----- Chats in Map -----");
  5162. for (i = 0; i < users; i++) {
  5163. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5164. pl_sd->mapindex == m_index &&
  5165. cd->usersd[0] == pl_sd) {
  5166. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5167. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5168. clif_displaymessage(fd, atcmd_output);
  5169. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5170. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5171. clif_displaymessage(fd, atcmd_output);
  5172. }
  5173. }
  5174. break;
  5175. default: // normally impossible to arrive here
  5176. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5177. return -1;
  5178. break;
  5179. }
  5180. return 0;
  5181. }
  5182. /*==========================================
  5183. *
  5184. *------------------------------------------
  5185. */
  5186. int atcommand_mount_peco(
  5187. const int fd, struct map_session_data* sd,
  5188. const char* command, const char* message)
  5189. {
  5190. nullpo_retr(-1, sd);
  5191. if (!pc_isriding(sd)) { // if actually no peco
  5192. if (pc_checkskill(sd, KN_RIDING)) {
  5193. pc_setoption(sd, sd->sc.option | 0x0020);
  5194. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  5195. } else {
  5196. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  5197. return -1;
  5198. }
  5199. } else { //Dismount
  5200. pc_setoption(sd, sd->sc.option & ~0x0020);
  5201. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  5202. }
  5203. return 0;
  5204. }
  5205. /*==========================================
  5206. *
  5207. *------------------------------------------
  5208. */
  5209. int atcommand_char_mount_peco(
  5210. const int fd, struct map_session_data* sd,
  5211. const char* command, const char* message)
  5212. {
  5213. struct map_session_data *pl_sd;
  5214. nullpo_retr(-1, sd);
  5215. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5216. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5217. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5218. return -1;
  5219. }
  5220. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5221. if (!pc_isriding(pl_sd)) { // if actually no peco
  5222. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5223. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5224. clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
  5225. } else {
  5226. clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
  5227. return -1;
  5228. }
  5229. } else { //Dismount
  5230. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5231. clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
  5232. }
  5233. } else {
  5234. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5235. return -1;
  5236. }
  5237. return 0;
  5238. }
  5239. /*==========================================
  5240. *Spy Commands by Syrus22
  5241. *------------------------------------------
  5242. */
  5243. int atcommand_guildspy(
  5244. const int fd, struct map_session_data* sd,
  5245. const char* command, const char* message)
  5246. {
  5247. char guild_name[NAME_LENGTH];
  5248. struct guild *g;
  5249. nullpo_retr(-1, sd);
  5250. malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
  5251. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  5252. if (!enable_spy)
  5253. {
  5254. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5255. return -1;
  5256. }
  5257. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5258. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5259. return -1;
  5260. }
  5261. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5262. (g = guild_search(atoi(message))) != NULL) {
  5263. if (sd->guildspy == g->guild_id) {
  5264. sd->guildspy = 0;
  5265. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  5266. clif_displaymessage(fd, atcmd_output);
  5267. } else {
  5268. sd->guildspy = g->guild_id;
  5269. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  5270. clif_displaymessage(fd, atcmd_output);
  5271. }
  5272. } else {
  5273. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  5274. return -1;
  5275. }
  5276. return 0;
  5277. }
  5278. /*==========================================
  5279. *
  5280. *------------------------------------------
  5281. */
  5282. int atcommand_partyspy(
  5283. const int fd, struct map_session_data* sd,
  5284. const char* command, const char* message)
  5285. {
  5286. char party_name[NAME_LENGTH];
  5287. struct party_data *p;
  5288. nullpo_retr(-1, sd);
  5289. malloc_tsetdword(party_name, '\0', sizeof(party_name));
  5290. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  5291. if (!enable_spy)
  5292. {
  5293. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5294. return -1;
  5295. }
  5296. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5297. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5298. return -1;
  5299. }
  5300. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5301. (p = party_search(atoi(message))) != NULL) {
  5302. if (sd->partyspy == p->party.party_id) {
  5303. sd->partyspy = 0;
  5304. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  5305. clif_displaymessage(fd, atcmd_output);
  5306. } else {
  5307. sd->partyspy = p->party.party_id;
  5308. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  5309. clif_displaymessage(fd, atcmd_output);
  5310. }
  5311. } else {
  5312. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  5313. return -1;
  5314. }
  5315. return 0;
  5316. }
  5317. /*==========================================
  5318. * @repairall [Valaris]
  5319. *------------------------------------------
  5320. */
  5321. int atcommand_repairall(
  5322. const int fd, struct map_session_data* sd,
  5323. const char* command, const char* message)
  5324. {
  5325. int count, i;
  5326. nullpo_retr(-1, sd);
  5327. count = 0;
  5328. for (i = 0; i < MAX_INVENTORY; i++) {
  5329. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5330. sd->status.inventory[i].attribute = 0;
  5331. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5332. count++;
  5333. }
  5334. }
  5335. if (count > 0) {
  5336. clif_misceffect(&sd->bl, 3);
  5337. clif_equiplist(sd);
  5338. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  5339. } else {
  5340. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  5341. return -1;
  5342. }
  5343. return 0;
  5344. }
  5345. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5346. int atcommand_nuke(
  5347. const int fd, struct map_session_data* sd,
  5348. const char* command, const char* message)
  5349. {
  5350. struct map_session_data *pl_sd;
  5351. nullpo_retr(-1, sd);
  5352. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5353. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5354. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5355. return -1;
  5356. }
  5357. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5358. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5359. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5360. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  5361. } else {
  5362. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5363. return -1;
  5364. }
  5365. } else {
  5366. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5367. return -1;
  5368. }
  5369. return 0;
  5370. }
  5371. /*==========================================
  5372. * @tonpc
  5373. *------------------------------------------
  5374. */
  5375. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5376. const char* command, const char* message)
  5377. {
  5378. char npcname[NAME_LENGTH];
  5379. struct npc_data *nd;
  5380. nullpo_retr(-1, sd);
  5381. malloc_tsetdword(npcname, 0, sizeof(npcname));
  5382. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5383. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5384. return -1;
  5385. }
  5386. if ((nd = npc_name2id(npcname)) != NULL) {
  5387. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5388. clif_displaymessage(fd, msg_txt(0)); // Warped.
  5389. else
  5390. return -1;
  5391. } else {
  5392. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5393. return -1;
  5394. }
  5395. return 0;
  5396. }
  5397. /*==========================================
  5398. *
  5399. *------------------------------------------
  5400. */
  5401. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5402. const char* command, const char* message)
  5403. {
  5404. char NPCname[NAME_LENGTH];
  5405. nullpo_retr(-1, sd);
  5406. malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
  5407. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5408. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5409. return -1;
  5410. }
  5411. if (npc_name2id(NPCname) != NULL) {
  5412. npc_enable(NPCname, 1);
  5413. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  5414. } else {
  5415. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5416. return -1;
  5417. }
  5418. return 0;
  5419. }
  5420. /*==========================================
  5421. *
  5422. *------------------------------------------
  5423. */
  5424. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5425. const char* command, const char* message)
  5426. {
  5427. char NPCname[NAME_LENGTH];
  5428. nullpo_retr(-1, sd);
  5429. malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
  5430. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5431. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  5432. return -1;
  5433. }
  5434. if (npc_name2id(NPCname) != NULL) {
  5435. npc_enable(NPCname, 0);
  5436. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5437. } else {
  5438. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5439. return -1;
  5440. }
  5441. return 0;
  5442. }
  5443. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5444. const char* command, const char* message)
  5445. {
  5446. FILE *fp;
  5447. if (!message || !*message) {
  5448. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5449. return -1;
  5450. }
  5451. // check if script file exists
  5452. if ((fp = fopen(message, "r")) == NULL) {
  5453. clif_displaymessage(fd, msg_txt(261));
  5454. return -1;
  5455. }
  5456. fclose(fp);
  5457. // add to list of script sources and run it
  5458. npc_addsrcfile((char *)message);
  5459. npc_parsesrcfile((char *)message);
  5460. clif_displaymessage(fd, msg_txt(262));
  5461. return 0;
  5462. }
  5463. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5464. const char* command, const char* message)
  5465. {
  5466. struct npc_data *nd;
  5467. char NPCname[NAME_LENGTH];
  5468. nullpo_retr(-1, sd);
  5469. malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
  5470. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5471. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5472. return -1;
  5473. }
  5474. if ((nd = npc_name2id(NPCname)) != NULL) {
  5475. npc_unload_duplicates(nd);
  5476. npc_unload(nd);
  5477. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5478. } else {
  5479. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5480. return -1;
  5481. }
  5482. return 0;
  5483. }
  5484. /*==========================================
  5485. * time in txt for time command (by [Yor])
  5486. *------------------------------------------
  5487. */
  5488. char * txt_time(unsigned int duration) {
  5489. int days, hours, minutes, seconds;
  5490. char temp[256];
  5491. static char temp1[256];
  5492. malloc_tsetdword(temp, '\0', sizeof(temp));
  5493. malloc_tsetdword(temp1, '\0', sizeof(temp1));
  5494. days = duration / (60 * 60 * 24);
  5495. duration = duration - (60 * 60 * 24 * days);
  5496. hours = duration / (60 * 60);
  5497. duration = duration - (60 * 60 * hours);
  5498. minutes = duration / 60;
  5499. seconds = duration - (60 * minutes);
  5500. if (days < 2)
  5501. sprintf(temp, msg_txt(219), days); // %d day
  5502. else
  5503. sprintf(temp, msg_txt(220), days); // %d days
  5504. if (hours < 2)
  5505. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  5506. else
  5507. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  5508. if (minutes < 2)
  5509. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  5510. else
  5511. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  5512. if (seconds < 2)
  5513. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  5514. else
  5515. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  5516. return temp1;
  5517. }
  5518. /*==========================================
  5519. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5520. * Calculation management of GM modification (@day/@night GM commands) is done
  5521. *------------------------------------------
  5522. */
  5523. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5524. const char* command, const char* message)
  5525. {
  5526. struct TimerData * timer_data;
  5527. struct TimerData * timer_data2;
  5528. time_t time_server; // variable for number of seconds (used with time() function)
  5529. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5530. char temp[256];
  5531. nullpo_retr(-1, sd);
  5532. malloc_tsetdword(temp, '\0', sizeof(temp));
  5533. time(&time_server); // get time in seconds since 1/1/1970
  5534. datetime = localtime(&time_server); // convert seconds in structure
  5535. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5536. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  5537. clif_displaymessage(fd, temp);
  5538. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5539. if (night_flag == 0)
  5540. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5541. else
  5542. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5543. } else if (battle_config.night_duration == 0)
  5544. if (night_flag == 1) { // we start with night
  5545. timer_data = get_timer(day_timer_tid);
  5546. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5547. clif_displaymessage(fd, temp);
  5548. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  5549. } else
  5550. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5551. else if (battle_config.day_duration == 0)
  5552. if (night_flag == 0) { // we start with day
  5553. timer_data = get_timer(night_timer_tid);
  5554. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5555. clif_displaymessage(fd, temp);
  5556. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  5557. } else
  5558. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5559. else {
  5560. if (night_flag == 0) {
  5561. timer_data = get_timer(night_timer_tid);
  5562. timer_data2 = get_timer(day_timer_tid);
  5563. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5564. clif_displaymessage(fd, temp);
  5565. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5566. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5567. else
  5568. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5569. clif_displaymessage(fd, temp);
  5570. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5571. clif_displaymessage(fd, temp);
  5572. } else {
  5573. timer_data = get_timer(day_timer_tid);
  5574. timer_data2 = get_timer(night_timer_tid);
  5575. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5576. clif_displaymessage(fd, temp);
  5577. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5578. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5579. else
  5580. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5581. clif_displaymessage(fd, temp);
  5582. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5583. clif_displaymessage(fd, temp);
  5584. }
  5585. }
  5586. return 0;
  5587. }
  5588. /*==========================================
  5589. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5590. * removes <quantity> item from a character
  5591. * item can be equiped or not.
  5592. * Inspired from a old command created by RoVeRT
  5593. *------------------------------------------
  5594. */
  5595. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5596. const char* command, const char* message)
  5597. {
  5598. struct map_session_data *pl_sd;
  5599. char item_name[100];
  5600. int i, number = 0, item_id, item_position, count;
  5601. struct item_data *item_data;
  5602. nullpo_retr(-1, sd);
  5603. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5604. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  5605. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  5606. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5607. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5608. return -1;
  5609. }
  5610. item_id = 0;
  5611. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5612. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5613. item_id = item_data->nameid;
  5614. if (item_id > 500) {
  5615. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5616. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5617. item_position = pc_search_inventory(pl_sd, item_id);
  5618. if (item_position >= 0) {
  5619. count = 0;
  5620. for(i = 0; i < number && item_position >= 0; i++) {
  5621. //Logs (A)dmins items [Lupus]
  5622. if(log_config.enable_logs&0x400)
  5623. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5624. pc_delitem(pl_sd, item_position, 1, 0);
  5625. count++;
  5626. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5627. }
  5628. sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
  5629. clif_displaymessage(pl_sd->fd, atcmd_output);
  5630. if (number == count)
  5631. sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
  5632. else
  5633. sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5634. clif_displaymessage(fd, atcmd_output);
  5635. } else {
  5636. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  5637. return -1;
  5638. }
  5639. } else {
  5640. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5641. return -1;
  5642. }
  5643. } else {
  5644. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5645. return -1;
  5646. }
  5647. } else {
  5648. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  5649. return -1;
  5650. }
  5651. return 0;
  5652. }
  5653. //Added by Coltaro
  5654. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  5655. //Well, using time_t could still work but for some reason that looks like more coding x_x
  5656. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) {
  5657. const int factor_year = 518400; //12*30*24*60 = 518400
  5658. const int factor_month = 43200; //30*24*60 = 43200
  5659. const int factor_day = 1440; //24*60 = 1440
  5660. const int factor_hour = 60;
  5661. *year = jailtime/factor_year;
  5662. jailtime -= *year*factor_year;
  5663. *month = jailtime/factor_month;
  5664. jailtime -= *month*factor_month;
  5665. *day = jailtime/factor_day;
  5666. jailtime -= *day*factor_day;
  5667. *hour = jailtime/factor_hour;
  5668. jailtime -= *hour*factor_hour;
  5669. *minute = jailtime;
  5670. *year = *year > 0? *year : 0;
  5671. *month = *month > 0? *month : 0;
  5672. *day = *day > 0? *day : 0;
  5673. *hour = *hour > 0? *hour : 0;
  5674. *minute = *minute > 0? *minute : 0;
  5675. return;
  5676. }
  5677. /*==========================================
  5678. * @jail <char_name> by [Yor]
  5679. * Special warp! No check with nowarp and nowarpto flag
  5680. *------------------------------------------
  5681. */
  5682. int atcommand_jail(
  5683. const int fd, struct map_session_data* sd,
  5684. const char* command, const char* message)
  5685. {
  5686. struct map_session_data *pl_sd;
  5687. int x, y;
  5688. unsigned short m_index;
  5689. nullpo_retr(-1, sd);
  5690. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5691. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5692. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5693. return -1;
  5694. }
  5695. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5696. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5697. return -1;
  5698. }
  5699. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5700. { // you can jail only lower or same GM
  5701. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5702. return -1;
  5703. }
  5704. if (pl_sd->mapindex == mapindex_name2id(MAP_JAIL))
  5705. { //Already jailed
  5706. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5707. return -1;
  5708. }
  5709. switch(rand() % 2) { //Jail Locations
  5710. case 0:
  5711. m_index = mapindex_name2id(MAP_JAIL);
  5712. x = 24;
  5713. y = 75;
  5714. break;
  5715. default:
  5716. m_index = mapindex_name2id(MAP_JAIL);
  5717. x = 49;
  5718. y = 75;
  5719. break;
  5720. }
  5721. if (pc_setpos(pl_sd, m_index, x, y, 3)) {
  5722. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5723. return -1;
  5724. }
  5725. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5726. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5727. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5728. return 0;
  5729. }
  5730. /*==========================================
  5731. * @unjail/@discharge <char_name> by [Yor]
  5732. * Special warp! No check with nowarp and nowarpto flag
  5733. *------------------------------------------
  5734. */
  5735. int atcommand_unjail(
  5736. const int fd, struct map_session_data* sd,
  5737. const char* command, const char* message)
  5738. {
  5739. struct map_session_data *pl_sd;
  5740. unsigned short m_index;
  5741. int x=0, y=0;
  5742. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5743. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5744. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5745. return -1;
  5746. }
  5747. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5748. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5749. return -1;
  5750. }
  5751. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5752. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5753. return -1;
  5754. }
  5755. if (pl_sd->mapindex != mapindex_name2id(MAP_JAIL)) {
  5756. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5757. return -1;
  5758. }
  5759. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5760. { //Retrieve return map.
  5761. m_index = pl_sd->sc.data[SC_JAILED].val3;
  5762. x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
  5763. y = pl_sd->sc.data[SC_JAILED].val4>>16;
  5764. status_change_end(&pl_sd->bl,SC_JAILED,-1);
  5765. } else
  5766. m_index = mapindex_name2id(MAP_PRONTERA);
  5767. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
  5768. pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
  5769. ) { //Send to Prontera is saved SC map fails.
  5770. pc_setsavepoint(pl_sd, m_index, x, y);
  5771. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5772. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5773. } else {
  5774. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5775. return -1;
  5776. }
  5777. return 0;
  5778. }
  5779. int atcommand_jailfor(
  5780. const int fd, struct map_session_data* sd,
  5781. const char* command, const char* message)
  5782. {
  5783. struct map_session_data *pl_sd = NULL;
  5784. int year, month, day, hour, minute, value;
  5785. char * modif_p;
  5786. int jailtime = 0,x,y;
  5787. short m_index = 0;
  5788. nullpo_retr(-1, sd);
  5789. if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5790. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5791. return -1;
  5792. }
  5793. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5794. modif_p = atcmd_output;
  5795. year = month = day = hour = minute = 0;
  5796. while (modif_p[0] != '\0') {
  5797. value = atoi(modif_p);
  5798. if (value == 0)
  5799. modif_p++;
  5800. else {
  5801. if (modif_p[0] == '-' || modif_p[0] == '+')
  5802. modif_p++;
  5803. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5804. modif_p++;
  5805. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  5806. minute = value;
  5807. modif_p = modif_p + 2;
  5808. } else if (modif_p[0] == 'h') {
  5809. hour = value;
  5810. modif_p++;
  5811. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5812. day = value;
  5813. modif_p++;
  5814. } else if (modif_p[0] == 'm') {
  5815. month = value;
  5816. modif_p++;
  5817. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5818. year = value;
  5819. modif_p++;
  5820. } else if (modif_p[0] != '\0') {
  5821. modif_p++;
  5822. }
  5823. }
  5824. }
  5825. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5826. clif_displaymessage(fd, "Invalid time for jail command.");
  5827. return -1;
  5828. }
  5829. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5830. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5831. return -1;
  5832. }
  5833. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5834. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5835. return -1;
  5836. }
  5837. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5838. if(jailtime==0) {
  5839. clif_displaymessage(fd, "Invalid time for jail command.");
  5840. return -1;
  5841. }
  5842. //Added by Coltaro
  5843. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5844. { //Update the player's jail time
  5845. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  5846. if (jailtime <= 0) {
  5847. jailtime = 0;
  5848. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5849. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5850. } else {
  5851. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5852. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  5853. clif_displaymessage(pl_sd->fd, atcmd_output);
  5854. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  5855. clif_displaymessage(fd, atcmd_output);
  5856. }
  5857. } else if (jailtime < 0) {
  5858. clif_displaymessage(fd, "Invalid time for jail command.");
  5859. return -1;
  5860. }
  5861. //Jail locations, add more as you wish.
  5862. switch(rand()%2)
  5863. {
  5864. case 1: //Jail #1
  5865. m_index = mapindex_name2id(MAP_JAIL);
  5866. x = 49; y = 75;
  5867. break;
  5868. default: //Default Jail
  5869. m_index = mapindex_name2id(MAP_JAIL);
  5870. x = 24; y = 75;
  5871. break;
  5872. }
  5873. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  5874. return 0;
  5875. }
  5876. //By Coltaro
  5877. int atcommand_jailtime(
  5878. const int fd, struct map_session_data* sd,
  5879. const char* command, const char* message)
  5880. {
  5881. int year, month, day, hour, minute;
  5882. nullpo_retr(-1, sd);
  5883. if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5884. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5885. return -1;
  5886. }
  5887. if (!sd->sc.count || sd->sc.data[SC_JAILED].timer == -1 || sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  5888. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5889. return -1;
  5890. }
  5891. //Get remaining jail time
  5892. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5893. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  5894. clif_displaymessage(fd, atcmd_output);
  5895. return 0;
  5896. }
  5897. //By Coltaro
  5898. int atcommand_charjailtime(
  5899. const int fd, struct map_session_data* sd,
  5900. const char* command, const char* message)
  5901. {
  5902. struct map_session_data* pl_sd;
  5903. int year, month, day, hour, minute;
  5904. nullpo_retr(-1, sd);
  5905. if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
  5906. clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
  5907. return -1;
  5908. }
  5909. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5910. if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
  5911. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5912. clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
  5913. return -1;
  5914. }
  5915. if (!pl_sd->sc.count || pl_sd->sc.data[SC_JAILED].timer == -1 || pl_sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail?)
  5916. clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
  5917. return -1;
  5918. }
  5919. //Get remaining jail time
  5920. get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5921. sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
  5922. clif_displaymessage(fd, atcmd_output);
  5923. } else {
  5924. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
  5925. return -1;
  5926. }
  5927. } else {
  5928. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5929. return -1;
  5930. }
  5931. return 0;
  5932. }
  5933. /*==========================================
  5934. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5935. *------------------------------------------
  5936. */
  5937. int atcommand_disguise(
  5938. const int fd, struct map_session_data* sd,
  5939. const char* command, const char* message)
  5940. {
  5941. int id = 0;
  5942. nullpo_retr(-1, sd);
  5943. if (!message || !*message) {
  5944. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5945. return -1;
  5946. }
  5947. if ((id = atoi(message)) > 0)
  5948. { //Acquired an ID
  5949. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5950. id = 0; //Invalid id for either mobs or npcs.
  5951. } else { //Acquired a Name
  5952. if ((id = mobdb_searchname(message)) == 0)
  5953. {
  5954. struct npc_data* nd = npc_name2id(message);
  5955. if (nd != NULL)
  5956. id = nd->n;
  5957. }
  5958. }
  5959. if (id == 0)
  5960. { // Monster/NPC name/id hasn't been found.
  5961. clif_displaymessage(fd, msg_txt(123));
  5962. return -1;
  5963. }
  5964. pc_disguise(sd, id);
  5965. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5966. return 0;
  5967. }
  5968. /*==========================================
  5969. * DisguiseAll
  5970. *------------------------------------------
  5971. */
  5972. int atcommand_disguiseall(
  5973. const int fd, struct map_session_data* sd,
  5974. const char* command, const char* message)
  5975. {
  5976. int mob_id=0, i=0, users;
  5977. struct map_session_data *pl_sd, **pl_allsd;
  5978. nullpo_retr(-1, sd);
  5979. if (!message || !*message) {
  5980. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5981. return -1;
  5982. }
  5983. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5984. mob_id = atoi(message);
  5985. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5986. pl_allsd = map_getallusers(&users);
  5987. for(i=0; i < users; i++) {
  5988. if((pl_sd = pl_allsd[i]))
  5989. pc_disguise(pl_sd, mob_id);
  5990. }
  5991. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5992. } else {
  5993. return -1;
  5994. }
  5995. return 0;
  5996. }
  5997. /*==========================================
  5998. * @undisguise by [Yor]
  5999. *------------------------------------------
  6000. */
  6001. int atcommand_undisguise(
  6002. const int fd, struct map_session_data* sd,
  6003. const char* command, const char* message)
  6004. {
  6005. nullpo_retr(-1, sd);
  6006. if (sd->disguise) {
  6007. pc_disguise(sd, 0);
  6008. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  6009. } else {
  6010. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  6011. return -1;
  6012. }
  6013. return 0;
  6014. }
  6015. /*==========================================
  6016. * UndisguiseAll
  6017. *------------------------------------------
  6018. */
  6019. int atcommand_undisguiseall(
  6020. const int fd, struct map_session_data* sd,
  6021. const char* command, const char* message)
  6022. {
  6023. struct map_session_data *pl_sd, **pl_allsd;
  6024. int i, users;
  6025. nullpo_retr(-1, sd);
  6026. pl_allsd = map_getallusers(&users);
  6027. for(i=0; i < users; i++) {
  6028. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  6029. pc_disguise(pl_sd, 0);
  6030. }
  6031. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  6032. return 0;
  6033. }
  6034. /*==========================================
  6035. * @exp by [Skotlex]
  6036. *------------------------------------------
  6037. */
  6038. int atcommand_exp(
  6039. const int fd, struct map_session_data* sd,
  6040. const char* command, const char* message)
  6041. {
  6042. char output[200];
  6043. double nextb, nextj;
  6044. nullpo_retr(-1, sd);
  6045. malloc_tsetdword(output, '\0', sizeof(output));
  6046. nextb = pc_nextbaseexp(sd);
  6047. if (nextb)
  6048. nextb = sd->status.base_exp*100.0/nextb;
  6049. nextj = pc_nextjobexp(sd);
  6050. if (nextj)
  6051. nextj = sd->status.job_exp*100.0/nextj;
  6052. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  6053. clif_displaymessage(fd, output);
  6054. return 0;
  6055. }
  6056. /*==========================================
  6057. * @broadcast by [Valaris]
  6058. *------------------------------------------
  6059. */
  6060. int atcommand_broadcast(
  6061. const int fd, struct map_session_data* sd,
  6062. const char* command, const char* message)
  6063. {
  6064. nullpo_retr(-1, sd);
  6065. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  6066. if (!message || !*message) {
  6067. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  6068. return -1;
  6069. }
  6070. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  6071. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  6072. return 0;
  6073. }
  6074. /*==========================================
  6075. * @localbroadcast by [Valaris]
  6076. *------------------------------------------
  6077. */
  6078. int atcommand_localbroadcast(
  6079. const int fd, struct map_session_data* sd,
  6080. const char* command, const char* message)
  6081. {
  6082. nullpo_retr(-1, sd);
  6083. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  6084. if (!message || !*message) {
  6085. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  6086. return -1;
  6087. }
  6088. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  6089. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  6090. return 0;
  6091. }
  6092. /*==========================================
  6093. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  6094. *------------------------------------------
  6095. */
  6096. int atcommand_chardisguise(
  6097. const int fd, struct map_session_data* sd,
  6098. const char* command, const char* message)
  6099. {
  6100. int mob_id;
  6101. char mob_name[NAME_LENGTH];
  6102. struct map_session_data* pl_sd;
  6103. nullpo_retr(-1, sd);
  6104. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6105. malloc_tsetdword(mob_name, '\0', sizeof(mob_name));
  6106. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  6107. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  6108. return -1;
  6109. }
  6110. if ((mob_id = atoi(mob_name)) > 0)
  6111. { //Acquired an ID
  6112. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  6113. mob_id = 0; //Invalid id for either mobs or npcs.
  6114. } else { //Acquired a Name
  6115. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  6116. {
  6117. struct npc_data* nd = npc_name2id(mob_name);
  6118. if (nd != NULL)
  6119. mob_id = nd->n;
  6120. }
  6121. }
  6122. if (mob_id == 0)
  6123. {
  6124. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  6125. return -1;
  6126. }
  6127. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6128. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  6129. pc_disguise(pl_sd, mob_id);
  6130. clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
  6131. } else {
  6132. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6133. return -1;
  6134. }
  6135. } else {
  6136. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6137. return -1;
  6138. }
  6139. return 0;
  6140. }
  6141. /*==========================================
  6142. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  6143. *------------------------------------------
  6144. */
  6145. int atcommand_charundisguise(
  6146. const int fd, struct map_session_data* sd,
  6147. const char* command, const char* message)
  6148. {
  6149. struct map_session_data* pl_sd;
  6150. nullpo_retr(-1, sd);
  6151. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6152. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6153. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  6154. return -1;
  6155. }
  6156. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6157. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  6158. if (pl_sd->disguise)
  6159. pc_disguise(pl_sd, 0);
  6160. else {
  6161. clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
  6162. return -1;
  6163. }
  6164. } else {
  6165. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6166. return -1;
  6167. }
  6168. } else {
  6169. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6170. return -1;
  6171. }
  6172. return 0;
  6173. }
  6174. /*==========================================
  6175. * @email <actual@email> <new@email> by [Yor]
  6176. *------------------------------------------
  6177. */
  6178. int atcommand_email(
  6179. const int fd, struct map_session_data* sd,
  6180. const char* command, const char* message)
  6181. {
  6182. char actual_email[100];
  6183. char new_email[100];
  6184. nullpo_retr(-1, sd);
  6185. malloc_tsetdword(actual_email, '\0', sizeof(actual_email));
  6186. malloc_tsetdword(new_email, '\0', sizeof(new_email));
  6187. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  6188. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  6189. return -1;
  6190. }
  6191. if (e_mail_check(actual_email) == 0) {
  6192. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  6193. return -1;
  6194. } else if (e_mail_check(new_email) == 0) {
  6195. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  6196. return -1;
  6197. } else if (strcmpi(new_email, "a@a.com") == 0) {
  6198. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  6199. return -1;
  6200. } else if (strcmpi(actual_email, new_email) == 0) {
  6201. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  6202. return -1;
  6203. } else {
  6204. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  6205. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  6206. }
  6207. return 0;
  6208. }
  6209. /*==========================================
  6210. *@effect
  6211. *------------------------------------------
  6212. */
  6213. int atcommand_effect(
  6214. const int fd, struct map_session_data* sd,
  6215. const char* command, const char* message)
  6216. {
  6217. int type = 0, flag = 0;
  6218. nullpo_retr(-1, sd);
  6219. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  6220. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  6221. return -1;
  6222. }
  6223. clif_specialeffect(&sd->bl, type, flag);
  6224. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  6225. return 0;
  6226. }
  6227. /*==========================================
  6228. * @charcartlist <character>: Displays the items list of a player's cart.
  6229. *------------------------------------------
  6230. */
  6231. int
  6232. atcommand_character_cart_list(
  6233. const int fd, struct map_session_data* sd,
  6234. const char* command, const char* message)
  6235. {
  6236. char outputtmp[200];
  6237. struct map_session_data *pl_sd;
  6238. struct item_data *item_data, *item_temp;
  6239. int i, j, count, counter, counter2;
  6240. nullpo_retr(-1, sd);
  6241. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6242. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  6243. malloc_tsetdword(outputtmp, '\0', sizeof(outputtmp));
  6244. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6245. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6246. return -1;
  6247. }
  6248. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6249. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6250. counter = 0;
  6251. count = 0;
  6252. for (i = 0; i < MAX_CART; i++) {
  6253. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6254. counter = counter + pl_sd->status.cart[i].amount;
  6255. count++;
  6256. if (count == 1) {
  6257. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6258. clif_displaymessage(fd, atcmd_output);
  6259. }
  6260. if (pl_sd->status.cart[i].refine)
  6261. 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);
  6262. else
  6263. 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);
  6264. clif_displaymessage(fd, atcmd_output);
  6265. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  6266. counter2 = 0;
  6267. for (j = 0; j < item_data->slot; j++) {
  6268. if (pl_sd->status.cart[i].card[j]) {
  6269. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6270. if (atcmd_output[0] == '\0')
  6271. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6272. else
  6273. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6274. strcat(atcmd_output, outputtmp);
  6275. }
  6276. }
  6277. }
  6278. if (atcmd_output[0] != '\0') {
  6279. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6280. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6281. clif_displaymessage(fd, atcmd_output);
  6282. }
  6283. }
  6284. }
  6285. if (count == 0)
  6286. clif_displaymessage(fd, "No item found in the cart of this player.");
  6287. else {
  6288. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6289. clif_displaymessage(fd, atcmd_output);
  6290. }
  6291. } else {
  6292. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6293. return -1;
  6294. }
  6295. } else {
  6296. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6297. return -1;
  6298. }
  6299. return 0;
  6300. }
  6301. /*==========================================
  6302. * @killer by MouseJstr
  6303. * enable killing players even when not in pvp
  6304. *------------------------------------------
  6305. */
  6306. int
  6307. atcommand_killer(
  6308. const int fd, struct map_session_data* sd,
  6309. const char* command, const char* message)
  6310. {
  6311. nullpo_retr(-1, sd);
  6312. sd->state.killer = !sd->state.killer;
  6313. if(sd->state.killer)
  6314. clif_displaymessage(fd, msg_txt(241));
  6315. else
  6316. clif_displaymessage(fd, msg_txt(287));
  6317. return 0;
  6318. }
  6319. /*==========================================
  6320. * @killable by MouseJstr
  6321. * enable other people killing you
  6322. *------------------------------------------
  6323. */
  6324. int
  6325. atcommand_killable(
  6326. const int fd, struct map_session_data* sd,
  6327. const char* command, const char* message)
  6328. {
  6329. nullpo_retr(-1, sd);
  6330. sd->state.killable = !sd->state.killable;
  6331. if(sd->state.killable)
  6332. clif_displaymessage(fd, msg_txt(242));
  6333. else
  6334. clif_displaymessage(fd, msg_txt(288));
  6335. return 0;
  6336. }
  6337. /*==========================================
  6338. * @charkillable by MouseJstr
  6339. * enable another player to be killed
  6340. *------------------------------------------
  6341. */
  6342. int
  6343. atcommand_charkillable(
  6344. const int fd, struct map_session_data* sd,
  6345. const char* command, const char* message)
  6346. {
  6347. struct map_session_data *pl_sd = NULL;
  6348. nullpo_retr(-1, sd);
  6349. if (!message || !*message)
  6350. return -1;
  6351. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6352. return -1;
  6353. pl_sd->state.killable = !pl_sd->state.killable;
  6354. if(pl_sd->state.killable)
  6355. clif_displaymessage(fd, msg_txt(289));
  6356. else
  6357. clif_displaymessage(fd, msg_txt(290));
  6358. return 0;
  6359. }
  6360. /*==========================================
  6361. * @skillon by MouseJstr
  6362. * turn skills on for the map
  6363. *------------------------------------------
  6364. */
  6365. int
  6366. atcommand_skillon(
  6367. const int fd, struct map_session_data* sd,
  6368. const char* command, const char* message)
  6369. {
  6370. nullpo_retr(-1, sd);
  6371. map[sd->bl.m].flag.noskill = 0;
  6372. clif_displaymessage(fd, msg_txt(244));
  6373. return 0;
  6374. }
  6375. /*==========================================
  6376. * @skilloff by MouseJstr
  6377. * Turn skills off on the map
  6378. *------------------------------------------
  6379. */
  6380. int
  6381. atcommand_skilloff(
  6382. const int fd, struct map_session_data* sd,
  6383. const char* command, const char* message)
  6384. {
  6385. nullpo_retr(-1, sd);
  6386. map[sd->bl.m].flag.noskill = 1;
  6387. clif_displaymessage(fd, msg_txt(243));
  6388. return 0;
  6389. }
  6390. /*==========================================
  6391. * @npcmove by MouseJstr
  6392. *
  6393. * move a npc
  6394. *------------------------------------------
  6395. */
  6396. int
  6397. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6398. const char* command, const char* message)
  6399. {
  6400. int x = 0, y = 0, m;
  6401. struct npc_data *nd = 0;
  6402. nullpo_retr(-1, sd);
  6403. if (!message || !*message)
  6404. return -1;
  6405. malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6406. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6407. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6408. return -1;
  6409. }
  6410. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6411. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6412. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6413. return -1;
  6414. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6415. return -1; //Not on a map.
  6416. if (x < 0) x = 0;
  6417. else if (x >= map[m].xs) x = map[m].xs-1;
  6418. if (y < 0) y = 0;
  6419. else if (y >= map[m].ys) y = map[m].ys-1;
  6420. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6421. map_moveblock(&nd->bl, x, y, gettick());
  6422. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6423. return 0;
  6424. }
  6425. /*==========================================
  6426. * @addwarp by MouseJstr
  6427. *
  6428. * Create a new static warp point.
  6429. *------------------------------------------
  6430. */
  6431. int
  6432. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6433. const char* command, const char* message)
  6434. {
  6435. char w1[64], w3[64], w4[64];
  6436. int x,y,ret;
  6437. nullpo_retr(-1, sd);
  6438. if (!message || !*message)
  6439. return -1;
  6440. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6441. return -1;
  6442. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6443. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6444. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6445. ret = npc_parse_warp(w1, "warp", w3, w4);
  6446. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6447. clif_displaymessage(fd, atcmd_output);
  6448. return ret;
  6449. }
  6450. /*==========================================
  6451. * @follow by [MouseJstr]
  6452. *
  6453. * Follow a player .. staying no more then 5 spaces away
  6454. *------------------------------------------
  6455. */
  6456. int
  6457. atcommand_follow(const int fd, struct map_session_data* sd,
  6458. const char* command, const char* message)
  6459. {
  6460. struct map_session_data *pl_sd = NULL;
  6461. nullpo_retr(-1, sd);
  6462. if (!message || !*message) {
  6463. if (sd->followtarget == -1)
  6464. return -1;
  6465. pc_stop_following (sd);
  6466. clif_displaymessage(fd, "Follow mode OFF.");
  6467. return 0;
  6468. }
  6469. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6470. if (sd->followtarget == pl_sd->bl.id) {
  6471. pc_stop_following (sd);
  6472. clif_displaymessage(fd, "Follow mode OFF.");
  6473. } else {
  6474. pc_follow(sd, pl_sd->bl.id);
  6475. clif_displaymessage(fd, "Follow mode ON.");
  6476. }
  6477. return 0;
  6478. } else {
  6479. clif_displaymessage(fd, "Character not found.");
  6480. return -1;
  6481. }
  6482. return 1;
  6483. }
  6484. /*==========================================
  6485. * @dropall by [MouseJstr]
  6486. *
  6487. * Drop all your possession on the ground
  6488. *------------------------------------------
  6489. */
  6490. int
  6491. atcommand_dropall(const int fd, struct map_session_data* sd,
  6492. const char* command, const char* message)
  6493. {
  6494. int i;
  6495. nullpo_retr(-1, sd);
  6496. for (i = 0; i < MAX_INVENTORY; i++) {
  6497. if (sd->status.inventory[i].amount) {
  6498. if(sd->status.inventory[i].equip != 0)
  6499. pc_unequipitem(sd, i, 3);
  6500. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6501. }
  6502. }
  6503. return 0;
  6504. }
  6505. /*==========================================
  6506. * @chardropall by [MouseJstr]
  6507. *
  6508. * Throw all the characters possessions on the ground. Normally
  6509. * done in response to them being disrespectful of a GM
  6510. *------------------------------------------
  6511. */
  6512. int
  6513. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6514. const char* command, const char* message)
  6515. {
  6516. int i;
  6517. struct map_session_data *pl_sd = NULL;
  6518. nullpo_retr(-1, sd);
  6519. if (!message || !*message)
  6520. return -1;
  6521. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6522. return -1;
  6523. for (i = 0; i < MAX_INVENTORY; i++) {
  6524. if (pl_sd->status.inventory[i].amount) {
  6525. if(pl_sd->status.inventory[i].equip != 0)
  6526. pc_unequipitem(pl_sd, i, 3);
  6527. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6528. }
  6529. }
  6530. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6531. clif_displaymessage(fd, "It is done");
  6532. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6533. return 0;
  6534. }
  6535. /*==========================================
  6536. * @storeall by [MouseJstr]
  6537. *
  6538. * Put everything into storage to simplify your inventory to make
  6539. * debugging easie
  6540. *------------------------------------------
  6541. */
  6542. int
  6543. atcommand_storeall(const int fd, struct map_session_data* sd,
  6544. const char* command, const char* message)
  6545. {
  6546. int i;
  6547. nullpo_retr(-1, sd);
  6548. if (sd->state.storage_flag != 1)
  6549. { //Open storage.
  6550. switch (storage_storageopen(sd)) {
  6551. case 2: //Try again
  6552. clif_displaymessage(fd, "run this command again..");
  6553. return 0;
  6554. case 1: //Failure
  6555. clif_displaymessage(fd, "You can't open the storage currently.");
  6556. return -1;
  6557. }
  6558. }
  6559. for (i = 0; i < MAX_INVENTORY; i++) {
  6560. if (sd->status.inventory[i].amount) {
  6561. if(sd->status.inventory[i].equip != 0)
  6562. pc_unequipitem(sd, i, 3);
  6563. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6564. }
  6565. }
  6566. storage_storageclose(sd);
  6567. clif_displaymessage(fd, "It is done");
  6568. return 0;
  6569. }
  6570. /*==========================================
  6571. * @charstoreall by [MouseJstr]
  6572. *
  6573. * A way to screw with players who piss you off
  6574. *------------------------------------------
  6575. */
  6576. int
  6577. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6578. const char* command, const char* message)
  6579. {
  6580. int i;
  6581. struct map_session_data *pl_sd = NULL;
  6582. nullpo_retr(-1, sd);
  6583. if (!message || !*message)
  6584. return -1;
  6585. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6586. return -1;
  6587. if (pl_sd->state.storage_flag != 1)
  6588. { //Open storage.
  6589. switch (storage_storageopen(pl_sd)) {
  6590. case 2: //Try again
  6591. clif_displaymessage(fd, "Had to open the characters storage window...");
  6592. clif_displaymessage(fd, "run this command again..");
  6593. return 0;
  6594. case 1: //Failure
  6595. clif_displaymessage(fd, "The character currently can't use the storage.");
  6596. return 1;
  6597. }
  6598. }
  6599. for (i = 0; i < MAX_INVENTORY; i++) {
  6600. if (pl_sd->status.inventory[i].amount) {
  6601. if(pl_sd->status.inventory[i].equip != 0)
  6602. pc_unequipitem(pl_sd, i, 3);
  6603. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6604. }
  6605. }
  6606. storage_storageclose(pl_sd);
  6607. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6608. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6609. clif_displaymessage(pl_sd->fd, " -- the management");
  6610. clif_displaymessage(fd, "It is done");
  6611. return 0;
  6612. }
  6613. /*==========================================
  6614. * @skillid by [MouseJstr]
  6615. *
  6616. * lookup a skill by name
  6617. *------------------------------------------
  6618. */
  6619. int
  6620. atcommand_skillid(const int fd, struct map_session_data* sd,
  6621. const char* command, const char* message)
  6622. {
  6623. int skillen, idx;
  6624. nullpo_retr(-1, sd);
  6625. if (!message || !*message)
  6626. return -1;
  6627. skillen = strlen(message);
  6628. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6629. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6630. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6631. {
  6632. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6633. clif_displaymessage(fd, atcmd_output);
  6634. }
  6635. }
  6636. return 0;
  6637. }
  6638. /*==========================================
  6639. * @useskill by [MouseJstr]
  6640. *
  6641. * A way of using skills without having to find them in the skills menu
  6642. *------------------------------------------
  6643. */
  6644. int
  6645. atcommand_useskill(const int fd, struct map_session_data* sd,
  6646. const char* command, const char* message)
  6647. {
  6648. struct map_session_data *pl_sd = NULL;
  6649. struct block_list *bl;
  6650. int skillnum;
  6651. int skilllv;
  6652. char target[255];
  6653. nullpo_retr(-1, sd);
  6654. if (!message || !*message)
  6655. return -1;
  6656. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6657. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6658. return -1;
  6659. }
  6660. if((pl_sd=map_nick2sd(target)) == NULL) {
  6661. return -1;
  6662. }
  6663. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  6664. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  6665. bl = &sd->hd->bl;
  6666. else
  6667. bl = &sd->bl;
  6668. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6669. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6670. else
  6671. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  6672. return 0;
  6673. }
  6674. /*==========================================
  6675. * @skilltree by [MouseJstr]
  6676. *
  6677. * prints the skill tree for a player required to get to a skill
  6678. *------------------------------------------
  6679. */
  6680. int
  6681. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6682. const char* command, const char* message)
  6683. {
  6684. struct map_session_data *pl_sd = NULL;
  6685. int skillnum, skillidx = -1;
  6686. int meets = 1, j, c=0;
  6687. char target[NAME_LENGTH], *tbl;
  6688. struct skill_tree_entry *ent;
  6689. nullpo_retr(-1, sd);
  6690. if (!message || !*message)
  6691. return -1;
  6692. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6693. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6694. return -1;
  6695. }
  6696. if((pl_sd=map_nick2sd(target)) == NULL)
  6697. return -1;
  6698. c = pc_calc_skilltree_normalize_job(pl_sd);
  6699. c = pc_mapid2jobid(c, pl_sd->status.sex);
  6700. tbl = job_name(c);
  6701. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6702. tbl, pc_checkskill(pl_sd, 1));
  6703. clif_displaymessage(fd, atcmd_output);
  6704. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6705. if (skill_tree[c][j].id == skillnum) {
  6706. skillidx = j;
  6707. break;
  6708. }
  6709. }
  6710. if (skillidx == -1) {
  6711. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6712. clif_displaymessage(fd, atcmd_output);
  6713. return 0;
  6714. }
  6715. ent = &skill_tree[c][skillidx];
  6716. for(j=0;j<5;j++)
  6717. if( ent->need[j].id &&
  6718. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6719. {
  6720. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6721. sprintf(atcmd_output, "player requires level %d of skill %s",
  6722. ent->need[j].lv, desc);
  6723. clif_displaymessage(fd, atcmd_output);
  6724. meets = 0;
  6725. }
  6726. if (meets == 1) {
  6727. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6728. clif_displaymessage(fd, atcmd_output);
  6729. }
  6730. return 0;
  6731. }
  6732. // Hand a ring with partners name on it to this char
  6733. void getring (struct map_session_data *sd)
  6734. {
  6735. int flag,item_id = 0;
  6736. struct item item_tmp;
  6737. if(sd->status.sex==0)
  6738. item_id = 2635;
  6739. else
  6740. item_id = 2634;
  6741. malloc_set(&item_tmp,0,sizeof(item_tmp));
  6742. item_tmp.nameid=item_id;
  6743. item_tmp.identify=1;
  6744. item_tmp.card[0]=255;
  6745. item_tmp.card[2]=sd->status.partner_id;
  6746. item_tmp.card[3]=sd->status.partner_id >> 16;
  6747. //Logs (A)dmins items [Lupus]
  6748. if(log_config.enable_logs&0x400)
  6749. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6750. if((flag = pc_additem(sd,&item_tmp,1))) {
  6751. clif_additem(sd,0,0,flag);
  6752. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6753. }
  6754. }
  6755. /*==========================================
  6756. * @marry by [MouseJstr], fixed by Lupus
  6757. *
  6758. * Marry two players
  6759. *------------------------------------------
  6760. */
  6761. int
  6762. atcommand_marry(const int fd, struct map_session_data* sd,
  6763. const char* command, const char* message)
  6764. {
  6765. struct map_session_data *pl_sd1 = NULL;
  6766. struct map_session_data *pl_sd2 = NULL;
  6767. char player1[128], player2[128]; //Length used for return error msgs
  6768. nullpo_retr(-1, sd);
  6769. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6770. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6771. return -1;
  6772. }
  6773. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6774. sprintf(player2, "Cannot find player '%s' online", player1);
  6775. clif_displaymessage(fd, player2);
  6776. return -1;
  6777. }
  6778. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6779. sprintf(player1, "Cannot find player '%s' online", player2);
  6780. clif_displaymessage(fd, player1);
  6781. return -1;
  6782. }
  6783. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6784. clif_displaymessage(fd, "They are married.. wish them well");
  6785. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6786. // Auto-give named rings (Aru)
  6787. getring (pl_sd1);
  6788. getring (pl_sd2);
  6789. return 0;
  6790. }
  6791. return -1;
  6792. }
  6793. /*==========================================
  6794. * @divorce by [MouseJstr], fixed by [Lupus]
  6795. *
  6796. * divorce two players
  6797. *------------------------------------------
  6798. */
  6799. int
  6800. atcommand_divorce(const int fd, struct map_session_data* sd,
  6801. const char* command, const char* message)
  6802. {
  6803. struct map_session_data *pl_sd = NULL;
  6804. nullpo_retr(-1, sd);
  6805. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6806. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6807. return -1;
  6808. }
  6809. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6810. if (pc_divorce(pl_sd) != 0) {
  6811. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6812. clif_displaymessage(fd, atcmd_output);
  6813. return -1;
  6814. } else {
  6815. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6816. clif_displaymessage(fd, atcmd_output);
  6817. return 0;
  6818. }
  6819. }
  6820. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6821. clif_displaymessage(fd, atcmd_output);
  6822. return -1;
  6823. }
  6824. #ifdef DMALLOC
  6825. unsigned long dmark_;
  6826. int
  6827. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6828. const char* command, const char* message)
  6829. {
  6830. dmark_ = dmalloc_mark();
  6831. clif_displaymessage(fd, "debug mark set");
  6832. return 0;
  6833. }
  6834. int
  6835. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6836. const char* command, const char* message)
  6837. {
  6838. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6839. dmark_ = dmalloc_mark();
  6840. clif_displaymessage(fd, "malloc changes logged");
  6841. return 0;
  6842. }
  6843. #endif
  6844. /*==========================================
  6845. * @grind by [MouseJstr]
  6846. *------------------------------------------
  6847. */
  6848. int
  6849. atcommand_grind(const int fd, struct map_session_data* sd,
  6850. const char* command, const char* message)
  6851. {
  6852. struct map_session_data *pl_sd = NULL;
  6853. int skillnum;
  6854. int inf;
  6855. char target[NAME_LENGTH];
  6856. nullpo_retr(-1, sd);
  6857. if (!message || !*message)
  6858. return -1;
  6859. if(sscanf(message, "%23s", target) != 1) {
  6860. clif_displaymessage(fd, "Usage: @grind <target>");
  6861. return -1;
  6862. }
  6863. if((pl_sd=map_nick2sd(target)) == NULL)
  6864. return -1;
  6865. for (skillnum = 1; skillnum < 500; skillnum++) {
  6866. sd->status.sp = sd->status.max_sp;
  6867. atcommand_alive(fd, sd, command, message);
  6868. inf = skill_get_inf(skillnum);
  6869. if (inf & INF_GROUND_SKILL)
  6870. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6871. else if (!(inf & INF_SUPPORT_SKILL))
  6872. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6873. }
  6874. return 0;
  6875. }
  6876. /*==========================================
  6877. * @grind2 by [MouseJstr]
  6878. *------------------------------------------
  6879. */
  6880. int
  6881. atcommand_grind2(const int fd, struct map_session_data* sd,
  6882. const char* command, const char* message)
  6883. {
  6884. int i;
  6885. short x, y;
  6886. for (i = 1000; i < MAX_MOB_DB; i++) {
  6887. if (!mobdb_checkid(i))
  6888. continue;
  6889. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6890. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6891. }
  6892. return 0;
  6893. }
  6894. /*==========================================
  6895. * @changelook by [Celest]
  6896. *------------------------------------------
  6897. */
  6898. int
  6899. atcommand_changelook(const int fd, struct map_session_data* sd,
  6900. const char* command, const char* message)
  6901. {
  6902. int i, j = 0, k = 0;
  6903. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6904. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6905. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6906. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6907. return -1;
  6908. } else if (i == 2) {
  6909. if (j < 1) j = 1;
  6910. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6911. j = pos[j - 1];
  6912. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6913. k = j; // swap
  6914. j = LOOK_HEAD_TOP;
  6915. }
  6916. clif_changelook(&sd->bl,j,k);
  6917. return 0;
  6918. }
  6919. /*==========================================
  6920. *Turns on/off Autotrade for a specific player
  6921. *------------------------------------------
  6922. *by durf (changed by Lupus)
  6923. */
  6924. int
  6925. atcommand_autotrade(
  6926. const int fd, struct map_session_data* sd,
  6927. const char* command, const char* message)
  6928. {
  6929. nullpo_retr(-1, sd);
  6930. if (sd->vender_id) //check if player's vending
  6931. {
  6932. sd->state.autotrade = 1;
  6933. clif_authfail_fd(fd, 15);
  6934. }
  6935. else
  6936. {
  6937. //"You should be vending to use @Autotrade."
  6938. clif_displaymessage(fd, msg_txt(549));
  6939. }
  6940. return 0;
  6941. }
  6942. /*==========================================
  6943. * Changes Master of your Guild to a specified guild member
  6944. *------------------------------------------
  6945. *by durf (changed by Lupus)
  6946. */
  6947. int
  6948. atcommand_changegm(
  6949. const int fd, struct map_session_data* sd,
  6950. const char* command, const char* message)
  6951. {
  6952. struct guild *g;
  6953. struct map_session_data *pl_sd;
  6954. nullpo_retr(-1, sd);
  6955. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6956. {
  6957. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6958. return -1;
  6959. }
  6960. if (strlen(message)==0)
  6961. {
  6962. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6963. return -1;
  6964. }
  6965. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6966. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6967. return -1;
  6968. }
  6969. guild_gm_change(sd->status.guild_id, pl_sd);
  6970. return 0;
  6971. }
  6972. /*==========================================
  6973. *Changes the leader of a party.
  6974. *------------------------------------------
  6975. *by Skotlex
  6976. */
  6977. int
  6978. atcommand_changeleader(
  6979. const int fd, struct map_session_data* sd,
  6980. const char* command, const char* message)
  6981. {
  6982. struct party_data *p;
  6983. struct map_session_data *pl_sd;
  6984. int mi, pl_mi;
  6985. nullpo_retr(-1, sd);
  6986. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6987. { //Need to be a party leader.
  6988. clif_displaymessage(fd, msg_txt(282));
  6989. return -1;
  6990. }
  6991. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6992. if (mi == MAX_PARTY)
  6993. return -1; //Shouldn't happen
  6994. if (!p->party.member[mi].leader)
  6995. { //Need to be a party leader.
  6996. clif_displaymessage(fd, msg_txt(282));
  6997. return -1;
  6998. }
  6999. if (strlen(message)==0)
  7000. {
  7001. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  7002. return -1;
  7003. }
  7004. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  7005. clif_displaymessage(fd, msg_txt(283));
  7006. return -1;
  7007. }
  7008. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  7009. if (pl_mi == MAX_PARTY)
  7010. return -1; //Shouldn't happen
  7011. //Change leadership.
  7012. p->party.member[mi].leader = 0;
  7013. if (p->data[mi].sd->fd)
  7014. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  7015. p->party.member[pl_mi].leader = 1;
  7016. if (p->data[pl_mi].sd->fd)
  7017. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  7018. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  7019. //Update info.
  7020. clif_party_main_info(p,-1);
  7021. clif_party_info(p,-1);
  7022. return 0;
  7023. }
  7024. /*==========================================
  7025. * Used to change the item share setting of a party.
  7026. *------------------------------------------
  7027. *by Skotlex
  7028. */
  7029. int
  7030. atcommand_partyoption(
  7031. const int fd, struct map_session_data* sd,
  7032. const char* command, const char* message)
  7033. {
  7034. struct party_data *p;
  7035. int mi, option;
  7036. char w1[15], w2[15];
  7037. nullpo_retr(-1, sd);
  7038. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  7039. {
  7040. clif_displaymessage(fd, msg_txt(282));
  7041. return -1;
  7042. }
  7043. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  7044. if (mi == MAX_PARTY)
  7045. return -1; //Shouldn't happen
  7046. if (!p->party.member[mi].leader)
  7047. {
  7048. clif_displaymessage(fd, msg_txt(282));
  7049. return -1;
  7050. }
  7051. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  7052. {
  7053. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  7054. return -1;
  7055. }
  7056. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  7057. option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
  7058. //Change item share type.
  7059. if (option != p->party.item)
  7060. party_changeoption(sd, p->party.exp, option);
  7061. else
  7062. clif_displaymessage(fd, msg_txt(286));
  7063. return 0;
  7064. }
  7065. /*==========================================
  7066. *Turns on/off AutoLoot for a specific player
  7067. *------------------------------------------
  7068. *by Upa-Kun
  7069. */
  7070. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7071. {
  7072. // autoloot command with value
  7073. int rate;
  7074. nullpo_retr(-1, sd);
  7075. // autoloot command without value
  7076. if(!message || !*message)
  7077. {
  7078. // autoloot on -> off
  7079. if(sd->state.autoloot)
  7080. {
  7081. clif_displaymessage(fd, "Autoloot is now off.");
  7082. sd->state.autoloot = 0;
  7083. return 0;
  7084. // autoloot off -> on
  7085. } else {
  7086. clif_displaymessage(fd, "Autoloot is now on.");
  7087. sd->state.autoloot = 10000;
  7088. return 0;
  7089. }
  7090. }
  7091. // get maximum droprate limit
  7092. rate = (int)(atof(message) * 100.);
  7093. // check for invalid value
  7094. if(rate > 10000)
  7095. {
  7096. clif_displaymessage(fd, "Invalid value. Choose value between 0 and 100.");
  7097. return 0;
  7098. }
  7099. // autoloot value is 0, turn autoloot off
  7100. if(rate == 0)
  7101. {
  7102. if(sd->state.autoloot == 0)
  7103. clif_displaymessage(fd, "Autoloot is already off.");
  7104. else {
  7105. clif_displaymessage(fd, "Autoloot is now off.");
  7106. sd->state.autoloot = 0;
  7107. }
  7108. return 0;
  7109. }
  7110. // autoloot value is 100, turn autoloot on
  7111. if(rate == 10000)
  7112. {
  7113. if(sd->state.autoloot == 10000)
  7114. clif_displaymessage(fd, "Autoloot is already on.");
  7115. else {
  7116. clif_displaymessage(fd, "Autoloot is now on.");
  7117. sd->state.autoloot = 10000;
  7118. }
  7119. return 0;
  7120. }
  7121. // autoloot value is between 0 and 100
  7122. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.", rate/100.);
  7123. clif_displaymessage(fd, atcmd_output);
  7124. sd->state.autoloot = rate;
  7125. return 0;
  7126. }
  7127. /*==========================================
  7128. * It is made to rain.
  7129. *------------------------------------------
  7130. */
  7131. int
  7132. atcommand_rain(
  7133. const int fd, struct map_session_data* sd,
  7134. const char* command, const char* message)
  7135. {
  7136. nullpo_retr(-1, sd);
  7137. if (map[sd->bl.m].flag.rain) {
  7138. map[sd->bl.m].flag.rain=0;
  7139. clif_weather(sd->bl.m);
  7140. clif_displaymessage(fd, "The rain has stopped.");
  7141. } else {
  7142. map[sd->bl.m].flag.rain=1;
  7143. clif_weather(sd->bl.m);
  7144. clif_displaymessage(fd, "It is made to rain.");
  7145. }
  7146. return 0;
  7147. }
  7148. /*==========================================
  7149. * It is made to snow.
  7150. *------------------------------------------
  7151. */
  7152. int
  7153. atcommand_snow(
  7154. const int fd, struct map_session_data* sd,
  7155. const char* command, const char* message)
  7156. {
  7157. nullpo_retr(-1, sd);
  7158. if (map[sd->bl.m].flag.snow) {
  7159. map[sd->bl.m].flag.snow=0;
  7160. clif_weather(sd->bl.m);
  7161. clif_displaymessage(fd, "Snow has stopped falling.");
  7162. } else {
  7163. map[sd->bl.m].flag.snow=1;
  7164. clif_weather(sd->bl.m);
  7165. clif_displaymessage(fd, "It is made to snow.");
  7166. }
  7167. return 0;
  7168. }
  7169. /*==========================================
  7170. * Cherry tree snowstorm is made to fall. (Sakura)
  7171. *------------------------------------------
  7172. */
  7173. int
  7174. atcommand_sakura(
  7175. const int fd, struct map_session_data* sd,
  7176. const char* command, const char* message)
  7177. {
  7178. nullpo_retr(-1, sd);
  7179. if (map[sd->bl.m].flag.sakura) {
  7180. map[sd->bl.m].flag.sakura=0;
  7181. clif_weather(sd->bl.m);
  7182. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  7183. } else {
  7184. map[sd->bl.m].flag.sakura=1;
  7185. clif_weather(sd->bl.m);
  7186. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  7187. }
  7188. return 0;
  7189. }
  7190. /*==========================================
  7191. * Clouds appear.
  7192. *------------------------------------------
  7193. */
  7194. int
  7195. atcommand_clouds(
  7196. const int fd, struct map_session_data* sd,
  7197. const char* command, const char* message)
  7198. {
  7199. nullpo_retr(-1, sd);
  7200. if (map[sd->bl.m].flag.clouds) {
  7201. map[sd->bl.m].flag.clouds=0;
  7202. clif_weather(sd->bl.m);
  7203. clif_displaymessage(fd, "The clouds has disappear.");
  7204. } else {
  7205. map[sd->bl.m].flag.clouds=1;
  7206. clif_weather(sd->bl.m);
  7207. clif_displaymessage(fd, "Clouds appear.");
  7208. }
  7209. return 0;
  7210. }
  7211. /*==========================================
  7212. * Different type of clouds using effect 516
  7213. *------------------------------------------
  7214. */
  7215. int
  7216. atcommand_clouds2(
  7217. const int fd, struct map_session_data* sd,
  7218. const char* command, const char* message)
  7219. {
  7220. nullpo_retr(-1, sd);
  7221. if (map[sd->bl.m].flag.clouds2) {
  7222. map[sd->bl.m].flag.clouds2=0;
  7223. clif_weather(sd->bl.m);
  7224. clif_displaymessage(fd, "The alternative clouds disappear.");
  7225. } else {
  7226. map[sd->bl.m].flag.clouds2=1;
  7227. clif_weather(sd->bl.m);
  7228. clif_displaymessage(fd, "Alternative clouds appear.");
  7229. }
  7230. return 0;
  7231. }
  7232. /*==========================================
  7233. * Fog hangs over.
  7234. *------------------------------------------
  7235. */
  7236. int
  7237. atcommand_fog(
  7238. const int fd, struct map_session_data* sd,
  7239. const char* command, const char* message)
  7240. {
  7241. nullpo_retr(-1, sd);
  7242. if (map[sd->bl.m].flag.fog) {
  7243. map[sd->bl.m].flag.fog=0;
  7244. clif_weather(sd->bl.m);
  7245. clif_displaymessage(fd, "The fog has gone.");
  7246. } else {
  7247. map[sd->bl.m].flag.fog=1;
  7248. clif_weather(sd->bl.m);
  7249. clif_displaymessage(fd, "Fog hangs over.");
  7250. }
  7251. return 0;
  7252. }
  7253. /*==========================================
  7254. * Fallen leaves fall.
  7255. *------------------------------------------
  7256. */
  7257. int
  7258. atcommand_leaves(
  7259. const int fd, struct map_session_data* sd,
  7260. const char* command, const char* message)
  7261. {
  7262. nullpo_retr(-1, sd);
  7263. if (map[sd->bl.m].flag.leaves) {
  7264. map[sd->bl.m].flag.leaves=0;
  7265. clif_weather(sd->bl.m);
  7266. clif_displaymessage(fd, "Leaves no longer fall.");
  7267. } else {
  7268. map[sd->bl.m].flag.leaves=1;
  7269. clif_weather(sd->bl.m);
  7270. clif_displaymessage(fd, "Fallen leaves fall.");
  7271. }
  7272. return 0;
  7273. }
  7274. /*==========================================
  7275. * Fireworks appear.
  7276. *------------------------------------------
  7277. */
  7278. int
  7279. atcommand_fireworks(
  7280. const int fd, struct map_session_data* sd,
  7281. const char* command, const char* message)
  7282. {
  7283. nullpo_retr(-1, sd);
  7284. if (map[sd->bl.m].flag.fireworks) {
  7285. map[sd->bl.m].flag.fireworks=0;
  7286. clif_weather(sd->bl.m);
  7287. clif_displaymessage(fd, "Fireworks are ended.");
  7288. } else {
  7289. map[sd->bl.m].flag.fireworks=1;
  7290. clif_weather(sd->bl.m);
  7291. clif_displaymessage(fd, "Fireworks are launched.");
  7292. }
  7293. return 0;
  7294. }
  7295. /*==========================================
  7296. * Clearing Weather Effects by Dexity
  7297. *------------------------------------------
  7298. */
  7299. int
  7300. atcommand_clearweather(
  7301. const int fd, struct map_session_data* sd,
  7302. const char* command, const char* message)
  7303. {
  7304. nullpo_retr(-1, sd);
  7305. map[sd->bl.m].flag.rain=0;
  7306. map[sd->bl.m].flag.snow=0;
  7307. map[sd->bl.m].flag.sakura=0;
  7308. map[sd->bl.m].flag.clouds=0;
  7309. map[sd->bl.m].flag.clouds2=0;
  7310. map[sd->bl.m].flag.fog=0;
  7311. map[sd->bl.m].flag.fireworks=0;
  7312. map[sd->bl.m].flag.leaves=0;
  7313. clif_weather(sd->bl.m);
  7314. clif_displaymessage(fd, msg_txt(291));
  7315. return 0;
  7316. }
  7317. /*===============================================================
  7318. * Sound Command - plays a sound for everyone! [Codemaster]
  7319. *---------------------------------------------------------------
  7320. */
  7321. int
  7322. atcommand_sound(
  7323. const int fd, struct map_session_data *sd,
  7324. const char *command, const char *message)
  7325. {
  7326. char sound_file[100];
  7327. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  7328. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  7329. return -1;
  7330. }
  7331. malloc_tsetdword(sound_file, '\0', sizeof(sound_file));
  7332. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  7333. return -1;
  7334. if(strstr(sound_file, ".wav") == NULL)
  7335. strcat(sound_file, ".wav");
  7336. clif_soundeffectall(&sd->bl, sound_file,0,2);
  7337. return 0;
  7338. }
  7339. /*==========================================
  7340. * MOB Search
  7341. *------------------------------------------
  7342. */
  7343. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  7344. {
  7345. int mob_id,fd;
  7346. static int number=0;
  7347. struct mob_data *md;
  7348. nullpo_retr(0, bl);
  7349. if(!ap){
  7350. number=0;
  7351. return 0;
  7352. }
  7353. mob_id = va_arg(ap,int);
  7354. fd = va_arg(ap,int);
  7355. md = (struct mob_data *)bl;
  7356. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7357. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7358. ++number,bl->x, bl->y,md->name);
  7359. clif_displaymessage(fd, atcmd_output);
  7360. }
  7361. return 0;
  7362. }
  7363. int atcommand_mobsearch(
  7364. const int fd, struct map_session_data* sd,
  7365. const char* command, const char* message)
  7366. {
  7367. char mob_name[100];
  7368. int mob_id,map_id = 0;
  7369. nullpo_retr(-1, sd);
  7370. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7371. return -1;
  7372. if ((mob_id = atoi(mob_name)) == 0)
  7373. mob_id = mobdb_searchname(mob_name);
  7374. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7375. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7376. clif_displaymessage(fd, atcmd_output);
  7377. return 0;
  7378. }
  7379. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7380. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7381. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7382. map_id = sd->bl.m;
  7383. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7384. mob_name, mapindex_id2name(sd->mapindex));
  7385. clif_displaymessage(fd, atcmd_output);
  7386. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7387. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7388. return 0;
  7389. }
  7390. /*==========================================
  7391. * ドロップアイテムの掃除
  7392. *------------------------------------------
  7393. */
  7394. /*==========================================
  7395. * cleanmap
  7396. *------------------------------------------
  7397. */
  7398. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7399. {
  7400. nullpo_retr(0, bl);
  7401. map_clearflooritem(bl->id);
  7402. return 0;
  7403. }
  7404. int
  7405. atcommand_cleanmap(
  7406. const int fd, struct map_session_data* sd,
  7407. const char* command, const char* message)
  7408. {
  7409. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7410. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7411. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7412. BL_ITEM);
  7413. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7414. return 0;
  7415. }
  7416. /*==========================================
  7417. * NPC/PETに話させる
  7418. *------------------------------------------
  7419. */
  7420. int
  7421. atcommand_npctalk(
  7422. const int fd, struct map_session_data* sd,
  7423. const char* command, const char* message)
  7424. {
  7425. char name[NAME_LENGTH],mes[100],temp[100];
  7426. struct npc_data *nd;
  7427. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7428. return -1;
  7429. if (!(nd = npc_name2id(name)))
  7430. return -1;
  7431. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7432. clif_message(&nd->bl, temp);
  7433. return 0;
  7434. }
  7435. int
  7436. atcommand_pettalk(
  7437. const int fd, struct map_session_data* sd,
  7438. const char* command, const char* message)
  7439. {
  7440. char mes[100],temp[100];
  7441. struct pet_data *pd;
  7442. nullpo_retr(-1, sd);
  7443. if(!sd->status.pet_id || !(pd=sd->pd))
  7444. return -1;
  7445. if (sd->sc.count && //no "chatting" while muted.
  7446. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7447. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7448. return -1;
  7449. if (sscanf(message, "%99[^\n]", mes) < 1)
  7450. return -1;
  7451. snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
  7452. clif_message(&pd->bl, temp);
  7453. return 0;
  7454. }
  7455. /*==========================================
  7456. * @users
  7457. * サーバー内の人数マップを表示させる
  7458. * 手抜きのため汚くなっているのは仕様です。
  7459. *------------------------------------------
  7460. */
  7461. static struct dbt *users_db = NULL;
  7462. static int users_all;
  7463. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7464. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7465. users_all++;
  7466. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7467. return 0;
  7468. }
  7469. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7470. char buf[256];
  7471. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7472. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7473. clif_displaymessage(sd->fd,buf);
  7474. return 0;
  7475. }
  7476. int
  7477. atcommand_users(
  7478. const int fd, struct map_session_data* sd,
  7479. const char* command, const char* message)
  7480. {
  7481. char buf[256];
  7482. users_all = 0;
  7483. users_db->clear(users_db, NULL);
  7484. clif_foreachclient(atcommand_users_sub1);
  7485. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7486. sprintf(buf,"all : %d",users_all);
  7487. clif_displaymessage(fd,buf);
  7488. return 0;
  7489. }
  7490. int
  7491. atcommand_reset(
  7492. const int fd, struct map_session_data* sd,
  7493. const char* command, const char* message)
  7494. {
  7495. pc_resetstate(sd);
  7496. pc_resetskill(sd,1);
  7497. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  7498. clif_displaymessage(fd, atcmd_output);
  7499. return 0;
  7500. }
  7501. /*==========================================
  7502. *
  7503. *------------------------------------------
  7504. */
  7505. int
  7506. atcommand_summon(
  7507. const int fd, struct map_session_data* sd,
  7508. const char* command, const char* message)
  7509. {
  7510. char name[NAME_LENGTH];
  7511. int mob_id = 0;
  7512. int duration = 0;
  7513. struct mob_data *md;
  7514. unsigned int tick=gettick();
  7515. nullpo_retr(-1, sd);
  7516. if (!message || !*message)
  7517. return -1;
  7518. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7519. return -1;
  7520. if (duration < 1)
  7521. duration =1;
  7522. else if (duration > 60)
  7523. duration =60;
  7524. if ((mob_id = atoi(name)) == 0)
  7525. mob_id = mobdb_searchname(name);
  7526. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7527. return -1;
  7528. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7529. if(md){
  7530. md->master_id=sd->bl.id;
  7531. md->special_state.ai=1;
  7532. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  7533. clif_misceffect2(&md->bl,344);
  7534. mob_spawn(md);
  7535. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7536. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7537. }
  7538. return 0;
  7539. }
  7540. /*==========================================
  7541. * @adjcmdlvl by [MouseJstr]
  7542. *
  7543. * Temp adjust the GM level required to use a GM command
  7544. *
  7545. * Used during beta testing to allow players to use GM commands
  7546. * for short periods of time
  7547. *------------------------------------------
  7548. */
  7549. int
  7550. atcommand_adjcmdlvl(
  7551. const int fd, struct map_session_data* sd,
  7552. const char* command, const char* message)
  7553. {
  7554. int i, newlev;
  7555. char cmd[100];
  7556. nullpo_retr(-1, sd);
  7557. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7558. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7559. return -1;
  7560. }
  7561. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7562. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7563. atcommand_info[i].level = newlev;
  7564. clif_displaymessage(fd, "@command level changed.");
  7565. return 0;
  7566. }
  7567. clif_displaymessage(fd, "@command not found.");
  7568. return -1;
  7569. }
  7570. /*==========================================
  7571. * @adjgmlvl by [MouseJstr]
  7572. *
  7573. * Create a temp GM
  7574. *
  7575. * Used during beta testing to allow players to use GM commands
  7576. * for short periods of time
  7577. *------------------------------------------
  7578. */
  7579. int
  7580. atcommand_adjgmlvl(
  7581. const int fd, struct map_session_data* sd,
  7582. const char* command, const char* message)
  7583. {
  7584. int newlev;
  7585. char user[NAME_LENGTH];
  7586. struct map_session_data *pl_sd;
  7587. nullpo_retr(-1, sd);
  7588. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7589. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7590. return -1;
  7591. }
  7592. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7593. return -1;
  7594. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7595. return 0;
  7596. }
  7597. /*==========================================
  7598. * @trade by [MouseJstr]
  7599. *
  7600. * Open a trade window with a remote player
  7601. *
  7602. * If I have to jump to a remote player one more time, I am
  7603. * gonna scream!
  7604. *------------------------------------------
  7605. */
  7606. int
  7607. atcommand_trade(
  7608. const int fd, struct map_session_data* sd,
  7609. const char* command, const char* message)
  7610. {
  7611. struct map_session_data *pl_sd = NULL;
  7612. nullpo_retr(-1, sd);
  7613. if (!message || !*message)
  7614. return -1;
  7615. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7616. trade_traderequest(sd, pl_sd);
  7617. return 0;
  7618. }
  7619. return -1;
  7620. }
  7621. /*==========================================
  7622. * @setbattleflag by [MouseJstr]
  7623. *
  7624. * set a battle_config flag without having to reboot
  7625. */
  7626. int
  7627. atcommand_setbattleflag(
  7628. const int fd, struct map_session_data* sd,
  7629. const char* command, const char* message)
  7630. {
  7631. char flag[128], value[128];
  7632. nullpo_retr(-1, sd);
  7633. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7634. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7635. return -1;
  7636. }
  7637. if (battle_set_value(flag, value) == 0)
  7638. clif_displaymessage(fd, "unknown battle_config flag");
  7639. else
  7640. clif_displaymessage(fd, "battle_config set as requested");
  7641. return 0;
  7642. }
  7643. /*===========================
  7644. * @unmute [Valaris]
  7645. *===========================
  7646. */
  7647. int atcommand_unmute(
  7648. const int fd, struct map_session_data* sd,
  7649. const char* command, const char* message)
  7650. {
  7651. struct map_session_data *pl_sd = NULL;
  7652. nullpo_retr(-1, sd);
  7653. if (!message || !*message)
  7654. return -1;
  7655. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7656. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7657. pl_sd->status.manner = 0;
  7658. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7659. clif_displaymessage(sd->fd,"Player unmuted");
  7660. }
  7661. else
  7662. clif_displaymessage(sd->fd,"Player is not muted");
  7663. }
  7664. return 0;
  7665. }
  7666. /*==========================================
  7667. * @uptime by MC Cameri
  7668. *------------------------------------------
  7669. */
  7670. int
  7671. atcommand_uptime(
  7672. const int fd, struct map_session_data* sd,
  7673. const char* command, const char* message)
  7674. {
  7675. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7676. minute = 60, days = 0, hours = 0, minutes = 0;
  7677. nullpo_retr(-1, sd);
  7678. seconds = get_uptime();
  7679. days = seconds/day;
  7680. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7681. hours = seconds/hour;
  7682. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7683. minutes = seconds/minute;
  7684. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7685. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  7686. clif_displaymessage(fd, atcmd_output);
  7687. return 0;
  7688. }
  7689. /*==========================================
  7690. * @changesex <sex>
  7691. * => Changes one's sex. Argument sex can be
  7692. * 0 or 1, m or f, male or female.
  7693. *------------------------------------------
  7694. */
  7695. int
  7696. atcommand_changesex(
  7697. const int fd, struct map_session_data* sd,
  7698. const char* command, const char* message)
  7699. {
  7700. nullpo_retr(-1, sd);
  7701. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7702. return 0;
  7703. }
  7704. /*================================================
  7705. * @mute - Mutes a player for a set amount of time
  7706. *------------------------------------------------
  7707. */
  7708. int atcommand_mute(
  7709. const int fd, struct map_session_data* sd,
  7710. const char* command, const char* message)
  7711. {
  7712. struct map_session_data *pl_sd = NULL;
  7713. int manner;
  7714. nullpo_retr(-1, sd);
  7715. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7716. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7717. return -1;
  7718. }
  7719. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7720. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7721. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7722. return -1;
  7723. }
  7724. clif_GM_silence(sd, pl_sd, 0);
  7725. pl_sd->status.manner -= manner;
  7726. if(pl_sd->status.manner < 0)
  7727. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7728. }
  7729. else {
  7730. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7731. return -1;
  7732. }
  7733. return 0;
  7734. }
  7735. /*==========================================
  7736. * @refresh (like @jumpto <<yourself>>)
  7737. *------------------------------------------
  7738. */
  7739. int atcommand_refresh(
  7740. const int fd, struct map_session_data* sd,
  7741. const char* command, const char* message)
  7742. {
  7743. nullpo_retr(-1, sd);
  7744. clif_refresh(sd);
  7745. return 0;
  7746. }
  7747. /*==========================================
  7748. * @petid <part of pet name>
  7749. * => Displays a list of matching pets.
  7750. *------------------------------------------
  7751. */
  7752. int
  7753. atcommand_petid(const int fd, struct map_session_data* sd,
  7754. const char* command, const char* message)
  7755. {
  7756. char searchtext[100];
  7757. char temp0[100];
  7758. char temp1[100];
  7759. int cnt = 0, i = 0;
  7760. nullpo_retr(-1, sd);
  7761. if (!message || !*message)
  7762. return -1;
  7763. if (sscanf(message, "%99s", searchtext) < 1)
  7764. return -1;
  7765. estr_lower(searchtext);
  7766. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7767. clif_displaymessage(fd,temp0);
  7768. while (i < MAX_PET_DB) {
  7769. strcpy(temp1,pet_db[i].name);
  7770. strcpy(temp1, estr_lower(temp1));
  7771. strcpy(temp0,pet_db[i].jname);
  7772. strcpy(temp0, estr_lower(temp1));
  7773. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7774. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7775. pet_db[i].jname);
  7776. if (cnt >= 100) { // Only if there are custom pets
  7777. clif_displaymessage(fd, "Be more specific, can't send more than"
  7778. " 100 results.");
  7779. } else {
  7780. clif_displaymessage(fd, temp0);
  7781. }
  7782. cnt++;
  7783. }
  7784. i++;
  7785. }
  7786. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7787. clif_displaymessage(fd, temp0);
  7788. return 0;
  7789. }
  7790. /*==========================================
  7791. * @identify
  7792. * => GM's magnifier.
  7793. *------------------------------------------
  7794. */
  7795. int
  7796. atcommand_identify(
  7797. const int fd, struct map_session_data* sd,
  7798. const char* command, const char* message)
  7799. {
  7800. int i,num;
  7801. nullpo_retr(-1, sd);
  7802. for(i=num=0;i<MAX_INVENTORY;i++){
  7803. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7804. num++;
  7805. }
  7806. }
  7807. if (num > 0) {
  7808. clif_item_identify_list(sd);
  7809. } else {
  7810. clif_displaymessage(fd,"There are no items to appraise.");
  7811. }
  7812. return 0;
  7813. }
  7814. /*==========================================
  7815. * @gmotd (Global MOTD)
  7816. * by davidsiaw :P
  7817. *------------------------------------------
  7818. */
  7819. int
  7820. atcommand_gmotd(
  7821. const int fd, struct map_session_data* sd,
  7822. const char* command, const char* message)
  7823. {
  7824. char buf[256];
  7825. FILE *fp;
  7826. nullpo_retr(-1, sd);
  7827. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7828. while (fgets(buf, 250, fp) != NULL){
  7829. int i;
  7830. for( i=0; buf[i]; i++){
  7831. if( buf[i]=='\r' || buf[i]=='\n'){
  7832. buf[i]=0;
  7833. break;
  7834. }
  7835. }
  7836. intif_GMmessage(buf,strlen(buf)+1,8);
  7837. }
  7838. fclose(fp);
  7839. }
  7840. return 0;
  7841. }
  7842. int atcommand_misceffect(
  7843. const int fd, struct map_session_data* sd,
  7844. const char* command, const char* message)
  7845. {
  7846. int effect = 0;
  7847. nullpo_retr(-1, sd);
  7848. if (!message || !*message)
  7849. return -1;
  7850. if (sscanf(message, "%d", &effect) < 1)
  7851. return -1;
  7852. clif_misceffect(&sd->bl,effect);
  7853. return 0;
  7854. }
  7855. int charid2sessionid(int charid)
  7856. {
  7857. struct map_session_data *pl_sd = NULL;
  7858. pl_sd = map_charid2sd(charid);
  7859. if (pl_sd) return pl_sd->fd;
  7860. return 0;
  7861. }
  7862. int accountid2sessionid(int accountid)
  7863. {
  7864. struct map_session_data *pl_sd = NULL;
  7865. pl_sd = map_id2sd(accountid);
  7866. if (pl_sd) return pl_sd->fd;
  7867. return 0;
  7868. }
  7869. /*==========================================
  7870. * Jump to a player by PID number
  7871. * Original by Dino9021
  7872. * Added in by nsstrunks
  7873. *------------------------------------------
  7874. */
  7875. int atcommand_jumptoid(
  7876. const int fd, struct map_session_data* sd,
  7877. const char* command, const char* message)
  7878. {
  7879. int cid=0;
  7880. int session_id=0;
  7881. struct map_session_data *pl_sd;
  7882. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7883. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  7884. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7885. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7886. return -1;
  7887. }
  7888. cid=atoi(message);
  7889. if ((session_id=charid2sessionid(cid))!=0)
  7890. {
  7891. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7892. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7893. clif_displaymessage(fd, msg_txt(247));
  7894. return -1;
  7895. }
  7896. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7897. clif_displaymessage(fd, msg_txt(248));
  7898. return -1;
  7899. }
  7900. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7901. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7902. clif_displaymessage(fd, atcmd_output);
  7903. } else {
  7904. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7905. return -1;
  7906. }
  7907. }
  7908. else
  7909. {
  7910. clif_displaymessage(fd,msg_txt(3));
  7911. }
  7912. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7913. return 0;
  7914. }
  7915. /*==========================================
  7916. * Jump to a player by PID number
  7917. * Original by Dino9021
  7918. * Added in by nsstrunks
  7919. *------------------------------------------
  7920. */
  7921. int atcommand_jumptoid2(
  7922. const int fd, struct map_session_data* sd,
  7923. const char* command, const char* message)
  7924. {
  7925. int aid=0;
  7926. int session_id=0;
  7927. struct map_session_data *pl_sd;
  7928. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7929. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  7930. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7931. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7932. return -1;
  7933. }
  7934. aid=atoi(message);
  7935. if ((session_id=accountid2sessionid(aid))!=0)
  7936. {
  7937. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7938. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7939. clif_displaymessage(fd, msg_txt(247));
  7940. return -1;
  7941. }
  7942. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7943. clif_displaymessage(fd, msg_txt(248));
  7944. return -1;
  7945. }
  7946. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7947. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7948. clif_displaymessage(fd, atcmd_output);
  7949. } else {
  7950. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7951. return -1;
  7952. }
  7953. }
  7954. else
  7955. {
  7956. clif_displaymessage(fd,msg_txt(3));
  7957. }
  7958. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7959. return 0;
  7960. }
  7961. /*==========================================
  7962. * Recall a player by PID number
  7963. * Original by Dino9021
  7964. * Added in by nsstrunks
  7965. *------------------------------------------
  7966. */
  7967. int atcommand_recallid(
  7968. const int fd, struct map_session_data* sd,
  7969. const char* command, const char* message)
  7970. {
  7971. int cid=0;
  7972. int session_id=0;
  7973. struct map_session_data *pl_sd;
  7974. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7975. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  7976. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7977. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7978. return -1;
  7979. }
  7980. cid=atoi(message);
  7981. if ((session_id=charid2sessionid(cid))!=0)
  7982. {
  7983. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7984. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7985. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7986. clif_displaymessage(fd, msg_txt(247));
  7987. return -1;
  7988. }
  7989. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7990. clif_displaymessage(fd, msg_txt(248));
  7991. return -1;
  7992. }
  7993. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7994. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  7995. clif_displaymessage(fd, atcmd_output);
  7996. } else {
  7997. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7998. return -1;
  7999. }
  8000. } else {
  8001. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  8002. return -1;
  8003. }
  8004. }
  8005. else
  8006. {
  8007. clif_displaymessage(fd,msg_txt(3));
  8008. }
  8009. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8010. return 0;
  8011. }
  8012. /*==========================================
  8013. * Recall a player by PID number
  8014. * Original by Dino9021
  8015. * Added in by nsstrunks
  8016. *------------------------------------------
  8017. */
  8018. int atcommand_recallid2(
  8019. const int fd, struct map_session_data* sd,
  8020. const char* command, const char* message)
  8021. {
  8022. int aid=0;
  8023. int session_id=0;
  8024. struct map_session_data *pl_sd;
  8025. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8026. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  8027. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8028. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  8029. return -1;
  8030. }
  8031. aid=atoi(message);
  8032. if ((session_id=accountid2sessionid(aid))!=0)
  8033. {
  8034. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8035. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  8036. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  8037. clif_displaymessage(fd, msg_txt(247));
  8038. return -1;
  8039. }
  8040. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  8041. clif_displaymessage(fd, msg_txt(248));
  8042. return -1;
  8043. }
  8044. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  8045. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  8046. clif_displaymessage(fd, atcmd_output);
  8047. } else {
  8048. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8049. return -1;
  8050. }
  8051. } else {
  8052. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  8053. return -1;
  8054. }
  8055. }
  8056. else
  8057. {
  8058. clif_displaymessage(fd,msg_txt(3));
  8059. }
  8060. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8061. return 0;
  8062. }
  8063. /*==========================================
  8064. * Kick a player by PID number
  8065. * Original by Dino9021
  8066. * Added in by nsstrunks
  8067. *------------------------------------------
  8068. */
  8069. int atcommand_kickid(
  8070. const int fd, struct map_session_data* sd,
  8071. const char* command, const char* message)
  8072. {
  8073. struct map_session_data *pl_sd;
  8074. int cid=0;
  8075. int session_id=0;
  8076. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8077. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8078. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  8079. return -1;
  8080. }
  8081. cid=atoi(message);
  8082. if ((session_id=charid2sessionid(cid))!=0)
  8083. {
  8084. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8085. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  8086. clif_GM_kick(sd, pl_sd, 1);
  8087. else {
  8088. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8089. return -1;
  8090. }
  8091. } else {
  8092. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8093. return -1;
  8094. }
  8095. }
  8096. else
  8097. {
  8098. clif_displaymessage(fd,msg_txt(3));
  8099. }
  8100. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8101. return 0;
  8102. }
  8103. /*==========================================
  8104. * Kick a player by PID number
  8105. * Original by Dino9021
  8106. * Added in by nsstrunks
  8107. *------------------------------------------
  8108. */
  8109. int atcommand_kickid2(
  8110. const int fd, struct map_session_data* sd,
  8111. const char* command, const char* message)
  8112. {
  8113. struct map_session_data *pl_sd;
  8114. int aid=0;
  8115. int session_id=0;
  8116. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8117. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8118. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  8119. return -1;
  8120. }
  8121. aid=atoi(message);
  8122. if ((session_id=accountid2sessionid(aid))!=0)
  8123. {
  8124. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8125. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  8126. clif_GM_kick(sd, pl_sd, 1);
  8127. else {
  8128. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8129. return -1;
  8130. }
  8131. } else {
  8132. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8133. return -1;
  8134. }
  8135. }
  8136. else
  8137. {
  8138. clif_displaymessage(fd,msg_txt(3));
  8139. }
  8140. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8141. return 0;
  8142. }
  8143. /*==========================================
  8144. * Revive a player by PID number
  8145. * Original by Dino9021
  8146. * Added in by nsstrunks
  8147. *------------------------------------------
  8148. */
  8149. int atcommand_reviveid(
  8150. const int fd, struct map_session_data* sd,
  8151. const char* command, const char* message)
  8152. {
  8153. int cid=0;
  8154. int session_id=0;
  8155. struct map_session_data *pl_sd;
  8156. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8157. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8158. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  8159. return -1;
  8160. }
  8161. cid=atoi(message);
  8162. if ((session_id=charid2sessionid(cid))!=0)
  8163. {
  8164. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8165. pl_sd->status.hp = pl_sd->status.max_hp;
  8166. pc_setstand(pl_sd);
  8167. if (battle_config.pc_invincible_time > 0)
  8168. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  8169. clif_updatestatus(pl_sd, SP_HP);
  8170. clif_updatestatus(pl_sd, SP_SP);
  8171. clif_resurrection(&pl_sd->bl, 1);
  8172. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  8173. } else {
  8174. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8175. return -1;
  8176. }
  8177. }
  8178. else
  8179. {
  8180. clif_displaymessage(fd,msg_txt(3));
  8181. }
  8182. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8183. return 0;
  8184. }
  8185. /*==========================================
  8186. * Revive a player by PID number
  8187. * Original by Dino9021
  8188. * Added in by nsstrunks
  8189. *------------------------------------------
  8190. */
  8191. int atcommand_reviveid2(
  8192. const int fd, struct map_session_data* sd,
  8193. const char* command, const char* message)
  8194. {
  8195. int aid=0;
  8196. int session_id=0;
  8197. struct map_session_data *pl_sd;
  8198. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8199. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8200. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  8201. return -1;
  8202. }
  8203. aid=atoi(message);
  8204. if ((session_id=accountid2sessionid(aid))!=0)
  8205. {
  8206. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8207. pl_sd->status.hp = pl_sd->status.max_hp;
  8208. pc_setstand(pl_sd);
  8209. if (battle_config.pc_invincible_time > 0)
  8210. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  8211. clif_updatestatus(pl_sd, SP_HP);
  8212. clif_updatestatus(pl_sd, SP_SP);
  8213. clif_resurrection(&pl_sd->bl, 1);
  8214. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  8215. } else {
  8216. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8217. return -1;
  8218. }
  8219. }
  8220. else
  8221. {
  8222. clif_displaymessage(fd,msg_txt(3));
  8223. }
  8224. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8225. return 0;
  8226. }
  8227. /*==========================================
  8228. * Kill a player by PID number
  8229. * Original by Dino9021
  8230. * Added in by nsstrunks
  8231. *------------------------------------------
  8232. */
  8233. int atcommand_killid(
  8234. const int fd, struct map_session_data* sd,
  8235. const char* command, const char* message)
  8236. {
  8237. int cid=0;
  8238. int session_id=0;
  8239. struct map_session_data *pl_sd;
  8240. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8241. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8242. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  8243. return -1;
  8244. }
  8245. cid=atoi(message);
  8246. if ((session_id=charid2sessionid(cid))!=0)
  8247. {
  8248. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8249. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  8250. status_kill(&pl_sd->bl);
  8251. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  8252. } else {
  8253. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8254. return -1;
  8255. }
  8256. } else {
  8257. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8258. return -1;
  8259. }
  8260. }
  8261. else
  8262. {
  8263. clif_displaymessage(fd,msg_txt(3));
  8264. }
  8265. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8266. return 0;
  8267. }
  8268. /*==========================================
  8269. * Kill a player by PID number
  8270. * Original by Dino9021
  8271. * Added in by nsstrunks
  8272. *------------------------------------------
  8273. */
  8274. int atcommand_killid2(
  8275. const int fd, struct map_session_data* sd,
  8276. const char* command, const char* message)
  8277. {
  8278. int aid=0;
  8279. int session_id=0;
  8280. struct map_session_data *pl_sd;
  8281. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8282. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8283. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  8284. return -1;
  8285. }
  8286. aid=atoi(message);
  8287. if ((session_id=accountid2sessionid(aid))!=0)
  8288. {
  8289. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8290. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  8291. status_kill(&pl_sd->bl);
  8292. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  8293. } else {
  8294. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8295. return -1;
  8296. }
  8297. } else {
  8298. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8299. return -1;
  8300. }
  8301. }
  8302. else
  8303. {
  8304. clif_displaymessage(fd,msg_txt(3));
  8305. }
  8306. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8307. return 0;
  8308. }
  8309. /*==========================================
  8310. * Make a player killable, by PID
  8311. * Original by Dino9021
  8312. * Added in by nsstrunks
  8313. *------------------------------------------
  8314. */
  8315. int
  8316. atcommand_charkillableid(
  8317. const int fd, struct map_session_data* sd,
  8318. const char* command, const char* message)
  8319. {
  8320. struct map_session_data *pl_sd = NULL;
  8321. int cid=0;
  8322. int session_id=0;
  8323. if (!message || (cid = atoi(message)) == 0 || !*message)
  8324. return -1;
  8325. cid=atoi(message);
  8326. if ((session_id=charid2sessionid(cid))!=0)
  8327. {
  8328. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8329. return -1;
  8330. pl_sd->state.killable = !pl_sd->state.killable;
  8331. if(pl_sd->state.killable)
  8332. clif_displaymessage(fd, msg_txt(289));
  8333. else
  8334. clif_displaymessage(fd, msg_txt(290));
  8335. }
  8336. else
  8337. clif_displaymessage(fd,msg_txt(3));
  8338. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8339. return 0;
  8340. }
  8341. /*==========================================
  8342. * Make a player killable, by PID
  8343. * Original by Dino9021
  8344. * Added in by nsstrunks
  8345. *------------------------------------------
  8346. */
  8347. int
  8348. atcommand_charkillableid2(
  8349. const int fd, struct map_session_data* sd,
  8350. const char* command, const char* message)
  8351. {
  8352. struct map_session_data *pl_sd = NULL;
  8353. int aid=0;
  8354. int session_id=0;
  8355. if (!message || (aid = atoi(message)) == 0 || !*message)
  8356. return -1;
  8357. aid=atoi(message);
  8358. if ((session_id=accountid2sessionid(aid))!=0)
  8359. {
  8360. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8361. return -1;
  8362. pl_sd->state.killable = !pl_sd->state.killable;
  8363. if(pl_sd->state.killable)
  8364. clif_displaymessage(fd, msg_txt(289));
  8365. else
  8366. clif_displaymessage(fd, msg_txt(290));
  8367. }
  8368. else
  8369. clif_displaymessage(fd,msg_txt(3));
  8370. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8371. return 0;
  8372. }
  8373. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8374. /*==========================================
  8375. * Mail System commands by [Valaris]
  8376. *------------------------------------------
  8377. */
  8378. int atcommand_listmail(
  8379. const int fd, struct map_session_data* sd,
  8380. const char* command, const char* message)
  8381. {
  8382. if(!mail_server_enable)
  8383. return 0;
  8384. nullpo_retr(-1, sd);
  8385. if(strlen(command)==12)
  8386. mail_check(sd,3);
  8387. else if(strlen(command)==9)
  8388. mail_check(sd,2);
  8389. else
  8390. mail_check(sd,1);
  8391. return 0;
  8392. }
  8393. int atcommand_readmail(
  8394. const int fd, struct map_session_data* sd,
  8395. const char* command, const char* message)
  8396. {
  8397. int index;
  8398. if(!mail_server_enable)
  8399. return 0;
  8400. nullpo_retr(-1, sd);
  8401. if (!message || !*message) {
  8402. clif_displaymessage(sd->fd,"You must specify a message number.");
  8403. return 0;
  8404. }
  8405. index = atoi(message);
  8406. if (index < 1) {
  8407. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8408. return 0;
  8409. }
  8410. if(strlen(command)==11)
  8411. mail_delete(sd,index);
  8412. else
  8413. mail_read(sd,index);
  8414. return 0;
  8415. }
  8416. int atcommand_sendmail(
  8417. const int fd, struct map_session_data* sd,
  8418. const char* command, const char* message)
  8419. {
  8420. char name[NAME_LENGTH],text[80];
  8421. if(!mail_server_enable)
  8422. return 0;
  8423. nullpo_retr(-1, sd);
  8424. if (!message || !*message) {
  8425. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8426. return 0;
  8427. }
  8428. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8429. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8430. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8431. return 0;
  8432. }
  8433. if(strlen(command)==17)
  8434. mail_send(sd,name,text,1);
  8435. else
  8436. mail_send(sd,name,text,0);
  8437. return 0;
  8438. }
  8439. /*==========================================
  8440. * Refresh online command for SQL [Valaris]
  8441. * Will refresh and check online column of
  8442. * players and set correctly.
  8443. *------------------------------------------
  8444. */
  8445. int atcommand_refreshonline(
  8446. const int fd, struct map_session_data* sd,
  8447. const char* command, const char* message)
  8448. {
  8449. send_users_tochar(-1, gettick(), 0, 0);
  8450. return 0;
  8451. }
  8452. #endif /* end sql only */
  8453. /*==========================================
  8454. * Show Monster DB Info v 1.0
  8455. * originally by [Lupus] eAthena
  8456. *------------------------------------------
  8457. */
  8458. int atcommand_mobinfo(
  8459. const int fd, struct map_session_data* sd,
  8460. const char* command, const char* message)
  8461. {
  8462. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8463. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8464. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8465. char atcmd_output2[200];
  8466. struct item_data *item_data;
  8467. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8468. int count;
  8469. int i, j, k;
  8470. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  8471. malloc_tsetdword(atcmd_output2, '\0', sizeof(atcmd_output2));
  8472. if (!message || !*message) {
  8473. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8474. return -1;
  8475. }
  8476. // If monster identifier/name argument is a name
  8477. if ((i = mobdb_checkid(atoi(message))))
  8478. {
  8479. mob_array[0] = mob_db(i);
  8480. count = 1;
  8481. } else
  8482. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8483. if (!count) {
  8484. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  8485. return -1;
  8486. }
  8487. if (count > MAX_SEARCH) {
  8488. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8489. clif_displaymessage(fd, atcmd_output);
  8490. count = MAX_SEARCH;
  8491. }
  8492. for (k = 0; k < count; k++) {
  8493. mob = mob_array[k];
  8494. // stats
  8495. if (mob->mexp)
  8496. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  8497. else
  8498. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  8499. clif_displaymessage(fd, atcmd_output);
  8500. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  8501. clif_displaymessage(fd, atcmd_output);
  8502. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  8503. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  8504. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  8505. clif_displaymessage(fd, atcmd_output);
  8506. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  8507. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  8508. mob->range2 , mob->range3, msize[mob->status.size],
  8509. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  8510. clif_displaymessage(fd, atcmd_output);
  8511. // drops
  8512. clif_displaymessage(fd, " Drops:");
  8513. strcpy(atcmd_output, " ");
  8514. j = 0;
  8515. for (i = 0; i < MAX_MOB_DROP; i++) {
  8516. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8517. continue;
  8518. if (item_data->slot)
  8519. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  8520. else
  8521. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  8522. strcat(atcmd_output, atcmd_output2);
  8523. if (++j % 3 == 0) {
  8524. clif_displaymessage(fd, atcmd_output);
  8525. strcpy(atcmd_output, " ");
  8526. }
  8527. }
  8528. if (j == 0)
  8529. clif_displaymessage(fd, "This monster has no drops.");
  8530. else if (j % 3 != 0)
  8531. clif_displaymessage(fd, atcmd_output);
  8532. // mvp
  8533. if (mob->mexp) {
  8534. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8535. clif_displaymessage(fd, atcmd_output);
  8536. strcpy(atcmd_output, " MVP Items:");
  8537. j = 0;
  8538. for (i = 0; i < 3; i++) {
  8539. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8540. continue;
  8541. if (mob->mvpitem[i].p > 0) {
  8542. j++;
  8543. if (j == 1)
  8544. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8545. else
  8546. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8547. strcat(atcmd_output, atcmd_output2);
  8548. }
  8549. }
  8550. if (j == 0)
  8551. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8552. else
  8553. clif_displaymessage(fd, atcmd_output);
  8554. }
  8555. }
  8556. return 0;
  8557. }
  8558. /*=========================================
  8559. * @showmobs by KarLaeda
  8560. * => For 5 sec displays the mobs on minimap
  8561. *------------------------------------------
  8562. */
  8563. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  8564. {
  8565. struct map_session_data *sd;
  8566. if (!session[id] || (sd = session[id]->session_data) == NULL)
  8567. return 0;
  8568. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  8569. return 1;
  8570. }
  8571. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  8572. {
  8573. int mob_id,fd;
  8574. struct map_session_data* sd;
  8575. static int number=0;
  8576. struct mob_data *md;
  8577. if(!ap){
  8578. number=0;
  8579. return 0;
  8580. }
  8581. mob_id = va_arg(ap,int);
  8582. fd = va_arg(ap,int);
  8583. sd = va_arg(ap,struct map_session_data*);
  8584. md = (struct mob_data *)bl;
  8585. if(md->special_state.ai || md->master_id)
  8586. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  8587. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  8588. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  8589. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  8590. }
  8591. return 0;
  8592. }
  8593. int atcommand_showmobs(
  8594. const int fd, struct map_session_data* sd,
  8595. const char* command, const char* message)
  8596. {
  8597. char mob_name[100];
  8598. int mob_id,map_id = 0;
  8599. nullpo_retr(-1, sd);
  8600. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  8601. return -1;
  8602. if ((mob_id = atoi(mob_name)) == 0)
  8603. mob_id = mobdb_searchname(mob_name);
  8604. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  8605. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  8606. clif_displaymessage(fd, atcmd_output);
  8607. return 0;
  8608. }
  8609. // Uncomment the following line to show mini-bosses & MVP.
  8610. //#define SHOW_MVP
  8611. #ifndef SHOW_MVP
  8612. if(mob_db(mob_id)->status.mode&MD_BOSS){
  8613. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  8614. clif_displaymessage(fd, atcmd_output);
  8615. return 0;
  8616. }
  8617. #endif
  8618. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  8619. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  8620. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  8621. map_id = sd->bl.m;
  8622. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  8623. mob_name, mapindex_id2name(sd->mapindex));
  8624. clif_displaymessage(fd, atcmd_output);
  8625. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  8626. atshowmobs_sub(&sd->bl,0);
  8627. return 0;
  8628. }
  8629. /*==========================================
  8630. * homunculus level up [orn]
  8631. *------------------------------------------
  8632. */
  8633. int atcommand_homlevel(
  8634. const int fd, struct map_session_data* sd,
  8635. const char* command, const char* message)
  8636. {
  8637. TBL_HOM * hd;
  8638. int level = 0, i = 0;
  8639. nullpo_retr(-1, sd);
  8640. if (!message || !*message)
  8641. return -1;
  8642. if ( !merc_is_hom_active(sd->hd) )
  8643. return 1 ;
  8644. level = atoi(message);
  8645. hd = sd->hd;
  8646. for (i = 1; i <= level && hd->exp_next; i++){
  8647. sd->homunculus.exp += hd->exp_next;
  8648. merc_hom_levelup(hd);
  8649. }
  8650. status_calc_homunculus(hd,0);
  8651. status_percent_heal(&hd->bl, 100, 100);
  8652. clif_misceffect2(&hd->bl,568);
  8653. return 0;
  8654. }
  8655. /*==========================================
  8656. * homunculus evolution H [orn]
  8657. *------------------------------------------
  8658. */
  8659. int atcommand_homevolution(
  8660. const int fd, struct map_session_data* sd,
  8661. const char* command, const char* message)
  8662. {
  8663. nullpo_retr(-1, sd);
  8664. if (sd->hd && sd->hd->homunculusDB->evo_class)
  8665. {
  8666. merc_hom_evolution(sd->hd) ;
  8667. }
  8668. return 0;
  8669. }
  8670. /*==========================================
  8671. * call choosen homunculus [orn]
  8672. *------------------------------------------
  8673. */
  8674. int
  8675. atcommand_makehomun(
  8676. const int fd, struct map_session_data* sd,
  8677. const char* command, const char* message)
  8678. {
  8679. int homunid;
  8680. nullpo_retr(-1, sd);
  8681. if(sscanf(message, "%d", &homunid)<1)
  8682. return -1;
  8683. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  8684. return -1;
  8685. if(sd->status.hom_id == 0)
  8686. {
  8687. merc_create_homunculus_request(sd,homunid);
  8688. }
  8689. else
  8690. {
  8691. clif_displaymessage(fd,msg_txt(450));
  8692. }
  8693. return 0;
  8694. }
  8695. /*==========================================
  8696. * modify homunculus intimacy [orn]
  8697. *------------------------------------------
  8698. */
  8699. int atcommand_homfriendly(
  8700. const int fd, struct map_session_data* sd,
  8701. const char* command, const char* message)
  8702. {
  8703. int friendly = 0;
  8704. nullpo_retr(-1, sd);
  8705. if (!message || !*message)
  8706. return -1;
  8707. friendly = atoi(message);
  8708. if (merc_is_hom_active(sd->hd)) {
  8709. if (friendly > 0 && friendly <= 1000) {
  8710. sd->homunculus.intimacy = friendly * 100 ;
  8711. clif_send_homdata(sd,SP_INTIMATE,friendly);
  8712. } else {
  8713. return -1;
  8714. }
  8715. }
  8716. return 0;
  8717. }
  8718. /*==========================================
  8719. * modify homunculus hunger [orn]
  8720. *------------------------------------------
  8721. */
  8722. int atcommand_homhungry(
  8723. const int fd, struct map_session_data* sd,
  8724. const char* command, const char* message)
  8725. {
  8726. int hungry = 0;
  8727. nullpo_retr(-1, sd);
  8728. if (!message || !*message)
  8729. return -1;
  8730. hungry = atoi(message);
  8731. if (sd->status.hom_id > 0 && sd->hd) {
  8732. if (hungry >= 0 && hungry <= 100) {
  8733. sd->homunculus.hunger = hungry;
  8734. clif_send_homdata(sd,SP_HUNGRY,sd->homunculus.hunger);
  8735. } else {
  8736. return -1;
  8737. }
  8738. }
  8739. return 0;
  8740. }
  8741. /*==========================================
  8742. * modify homunculus hunger [orn]
  8743. *------------------------------------------
  8744. */
  8745. int atcommand_homtalk(
  8746. const int fd, struct map_session_data* sd,
  8747. const char* command, const char* message)
  8748. {
  8749. char mes[100],temp[100];
  8750. nullpo_retr(-1, sd);
  8751. if(!sd->status.hom_id || !sd->hd || !sd->homunculus.hp)
  8752. return -1;
  8753. if (sscanf(message, "%99[^\n]", mes) < 1)
  8754. return -1;
  8755. snprintf(temp, sizeof temp ,"%s : %s",sd->homunculus.name,mes);
  8756. clif_message(&sd->hd->bl, temp);
  8757. return 0;
  8758. }
  8759. /*==========================================
  8760. * Show homunculus stats
  8761. *------------------------------------------
  8762. */
  8763. int atcommand_hominfo(
  8764. const int fd, struct map_session_data* sd,
  8765. const char* command, const char* message)
  8766. {
  8767. nullpo_retr(-1, sd);
  8768. if(!merc_is_hom_active(sd->hd))
  8769. return -1;
  8770. clif_displaymessage(fd, "Homunculus stats :");
  8771. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d", sd->hd->battle_status.hp, sd->hd->battle_status.max_hp, sd->hd->battle_status.sp, sd->hd->battle_status.max_sp);
  8772. clif_displaymessage(fd, atcmd_output);
  8773. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d", sd->hd->battle_status.rhw.atk2+sd->hd->battle_status.batk, sd->hd->battle_status.matk_min, sd->hd->battle_status.matk_max);
  8774. clif_displaymessage(fd, atcmd_output);
  8775. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u", sd->homunculus.hunger, sd->homunculus.intimacy);
  8776. clif_displaymessage(fd, atcmd_output);
  8777. return 0;
  8778. }
  8779. /*==========================================
  8780. * Show Items DB Info v 1.0
  8781. * originally by [Lupus] eAthena
  8782. *------------------------------------------
  8783. */
  8784. int atcommand_iteminfo(
  8785. const int fd, struct map_session_data* sd,
  8786. const char* command, const char* message)
  8787. {
  8788. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8789. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8790. struct item_data *item_data, *item_array[MAX_SEARCH];
  8791. int i, count = 1;
  8792. if (!message || !*message) {
  8793. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8794. return -1;
  8795. }
  8796. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8797. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8798. if (!count) {
  8799. clif_displaymessage(fd, "Item not found.");
  8800. return -1;
  8801. }
  8802. if (count > MAX_SEARCH) {
  8803. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8804. clif_displaymessage(fd, atcmd_output);
  8805. count = MAX_SEARCH;
  8806. }
  8807. for (i = 0; i < count; i++) {
  8808. item_data = item_array[i];
  8809. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8810. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  8811. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8812. (item_data->script==NULL)? "None" : "With script"
  8813. );
  8814. clif_displaymessage(fd, atcmd_output);
  8815. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
  8816. clif_displaymessage(fd, atcmd_output);
  8817. if (item_data->maxchance == 10000)
  8818. strcpy(atcmd_output, " - Available in the shops only");
  8819. else if (item_data->maxchance)
  8820. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8821. else
  8822. strcpy(atcmd_output, " - Monsters don't drop this item");
  8823. clif_displaymessage(fd, atcmd_output);
  8824. }
  8825. return 0;
  8826. }
  8827. /*==========================================
  8828. * Show who drops the item.
  8829. *------------------------------------------
  8830. */
  8831. int atcommand_whodrops(
  8832. const int fd, struct map_session_data* sd,
  8833. const char* command, const char* message)
  8834. {
  8835. struct item_data *item_data, *item_array[MAX_SEARCH];
  8836. int i,j, count = 1;
  8837. if (!message || !*message) {
  8838. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8839. return -1;
  8840. }
  8841. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8842. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8843. if (!count) {
  8844. clif_displaymessage(fd, "Item not found.");
  8845. return -1;
  8846. }
  8847. if (count > MAX_SEARCH) {
  8848. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8849. clif_displaymessage(fd, atcmd_output);
  8850. count = MAX_SEARCH;
  8851. }
  8852. for (i = 0; i < count; i++) {
  8853. item_data = item_array[i];
  8854. sprintf(atcmd_output, "Item: '%s'[%d]",
  8855. item_data->jname,item_data->slot);
  8856. clif_displaymessage(fd, atcmd_output);
  8857. if (item_data->mob[0].chance == 0) {
  8858. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8859. clif_displaymessage(fd, atcmd_output);
  8860. } else {
  8861. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8862. clif_displaymessage(fd, atcmd_output);
  8863. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8864. {
  8865. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8866. clif_displaymessage(fd, atcmd_output);
  8867. }
  8868. }
  8869. }
  8870. return 0;
  8871. }
  8872. /*==========================================
  8873. * @adopt by [Veider]
  8874. *
  8875. * adopt a novice
  8876. *------------------------------------------
  8877. */
  8878. int
  8879. atcommand_adopt(const int fd, struct map_session_data* sd,
  8880. const char* command, const char* message)
  8881. {
  8882. struct map_session_data *pl_sd1 = NULL;
  8883. struct map_session_data *pl_sd2 = NULL;
  8884. struct map_session_data *pl_sd3 = NULL;
  8885. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8886. nullpo_retr(-1, sd);
  8887. if (!message || !*message)
  8888. return -1;
  8889. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8890. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8891. return -1;
  8892. }
  8893. if (battle_config.etc_log)
  8894. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8895. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8896. sprintf(player2, "Cannot find player %s online", player1);
  8897. clif_displaymessage(fd, player2);
  8898. return -1;
  8899. }
  8900. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8901. sprintf(player1, "Cannot find player %s online", player2);
  8902. clif_displaymessage(fd, player1);
  8903. return -1;
  8904. }
  8905. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8906. sprintf(player1, "Cannot find player %s online", player3);
  8907. clif_displaymessage(fd, player1);
  8908. return -1;
  8909. }
  8910. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8911. clif_displaymessage(fd, "They are too young to be parents!");
  8912. return -1;
  8913. }
  8914. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8915. clif_displaymessage(fd, "They are family.. wish them luck");
  8916. return 0;
  8917. }
  8918. else
  8919. return -1;
  8920. }
  8921. int atcommand_version(
  8922. const int fd, struct map_session_data* sd,
  8923. const char* command, const char* message)
  8924. {
  8925. const char * revision;
  8926. if ((revision = get_svn_revision()) != 0) {
  8927. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8928. clif_displaymessage(fd,atcmd_output);
  8929. } else
  8930. clif_displaymessage(fd,"Cannot determine SVN revision");
  8931. return 0;
  8932. }
  8933. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8934. {
  8935. int time, id;
  8936. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8937. if (pl_sd == NULL)
  8938. return 0;
  8939. id = va_arg(ap, int);
  8940. time = va_arg(ap, int);
  8941. if (id != bl->id && !pc_isGM(pl_sd)) {
  8942. pl_sd->status.manner -= time;
  8943. if (pl_sd->status.manner < 0)
  8944. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8945. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8946. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8947. }
  8948. return 0;
  8949. }
  8950. /*==========================================
  8951. * @mutearea by MouseJstr
  8952. *------------------------------------------
  8953. */
  8954. int atcommand_mutearea(
  8955. const int fd, struct map_session_data* sd,
  8956. const char* command, const char* message)
  8957. {
  8958. int time;
  8959. nullpo_retr(0, sd);
  8960. time = atoi(message);
  8961. if (!time)
  8962. time = 15; // 15 minutes default
  8963. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8964. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8965. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8966. return 0;
  8967. }
  8968. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8969. {
  8970. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8971. if (bl == NULL)
  8972. return 0;
  8973. if (!pc_isGM(pl_sd))
  8974. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8975. return 0;
  8976. }
  8977. /*==========================================
  8978. * @shuffle by MouseJstr
  8979. *------------------------------------------
  8980. */
  8981. int atcommand_shuffle(
  8982. const int fd, struct map_session_data* sd,
  8983. const char* command, const char* message)
  8984. {
  8985. nullpo_retr(0, sd);
  8986. if (strcmp(message, "area")== 0) {
  8987. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8988. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8989. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8990. } else if (strcmp(message, "map")== 0) {
  8991. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8992. } else if (strcmp(message, "world") == 0) {
  8993. struct map_session_data **pl_allsd;
  8994. int i, users;
  8995. pl_allsd = map_getallusers(&users);
  8996. for (i = 0; i < users; i++)
  8997. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8998. } else
  8999. clif_displaymessage(fd, "options are area, map, or world");
  9000. return 0;
  9001. }
  9002. int atcommand_rates(
  9003. const int fd, struct map_session_data* sd,
  9004. const char* command, const char* message)
  9005. {
  9006. char buf[255];
  9007. nullpo_retr(0, sd);
  9008. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  9009. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  9010. clif_displaymessage(fd, buf);
  9011. return 0;
  9012. }
  9013. /*==========================================
  9014. * @me by lordalfa
  9015. * => Displays the OUTPUT string on top of
  9016. * the Visible players Heads.
  9017. *------------------------------------------
  9018. */
  9019. int atcommand_me(
  9020. const int fd, struct map_session_data* sd,
  9021. const char* command, const char* message)
  9022. {
  9023. char tempmes[200];
  9024. nullpo_retr(-1, sd);
  9025. malloc_tsetdword(tempmes, '\0', sizeof(tempmes));
  9026. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  9027. if (sd->sc.count && //no "chatting" while muted.
  9028. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  9029. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  9030. return -1;
  9031. if (!message || !*message) {
  9032. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  9033. return -1;
  9034. }
  9035. sscanf(message, "%199[^\n]", tempmes);
  9036. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  9037. clif_disp_overhead(sd, atcmd_output);
  9038. return 0;
  9039. }
  9040. /*==========================================
  9041. * @size
  9042. * => Resize your character sprite. [Valaris]
  9043. *------------------------------------------
  9044. */
  9045. int atcommand_size(
  9046. const int fd, struct map_session_data* sd,
  9047. const char* command, const char* message)
  9048. {
  9049. int size=0;
  9050. nullpo_retr(-1, sd);
  9051. if (!message || !*message)
  9052. return -1;
  9053. if (sscanf(message,"%d", &size) < 1)
  9054. return -1;
  9055. if(sd->state.size) {
  9056. sd->state.size=0;
  9057. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  9058. }
  9059. if(size==1) {
  9060. sd->state.size=1;
  9061. clif_specialeffect(&sd->bl,420,AREA);
  9062. } else if(size==2) {
  9063. sd->state.size=2;
  9064. clif_specialeffect(&sd->bl,422,AREA);
  9065. }
  9066. return 0;
  9067. }
  9068. /*==========================================
  9069. * @monsterignore
  9070. * => Makes monsters ignore you. [Valaris]
  9071. *------------------------------------------
  9072. */
  9073. int atcommand_monsterignore(
  9074. const int fd, struct map_session_data* sd,
  9075. const char* command, const char* message)
  9076. {
  9077. nullpo_retr(-1, sd);
  9078. if (!sd->state.monster_ignore) {
  9079. sd->state.monster_ignore = 1;
  9080. clif_displaymessage(sd->fd, "You are now inmune to attacks.");
  9081. } else {
  9082. sd->state.monster_ignore = 0;
  9083. clif_displaymessage(sd->fd, "Returned to normal state.");
  9084. }
  9085. return 0;
  9086. }
  9087. /*==========================================
  9088. * @fakename
  9089. * => Gives your character a fake name. [Valaris]
  9090. *------------------------------------------
  9091. */
  9092. int atcommand_fakename(
  9093. const int fd, struct map_session_data* sd,
  9094. const char* command, const char* message)
  9095. {
  9096. char name[NAME_LENGTH];
  9097. nullpo_retr(-1, sd);
  9098. if((!message || !*message) && strlen(sd->fakename) > 1) {
  9099. sd->fakename[0]='\0';
  9100. clif_charnameack(0, &sd->bl);
  9101. clif_displaymessage(sd->fd,"Returned to real name.");
  9102. return 0;
  9103. }
  9104. if (!message || !*message) {
  9105. clif_displaymessage(sd->fd,"You must enter a name.");
  9106. return 0;
  9107. }
  9108. if (sscanf(message, "%23[^\n]", name) < 1) {
  9109. return 0;
  9110. }
  9111. if(strlen(name) < 2) {
  9112. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  9113. return 0;
  9114. }
  9115. memcpy(sd->fakename,name,NAME_LENGTH-1);
  9116. clif_charnameack(0, &sd->bl);
  9117. clif_displaymessage(sd->fd,"Fake name enabled.");
  9118. return 0;
  9119. }
  9120. /*==========================================
  9121. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  9122. * => Shows information about the map flags [map name]
  9123. * Also set flags
  9124. *------------------------------------------
  9125. */
  9126. int atcommand_mapflag(
  9127. const int fd, struct map_session_data* sd,
  9128. const char* command, const char* message)
  9129. {
  9130. // WIP
  9131. return 0;
  9132. }
  9133. /*===================================
  9134. * Remove some messages
  9135. *-----------------------------------
  9136. */
  9137. int atcommand_showexp(
  9138. const int fd, struct map_session_data* sd,
  9139. const char* command, const char* message)
  9140. {
  9141. if (sd->state.showexp) {
  9142. sd->state.showexp = 0;
  9143. clif_displaymessage(fd, "Gained exp will not be shown.");
  9144. return 0;
  9145. }
  9146. sd->state.showexp = 1;
  9147. clif_displaymessage(fd, "Gained exp is now shown");
  9148. return 0;
  9149. }
  9150. int atcommand_showzeny(
  9151. const int fd, struct map_session_data* sd,
  9152. const char* command, const char* message)
  9153. {
  9154. if (sd->state.showzeny) {
  9155. sd->state.showzeny = 0;
  9156. clif_displaymessage(fd, "Gained zeny will not be shown.");
  9157. return 0;
  9158. }
  9159. sd->state.showzeny = 1;
  9160. clif_displaymessage(fd, "Gained zeny is now shown");
  9161. return 0;
  9162. }
  9163. int atcommand_showdelay(
  9164. const int fd, struct map_session_data* sd,
  9165. const char* command, const char* message)
  9166. {
  9167. if (sd->state.showdelay) {
  9168. sd->state.showdelay = 0;
  9169. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  9170. return 0;
  9171. }
  9172. sd->state.showdelay = 1;
  9173. clif_displaymessage(fd, "Skill delay failures are shown now.");
  9174. return 0;
  9175. }
  9176. /*==========================================
  9177. * Duel organizing functions [LuzZza]
  9178. *
  9179. * @duel [limit|nick] - create a duel
  9180. * @invite <nick> - invite player
  9181. * @accept - accept invitation
  9182. * @reject - reject invitation
  9183. * @leave - leave duel
  9184. *------------------------------------------
  9185. */
  9186. int atcommand_invite(
  9187. const int fd, struct map_session_data* sd,
  9188. const char* command, const char* message)
  9189. {
  9190. unsigned int did = sd->duel_group;
  9191. struct map_session_data *target_sd = map_nick2sd((char *)message);
  9192. if(did <= 0) {
  9193. // "Duel: @invite without @duel."
  9194. clif_displaymessage(fd, msg_txt(350));
  9195. return 0;
  9196. }
  9197. if(duel_list[did].max_players_limit > 0 &&
  9198. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  9199. // "Duel: Limit of players is reached."
  9200. clif_displaymessage(fd, msg_txt(351));
  9201. return 0;
  9202. }
  9203. if(target_sd == NULL) {
  9204. // "Duel: Player not found."
  9205. clif_displaymessage(fd, msg_txt(352));
  9206. return 0;
  9207. }
  9208. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9209. // "Duel: Player already in duel."
  9210. clif_displaymessage(fd, msg_txt(353));
  9211. return 0;
  9212. }
  9213. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  9214. {
  9215. sprintf(atcmd_output, msg_txt(364), message);
  9216. clif_displaymessage(fd, atcmd_output);
  9217. return 0;
  9218. }
  9219. duel_invite(did, sd, target_sd);
  9220. // "Duel: Invitation has been sent."
  9221. clif_displaymessage(fd, msg_txt(354));
  9222. return 0;
  9223. }
  9224. int atcommand_duel(
  9225. const int fd, struct map_session_data* sd,
  9226. const char* command, const char* message)
  9227. {
  9228. char output[256];
  9229. unsigned int maxpl=0, newduel;
  9230. struct map_session_data *target_sd;
  9231. /* // Commnted because it can be disabled in at-comms conf.
  9232. if(!battle_config.duel_enable) {
  9233. clif_displaymessage(fd, "Duel: duel is disable.");
  9234. return 0;
  9235. }
  9236. */
  9237. if(sd->duel_group > 0) {
  9238. duel_showinfo(sd->duel_group, sd);
  9239. return 0;
  9240. }
  9241. if(sd->duel_invite > 0) {
  9242. // "Duel: @duel without @reject."
  9243. clif_displaymessage(fd, msg_txt(355));
  9244. return 0;
  9245. }
  9246. if(!duel_checktime(sd)) {
  9247. // "Duel: You can take part in duel only one time per %d minutes."
  9248. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9249. clif_displaymessage(fd, output);
  9250. return 0;
  9251. }
  9252. if(strlen(message) > 0) {
  9253. if(sscanf(message, "%d", &maxpl) >= 1) {
  9254. if(maxpl < 2 || maxpl > 65535) {
  9255. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  9256. return 0;
  9257. }
  9258. duel_create(sd, maxpl);
  9259. } else {
  9260. target_sd = map_nick2sd((char *)message);
  9261. if(target_sd != NULL) {
  9262. if((newduel = duel_create(sd, 2)) != -1) {
  9263. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9264. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  9265. return 0;
  9266. }
  9267. duel_invite(newduel, sd, target_sd);
  9268. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  9269. }
  9270. } else {
  9271. // "Duel: Player not found."
  9272. clif_displaymessage(fd, msg_txt(352));
  9273. return 0;
  9274. }
  9275. }
  9276. } else
  9277. duel_create(sd, 0);
  9278. return 0;
  9279. }
  9280. int atcommand_leave(
  9281. const int fd, struct map_session_data* sd,
  9282. const char* command, const char* message)
  9283. {
  9284. if(sd->duel_group <= 0) {
  9285. // "Duel: @leave without @duel."
  9286. clif_displaymessage(fd, msg_txt(358));
  9287. return 0;
  9288. }
  9289. duel_leave(sd->duel_group, sd);
  9290. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  9291. return 0;
  9292. }
  9293. int atcommand_accept(
  9294. const int fd, struct map_session_data* sd,
  9295. const char* command, const char* message)
  9296. {
  9297. char output[256];
  9298. if(!duel_checktime(sd)) {
  9299. // "Duel: You can take part in duel only one time per %d minutes."
  9300. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9301. clif_displaymessage(fd, output);
  9302. return 0;
  9303. }
  9304. if(sd->duel_invite <= 0) {
  9305. // "Duel: @accept without invititation."
  9306. clif_displaymessage(fd, msg_txt(360));
  9307. return 0;
  9308. }
  9309. duel_accept(sd->duel_invite, sd);
  9310. // "Duel: Invitation has been accepted."
  9311. clif_displaymessage(fd, msg_txt(361));
  9312. return 0;
  9313. }
  9314. int atcommand_reject(
  9315. const int fd, struct map_session_data* sd,
  9316. const char* command, const char* message)
  9317. {
  9318. if(sd->duel_invite <= 0) {
  9319. // "Duel: @reject without invititation."
  9320. clif_displaymessage(fd, msg_txt(362));
  9321. return 0;
  9322. }
  9323. duel_reject(sd->duel_invite, sd);
  9324. // "Duel: Invitation has been rejected."
  9325. clif_displaymessage(fd, msg_txt(363));
  9326. return 0;
  9327. }
  9328. /*===================================
  9329. * Away message (@away, @aw) [LuzZza]
  9330. *-----------------------------------
  9331. */
  9332. int atcommand_away(
  9333. const int fd, struct map_session_data* sd,
  9334. const char* command, const char* message)
  9335. {
  9336. if(strlen(message) > 0) {
  9337. if(strlen(message) > 128)
  9338. return -1;
  9339. strcpy(sd->away_message, message);
  9340. //"Away automessage has been activated."
  9341. clif_displaymessage(fd, msg_txt(546));
  9342. } else {
  9343. if(strlen(sd->away_message) > 0) {
  9344. sd->away_message[0] = 0;
  9345. //"Away automessage has been disabled."
  9346. clif_displaymessage(fd, msg_txt(547));
  9347. return 0;
  9348. }
  9349. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  9350. clif_displaymessage(fd, msg_txt(548));
  9351. }
  9352. return 0;
  9353. }
  9354. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  9355. int atcommand_clone(
  9356. const int fd, struct map_session_data* sd,
  9357. const char* command, const char* message)
  9358. {
  9359. int x=0,y=0,flag=0,master=0,i=0;
  9360. struct map_session_data *pl_sd=NULL;
  9361. if (!message || !*message) {
  9362. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  9363. return 0;
  9364. }
  9365. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  9366. clif_displaymessage(fd, msg_txt(3));
  9367. return 0;
  9368. }
  9369. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  9370. clif_displaymessage(fd, msg_txt(126));
  9371. return 0;
  9372. }
  9373. if (strcmpi(command, "@clone") == 0)
  9374. flag = 1;
  9375. else if (strcmpi(command, "@slaveclone") == 0) {
  9376. flag = 2;
  9377. master = sd->bl.id;
  9378. if (battle_config.atc_slave_clone_limit
  9379. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  9380. clif_displaymessage(fd, msg_txt(127));
  9381. return 0;
  9382. }
  9383. }
  9384. do {
  9385. x = sd->bl.x + (rand() % 10 - 5);
  9386. y = sd->bl.y + (rand() % 10 - 5);
  9387. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  9388. if (i >= 10) {
  9389. x = sd->bl.x;
  9390. y = sd->bl.y;
  9391. }
  9392. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  9393. clif_displaymessage(fd, msg_txt(128+flag*2));
  9394. return 0;
  9395. }
  9396. clif_displaymessage(fd, msg_txt(129+flag*2));
  9397. return 0;
  9398. }
  9399. /*===================================
  9400. * Main chat [LuzZza]
  9401. * Usage: @main <on|off|message>
  9402. *-----------------------------------
  9403. */
  9404. int atcommand_main(
  9405. const int fd, struct map_session_data* sd,
  9406. const char* command, const char* message)
  9407. {
  9408. if(strlen(message) > 0) {
  9409. if(strcmpi(message, "on") == 0) {
  9410. if(!sd->state.mainchat) {
  9411. sd->state.mainchat = 1;
  9412. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  9413. } else {
  9414. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  9415. }
  9416. } else if(strcmpi(message, "off") == 0) {
  9417. if(sd->state.mainchat) {
  9418. sd->state.mainchat = 0;
  9419. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  9420. } else {
  9421. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  9422. }
  9423. } else {
  9424. if(!sd->state.mainchat) {
  9425. sd->state.mainchat = 1;
  9426. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  9427. }
  9428. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  9429. clif_displaymessage(fd, msg_txt(387));
  9430. return -1;
  9431. }
  9432. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  9433. // I use 0xFE000000 color for signalizing that this message is
  9434. // main chat message. 0xFE000000 is invalid color, same using
  9435. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  9436. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  9437. }
  9438. } else {
  9439. if(sd->state.mainchat)
  9440. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  9441. clif_displaymessage(fd, msg_txt(384));
  9442. else
  9443. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  9444. clif_displaymessage(fd, msg_txt(385));
  9445. }
  9446. return 0;
  9447. }
  9448. /*=====================================
  9449. * Autorejecting Invites/Deals [LuzZza]
  9450. * Usage: @noask
  9451. *-------------------------------------
  9452. */
  9453. int atcommand_noask(
  9454. const int fd, struct map_session_data* sd,
  9455. const char* command, const char* message)
  9456. {
  9457. if(sd->state.noask) {
  9458. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  9459. sd->state.noask = 0;
  9460. } else {
  9461. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  9462. sd->state.noask = 1;
  9463. }
  9464. return 0;
  9465. }
  9466. /*=====================================
  9467. * Send a @request message to all GMs of lowest_gm_level.
  9468. * Usage: @request <petition>
  9469. *-------------------------------------
  9470. */
  9471. int atcommand_request(
  9472. const int fd, struct map_session_data* sd,
  9473. const char* command, const char* message)
  9474. {
  9475. if (!message || !*message) {
  9476. clif_displaymessage(sd->fd,msg_txt(277));
  9477. return -1;
  9478. }
  9479. sprintf(atcmd_output, msg_txt(278), message);
  9480. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  9481. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  9482. clif_displaymessage(sd->fd,msg_txt(279));
  9483. return 0;
  9484. }
  9485. void do_init_atcommand() {
  9486. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  9487. duel_count = 0;
  9488. malloc_tsetdword(&duel_list[0], 0, sizeof(duel_list));
  9489. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  9490. return;
  9491. }
  9492. void do_final_atcommand() {
  9493. users_db->destroy(users_db,NULL);
  9494. }