atcommand.c 314 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include "../common/cbasetypes.h"
  9. #include "../common/mmo.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/core.h"
  13. #include "../common/showmsg.h"
  14. #include "../common/malloc.h"
  15. #include "../common/socket.h"
  16. #include "atcommand.h"
  17. #include "log.h"
  18. #include "clif.h"
  19. #include "chrif.h"
  20. #include "intif.h"
  21. #include "itemdb.h"
  22. #include "map.h"
  23. #include "pc.h"
  24. #include "status.h"
  25. #include "skill.h"
  26. #include "mob.h"
  27. #include "pet.h"
  28. #include "mercenary.h" //[orn]
  29. #include "battle.h"
  30. #include "party.h"
  31. #include "guild.h"
  32. #include "script.h"
  33. #include "npc.h"
  34. #include "trade.h"
  35. #include "unit.h"
  36. #ifndef TXT_ONLY
  37. #include "mail.h"
  38. #endif
  39. char atcommand_symbol = '@'; // first char of the commands (by [Yor])
  40. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  41. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  42. ACMD_FUNC(broadcast);
  43. ACMD_FUNC(localbroadcast);
  44. ACMD_FUNC(rura);
  45. ACMD_FUNC(where);
  46. ACMD_FUNC(jumpto);
  47. ACMD_FUNC(jump);
  48. ACMD_FUNC(who);
  49. ACMD_FUNC(who2);
  50. ACMD_FUNC(who3);
  51. ACMD_FUNC(whomap);
  52. ACMD_FUNC(whomap2);
  53. ACMD_FUNC(whomap3);
  54. ACMD_FUNC(whogm); // by Yor
  55. ACMD_FUNC(whozeny); // [Valaris]
  56. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  57. ACMD_FUNC(save);
  58. ACMD_FUNC(load);
  59. ACMD_FUNC(speed);
  60. ACMD_FUNC(charspeed);
  61. ACMD_FUNC(storage);
  62. ACMD_FUNC(guildstorage);
  63. ACMD_FUNC(option);
  64. ACMD_FUNC(hide);
  65. ACMD_FUNC(jobchange);
  66. ACMD_FUNC(die);
  67. ACMD_FUNC(kill);
  68. ACMD_FUNC(alive);
  69. ACMD_FUNC(kami);
  70. ACMD_FUNC(heal);
  71. ACMD_FUNC(item);
  72. ACMD_FUNC(item2);
  73. ACMD_FUNC(itemreset);
  74. ACMD_FUNC(baselevelup);
  75. ACMD_FUNC(joblevelup);
  76. ACMD_FUNC(help);
  77. ACMD_FUNC(help2);
  78. ACMD_FUNC(gm);
  79. ACMD_FUNC(pvpoff);
  80. ACMD_FUNC(pvpon);
  81. ACMD_FUNC(gvgoff);
  82. ACMD_FUNC(gvgon);
  83. ACMD_FUNC(model);
  84. ACMD_FUNC(go);
  85. ACMD_FUNC(monster);
  86. ACMD_FUNC(monstersmall);
  87. ACMD_FUNC(monsterbig);
  88. ACMD_FUNC(spawn);
  89. ACMD_FUNC(killmonster);
  90. ACMD_FUNC(killmonster2);
  91. ACMD_FUNC(refine);
  92. ACMD_FUNC(produce);
  93. ACMD_FUNC(memo);
  94. ACMD_FUNC(gat);
  95. ACMD_FUNC(packet);
  96. ACMD_FUNC(waterlevel);
  97. ACMD_FUNC(statuspoint);
  98. ACMD_FUNC(skillpoint);
  99. ACMD_FUNC(zeny);
  100. ACMD_FUNC(param);
  101. ACMD_FUNC(guildlevelup);
  102. ACMD_FUNC(makeegg);
  103. ACMD_FUNC(hatch);
  104. ACMD_FUNC(petfriendly);
  105. ACMD_FUNC(pethungry);
  106. ACMD_FUNC(petrename);
  107. ACMD_FUNC(recall);
  108. ACMD_FUNC(recallall);
  109. ACMD_FUNC(revive);
  110. ACMD_FUNC(night);
  111. ACMD_FUNC(day);
  112. ACMD_FUNC(doom);
  113. ACMD_FUNC(doommap);
  114. ACMD_FUNC(raise);
  115. ACMD_FUNC(raisemap);
  116. ACMD_FUNC(kick);
  117. ACMD_FUNC(kickall);
  118. ACMD_FUNC(allskill);
  119. ACMD_FUNC(questskill);
  120. ACMD_FUNC(lostskill);
  121. ACMD_FUNC(spiritball);
  122. ACMD_FUNC(party);
  123. ACMD_FUNC(guild);
  124. ACMD_FUNC(agitstart);
  125. ACMD_FUNC(agitend);
  126. ACMD_FUNC(reloaditemdb);
  127. ACMD_FUNC(reloadmobdb);
  128. ACMD_FUNC(reloadskilldb);
  129. ACMD_FUNC(reloadscript);
  130. ACMD_FUNC(reloadgmdb); // by Yor
  131. ACMD_FUNC(reloadatcommand);
  132. ACMD_FUNC(reloadbattleconf);
  133. ACMD_FUNC(reloadstatusdb);
  134. ACMD_FUNC(reloadpcdb);
  135. ACMD_FUNC(reloadmotd); // [Valaris]
  136. ACMD_FUNC(mapexit);
  137. ACMD_FUNC(idsearch);
  138. ACMD_FUNC(mapinfo);
  139. ACMD_FUNC(dye); //** by fritz
  140. ACMD_FUNC(hair_style); //** by fritz
  141. ACMD_FUNC(hair_color); //** by fritz
  142. ACMD_FUNC(stat_all); //** by fritz
  143. ACMD_FUNC(char_block); // by Yor
  144. ACMD_FUNC(char_ban); // by Yor
  145. ACMD_FUNC(char_unblock); // by Yor
  146. ACMD_FUNC(char_unban); // by Yor
  147. ACMD_FUNC(mount_peco); // by Valaris
  148. ACMD_FUNC(char_mount_peco); // by Yor
  149. ACMD_FUNC(guildspy); // [Syrus22]
  150. ACMD_FUNC(partyspy); // [Syrus22]
  151. ACMD_FUNC(repairall); // [Valaris]
  152. ACMD_FUNC(guildrecall); // by Yor
  153. ACMD_FUNC(partyrecall); // by Yor
  154. ACMD_FUNC(nuke); // [Valaris]
  155. ACMD_FUNC(shownpc);
  156. ACMD_FUNC(hidenpc);
  157. ACMD_FUNC(loadnpc);
  158. ACMD_FUNC(unloadnpc);
  159. ACMD_FUNC(servertime); // by Yor
  160. ACMD_FUNC(chardelitem); // by Yor
  161. ACMD_FUNC(jail); // by Yor
  162. ACMD_FUNC(unjail); // by Yor
  163. ACMD_FUNC(jailfor); // Alias Meruru
  164. ACMD_FUNC(jailtime); // Coltaro
  165. ACMD_FUNC(charjailtime); // Coltaro
  166. ACMD_FUNC(disguise); // [Valaris]
  167. ACMD_FUNC(undisguise); // by Yor
  168. ACMD_FUNC(chardisguise); // Kalaspuff
  169. ACMD_FUNC(charundisguise); // Kalaspuff
  170. ACMD_FUNC(email); // by Yor
  171. ACMD_FUNC(effect);//by Apple
  172. ACMD_FUNC(character_cart_list); // by Yor
  173. ACMD_FUNC(addwarp); // by MouseJstr
  174. ACMD_FUNC(follow); // by MouseJstr
  175. ACMD_FUNC(skillon); // by MouseJstr
  176. ACMD_FUNC(skilloff); // by MouseJstr
  177. ACMD_FUNC(killer); // by MouseJstr
  178. ACMD_FUNC(npcmove); // by MouseJstr
  179. ACMD_FUNC(killable); // by MouseJstr
  180. ACMD_FUNC(charkillable); // by MouseJstr
  181. ACMD_FUNC(dropall); // by MouseJstr
  182. ACMD_FUNC(chardropall); // by MouseJstr
  183. ACMD_FUNC(storeall); // by MouseJstr
  184. ACMD_FUNC(charstoreall); // by MouseJstr
  185. ACMD_FUNC(skillid); // by MouseJstr
  186. ACMD_FUNC(useskill); // by MouseJstr
  187. ACMD_FUNC(summon);
  188. ACMD_FUNC(rain);
  189. ACMD_FUNC(snow);
  190. ACMD_FUNC(sakura);
  191. ACMD_FUNC(clouds);
  192. ACMD_FUNC(clouds2); // [Valaris]
  193. ACMD_FUNC(fog);
  194. ACMD_FUNC(fireworks);
  195. ACMD_FUNC(leaves);
  196. ACMD_FUNC(adjgmlvl); // by MouseJstr
  197. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  198. ACMD_FUNC(trade); // by MouseJstr
  199. ACMD_FUNC(send); // by davidsiaw
  200. ACMD_FUNC(setbattleflag); // by MouseJstr
  201. ACMD_FUNC(unmute); // [Valaris]
  202. ACMD_FUNC(clearweather); // Dexity
  203. ACMD_FUNC(uptime); // by MC Cameri
  204. ACMD_FUNC(changesex); // by MC Cameri
  205. ACMD_FUNC(mute); // celest
  206. ACMD_FUNC(refresh); // by MC Cameri
  207. ACMD_FUNC(petid); // by MC Cameri
  208. ACMD_FUNC(identify); // by MC Cameri
  209. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  210. ACMD_FUNC(misceffect); // by MC Cameri
  211. ACMD_FUNC(mobsearch);
  212. ACMD_FUNC(cleanmap);
  213. ACMD_FUNC(npctalk);
  214. ACMD_FUNC(pettalk);
  215. ACMD_FUNC(users);
  216. ACMD_FUNC(reset);
  217. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  218. #ifndef TXT_ONLY
  219. ACMD_FUNC(checkmail); // [Valaris]
  220. ACMD_FUNC(listmail); // [Valaris]
  221. ACMD_FUNC(listnewmail); // [Valaris]
  222. ACMD_FUNC(readmail); // [Valaris]
  223. ACMD_FUNC(sendmail); // [Valaris]
  224. ACMD_FUNC(sendprioritymail); // [Valaris]
  225. ACMD_FUNC(deletemail); // [Valaris]
  226. ACMD_FUNC(refreshonline); // [Valaris]
  227. #endif /* TXT_ONLY */
  228. ACMD_FUNC(skilltree); // by MouseJstr
  229. ACMD_FUNC(marry); // by MouseJstr
  230. ACMD_FUNC(divorce); // by MouseJstr
  231. ACMD_FUNC(grind); // by MouseJstr
  232. ACMD_FUNC(grind2); // by MouseJstr
  233. #ifdef DMALLOC
  234. ACMD_FUNC(dmstart); // by MouseJstr
  235. ACMD_FUNC(dmtick); // by MouseJstr
  236. #endif
  237. ACMD_FUNC(jumptoid); // by Dino9021
  238. ACMD_FUNC(jumptoid2); // by Dino9021
  239. ACMD_FUNC(recallid); // by Dino9021
  240. ACMD_FUNC(recallid2); // by Dino9021
  241. ACMD_FUNC(kickid); // by Dino9021
  242. ACMD_FUNC(kickid2); // by Dino9021
  243. ACMD_FUNC(reviveid); // by Dino9021
  244. ACMD_FUNC(reviveid2); // by Dino9021
  245. ACMD_FUNC(killid); // by Dino9021
  246. ACMD_FUNC(killid2); // by Dino9021
  247. ACMD_FUNC(charkillableid); // by Dino9021
  248. ACMD_FUNC(charkillableid2); // by Dino9021
  249. ACMD_FUNC(sound);
  250. ACMD_FUNC(undisguiseall);
  251. ACMD_FUNC(disguiseall);
  252. ACMD_FUNC(changelook);
  253. ACMD_FUNC(mobinfo); //by Lupus
  254. ACMD_FUNC(exp); // by Skotlex
  255. ACMD_FUNC(adopt); // by Veider
  256. ACMD_FUNC(version); // by Ancyker
  257. ACMD_FUNC(mutearea); // by MouseJstr
  258. ACMD_FUNC(shuffle); // by MouseJstr
  259. ACMD_FUNC(rates); // by MouseJstr
  260. ACMD_FUNC(iteminfo); // Lupus
  261. ACMD_FUNC(whodrops); //Skotlex
  262. ACMD_FUNC(mapflag); // Lupus
  263. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  264. ACMD_FUNC(monsterignore); // [Valaris]
  265. ACMD_FUNC(fakename); //[Valaris]
  266. ACMD_FUNC(size); //[Valaris]
  267. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  268. ACMD_FUNC(showzeny);
  269. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  270. ACMD_FUNC(autotrade);// durf
  271. ACMD_FUNC(changeleader);// [Skotlex]
  272. ACMD_FUNC(partyoption);// [Skotlex]
  273. ACMD_FUNC(changegm);// durf
  274. // Duel [LuzZza]
  275. ACMD_FUNC(invite);
  276. ACMD_FUNC(duel);
  277. ACMD_FUNC(leave);
  278. ACMD_FUNC(accept);
  279. ACMD_FUNC(reject);
  280. ACMD_FUNC(away); // LuzZza
  281. ACMD_FUNC(main); // LuzZza
  282. ACMD_FUNC(clone); // [Valaris]
  283. ACMD_FUNC(tonpc); // LuzZza
  284. ACMD_FUNC(commands); // [Skotlex]
  285. ACMD_FUNC(noask); //LuzZza
  286. ACMD_FUNC(request); //[Skotlex]
  287. ACMD_FUNC(homlevel); //[orn]
  288. ACMD_FUNC(homevolution); //[orn]
  289. ACMD_FUNC(makehomun); //[orn]
  290. ACMD_FUNC(homfriendly); //[orn]
  291. ACMD_FUNC(homhungry); //[orn]
  292. ACMD_FUNC(homtalk); //[orn]
  293. ACMD_FUNC(hominfo); //[Toms]
  294. ACMD_FUNC(homstats); //[Skotlex]
  295. ACMD_FUNC(showmobs); //KarLaeda
  296. /*==========================================
  297. *AtCommandInfo atcommand_info[]構造体の定義
  298. *------------------------------------------
  299. */
  300. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  301. // to set default level, read atcommand_athena.conf first please.
  302. static AtCommandInfo atcommand_info[] = {
  303. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  304. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  305. { AtCommand_Where, "@where", 1, atcommand_where },
  306. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  307. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  308. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  309. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  310. { AtCommand_Who, "@who", 20, atcommand_who },
  311. { AtCommand_Who, "@whois", 20, atcommand_who },
  312. { AtCommand_Who, "@w", 20, atcommand_who },
  313. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  314. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  315. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  316. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  317. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  318. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  319. { AtCommand_Save, "@save", 40, atcommand_save },
  320. { AtCommand_Load, "@return", 40, atcommand_load },
  321. { AtCommand_Load, "@load", 40, atcommand_load },
  322. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  323. { AtCommand_CharSpeed, "@charspeed", 40, atcommand_charspeed },
  324. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  325. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  326. { AtCommand_Option, "@option", 40, atcommand_option },
  327. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  328. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  329. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  330. { AtCommand_Die, "@die", 1, atcommand_die },
  331. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  332. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  333. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  334. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  335. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  336. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  337. { AtCommand_Item, "@item", 60, atcommand_item },
  338. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  339. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  340. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  341. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  342. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  343. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  344. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  345. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  346. { AtCommand_H, "@h", 20, atcommand_help },
  347. { AtCommand_Help, "@help", 20, atcommand_help },
  348. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  349. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  350. { AtCommand_GM, "@gm", 100,atcommand_gm },
  351. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  352. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  353. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  354. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  355. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  356. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  357. { AtCommand_Model, "@model", 20, atcommand_model },
  358. { AtCommand_Go, "@go", 10, atcommand_go },
  359. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  360. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  361. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  362. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  363. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  364. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  365. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  366. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  367. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  368. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  369. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  370. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  371. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  372. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  373. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  374. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  375. { AtCommand_Strength, "@str", 60, atcommand_param },
  376. { AtCommand_Agility, "@agi", 60, atcommand_param },
  377. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  378. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  379. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  380. { AtCommand_Luck, "@luk", 60, atcommand_param },
  381. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  382. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  383. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  384. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  385. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  386. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  387. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  388. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  389. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  390. { AtCommand_Night, "@night", 80, atcommand_night },
  391. { AtCommand_Day, "@day", 80, atcommand_day },
  392. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  393. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  394. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  395. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  396. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  397. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  398. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  399. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  400. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  401. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  402. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  403. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  404. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  405. { AtCommand_Party, "@party", 1, atcommand_party },
  406. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  407. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  408. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  409. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  410. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  411. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  412. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  413. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  414. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  415. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  416. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  417. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  418. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  419. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  420. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  421. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  422. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  423. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  424. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  425. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  426. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  427. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  428. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  429. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  430. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  431. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  432. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  433. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  434. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  435. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  436. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  437. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  438. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  439. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  440. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  441. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  442. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  443. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  444. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  445. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  446. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  447. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  448. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  449. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  450. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  451. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  452. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  453. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  454. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  455. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  456. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  457. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  458. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  459. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  460. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  461. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  462. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  463. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  464. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  465. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  466. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  467. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  468. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  469. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  470. { AtCommand_JailFor, "@jailfor", 20, atcommand_jailfor }, //Meruru
  471. { 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 ;))
  472. { AtCommand_CharJailTime, "@charjailtime", 20, atcommand_charjailtime },
  473. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  474. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  475. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  476. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  477. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  478. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  479. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  480. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  481. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  482. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  483. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  484. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  485. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  486. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  487. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  488. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  489. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  490. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  491. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  492. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  493. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  494. // { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
  495. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  496. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  497. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  498. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  499. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  500. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  501. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  502. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  503. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  504. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  505. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  506. { AtCommand_Send, "@send", 60, atcommand_send },
  507. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  508. { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
  509. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  510. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  511. { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken] <- why not? [Skotlex]
  512. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  513. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  514. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  515. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  516. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  517. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  518. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  519. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  520. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  521. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  522. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  523. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  524. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  525. { AtCommand_Users, "@users", 40, atcommand_users },
  526. { AtCommand_ResetState, "@reset", 40, atcommand_reset },
  527. #ifndef TXT_ONLY // sql-only commands
  528. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  529. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  530. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  531. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  532. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  533. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  534. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  535. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  536. #endif /* TXT_ONLY */
  537. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  538. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  539. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  540. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  541. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  542. #ifdef DMALLOC
  543. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  544. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  545. #endif
  546. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  547. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  548. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  549. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  550. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  551. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  552. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  553. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  554. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  555. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  556. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  557. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  558. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  559. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  560. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  561. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  562. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  563. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  564. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  565. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  566. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  567. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  568. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  569. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  570. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  571. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  572. { AtCommand_Version, "@version", 1, atcommand_version },
  573. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  574. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  575. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  576. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  577. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  578. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  579. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  580. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  581. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  582. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  583. { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
  584. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  585. { AtCommand_Size, "@size", 20, atcommand_size },
  586. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  587. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  588. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  589. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  590. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  591. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  592. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  593. { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
  594. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  595. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  596. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  597. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  598. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  599. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  600. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  601. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  602. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  603. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  604. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  605. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  606. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  607. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  608. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  609. { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
  610. { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
  611. { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
  612. { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
  613. { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
  614. { AtCommand_HomTalk, "@homtalk", 10, atcommand_homtalk },
  615. { AtCommand_HomInfo, "@hominfo", 1, atcommand_hominfo },
  616. { AtCommand_HomStats, "@homstats", 1, atcommand_homstats },
  617. { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
  618. // add new commands before this line
  619. { AtCommand_Unknown, NULL, 1, NULL }
  620. };
  621. /*=========================================
  622. * Generic variables
  623. *-----------------------------------------
  624. */
  625. char atcmd_output[200];
  626. char atcmd_player_name[100];
  627. char atcmd_temp[100];
  628. /*==========================================
  629. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  630. *------------------------------------------
  631. */
  632. char *estr_lower(char *str)
  633. {
  634. int i;
  635. for (i=0; str[i]; i++)
  636. if ((str[i] >= 65) && (str[i] <= 90))
  637. str[i] += 32;
  638. return str;
  639. }
  640. // compare function for sorting high to lowest
  641. int hightolow_compare (const void * a, const void * b)
  642. {
  643. return ( *(int*)b - *(int*)a );
  644. }
  645. // compare function for sorting lowest to highest
  646. int lowtohigh_compare (const void * a, const void * b)
  647. {
  648. return ( *(int*)a - *(int*)b );
  649. }
  650. //-----------------------------------------------------------
  651. // Return the message string of the specified number by [Yor]
  652. //-----------------------------------------------------------
  653. char * msg_txt(int msg_number) {
  654. if (msg_number >= 0 && msg_number < MAX_MSG &&
  655. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  656. return msg_table[msg_number];
  657. return "??";
  658. }
  659. //-----------------------------------------------------------
  660. // Returns Players title (from msg_athena.conf) [Lupus]
  661. //-----------------------------------------------------------
  662. char * player_title_txt(int level) {
  663. if (level < battle_config.title_lvl1)
  664. return ""; //w/o any titles
  665. if (level >= battle_config.title_lvl8)
  666. sprintf(atcmd_temp, msg_txt(332), level);
  667. else
  668. if (level >= battle_config.title_lvl7)
  669. sprintf(atcmd_temp, msg_txt(331), level);
  670. else
  671. if (level >= battle_config.title_lvl6)
  672. sprintf(atcmd_temp, msg_txt(330), level);
  673. else
  674. if (level >= battle_config.title_lvl5)
  675. sprintf(atcmd_temp, msg_txt(329), level);
  676. else
  677. if (level >= battle_config.title_lvl4)
  678. sprintf(atcmd_temp, msg_txt(328), level);
  679. else
  680. if (level >= battle_config.title_lvl3)
  681. sprintf(atcmd_temp, msg_txt(327), level);
  682. else
  683. if (level >= battle_config.title_lvl2)
  684. sprintf(atcmd_temp, msg_txt(326), level);
  685. else
  686. sprintf(atcmd_temp, msg_txt(325), level); //lvl1
  687. return atcmd_temp;
  688. }
  689. //------------------------------------------------------------
  690. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  691. //------------------------------------------------------------
  692. int e_mail_check(char *email) {
  693. char ch;
  694. char* last_arobas;
  695. // athena limits
  696. if (strlen(email) < 3 || strlen(email) > 39)
  697. return 0;
  698. // part of RFC limits (official reference of e-mail description)
  699. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  700. return 0;
  701. if (email[strlen(email)-1] == '.')
  702. return 0;
  703. last_arobas = strrchr(email, '@');
  704. if (strstr(last_arobas, "@.") != NULL ||
  705. strstr(last_arobas, "..") != NULL)
  706. return 0;
  707. for(ch = 1; ch < 32; ch++) {
  708. if (strchr(last_arobas, ch) != NULL) {
  709. return 0;
  710. break;
  711. }
  712. }
  713. if (strchr(last_arobas, ' ') != NULL ||
  714. strchr(last_arobas, ';') != NULL)
  715. return 0;
  716. // all correct
  717. return 1;
  718. }
  719. /*==========================================
  720. * get_atcommand_level @コマンドの必要レベルを取得
  721. *------------------------------------------
  722. */
  723. int get_atcommand_level(const AtCommandType type) {
  724. int i;
  725. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  726. if (atcommand_info[i].type == type)
  727. return atcommand_info[i].level;
  728. return 100; // 100: command can not be used
  729. }
  730. AtCommandType
  731. is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl) {
  732. AtCommandInfo info;
  733. AtCommandType type;
  734. memset(&info, 0, sizeof(info));
  735. type = atcommand(sd, gmlvl, str, &info);
  736. if (type != AtCommand_None) {
  737. char command[100];
  738. const char* p = str;
  739. if (map[sd->bl.m].nocommand &&
  740. gmlvl < map[sd->bl.m].nocommand)
  741. { //Command not allowed on this map.
  742. sprintf(atcmd_output, msg_txt(143));
  743. clif_displaymessage(fd, atcmd_output);
  744. return AtCommand_None;
  745. }
  746. memset(command, '\0', sizeof(command));
  747. memset(atcmd_output, '\0', sizeof(atcmd_output));
  748. while (*p && !isspace(*p))
  749. p++;
  750. if (p - str >= sizeof(command)) // too long
  751. return AtCommand_Unknown;
  752. strncpy(command, str, p - str);
  753. while (isspace(*p))
  754. p++;
  755. if (type == AtCommand_Unknown || info.proc == NULL) {
  756. sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
  757. clif_displaymessage(fd, atcmd_output);
  758. } else {
  759. if (info.proc(fd, sd, command, p) != 0) {
  760. // Command can not be executed
  761. sprintf(atcmd_output, msg_txt(154), command); // %s failed.
  762. clif_displaymessage(fd, atcmd_output);
  763. }
  764. }
  765. return info.type;
  766. }
  767. return AtCommand_None;
  768. }
  769. /*==========================================
  770. *is_atcommand @コマンドに存在するかどうか確認する
  771. *------------------------------------------
  772. */
  773. AtCommandType
  774. is_atcommand(const int fd, struct map_session_data* sd, const char* message) {
  775. const char* str = message;
  776. int s_flag = 0;
  777. nullpo_retr(AtCommand_None, sd);
  778. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
  779. return AtCommand_Unknown;
  780. }
  781. if (!message || !*message)
  782. return AtCommand_None;
  783. str += strlen(sd->status.name);
  784. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  785. if (*str == ':')
  786. s_flag = 1;
  787. str++;
  788. }
  789. if (!*str)
  790. return AtCommand_None;
  791. return is_atcommand_sub(fd,sd,str,pc_isGM(sd));
  792. }
  793. /*==========================================
  794. *
  795. *------------------------------------------
  796. */
  797. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  798. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  799. if (!info)
  800. return AtCommand_None;
  801. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  802. return AtCommand_None;
  803. if (!p || !*p) {
  804. ShowError("at command message is empty\n");
  805. return AtCommand_None;
  806. }
  807. if(p[0] == '|')
  808. p += 3;
  809. if (*p == atcommand_symbol) { // check first char, try to skip |00 (or something else) [Lance]
  810. char command[101];
  811. int i = 0;
  812. memset(info, 0, sizeof(AtCommandInfo));
  813. sscanf(p, "%100s", command);
  814. command[sizeof(command)-1] = '\0';
  815. while (atcommand_info[i].type != AtCommand_Unknown) {
  816. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  817. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  818. break;
  819. }
  820. i++;
  821. }
  822. if (atcommand_info[i].type == AtCommand_Unknown) {
  823. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  824. if (level == 0)
  825. return AtCommand_None;
  826. else
  827. return AtCommand_Unknown;
  828. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  829. log_atcommand(sd, message);
  830. }
  831. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  832. } else {
  833. return AtCommand_None;
  834. }
  835. return info->type;
  836. }
  837. /*==========================================
  838. * Read Message Data
  839. *------------------------------------------
  840. */
  841. int msg_config_read(const char *cfgName) {
  842. int msg_number;
  843. char line[1024], w1[1024], w2[1024];
  844. FILE *fp;
  845. static int called = 1;
  846. if ((fp = fopen(cfgName, "r")) == NULL) {
  847. ShowError("Messages file not found: %s\n", cfgName);
  848. return 1;
  849. }
  850. if ((--called) == 0)
  851. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  852. while(fgets(line, sizeof(line)-1, fp)) {
  853. if (line[0] == '/' && line[1] == '/')
  854. continue;
  855. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  856. if (strcmpi(w1, "import") == 0) {
  857. msg_config_read(w2);
  858. } else {
  859. msg_number = atoi(w1);
  860. if (msg_number >= 0 && msg_number < MAX_MSG) {
  861. if (msg_table[msg_number] != NULL)
  862. aFree(msg_table[msg_number]);
  863. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  864. strcpy(msg_table[msg_number],w2);
  865. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  866. }
  867. }
  868. }
  869. }
  870. fclose(fp);
  871. return 0;
  872. }
  873. /*==========================================
  874. * Cleanup Message Data
  875. *------------------------------------------
  876. */
  877. void do_final_msg (void) {
  878. int i;
  879. for (i = 0; i < MAX_MSG; i++)
  880. aFree(msg_table[i]);
  881. return;
  882. }
  883. /*==========================================
  884. *
  885. *------------------------------------------
  886. */
  887. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  888. int i;
  889. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  890. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  891. return &atcommand_info[i];
  892. return NULL;
  893. }
  894. /*==========================================
  895. *
  896. *------------------------------------------
  897. */
  898. int atcommand_config_read(const char *cfgName) {
  899. char line[1024], w1[1024], w2[1024];
  900. AtCommandInfo* p;
  901. FILE* fp;
  902. if ((fp = fopen(cfgName, "r")) == NULL) {
  903. ShowError("At commands configuration file not found: %s\n", cfgName);
  904. return 1;
  905. }
  906. while (fgets(line, sizeof(line)-1, fp)) {
  907. if (line[0] == '/' && line[1] == '/')
  908. continue;
  909. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  910. continue;
  911. p = get_atcommandinfo_byname(w1);
  912. if (p != NULL) {
  913. p->level = atoi(w2);
  914. if (p->level > 100)
  915. p->level = 100;
  916. else if (p->level < 0)
  917. p->level = 0;
  918. }
  919. if (strcmpi(w1, "import") == 0)
  920. atcommand_config_read(w2);
  921. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  922. w2[0] != '/' && // symbol of standard ragnarok GM commands
  923. w2[0] != '%' && // symbol of party chat speaking
  924. w2[0] != '$' && // symbol of guild chat
  925. w2[0] != '#') // symbol of charcommand
  926. atcommand_symbol = w2[0];
  927. }
  928. fclose(fp);
  929. return 0;
  930. }
  931. /*==========================================
  932. // @ command processing functions
  933. *------------------------------------------
  934. */
  935. /*==========================================
  936. * @commands Lists available @ commands to you (code 98% from Meruru)
  937. *------------------------------------------
  938. */
  939. int atcommand_commands(
  940. const int fd, struct map_session_data* sd,
  941. const char* command, const char* message)
  942. {
  943. char cz_line_buff[MESSAGE_SIZE+1];
  944. register char *lpcz_cur = cz_line_buff;
  945. register unsigned int ui_slen;
  946. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  947. memset(cz_line_buff,' ',MESSAGE_SIZE);
  948. cz_line_buff[MESSAGE_SIZE] = 0;
  949. clif_displaymessage(fd, msg_txt(273));
  950. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  951. {
  952. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  953. continue;
  954. count++;
  955. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  956. //rember not <= bc we need null terminator
  957. if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  958. {
  959. clif_displaymessage(fd,(char*)cz_line_buff);
  960. lpcz_cur = cz_line_buff;
  961. memset(cz_line_buff,' ',MESSAGE_SIZE);
  962. cz_line_buff[MESSAGE_SIZE] = 0;
  963. }
  964. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  965. lpcz_cur += ui_slen+(10-ui_slen%10);
  966. }
  967. clif_displaymessage(fd,(char*)cz_line_buff);
  968. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  969. clif_displaymessage(fd, atcmd_output);
  970. return 0;
  971. }
  972. /*==========================================
  973. * @send (used for testing packet sends from the client)
  974. *------------------------------------------
  975. */
  976. int atcommand_send(
  977. const int fd, struct map_session_data* sd,
  978. const char* command, const char* message)
  979. {
  980. int len=0,off,end,type;
  981. long num;
  982. (void)command; // not used
  983. // read message type as hex number (without the 0x)
  984. if(!message || !*message ||
  985. !((sscanf(message, "len %x", &type)==1 && (len=1))
  986. || sscanf(message, "%x", &type)==1) )
  987. {
  988. clif_displaymessage(fd, "Usage:");
  989. clif_displaymessage(fd, " @send len <packet hex number>");
  990. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  991. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  992. return -1;
  993. }
  994. #define PARSE_ERROR(error,p) \
  995. {\
  996. clif_displaymessage(fd, (error));\
  997. sprintf(atcmd_output, ">%s", (p));\
  998. clif_displaymessage(fd, atcmd_output);\
  999. }
  1000. //define PARSE_ERROR
  1001. #define CHECK_EOS(p) \
  1002. if(*(p) == 0){\
  1003. clif_displaymessage(fd, "Unexpected end of string");\
  1004. return -1;\
  1005. }
  1006. //define CHECK_EOS
  1007. #define SKIP_VALUE(p) \
  1008. {\
  1009. while(*(p) && !isspace(*(p))) ++(p); /* non-space */\
  1010. while(*(p) && isspace(*(p))) ++(p); /* space */\
  1011. }
  1012. //define SKIP_VALUE
  1013. #define GET_VALUE(p,num) \
  1014. {\
  1015. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  1016. PARSE_ERROR("Invalid number in:",(p));\
  1017. return -1;\
  1018. }\
  1019. }
  1020. //define GET_VALUE
  1021. if (type > 0 && type < MAX_PACKET_DB) {
  1022. if(len)
  1023. {// show packet length
  1024. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  1025. clif_displaymessage(fd, atcmd_output);
  1026. return 0;
  1027. }
  1028. len=packet_db[sd->packet_ver][type].len;
  1029. off=2;
  1030. if(len == 0)
  1031. {// unknown packet - ERROR
  1032. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  1033. clif_displaymessage(fd, atcmd_output);
  1034. return -1;
  1035. } else if(len == -1)
  1036. {// dynamic packet
  1037. len=SHRT_MAX-4; // maximum length
  1038. off=4;
  1039. }
  1040. WFIFOHEAD(fd, len);
  1041. WFIFOW(fd,0)=TOW(type);
  1042. // parse packet contents
  1043. SKIP_VALUE(message);
  1044. while(*message != 0 && off < len){
  1045. if(isdigit(*message) || *message == '-' || *message == '+')
  1046. {// default (byte)
  1047. GET_VALUE(message,num);
  1048. WFIFOB(fd,off)=TOB(num);
  1049. ++off;
  1050. } else if(toupper(*message) == 'B')
  1051. {// byte
  1052. ++message;
  1053. GET_VALUE(message,num);
  1054. WFIFOB(fd,off)=TOB(num);
  1055. ++off;
  1056. } else if(toupper(*message) == 'W')
  1057. {// word (2 bytes)
  1058. ++message;
  1059. GET_VALUE(message,num);
  1060. WFIFOW(fd,off)=TOW(num);
  1061. off+=2;
  1062. } else if(toupper(*message) == 'L')
  1063. {// long word (4 bytes)
  1064. ++message;
  1065. GET_VALUE(message,num);
  1066. WFIFOL(fd,off)=TOL(num);
  1067. off+=4;
  1068. } else if(toupper(*message) == 'S')
  1069. {// string - escapes are valid
  1070. // get string length - num <= 0 means not fixed length (default)
  1071. ++message;
  1072. if(*message == '"'){
  1073. num=0;
  1074. } else {
  1075. GET_VALUE(message,num);
  1076. while(*message != '"')
  1077. {// find start of string
  1078. if(*message == 0 || isspace(*message)){
  1079. PARSE_ERROR("Not a string:",message);
  1080. return -1;
  1081. }
  1082. ++message;
  1083. }
  1084. }
  1085. // parse string
  1086. ++message;
  1087. CHECK_EOS(message);
  1088. end=(num<=0? 0: min(off+((int)num),len));
  1089. for(; *message != '"' && (off < end || end == 0); ++off){
  1090. if(*message == '\\'){
  1091. ++message;
  1092. CHECK_EOS(message);
  1093. switch(*message){
  1094. case 'a': num=0x07; break; // Bell
  1095. case 'b': num=0x08; break; // Backspace
  1096. case 't': num=0x09; break; // Horizontal tab
  1097. case 'n': num=0x0A; break; // Line feed
  1098. case 'v': num=0x0B; break; // Vertical tab
  1099. case 'f': num=0x0C; break; // Form feed
  1100. case 'r': num=0x0D; break; // Carriage return
  1101. case 'e': num=0x1B; break; // Escape
  1102. default: num=*message; break;
  1103. case 'x': // Hexadecimal
  1104. {
  1105. ++message;
  1106. CHECK_EOS(message);
  1107. if(!isxdigit(*message)){
  1108. PARSE_ERROR("Not a hexadecimal digit:",message);
  1109. return -1;
  1110. }
  1111. num=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1112. if(isxdigit(*message)){
  1113. ++message;
  1114. CHECK_EOS(message);
  1115. num<<=8;
  1116. num+=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1117. }
  1118. WFIFOB(fd,off)=TOB(num);
  1119. ++message;
  1120. CHECK_EOS(message);
  1121. continue;
  1122. }
  1123. case '0':
  1124. case '1':
  1125. case '2':
  1126. case '3':
  1127. case '4':
  1128. case '5':
  1129. case '6':
  1130. case '7': // Octal
  1131. {
  1132. num=*message-'0'; // 1st octal digit
  1133. ++message;
  1134. CHECK_EOS(message);
  1135. if(isdigit(*message) && *message < '8'){
  1136. num<<=3;
  1137. num+=*message-'0'; // 2nd octal digit
  1138. ++message;
  1139. CHECK_EOS(message);
  1140. if(isdigit(*message) && *message < '8'){
  1141. num<<=3;
  1142. num+=*message-'0'; // 3rd octal digit
  1143. ++message;
  1144. CHECK_EOS(message);
  1145. }
  1146. }
  1147. WFIFOB(fd,off)=TOB(num);
  1148. continue;
  1149. }
  1150. }
  1151. } else
  1152. num=*message;
  1153. WFIFOB(fd,off)=TOB(num);
  1154. ++message;
  1155. CHECK_EOS(message);
  1156. }//for
  1157. while(*message != '"')
  1158. {// ignore extra characters
  1159. ++message;
  1160. CHECK_EOS(message);
  1161. }
  1162. // terminate the string
  1163. if(off < end)
  1164. {// fill the rest with 0's
  1165. memset(WFIFOP(fd,off),0,end-off);
  1166. off=end;
  1167. }
  1168. } else
  1169. {// unknown
  1170. PARSE_ERROR("Unknown type of value in:",message);
  1171. return -1;
  1172. }
  1173. SKIP_VALUE(message);
  1174. }
  1175. if(packet_db[sd->packet_ver][type].len == -1)
  1176. {// send dynamic packet
  1177. WFIFOW(fd,2)=TOW(off);
  1178. WFIFOSET(fd,off);
  1179. } else
  1180. {// send static packet
  1181. if(off < len)
  1182. memset(WFIFOP(fd,off),0,len-off);
  1183. WFIFOSET(fd,len);
  1184. }
  1185. } else {
  1186. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  1187. return -1;
  1188. }
  1189. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  1190. clif_displaymessage(fd, atcmd_output);
  1191. return 0;
  1192. #undef PARSE_ERROR
  1193. #undef CHECK_EOS
  1194. #undef SKIP_VALUE
  1195. #undef GET_VALUE
  1196. }
  1197. // @rura
  1198. /*==========================================
  1199. *
  1200. *------------------------------------------
  1201. */
  1202. int atcommand_rura(
  1203. const int fd, struct map_session_data* sd,
  1204. const char* command, const char* message)
  1205. {
  1206. char map_name[MAP_NAME_LENGTH];
  1207. unsigned short mapindex;
  1208. int x = 0, y = 0;
  1209. int m = -1;
  1210. nullpo_retr(-1, sd);
  1211. memset(map_name, '\0', sizeof(map_name));
  1212. if (!message || !*message ||
  1213. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1214. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1215. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1216. return -1;
  1217. }
  1218. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1219. strcat(map_name, ".gat");
  1220. mapindex = mapindex_name2id(map_name);
  1221. if (mapindex)
  1222. m = map_mapindex2mapid(mapindex);
  1223. if (!mapindex || m < 0) {
  1224. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1225. return -1;
  1226. }
  1227. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  1228. { //This is to prevent the pc_setpos call from printing an error.
  1229. clif_displaymessage(fd, msg_txt(2));
  1230. x = y = 0; //Invalid cell, use random spot.
  1231. }
  1232. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1233. clif_displaymessage(fd, msg_txt(247));
  1234. return -1;
  1235. }
  1236. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1237. clif_displaymessage(fd, msg_txt(248));
  1238. return -1;
  1239. }
  1240. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1241. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1242. else {
  1243. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1244. return -1;
  1245. }
  1246. return 0;
  1247. }
  1248. /*==========================================
  1249. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1250. *------------------------------------------
  1251. */
  1252. int atcommand_where(
  1253. const int fd, struct map_session_data* sd,
  1254. const char* command, const char* message)
  1255. {
  1256. struct map_session_data *pl_sd = NULL;
  1257. int GM_level, pl_GM_level;
  1258. nullpo_retr(-1, sd);
  1259. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1260. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1261. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1262. return -1;
  1263. }
  1264. pl_sd = map_nick2sd(atcmd_player_name);
  1265. if (pl_sd == NULL)
  1266. return -1;
  1267. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1268. return -1;
  1269. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1270. pl_GM_level = pc_isGM(pl_sd);
  1271. if (battle_config.hide_GM_session) {
  1272. if(GM_level < pl_GM_level) {
  1273. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1274. return -1;
  1275. }
  1276. }
  1277. }
  1278. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1279. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1280. clif_displaymessage(fd, atcmd_output);
  1281. return 0;
  1282. }
  1283. /*==========================================
  1284. *
  1285. *------------------------------------------
  1286. */
  1287. int atcommand_jumpto(
  1288. const int fd, struct map_session_data* sd,
  1289. const char* command, const char* message)
  1290. {
  1291. struct map_session_data *pl_sd = NULL;
  1292. nullpo_retr(-1, sd);
  1293. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1294. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1295. return -1;
  1296. }
  1297. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1298. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1299. return -1;
  1300. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1301. return -1;
  1302. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1303. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1304. clif_displaymessage(fd, msg_txt(247));
  1305. return -1;
  1306. }
  1307. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1308. clif_displaymessage(fd, msg_txt(248));
  1309. return -1;
  1310. }
  1311. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1312. sprintf(atcmd_output, msg_txt(4), atcmd_player_name); // Jump to %s
  1313. clif_displaymessage(fd, atcmd_output);
  1314. } else {
  1315. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1316. return -1;
  1317. }
  1318. return 0;
  1319. }
  1320. /*==========================================
  1321. *
  1322. *------------------------------------------
  1323. */
  1324. int atcommand_jump(
  1325. const int fd, struct map_session_data* sd,
  1326. const char* command, const char* message)
  1327. {
  1328. int x = 0, y = 0;
  1329. nullpo_retr(-1, sd);
  1330. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1331. sscanf(message, "%d %d", &x, &y);
  1332. if (x <= 0) //If coordinates are 'wrong', random jump.
  1333. x = -1;
  1334. if (y <= 0)
  1335. y = -1;
  1336. 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)) {
  1337. clif_displaymessage(fd, msg_txt(248));
  1338. return -1;
  1339. }
  1340. pc_setpos(sd, sd->mapindex, x, y, 3);
  1341. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
  1342. clif_displaymessage(fd, atcmd_output);
  1343. return 0;
  1344. }
  1345. /*==========================================
  1346. * @who3 = Player name, his location
  1347. *------------------------------------------
  1348. */
  1349. int atcommand_who3(
  1350. const int fd, struct map_session_data* sd,
  1351. const char* command, const char* message)
  1352. {
  1353. char temp0[100];
  1354. struct map_session_data *pl_sd, **pl_allsd;
  1355. int i, j, count, users;
  1356. int pl_GM_level, GM_level;
  1357. char match_text[100];
  1358. char player_name[NAME_LENGTH];
  1359. nullpo_retr(-1, sd);
  1360. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1361. memset(match_text, '\0', sizeof(match_text));
  1362. memset(player_name, '\0', sizeof(player_name));
  1363. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1364. strcpy(match_text, "");
  1365. for (j = 0; match_text[j]; j++)
  1366. match_text[j] = tolower(match_text[j]);
  1367. count = 0;
  1368. GM_level = pc_isGM(sd);
  1369. pl_allsd = map_getallusers(&users);
  1370. for (i = 0; i < users; i++) {
  1371. if ((pl_sd = pl_allsd[i])) {
  1372. pl_GM_level = pc_isGM(pl_sd);
  1373. 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
  1374. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1375. for (j = 0; player_name[j]; j++)
  1376. player_name[j] = tolower(player_name[j]);
  1377. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1378. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1379. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1380. } else {
  1381. atcmd_output[0]=0;
  1382. }
  1383. //Player name
  1384. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1385. strcat(atcmd_output,temp0);
  1386. //Player title, if exists
  1387. if (pl_GM_level > 0) {
  1388. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1389. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1390. strcat(atcmd_output,temp0);
  1391. }
  1392. //Players Location: map x y
  1393. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1394. strcat(atcmd_output,temp0);
  1395. clif_displaymessage(fd, atcmd_output);
  1396. count++;
  1397. }
  1398. }
  1399. }
  1400. }
  1401. if (count == 0)
  1402. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1403. else if (count == 1)
  1404. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1405. else {
  1406. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1407. clif_displaymessage(fd, atcmd_output);
  1408. }
  1409. return 0;
  1410. }
  1411. /*==========================================
  1412. * Player name, BLevel, Job,
  1413. *------------------------------------------
  1414. */
  1415. int atcommand_who2(
  1416. const int fd, struct map_session_data* sd,
  1417. const char* command, const char* message)
  1418. {
  1419. char temp0[100];
  1420. struct map_session_data *pl_sd, **pl_allsd;
  1421. int i, j, count, users;
  1422. int pl_GM_level, GM_level;
  1423. char match_text[100];
  1424. char player_name[NAME_LENGTH];
  1425. nullpo_retr(-1, sd);
  1426. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1427. memset(match_text, '\0', sizeof(match_text));
  1428. memset(player_name, '\0', sizeof(player_name));
  1429. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1430. strcpy(match_text, "");
  1431. for (j = 0; match_text[j]; j++)
  1432. match_text[j] = tolower(match_text[j]);
  1433. count = 0;
  1434. GM_level = pc_isGM(sd);
  1435. pl_allsd = map_getallusers(&users);
  1436. for (i = 0; i < users; i++) {
  1437. if ((pl_sd = pl_allsd[i])) {
  1438. pl_GM_level = pc_isGM(pl_sd);
  1439. 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
  1440. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1441. for (j = 0; player_name[j]; j++)
  1442. player_name[j] = tolower(player_name[j]);
  1443. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1444. //Players Name
  1445. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1446. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1447. //Player title, if exists
  1448. if (pl_GM_level > 0) {
  1449. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1450. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1451. strcat(atcmd_output,temp0);
  1452. }
  1453. //Players Base Level / Job name
  1454. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1455. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1456. strcat(atcmd_output,temp0);
  1457. clif_displaymessage(fd, atcmd_output);
  1458. count++;
  1459. }
  1460. }
  1461. }
  1462. }
  1463. if (count == 0)
  1464. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1465. else if (count == 1)
  1466. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1467. else {
  1468. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1469. clif_displaymessage(fd, atcmd_output);
  1470. }
  1471. return 0;
  1472. }
  1473. /*==========================================
  1474. * Player name, Playrs Party / Guild name
  1475. *------------------------------------------
  1476. */
  1477. int atcommand_who(
  1478. const int fd, struct map_session_data* sd,
  1479. const char* command, const char* message)
  1480. {
  1481. char temp0[100];
  1482. struct map_session_data *pl_sd, **pl_allsd;
  1483. int i, j, count, users;
  1484. int pl_GM_level, GM_level;
  1485. char match_text[100];
  1486. char player_name[NAME_LENGTH];
  1487. struct guild *g;
  1488. struct party_data *p;
  1489. nullpo_retr(-1, sd);
  1490. memset(temp0, '\0', sizeof(temp0));
  1491. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1492. memset(match_text, '\0', sizeof(match_text));
  1493. memset(player_name, '\0', sizeof(player_name));
  1494. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1495. strcpy(match_text, "");
  1496. for (j = 0; match_text[j]; j++)
  1497. match_text[j] = tolower(match_text[j]);
  1498. count = 0;
  1499. GM_level = pc_isGM(sd);
  1500. pl_allsd = map_getallusers(&users);
  1501. for (i = 0; i < users; i++) {
  1502. if ((pl_sd = pl_allsd[i])) {
  1503. pl_GM_level = pc_isGM(pl_sd);
  1504. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1505. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1506. for (j = 0; player_name[j]; j++)
  1507. player_name[j] = tolower(player_name[j]);
  1508. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1509. g = guild_search(pl_sd->status.guild_id);
  1510. p = party_search(pl_sd->status.party_id);
  1511. //Players Name
  1512. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1513. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1514. //Player title, if exists
  1515. if (pl_GM_level > 0) {
  1516. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1517. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1518. strcat(atcmd_output,temp0);
  1519. }
  1520. //Players Party if exists
  1521. if (p != NULL) {
  1522. //sprintf(temp0," | Party: '%s'", p->name);
  1523. sprintf(temp0, msg_txt(335), p->party.name);
  1524. strcat(atcmd_output,temp0);
  1525. }
  1526. //Players Guild if exists
  1527. if (g != NULL) {
  1528. //sprintf(temp0," | Guild: '%s'", g->name);
  1529. sprintf(temp0, msg_txt(336), g->name);
  1530. strcat(atcmd_output,temp0);
  1531. }
  1532. clif_displaymessage(fd, atcmd_output);
  1533. count++;
  1534. }
  1535. }
  1536. }
  1537. }
  1538. if (count == 0)
  1539. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1540. else if (count == 1)
  1541. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1542. else {
  1543. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1544. clif_displaymessage(fd, atcmd_output);
  1545. }
  1546. return 0;
  1547. }
  1548. /*==========================================
  1549. *
  1550. *------------------------------------------
  1551. */
  1552. int atcommand_whomap3(
  1553. const int fd, struct map_session_data* sd,
  1554. const char* command, const char* message)
  1555. {
  1556. struct map_session_data *pl_sd, **pl_allsd;
  1557. int i, count, users;
  1558. int pl_GM_level, GM_level;
  1559. int map_id;
  1560. char map_name[MAP_NAME_LENGTH];
  1561. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1562. memset(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) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1582. else
  1583. 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);
  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_whomap2(
  1605. const int fd, struct map_session_data* sd,
  1606. const char* command, const char* message)
  1607. {
  1608. struct map_session_data *pl_sd, **pl_allsd;
  1609. int i, count, users;
  1610. int pl_GM_level, GM_level;
  1611. int map_id = 0;
  1612. char map_name[MAP_NAME_LENGTH];
  1613. nullpo_retr(-1, sd);
  1614. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1615. memset(map_name, '\0', sizeof(map_name));
  1616. if (!message || !*message)
  1617. map_id = sd->bl.m;
  1618. else {
  1619. sscanf(message, "%15s", map_name);
  1620. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1621. strcat(map_name, ".gat");
  1622. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1623. map_id = sd->bl.m;
  1624. }
  1625. count = 0;
  1626. GM_level = pc_isGM(sd);
  1627. pl_allsd = map_getallusers(&users);
  1628. for (i = 0; i < users; i++) {
  1629. if ((pl_sd = pl_allsd[i])) {
  1630. pl_GM_level = pc_isGM(pl_sd);
  1631. 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
  1632. if (pl_sd->bl.m == map_id) {
  1633. if (pl_GM_level > 0)
  1634. 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);
  1635. else
  1636. 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);
  1637. clif_displaymessage(fd, atcmd_output);
  1638. count++;
  1639. }
  1640. }
  1641. }
  1642. }
  1643. if (count == 0)
  1644. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1645. else if (count == 1)
  1646. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1647. else {
  1648. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1649. }
  1650. clif_displaymessage(fd, atcmd_output);
  1651. return 0;
  1652. }
  1653. /*==========================================
  1654. *
  1655. *------------------------------------------
  1656. */
  1657. int atcommand_whomap(
  1658. const int fd, struct map_session_data* sd,
  1659. const char* command, const char* message)
  1660. {
  1661. char temp0[100];
  1662. char temp1[100];
  1663. struct map_session_data *pl_sd, **pl_allsd;
  1664. int i, count, users;
  1665. int pl_GM_level, GM_level;
  1666. int map_id = 0;
  1667. char map_name[MAP_NAME_LENGTH];
  1668. struct guild *g;
  1669. struct party_data *p;
  1670. nullpo_retr(-1, sd);
  1671. memset(temp0, '\0', sizeof(temp0));
  1672. memset(temp1, '\0', sizeof(temp1));
  1673. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1674. memset(map_name, '\0', sizeof(map_name));
  1675. if (!message || !*message)
  1676. map_id = sd->bl.m;
  1677. else {
  1678. sscanf(message, "%15s", map_name);
  1679. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1680. strcat(map_name, ".gat");
  1681. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1682. map_id = sd->bl.m;
  1683. }
  1684. count = 0;
  1685. GM_level = pc_isGM(sd);
  1686. pl_allsd = map_getallusers(&users);
  1687. for (i = 0; i < users; i++) {
  1688. if ((pl_sd = pl_allsd[i])) {
  1689. pl_GM_level = pc_isGM(pl_sd);
  1690. 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
  1691. if (pl_sd->bl.m == map_id) {
  1692. g = guild_search(pl_sd->status.guild_id);
  1693. if (g == NULL)
  1694. sprintf(temp1, "None");
  1695. else
  1696. sprintf(temp1, "%s", g->name);
  1697. p = party_search(pl_sd->status.party_id);
  1698. if (p == NULL)
  1699. sprintf(temp0, "None");
  1700. else
  1701. sprintf(temp0, "%s", p->party.name);
  1702. if (pl_GM_level > 0)
  1703. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1704. else
  1705. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1706. clif_displaymessage(fd, atcmd_output);
  1707. count++;
  1708. }
  1709. }
  1710. }
  1711. }
  1712. if (count == 0)
  1713. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1714. else if (count == 1)
  1715. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1716. else {
  1717. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1718. }
  1719. clif_displaymessage(fd, atcmd_output);
  1720. return 0;
  1721. }
  1722. /*==========================================
  1723. *
  1724. *------------------------------------------
  1725. */
  1726. int atcommand_whogm(
  1727. const int fd, struct map_session_data* sd,
  1728. const char* command, const char* message)
  1729. {
  1730. char temp0[100];
  1731. char temp1[100];
  1732. struct map_session_data *pl_sd, **pl_allsd;
  1733. int i, j, count, users;
  1734. int pl_GM_level, GM_level;
  1735. char match_text[100];
  1736. char player_name[NAME_LENGTH];
  1737. struct guild *g;
  1738. struct party_data *p;
  1739. nullpo_retr(-1, sd);
  1740. memset(temp0, '\0', sizeof(temp0));
  1741. memset(temp1, '\0', sizeof(temp1));
  1742. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1743. memset(match_text, '\0', sizeof(match_text));
  1744. memset(player_name, '\0', sizeof(player_name));
  1745. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1746. strcpy(match_text, "");
  1747. for (j = 0; match_text[j]; j++)
  1748. match_text[j] = tolower(match_text[j]);
  1749. count = 0;
  1750. GM_level = pc_isGM(sd);
  1751. pl_allsd = map_getallusers(&users);
  1752. for (i = 0; i < users; i++) {
  1753. if ((pl_sd = pl_allsd[i])) {
  1754. pl_GM_level = pc_isGM(pl_sd);
  1755. if (pl_GM_level > 0) {
  1756. 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
  1757. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1758. for (j = 0; player_name[j]; j++)
  1759. player_name[j] = tolower(player_name[j]);
  1760. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1761. 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);
  1762. clif_displaymessage(fd, atcmd_output);
  1763. 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);
  1764. clif_displaymessage(fd, atcmd_output);
  1765. g = guild_search(pl_sd->status.guild_id);
  1766. if (g == NULL)
  1767. sprintf(temp1, "None");
  1768. else
  1769. sprintf(temp1, "%s", g->name);
  1770. p = party_search(pl_sd->status.party_id);
  1771. if (p == NULL)
  1772. sprintf(temp0, "None");
  1773. else
  1774. sprintf(temp0, "%s", p->party.name);
  1775. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1776. clif_displaymessage(fd, atcmd_output);
  1777. count++;
  1778. }
  1779. }
  1780. }
  1781. }
  1782. }
  1783. if (count == 0)
  1784. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1785. else if (count == 1)
  1786. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1787. else {
  1788. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1789. clif_displaymessage(fd, atcmd_output);
  1790. }
  1791. return 0;
  1792. }
  1793. int atcommand_whozeny(
  1794. const int fd, struct map_session_data* sd,
  1795. const char* command, const char* message)
  1796. {
  1797. struct map_session_data *pl_sd, **pl_allsd;
  1798. int i, j, count,c, users;
  1799. char match_text[100];
  1800. char player_name[NAME_LENGTH];
  1801. int *zeny;
  1802. int *counted;
  1803. nullpo_retr(-1, sd);
  1804. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1805. memset(match_text, '\0', sizeof(match_text));
  1806. memset(player_name, '\0', sizeof(player_name));
  1807. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1808. strcpy(match_text, "");
  1809. for (j = 0; match_text[j]; j++)
  1810. match_text[j] = tolower(match_text[j]);
  1811. count = 0;
  1812. pl_allsd = map_getallusers(&users);
  1813. if (users < 1)
  1814. {
  1815. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1816. return 0;
  1817. }
  1818. zeny = (int *)aMallocA(users*sizeof(int));
  1819. counted = (int *)aMallocA(users*sizeof(int));
  1820. for (i = 0; i < users; i++) {
  1821. if ((pl_sd = pl_allsd[i])) {
  1822. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1823. for (j = 0; player_name[j]; j++)
  1824. player_name[j] = tolower(player_name[j]);
  1825. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1826. zeny[count]=pl_sd->status.zeny;
  1827. counted[i]=0;
  1828. count++;
  1829. }
  1830. }
  1831. }
  1832. qsort(zeny, count, sizeof(int), hightolow_compare);
  1833. for (c = 0; c < count && c < 50; c++) {
  1834. if(!zeny[c])
  1835. continue;
  1836. for (i = 0; i < users; i++) {
  1837. if(!zeny[c])
  1838. continue;
  1839. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1840. if(pl_sd->status.zeny==zeny[c]) {
  1841. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1842. clif_displaymessage(fd, atcmd_output);
  1843. zeny[c]=0;
  1844. counted[i]=1;
  1845. }
  1846. }
  1847. }
  1848. }
  1849. if (count == 0)
  1850. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1851. else if (count == 1)
  1852. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1853. else {
  1854. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1855. clif_displaymessage(fd, atcmd_output);
  1856. }
  1857. aFree(zeny);
  1858. aFree(counted);
  1859. return 0;
  1860. }
  1861. // cause random emote on all online players [Valaris]
  1862. int atcommand_happyhappyjoyjoy(
  1863. const int fd, struct map_session_data* sd,
  1864. const char* command, const char* message)
  1865. {
  1866. struct map_session_data *pl_sd, **pl_allsd;
  1867. int i,e, users;
  1868. nullpo_retr(-1, sd);
  1869. pl_allsd = map_getallusers(&users);
  1870. for (i = 0; i < users; i++) {
  1871. if ((pl_sd = pl_allsd[i])) {
  1872. e=rand()%40;
  1873. if(e==34)
  1874. e = 0;
  1875. clif_emotion(&pl_sd->bl,e);
  1876. }
  1877. }
  1878. return 0;
  1879. }
  1880. /*==========================================
  1881. *
  1882. *------------------------------------------
  1883. */
  1884. int atcommand_save(
  1885. const int fd, struct map_session_data* sd,
  1886. const char* command, const char* message)
  1887. {
  1888. nullpo_retr(-1, sd);
  1889. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1890. if (sd->status.pet_id > 0 && sd->pd)
  1891. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1892. chrif_save(sd,0);
  1893. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  1894. return 0;
  1895. }
  1896. /*==========================================
  1897. *
  1898. *------------------------------------------
  1899. */
  1900. int atcommand_load(
  1901. const int fd, struct map_session_data* sd,
  1902. const char* command, const char* message)
  1903. {
  1904. int m;
  1905. nullpo_retr(-1, sd);
  1906. m = map_mapindex2mapid(sd->status.save_point.map);
  1907. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1908. clif_displaymessage(fd, msg_txt(249));
  1909. return -1;
  1910. }
  1911. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1912. clif_displaymessage(fd, msg_txt(248));
  1913. return -1;
  1914. }
  1915. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1916. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1917. return 0;
  1918. }
  1919. /*==========================================
  1920. *
  1921. *------------------------------------------
  1922. */
  1923. int atcommand_speed(
  1924. const int fd, struct map_session_data* sd,
  1925. const char* command, const char* message)
  1926. {
  1927. int speed;
  1928. nullpo_retr(-1, sd);
  1929. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1930. if (!message || !*message) {
  1931. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1932. clif_displaymessage(fd, atcmd_output);
  1933. return -1;
  1934. }
  1935. speed = atoi(message);
  1936. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1937. sd->base_status.speed = speed;
  1938. status_calc_bl(&sd->bl, SCB_SPEED);
  1939. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1940. } else {
  1941. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1942. clif_displaymessage(fd, atcmd_output);
  1943. return -1;
  1944. }
  1945. return 0;
  1946. }
  1947. /*==========================================
  1948. *
  1949. *------------------------------------------
  1950. */
  1951. int atcommand_charspeed(
  1952. const int fd, struct map_session_data* sd,
  1953. const char* command, const char* message)
  1954. {
  1955. struct map_session_data *pl_sd;
  1956. int speed;
  1957. nullpo_retr(-1, sd);
  1958. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1959. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1960. if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
  1961. sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1962. clif_displaymessage(fd, atcmd_output);
  1963. return -1;
  1964. }
  1965. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  1966. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1967. return -1;
  1968. }
  1969. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1970. { //GM level check
  1971. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1972. return -1;
  1973. }
  1974. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1975. pl_sd->base_status.speed = speed;
  1976. status_calc_bl(&pl_sd->bl, SCB_SPEED);
  1977. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1978. if(pl_sd->fd)
  1979. clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
  1980. } else {
  1981. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1982. clif_displaymessage(fd, atcmd_output);
  1983. return -1;
  1984. }
  1985. return 0;
  1986. }
  1987. /*==========================================
  1988. *
  1989. *------------------------------------------
  1990. */
  1991. int atcommand_storage(
  1992. const int fd, struct map_session_data* sd,
  1993. const char* command, const char* message)
  1994. {
  1995. nullpo_retr(-1, sd);
  1996. if (storage_storageopen(sd) == 1)
  1997. { //Already open.
  1998. clif_displaymessage(fd, msg_txt(250));
  1999. return -1;
  2000. }
  2001. return 0;
  2002. }
  2003. /*==========================================
  2004. *
  2005. *------------------------------------------
  2006. */
  2007. int atcommand_guildstorage(
  2008. const int fd, struct map_session_data* sd,
  2009. const char* command, const char* message)
  2010. {
  2011. struct storage *stor; //changes from Freya/Yor
  2012. nullpo_retr(-1, sd);
  2013. if (sd->status.guild_id > 0) {
  2014. if (sd->state.storage_flag) {
  2015. clif_displaymessage(fd, msg_txt(251));
  2016. return -1;
  2017. }
  2018. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  2019. clif_displaymessage(fd, msg_txt(251));
  2020. return -1;
  2021. }
  2022. storage_guild_storageopen(sd);
  2023. } else {
  2024. clif_displaymessage(fd, msg_txt(252));
  2025. return -1;
  2026. }
  2027. return 0;
  2028. }
  2029. /*==========================================
  2030. *
  2031. *------------------------------------------
  2032. */
  2033. int atcommand_option(
  2034. const int fd, struct map_session_data* sd,
  2035. const char* command, const char* message)
  2036. {
  2037. int param1 = 0, param2 = 0, param3 = 0;
  2038. nullpo_retr(-1, sd);
  2039. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  2040. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  2041. return -1;
  2042. }
  2043. sd->sc.opt1 = param1;
  2044. sd->sc.opt2 = param2;
  2045. if (!(sd->sc.option & OPTION_CART) && param3 & OPTION_CART) {
  2046. clif_cartlist(sd);
  2047. clif_updatestatus(sd, SP_CARTINFO);
  2048. }
  2049. pc_setoption(sd, param3);
  2050. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  2051. return 0;
  2052. }
  2053. /*==========================================
  2054. *
  2055. *------------------------------------------
  2056. */
  2057. int atcommand_hide(
  2058. const int fd, struct map_session_data* sd,
  2059. const char* command, const char* message)
  2060. {
  2061. nullpo_retr(-1, sd);
  2062. if (sd->sc.option & OPTION_INVISIBLE) {
  2063. sd->sc.option &= ~OPTION_INVISIBLE;
  2064. if (sd->disguise)
  2065. status_set_viewdata(&sd->bl, sd->disguise);
  2066. else
  2067. status_set_viewdata(&sd->bl, sd->status.class_);
  2068. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  2069. } else {
  2070. sd->sc.option |= OPTION_INVISIBLE;
  2071. sd->vd.class_ = INVISIBLE_CLASS;
  2072. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  2073. }
  2074. clif_changeoption(&sd->bl);
  2075. return 0;
  2076. }
  2077. /*==========================================
  2078. * 転職する upperを指定すると転生や養子にもなれる
  2079. *------------------------------------------
  2080. */
  2081. int atcommand_jobchange(
  2082. const int fd, struct map_session_data* sd,
  2083. const char* command, const char* message)
  2084. {
  2085. int job = 0, upper = 0;
  2086. nullpo_retr(-1, sd);
  2087. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  2088. int i, found = 0;
  2089. const struct { char name[16]; int id; } jobs[] = {
  2090. { "novice", 0 },
  2091. { "swordsman", 1 },
  2092. { "mage", 2 },
  2093. { "archer", 3 },
  2094. { "acolyte", 4 },
  2095. { "merchant", 5 },
  2096. { "thief", 6 },
  2097. { "knight", 7 },
  2098. { "priest", 8 },
  2099. { "priestess", 8 },
  2100. { "wizard", 9 },
  2101. { "blacksmith", 10 },
  2102. { "hunter", 11 },
  2103. { "assassin", 12 },
  2104. { "crusader", 14 },
  2105. { "monk", 15 },
  2106. { "sage", 16 },
  2107. { "rogue", 17 },
  2108. { "alchemist", 18 },
  2109. { "bard", 19 },
  2110. { "dancer", 20 },
  2111. { "super novice", 23 },
  2112. { "supernovice", 23 },
  2113. { "gunslinger", 24 },
  2114. { "gunner", 24 },
  2115. { "ninja", 25 },
  2116. { "high novice", 4001 },
  2117. { "swordsman high", 4002 },
  2118. { "mage high", 4003 },
  2119. { "archer high", 4004 },
  2120. { "acolyte high", 4005 },
  2121. { "merchant high", 4006 },
  2122. { "thief high", 4007 },
  2123. { "lord knight", 4008 },
  2124. { "high priest", 4009 },
  2125. { "high priestess", 4009 },
  2126. { "high wizard", 4010 },
  2127. { "whitesmith", 4011 },
  2128. { "sniper", 4012 },
  2129. { "assassin cross", 4013 },
  2130. { "paladin", 4015 },
  2131. { "champion", 4016 },
  2132. { "professor", 4017 },
  2133. { "stalker", 4018 },
  2134. { "creator", 4019 },
  2135. { "clown", 4020 },
  2136. { "gypsy", 4021 },
  2137. { "baby novice", 4023 },
  2138. { "baby swordsman", 4024 },
  2139. { "baby mage", 4025 },
  2140. { "baby archer", 4026 },
  2141. { "baby acolyte", 4027 },
  2142. { "baby merchant", 4028 },
  2143. { "baby thief", 4029 },
  2144. { "baby knight", 4030 },
  2145. { "baby priest", 4031 },
  2146. { "baby priestess", 4031 },
  2147. { "baby wizard", 4032 },
  2148. { "baby blacksmith",4033 },
  2149. { "baby hunter", 4034 },
  2150. { "baby assassin", 4035 },
  2151. { "baby crusader", 4037 },
  2152. { "baby monk", 4038 },
  2153. { "baby sage", 4039 },
  2154. { "baby rogue", 4040 },
  2155. { "baby alchemist", 4041 },
  2156. { "baby bard", 4042 },
  2157. { "baby dancer", 4043 },
  2158. { "super baby", 4045 },
  2159. { "taekwon", 4046 },
  2160. { "taekwon boy", 4046 },
  2161. { "taekwon girl", 4046 },
  2162. { "star gladiator", 4047 },
  2163. { "soul linker", 4049 },
  2164. };
  2165. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2166. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2167. job = jobs[i].id;
  2168. upper = 0;
  2169. found = 1;
  2170. break;
  2171. }
  2172. }
  2173. if (!found) {
  2174. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2175. return -1;
  2176. }
  2177. }
  2178. if (job == 37 ||job == 45)
  2179. return 0;
  2180. if ((job >= 0 && job < MAX_PC_CLASS))
  2181. {
  2182. int j;
  2183. for (j=0; j < MAX_INVENTORY; j++) {
  2184. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2185. pc_unequipitem(sd, j, 3);
  2186. }
  2187. if (pc_jobchange(sd, job, upper) == 0)
  2188. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  2189. else {
  2190. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  2191. return -1;
  2192. }
  2193. } else {
  2194. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2195. return -1;
  2196. }
  2197. return 0;
  2198. }
  2199. /*==========================================
  2200. *
  2201. *------------------------------------------
  2202. */
  2203. int atcommand_die(
  2204. const int fd, struct map_session_data* sd,
  2205. const char* command, const char* message)
  2206. {
  2207. nullpo_retr(-1, sd);
  2208. clif_specialeffect(&sd->bl,450,SELF);
  2209. status_kill(&sd->bl);
  2210. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  2211. return 0;
  2212. }
  2213. /*==========================================
  2214. *
  2215. *------------------------------------------
  2216. */
  2217. int atcommand_kill(
  2218. const int fd, struct map_session_data* sd,
  2219. const char* command, const char* message)
  2220. {
  2221. struct map_session_data *pl_sd;
  2222. nullpo_retr(-1, sd);
  2223. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2224. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2225. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2226. return -1;
  2227. }
  2228. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2229. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2230. status_kill(&pl_sd->bl);
  2231. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  2232. } else {
  2233. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2234. return -1;
  2235. }
  2236. } else {
  2237. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2238. return -1;
  2239. }
  2240. return 0;
  2241. }
  2242. /*==========================================
  2243. *
  2244. *------------------------------------------
  2245. */
  2246. int atcommand_alive(
  2247. const int fd, struct map_session_data* sd,
  2248. const char* command, const char* message)
  2249. {
  2250. nullpo_retr(-1, sd);
  2251. if (!status_revive(&sd->bl, 100, 100))
  2252. return -1;
  2253. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2254. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  2255. return 0;
  2256. }
  2257. /*==========================================
  2258. * +kamic [LuzZza]
  2259. *------------------------------------------
  2260. */
  2261. int atcommand_kami(
  2262. const int fd, struct map_session_data* sd,
  2263. const char* command, const char* message)
  2264. {
  2265. unsigned long color=0;
  2266. nullpo_retr(-1, sd);
  2267. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2268. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2269. if (!message || !*message) {
  2270. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2271. return -1;
  2272. }
  2273. sscanf(message, "%199[^\n]", atcmd_output);
  2274. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2275. } else {
  2276. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2277. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2278. return -1;
  2279. }
  2280. if(color > 0xFFFFFF) {
  2281. clif_displaymessage(fd, "Invalid color.");
  2282. return -1;
  2283. }
  2284. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2285. }
  2286. return 0;
  2287. }
  2288. /*==========================================
  2289. *
  2290. *------------------------------------------
  2291. */
  2292. int atcommand_heal(
  2293. const int fd, struct map_session_data* sd,
  2294. const char* command, const char* message)
  2295. {
  2296. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2297. nullpo_retr(-1, sd);
  2298. sscanf(message, "%d %d", &hp, &sp);
  2299. if (hp == 0 && sp == 0) {
  2300. if (!status_percent_heal(&sd->bl, 100, 100))
  2301. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2302. else
  2303. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2304. return 0;
  2305. }
  2306. if(hp > 0 && sp >= 0) {
  2307. if(!status_heal(&sd->bl, hp, sp, 0))
  2308. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2309. else
  2310. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2311. return 0;
  2312. }
  2313. if(hp < 0 && sp <= 0) {
  2314. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2315. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2316. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2317. return 0;
  2318. }
  2319. //Opposing signs.
  2320. if (hp) {
  2321. if (hp > 0)
  2322. status_heal(&sd->bl, hp, 0, 0);
  2323. else {
  2324. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2325. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2326. }
  2327. }
  2328. if (sp) {
  2329. if (sp > 0)
  2330. status_heal(&sd->bl, 0, sp, 0);
  2331. else
  2332. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2333. }
  2334. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2335. return 0;
  2336. }
  2337. /*==========================================
  2338. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2339. *------------------------------------------
  2340. */
  2341. int atcommand_item(
  2342. const int fd, struct map_session_data* sd,
  2343. const char* command, const char* message)
  2344. {
  2345. char item_name[100];
  2346. int number = 0, item_id, flag;
  2347. struct item item_tmp;
  2348. struct item_data *item_data;
  2349. int get_count, i;
  2350. nullpo_retr(-1, sd);
  2351. memset(item_name, '\0', sizeof(item_name));
  2352. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2353. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2354. return -1;
  2355. }
  2356. if (number <= 0)
  2357. number = 1;
  2358. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2359. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2360. {
  2361. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2362. return -1;
  2363. }
  2364. item_id = item_data->nameid;
  2365. get_count = number;
  2366. //Check if it's stackable.
  2367. if (!itemdb_isstackable2(item_data))
  2368. get_count = 1;
  2369. for (i = 0; i < number; i += get_count) {
  2370. // if not pet egg
  2371. if (!pet_create_egg(sd, item_id)) {
  2372. memset(&item_tmp, 0, sizeof(item_tmp));
  2373. item_tmp.nameid = item_id;
  2374. item_tmp.identify = 1;
  2375. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2376. clif_additem(sd, 0, 0, flag);
  2377. }
  2378. }
  2379. //Logs (A)dmins items [Lupus]
  2380. if(log_config.enable_logs&0x400)
  2381. log_pick_pc(sd, "A", item_id, number, NULL);
  2382. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2383. return 0;
  2384. }
  2385. /*==========================================
  2386. *
  2387. *------------------------------------------
  2388. */
  2389. int atcommand_item2(
  2390. const int fd, struct map_session_data* sd,
  2391. const char* command, const char* message)
  2392. {
  2393. struct item item_tmp;
  2394. struct item_data *item_data;
  2395. char item_name[100];
  2396. int item_id, number = 0;
  2397. int identify = 0, refine = 0, attr = 0;
  2398. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2399. int flag;
  2400. int loop, get_count, i;
  2401. nullpo_retr(-1, sd);
  2402. memset(item_name, '\0', sizeof(item_name));
  2403. 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) {
  2404. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2405. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2406. return -1;
  2407. }
  2408. if (number <= 0)
  2409. number = 1;
  2410. item_id = 0;
  2411. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2412. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2413. item_id = item_data->nameid;
  2414. if (item_id > 500) {
  2415. loop = 1;
  2416. get_count = number;
  2417. if (item_data->type == 4 || item_data->type == 5 ||
  2418. item_data->type == 7 || item_data->type == 8) {
  2419. loop = number;
  2420. get_count = 1;
  2421. if (item_data->type == 7) {
  2422. identify = 1;
  2423. refine = 0;
  2424. }
  2425. if (item_data->type == 8)
  2426. refine = 0;
  2427. if (refine > 10)
  2428. refine = 10;
  2429. } else {
  2430. identify = 1;
  2431. refine = attr = 0;
  2432. }
  2433. for (i = 0; i < loop; i++) {
  2434. memset(&item_tmp, 0, sizeof(item_tmp));
  2435. item_tmp.nameid = item_id;
  2436. item_tmp.identify = identify;
  2437. item_tmp.refine = refine;
  2438. item_tmp.attribute = attr;
  2439. item_tmp.card[0] = c1;
  2440. item_tmp.card[1] = c2;
  2441. item_tmp.card[2] = c3;
  2442. item_tmp.card[3] = c4;
  2443. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2444. clif_additem(sd, 0, 0, flag);
  2445. }
  2446. //Logs (A)dmins items [Lupus]
  2447. if(log_config.enable_logs&0x400)
  2448. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  2449. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2450. } else {
  2451. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2452. return -1;
  2453. }
  2454. return 0;
  2455. }
  2456. /*==========================================
  2457. *
  2458. *------------------------------------------
  2459. */
  2460. int atcommand_itemreset(
  2461. const int fd, struct map_session_data* sd,
  2462. const char* command, const char* message)
  2463. {
  2464. int i;
  2465. nullpo_retr(-1, sd);
  2466. for (i = 0; i < MAX_INVENTORY; i++) {
  2467. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2468. //Logs (A)dmins items [Lupus]
  2469. if(log_config.enable_logs&0x400)
  2470. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2471. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2472. }
  2473. }
  2474. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  2475. return 0;
  2476. }
  2477. /*==========================================
  2478. * Atcommand @lvlup
  2479. *------------------------------------------
  2480. */
  2481. int atcommand_baselevelup(
  2482. const int fd, struct map_session_data* sd,
  2483. const char* command, const char* message)
  2484. {
  2485. int level=0, i=0, status_point=0;
  2486. nullpo_retr(-1, sd);
  2487. level = atoi(message);
  2488. if (!message || !*message || !level) {
  2489. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2490. return -1;
  2491. }
  2492. if (level > 0) {
  2493. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2494. clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
  2495. return -1;
  2496. } /* End Addition */
  2497. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2498. level = pc_maxbaselv(sd) - sd->status.base_level;
  2499. for (i = 1; i <= level; i++)
  2500. status_point += (sd->status.base_level + i + 14) / 5;
  2501. if (sd->status.status_point > USHRT_MAX - status_point)
  2502. sd->status.status_point = USHRT_MAX;
  2503. else
  2504. sd->status.status_point += status_point;
  2505. sd->status.base_level += (unsigned int)level;
  2506. clif_updatestatus(sd, SP_BASELEVEL);
  2507. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2508. clif_updatestatus(sd, SP_STATUSPOINT);
  2509. status_calc_pc(sd, 0);
  2510. status_percent_heal(&sd->bl, 100, 100);
  2511. clif_misceffect(&sd->bl, 0);
  2512. clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
  2513. } else {
  2514. if (sd->status.base_level == 1) {
  2515. clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
  2516. return -1;
  2517. }
  2518. level*=-1;
  2519. if ((unsigned int)level >= sd->status.base_level)
  2520. level = sd->status.base_level-1;
  2521. if (sd->status.status_point > 0) {
  2522. for (i = 0; i > -level; i--)
  2523. status_point += (sd->status.base_level + i + 14) / 5;
  2524. if (sd->status.status_point < status_point)
  2525. pc_resetstate(sd);
  2526. if (sd->status.status_point < status_point)
  2527. sd->status.status_point = 0;
  2528. else
  2529. sd->status.status_point -= status_point;
  2530. clif_updatestatus(sd, SP_STATUSPOINT);
  2531. } /* to add: remove status points from stats */
  2532. sd->status.base_level -= (unsigned int)level;
  2533. clif_updatestatus(sd, SP_BASELEVEL);
  2534. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2535. status_calc_pc(sd, 0);
  2536. clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
  2537. }
  2538. return 0;
  2539. }
  2540. /*==========================================
  2541. *
  2542. *------------------------------------------
  2543. */
  2544. int atcommand_joblevelup(
  2545. const int fd, struct map_session_data* sd,
  2546. const char* command, const char* message)
  2547. {
  2548. int level=0;
  2549. nullpo_retr(-1, sd);
  2550. level = atoi(message);
  2551. if (!message || !*message || !level) {
  2552. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2553. return -1;
  2554. }
  2555. if (level > 0) {
  2556. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2557. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  2558. return -1;
  2559. }
  2560. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2561. level = pc_maxjoblv(sd) - sd->status.job_level;
  2562. sd->status.job_level += (unsigned int)level;
  2563. clif_updatestatus(sd, SP_JOBLEVEL);
  2564. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2565. if (sd->status.skill_point > USHRT_MAX - level)
  2566. sd->status.skill_point = USHRT_MAX;
  2567. else
  2568. sd->status.skill_point += level;
  2569. clif_updatestatus(sd, SP_SKILLPOINT);
  2570. status_calc_pc(sd, 0);
  2571. clif_misceffect(&sd->bl, 1);
  2572. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  2573. } else {
  2574. if (sd->status.job_level == 1) {
  2575. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  2576. return -1;
  2577. }
  2578. level *=-1;
  2579. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2580. level = sd->status.job_level-1;
  2581. sd->status.job_level -= (unsigned int)level;
  2582. clif_updatestatus(sd, SP_JOBLEVEL);
  2583. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2584. if (sd->status.skill_point < level)
  2585. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2586. if (sd->status.skill_point < level)
  2587. sd->status.skill_point = 0;
  2588. else
  2589. sd->status.skill_point -= level;
  2590. clif_updatestatus(sd, SP_SKILLPOINT);
  2591. status_calc_pc(sd, 0);
  2592. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  2593. }
  2594. return 0;
  2595. }
  2596. /*==========================================
  2597. * @help
  2598. *------------------------------------------
  2599. */
  2600. int atcommand_help(
  2601. const int fd, struct map_session_data* sd,
  2602. const char* command, const char* message)
  2603. {
  2604. char buf[2048], w1[2048], w2[2048];
  2605. int i, gm_level;
  2606. FILE* fp;
  2607. nullpo_retr(-1, sd);
  2608. memset(buf, '\0', sizeof(buf));
  2609. if ((fp = fopen(help_txt, "r")) != NULL) {
  2610. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2611. gm_level = pc_isGM(sd);
  2612. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2613. if (buf[0] == '/' && buf[1] == '/')
  2614. continue;
  2615. for (i = 0; buf[i] != '\0'; i++) {
  2616. if (buf[i] == '\r' || buf[i] == '\n') {
  2617. buf[i] = '\0';
  2618. break;
  2619. }
  2620. }
  2621. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2622. clif_displaymessage(fd, buf);
  2623. else if (gm_level >= atoi(w1))
  2624. clif_displaymessage(fd, w2);
  2625. }
  2626. fclose(fp);
  2627. } else {
  2628. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2629. return -1;
  2630. }
  2631. return 0;
  2632. }
  2633. /*==========================================
  2634. * @help2 - Char commands [Kayla]
  2635. *------------------------------------------
  2636. */
  2637. int atcommand_help2(
  2638. const int fd, struct map_session_data* sd,
  2639. const char* command, const char* message)
  2640. {
  2641. char buf[2048], w1[2048], w2[2048];
  2642. int i, gm_level;
  2643. FILE* fp;
  2644. nullpo_retr(-1, sd);
  2645. memset(buf, '\0', sizeof(buf));
  2646. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2647. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2648. gm_level = pc_isGM(sd);
  2649. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2650. if (buf[0] == '/' && buf[1] == '/')
  2651. continue;
  2652. for (i = 0; buf[i] != '\0'; i++) {
  2653. if (buf[i] == '\r' || buf[i] == '\n') {
  2654. buf[i] = '\0';
  2655. break;
  2656. }
  2657. }
  2658. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2659. clif_displaymessage(fd, buf);
  2660. else if (gm_level >= atoi(w1))
  2661. clif_displaymessage(fd, w2);
  2662. }
  2663. fclose(fp);
  2664. } else {
  2665. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2666. return -1;
  2667. }
  2668. return 0;
  2669. }
  2670. /*==========================================
  2671. * @gm
  2672. *------------------------------------------
  2673. */
  2674. int atcommand_gm(
  2675. const int fd, struct map_session_data* sd,
  2676. const char* command, const char* message)
  2677. {
  2678. char password[100];
  2679. nullpo_retr(-1, sd);
  2680. memset(password, '\0', sizeof(password));
  2681. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2682. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2683. return -1;
  2684. }
  2685. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2686. clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
  2687. return -1;
  2688. } else
  2689. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2690. return 0;
  2691. }
  2692. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) {
  2693. TBL_PC* sd = (TBL_PC*)bl;
  2694. clif_pvpset(sd, 0, 0, 2);
  2695. if (sd->pvp_timer != UINT_MAX) {
  2696. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  2697. sd->pvp_timer = UINT_MAX;
  2698. }
  2699. return 0;
  2700. }
  2701. /*==========================================
  2702. *
  2703. *------------------------------------------
  2704. */
  2705. int atcommand_pvpoff(
  2706. const int fd, struct map_session_data* sd,
  2707. const char* command, const char* message)
  2708. {
  2709. nullpo_retr(-1, sd);
  2710. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2711. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2712. return -1;
  2713. }
  2714. if (!map[sd->bl.m].flag.pvp) {
  2715. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2716. return -1;
  2717. }
  2718. map[sd->bl.m].flag.pvp = 0;
  2719. clif_send0199(sd->bl.m, 0);
  2720. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  2721. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2722. return 0;
  2723. }
  2724. /*==========================================
  2725. *
  2726. *------------------------------------------
  2727. */
  2728. int atcommand_pvpon(
  2729. const int fd, struct map_session_data* sd,
  2730. const char* command, const char* message)
  2731. {
  2732. struct map_session_data *pl_sd, **pl_allsd;
  2733. int i, users;
  2734. nullpo_retr(-1, sd);
  2735. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2736. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2737. return -1;
  2738. }
  2739. if (!map[sd->bl.m].flag.pvp) {
  2740. map[sd->bl.m].flag.pvp = 1;
  2741. clif_send0199(sd->bl.m, 1);
  2742. pl_allsd = map_getallusers(&users);
  2743. for (i = 0; i < users; i++) {
  2744. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2745. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2746. pl_sd->pvp_rank = 0;
  2747. pl_sd->pvp_lastusers = 0;
  2748. pl_sd->pvp_point = 5;
  2749. pl_sd->pvp_won = 0;
  2750. pl_sd->pvp_lost = 0;
  2751. }
  2752. }
  2753. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2754. } else {
  2755. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2756. return -1;
  2757. }
  2758. return 0;
  2759. }
  2760. /*==========================================
  2761. *
  2762. *------------------------------------------
  2763. */
  2764. int atcommand_gvgoff(
  2765. const int fd, struct map_session_data* sd,
  2766. const char* command, const char* message)
  2767. {
  2768. nullpo_retr(-1, sd);
  2769. if (map[sd->bl.m].flag.gvg) {
  2770. map[sd->bl.m].flag.gvg = 0;
  2771. clif_send0199(sd->bl.m, 0);
  2772. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2773. } else {
  2774. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2775. return -1;
  2776. }
  2777. return 0;
  2778. }
  2779. /*==========================================
  2780. *
  2781. *------------------------------------------
  2782. */
  2783. int atcommand_gvgon(
  2784. const int fd, struct map_session_data* sd,
  2785. const char* command, const char* message)
  2786. {
  2787. nullpo_retr(-1, sd);
  2788. if (!map[sd->bl.m].flag.gvg) {
  2789. map[sd->bl.m].flag.gvg = 1;
  2790. clif_send0199(sd->bl.m, 3);
  2791. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2792. } else {
  2793. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2794. return -1;
  2795. }
  2796. return 0;
  2797. }
  2798. /*==========================================
  2799. *
  2800. *------------------------------------------
  2801. */
  2802. int atcommand_model(
  2803. const int fd, struct map_session_data* sd,
  2804. const char* command, const char* message)
  2805. {
  2806. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2807. nullpo_retr(-1, sd);
  2808. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2809. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2810. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2811. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2812. clif_displaymessage(fd, atcmd_output);
  2813. return -1;
  2814. }
  2815. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2816. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2817. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2818. /* Removed because this check is TOO strange. [Skotlex]
  2819. //秒フ色変更
  2820. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2821. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2822. //秒フ色未実装職の判定
  2823. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2824. return -1;
  2825. } else {
  2826. */
  2827. pc_changelook(sd, LOOK_HAIR, hair_style);
  2828. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2829. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2830. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2831. // }
  2832. } else {
  2833. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2834. return -1;
  2835. }
  2836. return 0;
  2837. }
  2838. /*==========================================
  2839. * @dye && @ccolor
  2840. *------------------------------------------
  2841. */
  2842. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2843. {
  2844. int cloth_color = 0;
  2845. nullpo_retr(-1, sd);
  2846. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2847. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2848. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2849. clif_displaymessage(fd, atcmd_output);
  2850. return -1;
  2851. }
  2852. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2853. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2854. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2855. } else {
  2856. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2857. return -1;
  2858. }
  2859. return 0;
  2860. }
  2861. /*==========================================
  2862. * @hairstyle && @hstyle
  2863. *------------------------------------------
  2864. */
  2865. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2866. {
  2867. int hair_style = 0;
  2868. nullpo_retr(-1, sd);
  2869. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2870. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2871. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2872. clif_displaymessage(fd, atcmd_output);
  2873. return -1;
  2874. }
  2875. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2876. /* Removed because this check is TOO strange. [Skotlex]
  2877. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2878. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2879. return -1;
  2880. } else {
  2881. */
  2882. pc_changelook(sd, LOOK_HAIR, hair_style);
  2883. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2884. // }
  2885. } else {
  2886. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2887. return -1;
  2888. }
  2889. return 0;
  2890. }
  2891. /*==========================================
  2892. * @charhairstyle by [MouseJstr]
  2893. *------------------------------------------
  2894. */
  2895. int
  2896. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2897. const char* command, const char* message)
  2898. {
  2899. nullpo_retr(-1, sd);
  2900. return 0;
  2901. }
  2902. /*==========================================
  2903. * @haircolor && @hcolor
  2904. *------------------------------------------
  2905. */
  2906. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2907. {
  2908. int hair_color = 0;
  2909. nullpo_retr(-1, sd);
  2910. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2911. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2912. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2913. clif_displaymessage(fd, atcmd_output);
  2914. return -1;
  2915. }
  2916. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2917. /* Removed for being such a strange check. [Skotlex]
  2918. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2919. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2920. return -1;
  2921. } else {
  2922. */
  2923. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2924. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2925. // }
  2926. } else {
  2927. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2928. return -1;
  2929. }
  2930. return 0;
  2931. }
  2932. /*==========================================
  2933. * @go [city_number or city_name] - Updated by Harbin
  2934. *------------------------------------------
  2935. */
  2936. int atcommand_go(
  2937. const int fd, struct map_session_data* sd,
  2938. const char* command, const char* message)
  2939. {
  2940. int i;
  2941. int town;
  2942. char map_name[MAP_NAME_LENGTH];
  2943. int m;
  2944. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2945. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2946. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2947. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2948. { MAP_PAYON, 162, 233 }, // 3=Payon
  2949. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2950. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2951. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2952. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2953. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2954. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2955. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2956. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2957. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2958. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2959. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2960. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  2961. { MAP_JAIL, 23, 61 }, // 16=Prison
  2962. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2963. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2964. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2965. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2966. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2967. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2968. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2969. { MAP_VEINS, 216, 123 }, // 24=Veins
  2970. };
  2971. nullpo_retr(-1, sd);
  2972. if(map[sd->bl.m].flag.nogo) {
  2973. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2974. return 0;
  2975. }
  2976. memset(map_name, '\0', sizeof(map_name));
  2977. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2978. // get the number
  2979. town = atoi(message);
  2980. // if no value, display all value
  2981. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2982. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2983. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  2984. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2985. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2986. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2987. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2988. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2989. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2990. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2991. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2992. clif_displaymessage(fd, " 24=Veins");
  2993. return -1;
  2994. } else {
  2995. // get possible name of the city and add .gat if not in the name
  2996. map_name[MAP_NAME_LENGTH-1] = '\0';
  2997. for (i = 0; map_name[i]; i++)
  2998. map_name[i] = tolower(map_name[i]);
  2999. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3000. strcat(map_name, ".gat");
  3001. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  3002. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  3003. town = 0;
  3004. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  3005. town = 1;
  3006. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  3007. town = 2;
  3008. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  3009. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  3010. town = 3;
  3011. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  3012. town = 4;
  3013. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  3014. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  3015. town = 5;
  3016. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  3017. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  3018. town = 6;
  3019. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  3020. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  3021. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  3022. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  3023. town = 7;
  3024. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  3025. town = 8;
  3026. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  3027. town = 9;
  3028. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  3029. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  3030. town = 10;
  3031. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  3032. town = 11;
  3033. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  3034. town = 12;
  3035. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  3036. town = 13;
  3037. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  3038. town = 14;
  3039. } else if (strncmp(map_name, "new_zone01.gat", 3) == 0 || // 3 first characters (or "newbies")
  3040. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  3041. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  3042. town = 15;
  3043. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  3044. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  3045. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  3046. town = 16;
  3047. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  3048. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  3049. town = 17;
  3050. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  3051. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  3052. town = 18;
  3053. } else if (strncmp(map_name, "einbroch.gat", 5) == 0 || // 5 first characters
  3054. strncmp(map_name, "ainbroch.gat", 5) == 0) { // writing error (5 first characters)
  3055. town = 19;
  3056. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  3057. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  3058. town = 20;
  3059. } else if (strncmp(map_name, "einbech.gat", 3) == 0) { // 3 first characters
  3060. town = 21;
  3061. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  3062. town = 22;
  3063. } else if (strncmp(map_name, "rachel.gat", 3) == 0) { // 3 first characters
  3064. town = 23;
  3065. } else if (strncmp(map_name, "veins.gat", 3) == 0) { // 3 first characters
  3066. town = 24;
  3067. }
  3068. if (town >= -3 && town <= -1) {
  3069. if (sd->status.memo_point[-town-1].map) {
  3070. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  3071. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3072. clif_displaymessage(fd, msg_txt(247));
  3073. return -1;
  3074. }
  3075. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3076. clif_displaymessage(fd, msg_txt(248));
  3077. return -1;
  3078. }
  3079. 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) {
  3080. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3081. } else {
  3082. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3083. return -1;
  3084. }
  3085. } else {
  3086. sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
  3087. clif_displaymessage(fd, atcmd_output);
  3088. return -1;
  3089. }
  3090. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  3091. m = map_mapname2mapid((char *)data[town].map);
  3092. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3093. clif_displaymessage(fd, msg_txt(247));
  3094. return -1;
  3095. }
  3096. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3097. clif_displaymessage(fd, msg_txt(248));
  3098. return -1;
  3099. }
  3100. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  3101. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3102. } else {
  3103. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3104. return -1;
  3105. }
  3106. } else { // if you arrive here, you have an error in town variable when reading of names
  3107. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  3108. return -1;
  3109. }
  3110. }
  3111. return 0;
  3112. }
  3113. /*==========================================
  3114. *
  3115. *------------------------------------------
  3116. */
  3117. int atcommand_monster(
  3118. const int fd, struct map_session_data* sd,
  3119. const char* command, const char* message)
  3120. {
  3121. char name[NAME_LENGTH];
  3122. char monster[NAME_LENGTH];
  3123. int mob_id;
  3124. int number = 0;
  3125. int count;
  3126. int i, k, range;
  3127. short mx, my;
  3128. nullpo_retr(-1, sd);
  3129. memset(name, '\0', sizeof(name));
  3130. memset(monster, '\0', sizeof(monster));
  3131. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3132. if (!message || !*message) {
  3133. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3134. return -1;
  3135. }
  3136. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3137. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3138. //All data can be left as it is.
  3139. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3140. //Here, it is possible name was not given and we are using monster for it.
  3141. if (count < 3) //Blank mob's name.
  3142. name[0] = '\0';
  3143. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3144. //All data can be left as it is.
  3145. } else if (sscanf(message, "%23s", monster) > 0) {
  3146. //As before, name may be already filled.
  3147. name[0] = '\0';
  3148. } else {
  3149. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3150. return -1;
  3151. }
  3152. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3153. mob_id = mobdb_checkid(atoi(monster));
  3154. if (mob_id == 0) {
  3155. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3156. return -1;
  3157. }
  3158. if (mob_id == MOBID_EMPERIUM) {
  3159. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  3160. return -1;
  3161. }
  3162. if (number <= 0)
  3163. number = 1;
  3164. if (strlen(name) < 1)
  3165. strcpy(name, "--ja--");
  3166. // 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
  3167. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3168. number = battle_config.atc_spawn_quantity_limit;
  3169. if (battle_config.etc_log)
  3170. 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);
  3171. count = 0;
  3172. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3173. for (i = 0; i < number; i++) {
  3174. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3175. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3176. count += (k != 0) ? 1 : 0;
  3177. }
  3178. if (count != 0)
  3179. if (number == count)
  3180. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  3181. else {
  3182. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  3183. clif_displaymessage(fd, atcmd_output);
  3184. }
  3185. else {
  3186. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3187. return -1;
  3188. }
  3189. return 0;
  3190. }
  3191. // small monster spawning [Valaris]
  3192. int atcommand_monstersmall(
  3193. const int fd, struct map_session_data* sd,
  3194. const char* command, const char* message) {
  3195. char name[NAME_LENGTH] = "";
  3196. char monster[NAME_LENGTH] = "";
  3197. int mob_id = 0;
  3198. int number = 0;
  3199. int x = 0;
  3200. int y = 0;
  3201. int count;
  3202. int i;
  3203. nullpo_retr(-1, sd);
  3204. if (!message || !*message) {
  3205. clif_displaymessage(fd, "Give a monster name/id please.");
  3206. return -1;
  3207. }
  3208. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3209. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3210. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3211. clif_displaymessage(fd, "Give a monster name/id please.");
  3212. return -1;
  3213. }
  3214. // If monster identifier/name argument is a name
  3215. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3216. mob_id = atoi(monster);
  3217. if (mob_id == 0) {
  3218. clif_displaymessage(fd, msg_txt(40));
  3219. return -1;
  3220. }
  3221. if (mob_id == MOBID_EMPERIUM) {
  3222. clif_displaymessage(fd, msg_txt(83));
  3223. return -1;
  3224. }
  3225. if (mobdb_checkid(mob_id) == 0) {
  3226. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3227. return -1;
  3228. }
  3229. if (number <= 0)
  3230. number = 1;
  3231. if (strlen(name) < 1)
  3232. strcpy(name, "--ja--");
  3233. // 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
  3234. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3235. number = battle_config.atc_spawn_quantity_limit;
  3236. count = 0;
  3237. for (i = 0; i < number; i++) {
  3238. int mx, my;
  3239. if (x <= 0)
  3240. mx = sd->bl.x + (rand() % 11 - 5);
  3241. else
  3242. mx = x;
  3243. if (y <= 0)
  3244. my = sd->bl.y + (rand() % 11 - 5);
  3245. else
  3246. my = y;
  3247. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3248. }
  3249. if (count != 0)
  3250. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3251. else
  3252. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3253. return 0;
  3254. }
  3255. // big monster spawning [Valaris]
  3256. int atcommand_monsterbig(
  3257. const int fd, struct map_session_data* sd,
  3258. const char* command, const char* message) {
  3259. char name[NAME_LENGTH] = "";
  3260. char monster[NAME_LENGTH] = "";
  3261. int mob_id = 0;
  3262. int number = 0;
  3263. int x = 0;
  3264. int y = 0;
  3265. int count;
  3266. int i;
  3267. nullpo_retr(-1, sd);
  3268. if (!message || !*message) {
  3269. clif_displaymessage(fd, "Give a monster name/id please.");
  3270. return -1;
  3271. }
  3272. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3273. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3274. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3275. clif_displaymessage(fd, "Give a monster name/id please.");
  3276. return -1;
  3277. }
  3278. // If monster identifier/name argument is a name
  3279. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3280. mob_id = atoi(monster);
  3281. if (mob_id == 0) {
  3282. clif_displaymessage(fd, msg_txt(40));
  3283. return -1;
  3284. }
  3285. if (mob_id == MOBID_EMPERIUM) {
  3286. clif_displaymessage(fd, msg_txt(83));
  3287. return -1;
  3288. }
  3289. if (mobdb_checkid(mob_id) == 0) {
  3290. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3291. return -1;
  3292. }
  3293. if (number <= 0)
  3294. number = 1;
  3295. if (strlen(name) < 1)
  3296. strcpy(name, "--ja--");
  3297. // 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
  3298. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3299. number = battle_config.atc_spawn_quantity_limit;
  3300. count = 0;
  3301. for (i = 0; i < number; i++) {
  3302. int mx, my;
  3303. if (x <= 0)
  3304. mx = sd->bl.x + (rand() % 11 - 5);
  3305. else
  3306. mx = x;
  3307. if (y <= 0)
  3308. my = sd->bl.y + (rand() % 11 - 5);
  3309. else
  3310. my = y;
  3311. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3312. }
  3313. if (count != 0)
  3314. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3315. else
  3316. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3317. return 0;
  3318. }
  3319. /*==========================================
  3320. *
  3321. *------------------------------------------
  3322. */
  3323. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3324. struct mob_data *md;
  3325. int flag;
  3326. nullpo_retr(0, ap);
  3327. nullpo_retr(0, md=(struct mob_data *)bl);
  3328. flag = va_arg(ap, int);
  3329. if (md->guardian_data)
  3330. return 0; //Do not touch WoE mobs!
  3331. if (flag)
  3332. status_zap(bl,md->status.hp, 0);
  3333. else
  3334. status_kill(bl);
  3335. return 1;
  3336. }
  3337. void atcommand_killmonster_sub(
  3338. const int fd, struct map_session_data* sd, const char* message,
  3339. const int drop)
  3340. {
  3341. int map_id;
  3342. char map_name[MAP_NAME_LENGTH];
  3343. if (!sd) return;
  3344. memset(map_name, '\0', sizeof(map_name));
  3345. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3346. map_id = sd->bl.m;
  3347. else {
  3348. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3349. strcat(map_name, ".gat");
  3350. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3351. map_id = sd->bl.m;
  3352. }
  3353. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3354. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  3355. return;
  3356. }
  3357. /*==========================================
  3358. *
  3359. *------------------------------------------
  3360. */
  3361. int atcommand_killmonster(
  3362. const int fd, struct map_session_data* sd,
  3363. const char* command, const char* message)
  3364. {
  3365. if (!sd) return 0;
  3366. atcommand_killmonster_sub(fd, sd, message, 1);
  3367. return 0;
  3368. }
  3369. /*==========================================
  3370. *
  3371. *------------------------------------------
  3372. */
  3373. int atcommand_killmonster2(
  3374. const int fd, struct map_session_data* sd,
  3375. const char* command, const char* message)
  3376. {
  3377. if (!sd) return 0;
  3378. atcommand_killmonster_sub(fd, sd, message, 0);
  3379. return 0;
  3380. }
  3381. /*==========================================
  3382. *
  3383. *------------------------------------------
  3384. */
  3385. int atcommand_refine(
  3386. const int fd, struct map_session_data* sd,
  3387. const char* command, const char* message)
  3388. {
  3389. int i,j, position = 0, refine = 0, current_position, final_refine;
  3390. int count;
  3391. nullpo_retr(-1, sd);
  3392. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3393. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3394. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3395. return -1;
  3396. }
  3397. if (refine < -MAX_REFINE)
  3398. refine = -MAX_REFINE;
  3399. else if (refine > MAX_REFINE)
  3400. refine = MAX_REFINE;
  3401. else if (refine == 0)
  3402. refine = 1;
  3403. count = 0;
  3404. for (j = 0; j < EQI_MAX-1; j++) {
  3405. if ((i = sd->equip_index[j]) < 0)
  3406. continue;
  3407. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  3408. continue;
  3409. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  3410. continue;
  3411. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  3412. continue;
  3413. if(position && !(sd->status.inventory[i].equip & position))
  3414. continue;
  3415. final_refine = sd->status.inventory[i].refine + refine;
  3416. if (final_refine > MAX_REFINE)
  3417. final_refine = MAX_REFINE;
  3418. else if (final_refine < 0)
  3419. final_refine = 0;
  3420. if (sd->status.inventory[i].refine != final_refine) {
  3421. sd->status.inventory[i].refine = final_refine;
  3422. current_position = sd->status.inventory[i].equip;
  3423. pc_unequipitem(sd, i, 3);
  3424. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3425. clif_delitem(sd, i, 1);
  3426. clif_additem(sd, i, 1, 0);
  3427. pc_equipitem(sd, i, current_position);
  3428. clif_misceffect(&sd->bl, 3);
  3429. count++;
  3430. }
  3431. }
  3432. if (count == 0)
  3433. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  3434. else if (count == 1)
  3435. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  3436. else {
  3437. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  3438. clif_displaymessage(fd, atcmd_output);
  3439. }
  3440. return 0;
  3441. }
  3442. /*==========================================
  3443. *
  3444. *------------------------------------------
  3445. */
  3446. int atcommand_produce(
  3447. const int fd, struct map_session_data* sd,
  3448. const char* command, const char* message)
  3449. {
  3450. char item_name[100];
  3451. int item_id, attribute = 0, star = 0;
  3452. int flag = 0;
  3453. struct item_data *item_data;
  3454. struct item tmp_item;
  3455. nullpo_retr(-1, sd);
  3456. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3457. memset(item_name, '\0', sizeof(item_name));
  3458. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3459. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3460. return -1;
  3461. }
  3462. item_id = 0;
  3463. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  3464. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  3465. {
  3466. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  3467. clif_displaymessage(fd, atcmd_output);
  3468. return -1;
  3469. }
  3470. item_id = item_data->nameid;
  3471. if (itemdb_isequip2(item_data)) {
  3472. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3473. attribute = ATTRIBUTE_NORMAL;
  3474. if (star < MIN_STAR || star > MAX_STAR)
  3475. star = 0;
  3476. memset(&tmp_item, 0, sizeof tmp_item);
  3477. tmp_item.nameid = item_id;
  3478. tmp_item.amount = 1;
  3479. tmp_item.identify = 1;
  3480. tmp_item.card[0] = CARD0_FORGE;
  3481. tmp_item.card[1] = item_data->type==IT_WEAPON?
  3482. ((star*5) << 8) + attribute:0;
  3483. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  3484. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  3485. clif_produceeffect(sd, 0, item_id);
  3486. clif_misceffect(&sd->bl, 3);
  3487. //Logs (A)dmins items [Lupus]
  3488. if(log_config.enable_logs&0x400)
  3489. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  3490. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3491. clif_additem(sd, 0, 0, flag);
  3492. } else {
  3493. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3494. clif_displaymessage(fd, atcmd_output);
  3495. return -1;
  3496. }
  3497. return 0;
  3498. }
  3499. /*==========================================
  3500. * Sub-function to display actual memo points
  3501. *------------------------------------------
  3502. */
  3503. void atcommand_memo_sub(struct map_session_data* sd) {
  3504. int i;
  3505. if (!sd) return;
  3506. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3507. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3508. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3509. if (sd->status.memo_point[i].map)
  3510. 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);
  3511. else
  3512. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  3513. clif_displaymessage(sd->fd, atcmd_output);
  3514. }
  3515. return;
  3516. }
  3517. /*==========================================
  3518. *
  3519. *------------------------------------------
  3520. */
  3521. int atcommand_memo(
  3522. const int fd, struct map_session_data* sd,
  3523. const char* command, const char* message)
  3524. {
  3525. int position = 0;
  3526. nullpo_retr(-1, sd);
  3527. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3528. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3529. atcommand_memo_sub(sd);
  3530. else {
  3531. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3532. 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)) {
  3533. clif_displaymessage(fd, msg_txt(253));
  3534. return -1;
  3535. }
  3536. if (sd->status.memo_point[position].map) {
  3537. 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).
  3538. clif_displaymessage(fd, atcmd_output);
  3539. }
  3540. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3541. sd->status.memo_point[position].x = sd->bl.x;
  3542. sd->status.memo_point[position].y = sd->bl.y;
  3543. clif_skill_memo(sd, 0);
  3544. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3545. clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
  3546. atcommand_memo_sub(sd);
  3547. } else {
  3548. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3549. clif_displaymessage(fd, atcmd_output);
  3550. atcommand_memo_sub(sd);
  3551. return -1;
  3552. }
  3553. }
  3554. return 0;
  3555. }
  3556. /*==========================================
  3557. *
  3558. *------------------------------------------
  3559. */
  3560. int atcommand_gat(
  3561. const int fd, struct map_session_data* sd,
  3562. const char* command, const char* message)
  3563. {
  3564. int y;
  3565. nullpo_retr(-1, sd);
  3566. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3567. for (y = 2; y >= -2; y--) {
  3568. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3569. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3570. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3571. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3572. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3573. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3574. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3575. clif_displaymessage(fd, atcmd_output);
  3576. }
  3577. return 0;
  3578. }
  3579. /*==========================================
  3580. *
  3581. *------------------------------------------
  3582. */
  3583. int atcommand_packet(
  3584. const int fd, struct map_session_data* sd,
  3585. const char* command, const char* message)
  3586. {
  3587. static int packet_mode = 0;
  3588. int i, x = 0, y = 0;
  3589. nullpo_retr(-1, sd);
  3590. if (strstr(command, "packetmode")) {
  3591. packet_mode = atoi(message);
  3592. clif_displaymessage(fd, "Packet mode changed.");
  3593. return 0;
  3594. }
  3595. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3596. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3597. return -1;
  3598. }
  3599. if (i == 1) y = 1;
  3600. switch (packet_mode)
  3601. {
  3602. case 0:
  3603. clif_status_change(&sd->bl, x, y);
  3604. break;
  3605. case 1:
  3606. sd->status.skill[sd->cloneskill_id].id=0;
  3607. sd->status.skill[sd->cloneskill_id].lv=0;
  3608. sd->status.skill[sd->cloneskill_id].flag=0;
  3609. sd->cloneskill_id = x;
  3610. sd->status.skill[x].id = x;
  3611. sd->status.skill[x].lv = skill_get_max(x);
  3612. sd->status.skill[x].flag = 13;//cloneskill flag
  3613. clif_skillinfoblock(sd);
  3614. break;
  3615. case 2:
  3616. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3617. case 3:
  3618. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3619. default:
  3620. break;
  3621. //added later
  3622. }
  3623. return 0;
  3624. }
  3625. /*==========================================
  3626. * @waterlevel [Skotlex]
  3627. *------------------------------------------
  3628. */
  3629. int atcommand_waterlevel(
  3630. const int fd, struct map_session_data* sd,
  3631. const char* command, const char* message)
  3632. {
  3633. int newlevel;
  3634. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3635. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3636. clif_displaymessage(fd, atcmd_output);
  3637. return 0;
  3638. }
  3639. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3640. if (newlevel > 0)
  3641. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3642. else
  3643. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3644. clif_displaymessage(fd, atcmd_output);
  3645. } else {
  3646. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3647. clif_displaymessage(fd, atcmd_output);
  3648. }
  3649. return 0;
  3650. }
  3651. /*==========================================
  3652. * @stpoint (Rewritten by [Yor])
  3653. *------------------------------------------
  3654. */
  3655. int atcommand_statuspoint(
  3656. const int fd, struct map_session_data* sd,
  3657. const char* command, const char* message)
  3658. {
  3659. int point, new_status_point;
  3660. if (!message || !*message || (point = atoi(message)) == 0) {
  3661. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3662. return -1;
  3663. }
  3664. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3665. new_status_point = USHRT_MAX;
  3666. else
  3667. if (point < 0 && sd->status.status_point < -point)
  3668. new_status_point = 0;
  3669. else
  3670. new_status_point = sd->status.status_point + point;
  3671. if (new_status_point != (int)sd->status.status_point) {
  3672. sd->status.status_point = (unsigned short)new_status_point;
  3673. clif_updatestatus(sd, SP_STATUSPOINT);
  3674. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  3675. } else {
  3676. if (point < 0)
  3677. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3678. else
  3679. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3680. return -1;
  3681. }
  3682. return 0;
  3683. }
  3684. /*==========================================
  3685. * @skpoint (Rewritten by [Yor])
  3686. *------------------------------------------
  3687. */
  3688. int atcommand_skillpoint(
  3689. const int fd, struct map_session_data* sd,
  3690. const char* command, const char* message)
  3691. {
  3692. int point, new_skill_point;
  3693. nullpo_retr(-1, sd);
  3694. if (!message || !*message || (point = atoi(message)) == 0) {
  3695. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3696. return -1;
  3697. }
  3698. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3699. new_skill_point = USHRT_MAX;
  3700. else if (point < 0 && sd->status.skill_point < -point)
  3701. new_skill_point = 0;
  3702. else
  3703. new_skill_point = sd->status.skill_point + point;
  3704. if (new_skill_point != (int)sd->status.skill_point) {
  3705. sd->status.skill_point = (unsigned short)new_skill_point;
  3706. clif_updatestatus(sd, SP_SKILLPOINT);
  3707. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  3708. } else {
  3709. if (point < 0)
  3710. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3711. else
  3712. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3713. return -1;
  3714. }
  3715. return 0;
  3716. }
  3717. /*==========================================
  3718. * @zeny (Rewritten by [Yor])
  3719. *------------------------------------------
  3720. */
  3721. int atcommand_zeny(
  3722. const int fd, struct map_session_data* sd,
  3723. const char* command, const char* message)
  3724. {
  3725. int zeny, new_zeny;
  3726. nullpo_retr(-1, sd);
  3727. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3728. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3729. return -1;
  3730. }
  3731. new_zeny = sd->status.zeny + zeny;
  3732. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3733. new_zeny = MAX_ZENY;
  3734. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3735. new_zeny = 0;
  3736. if (new_zeny != sd->status.zeny) {
  3737. sd->status.zeny = new_zeny;
  3738. clif_updatestatus(sd, SP_ZENY);
  3739. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  3740. } else {
  3741. if (zeny < 0)
  3742. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3743. else
  3744. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3745. return -1;
  3746. }
  3747. return 0;
  3748. }
  3749. /*==========================================
  3750. *
  3751. *------------------------------------------
  3752. */
  3753. int atcommand_param(
  3754. const int fd, struct map_session_data* sd,
  3755. const char* command, const char* message)
  3756. {
  3757. int index, value = 0, new_value, max;
  3758. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3759. short* status[6];
  3760. //we don't use direct initialization because it isn't part of the c standard.
  3761. nullpo_retr(-1, sd);
  3762. status[0] = &sd->status.str;
  3763. status[1] = &sd->status.agi;
  3764. status[2] = &sd->status.vit;
  3765. status[3] = &sd->status.int_;
  3766. status[4] = &sd->status.dex;
  3767. status[5] = &sd->status.luk;
  3768. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3769. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3770. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3771. clif_displaymessage(fd, atcmd_output);
  3772. return -1;
  3773. }
  3774. index = -1;
  3775. for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
  3776. if (strcmpi(command, param[index]) == 0)
  3777. break;
  3778. }
  3779. if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
  3780. // normaly impossible...
  3781. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3782. clif_displaymessage(fd, atcmd_output);
  3783. return -1;
  3784. }
  3785. max = pc_maxparameter(sd);
  3786. if (value > 0 && *status[index] > max - value)
  3787. new_value = max;
  3788. else if (value < 0 && *status[index] <= -value)
  3789. new_value = 1;
  3790. else
  3791. new_value = *status[index] + value;
  3792. if (new_value != (int)*status[index]) {
  3793. *status[index] = new_value;
  3794. clif_updatestatus(sd, SP_STR + index);
  3795. clif_updatestatus(sd, SP_USTR + index);
  3796. status_calc_pc(sd, 0);
  3797. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3798. } else {
  3799. if (value < 0)
  3800. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3801. else
  3802. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3803. return -1;
  3804. }
  3805. return 0;
  3806. }
  3807. /*==========================================
  3808. *
  3809. *------------------------------------------
  3810. */
  3811. //** Stat all by fritz (rewritten by [Yor])
  3812. int atcommand_stat_all(
  3813. const int fd, struct map_session_data* sd,
  3814. const char* command, const char* message)
  3815. {
  3816. int index, count, value = 0, max, new_value;
  3817. short* status[6];
  3818. //we don't use direct initialization because it isn't part of the c standard.
  3819. nullpo_retr(-1, sd);
  3820. status[0] = &sd->status.str;
  3821. status[1] = &sd->status.agi;
  3822. status[2] = &sd->status.vit;
  3823. status[3] = &sd->status.int_;
  3824. status[4] = &sd->status.dex;
  3825. status[5] = &sd->status.luk;
  3826. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3827. value = pc_maxparameter(sd);
  3828. count = 0;
  3829. max = pc_maxparameter(sd);
  3830. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3831. if (value > 0 && *status[index] > max - value)
  3832. new_value = max;
  3833. else if (value < 0 && *status[index] <= -value)
  3834. new_value = 1;
  3835. else
  3836. new_value = *status[index] +value;
  3837. if (new_value != (int)*status[index]) {
  3838. *status[index] = new_value;
  3839. clif_updatestatus(sd, SP_STR + index);
  3840. clif_updatestatus(sd, SP_USTR + index);
  3841. status_calc_pc(sd, 0);
  3842. count++;
  3843. }
  3844. }
  3845. if (count > 0) // if at least 1 stat modified
  3846. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3847. else {
  3848. if (value < 0)
  3849. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  3850. else
  3851. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  3852. return -1;
  3853. }
  3854. return 0;
  3855. }
  3856. /*==========================================
  3857. *
  3858. *------------------------------------------
  3859. */
  3860. int atcommand_guildlevelup(
  3861. const int fd, struct map_session_data* sd,
  3862. const char* command, const char* message)
  3863. {
  3864. int level = 0;
  3865. short added_level;
  3866. struct guild *guild_info;
  3867. nullpo_retr(-1, sd);
  3868. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3869. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3870. return -1;
  3871. }
  3872. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3873. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3874. return -1;
  3875. }
  3876. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3877. clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3878. return -1;
  3879. }
  3880. added_level = (short)level;
  3881. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3882. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3883. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3884. added_level = 1 - guild_info->guild_lv;
  3885. if (added_level != 0) {
  3886. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3887. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3888. } else {
  3889. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3890. return -1;
  3891. }
  3892. return 0;
  3893. }
  3894. /*==========================================
  3895. *
  3896. *------------------------------------------
  3897. */
  3898. int atcommand_makeegg(
  3899. const int fd, struct map_session_data* sd,
  3900. const char* command, const char* message)
  3901. {
  3902. struct item_data *item_data;
  3903. int id, pet_id;
  3904. nullpo_retr(-1, sd);
  3905. if (!message || !*message) {
  3906. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3907. return -1;
  3908. }
  3909. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3910. id = item_data->nameid;
  3911. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3912. id = atoi(message);
  3913. pet_id = search_petDB_index(id, PET_CLASS);
  3914. if (pet_id < 0)
  3915. pet_id = search_petDB_index(id, PET_EGG);
  3916. if (pet_id >= 0) {
  3917. sd->catch_target_class = pet_db[pet_id].class_;
  3918. intif_create_pet(
  3919. sd->status.account_id, sd->status.char_id,
  3920. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3921. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3922. 100, 0, 1, pet_db[pet_id].jname);
  3923. } else {
  3924. clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
  3925. return -1;
  3926. }
  3927. return 0;
  3928. }
  3929. /*==========================================
  3930. *
  3931. *------------------------------------------
  3932. */
  3933. int atcommand_hatch(
  3934. const int fd, struct map_session_data* sd,
  3935. const char* command, const char* message)
  3936. {
  3937. nullpo_retr(-1, sd);
  3938. if (sd->status.pet_id <= 0)
  3939. clif_sendegg(sd);
  3940. else {
  3941. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3942. return -1;
  3943. }
  3944. return 0;
  3945. }
  3946. /*==========================================
  3947. *
  3948. *------------------------------------------
  3949. */
  3950. int atcommand_petfriendly(
  3951. const int fd, struct map_session_data* sd,
  3952. const char* command, const char* message)
  3953. {
  3954. int friendly;
  3955. struct pet_data *pd;
  3956. nullpo_retr(-1, sd);
  3957. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3958. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3959. return -1;
  3960. }
  3961. pd = sd->pd;
  3962. if (!pd) {
  3963. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3964. return -1;
  3965. }
  3966. if (friendly < 0 || friendly > 1000)
  3967. {
  3968. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3969. return -1;
  3970. }
  3971. if (friendly == pd->pet.intimate) {
  3972. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  3973. return -1;
  3974. }
  3975. pd->pet.intimate = friendly;
  3976. clif_send_petstatus(sd);
  3977. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  3978. return 0;
  3979. }
  3980. /*==========================================
  3981. *
  3982. *------------------------------------------
  3983. */
  3984. int atcommand_pethungry(
  3985. const int fd, struct map_session_data* sd,
  3986. const char* command, const char* message)
  3987. {
  3988. int hungry;
  3989. struct pet_data *pd;
  3990. nullpo_retr(-1, sd);
  3991. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3992. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3993. return -1;
  3994. }
  3995. pd = sd->pd;
  3996. if (!sd->status.pet_id || !pd) {
  3997. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3998. return -1;
  3999. }
  4000. if (hungry < 0 || hungry > 100) {
  4001. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4002. return -1;
  4003. }
  4004. if (hungry == pd->pet.hungry) {
  4005. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  4006. return -1;
  4007. }
  4008. pd->pet.hungry = hungry;
  4009. clif_send_petstatus(sd);
  4010. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  4011. return 0;
  4012. }
  4013. /*==========================================
  4014. *
  4015. *------------------------------------------
  4016. */
  4017. int atcommand_petrename(
  4018. const int fd, struct map_session_data* sd,
  4019. const char* command, const char* message)
  4020. {
  4021. struct pet_data *pd;
  4022. nullpo_retr(-1, sd);
  4023. if (!sd->status.pet_id || !sd->pd) {
  4024. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  4025. return -1;
  4026. }
  4027. pd = sd->pd;
  4028. if (!pd->pet.rename_flag) {
  4029. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  4030. return -1;
  4031. }
  4032. pd->pet.rename_flag = 0;
  4033. intif_save_petdata(sd->status.account_id, &pd->pet);
  4034. clif_send_petstatus(sd);
  4035. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  4036. return 0;
  4037. }
  4038. /*==========================================
  4039. *
  4040. *------------------------------------------
  4041. */
  4042. int
  4043. atcommand_recall(
  4044. const int fd, struct map_session_data* sd,
  4045. const char* command, const char* message)
  4046. {
  4047. struct map_session_data *pl_sd = NULL;
  4048. nullpo_retr(-1, sd);
  4049. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4050. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  4051. return -1;
  4052. }
  4053. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4054. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  4055. return -1;
  4056. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  4057. return -1;
  4058. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4059. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4060. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4061. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4062. return -1;
  4063. }
  4064. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4065. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  4066. return -1;
  4067. }
  4068. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4069. sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
  4070. clif_displaymessage(fd, atcmd_output);
  4071. } else {
  4072. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4073. return -1;
  4074. }
  4075. } else {
  4076. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4077. return -1;
  4078. }
  4079. return 0;
  4080. }
  4081. /*==========================================
  4082. *
  4083. *------------------------------------------
  4084. */
  4085. int atcommand_revive(
  4086. const int fd, struct map_session_data* sd,
  4087. const char* command, const char* message)
  4088. {
  4089. struct map_session_data *pl_sd;
  4090. nullpo_retr(-1, sd);
  4091. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4092. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4093. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  4094. return -1;
  4095. }
  4096. pl_sd = map_nick2sd(atcmd_player_name);
  4097. if (!pl_sd) {
  4098. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4099. return -1;
  4100. }
  4101. if (!status_revive(&pl_sd->bl, 100, 0))
  4102. return -1;
  4103. clif_skill_nodamage(&sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  4104. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  4105. return 0;
  4106. }
  4107. /*==========================================
  4108. * charblock command (usage: charblock <player_name>)
  4109. * This command do a definitiv ban on a player
  4110. *------------------------------------------
  4111. */
  4112. int atcommand_char_block(
  4113. const int fd, struct map_session_data* sd,
  4114. const char* command, const char* message)
  4115. {
  4116. nullpo_retr(-1, sd);
  4117. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4118. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4119. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4120. return -1;
  4121. }
  4122. // check player name
  4123. if (strlen(atcmd_player_name) < 4) {
  4124. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4125. return -1;
  4126. } else if (strlen(atcmd_player_name) > 23) {
  4127. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4128. return -1;
  4129. } else {
  4130. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4131. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4132. }
  4133. return 0;
  4134. }
  4135. /*==========================================
  4136. * charban command (usage: charban <time> <player_name>)
  4137. * This command do a limited ban on a player
  4138. * Time is done as follows:
  4139. * Adjustment value (-1, 1, +1, etc...)
  4140. * Modified element:
  4141. * a or y: year
  4142. * m: month
  4143. * j or d: day
  4144. * h: hour
  4145. * mn: minute
  4146. * s: second
  4147. * <example> @ban +1m-2mn1s-6y test_player
  4148. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4149. *------------------------------------------
  4150. */
  4151. int atcommand_char_ban(
  4152. const int fd, struct map_session_data* sd,
  4153. const char* command, const char* message)
  4154. {
  4155. char * modif_p;
  4156. int year, month, day, hour, minute, second, value;
  4157. nullpo_retr(-1, sd);
  4158. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4159. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4160. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4161. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4162. return -1;
  4163. }
  4164. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4165. modif_p = atcmd_output;
  4166. year = month = day = hour = minute = second = 0;
  4167. while (modif_p[0] != '\0') {
  4168. value = atoi(modif_p);
  4169. if (value == 0)
  4170. modif_p++;
  4171. else {
  4172. if (modif_p[0] == '-' || modif_p[0] == '+')
  4173. modif_p++;
  4174. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4175. modif_p++;
  4176. if (modif_p[0] == 's') {
  4177. second = value;
  4178. modif_p++;
  4179. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4180. minute = value;
  4181. modif_p = modif_p + 2;
  4182. } else if (modif_p[0] == 'h') {
  4183. hour = value;
  4184. modif_p++;
  4185. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4186. day = value;
  4187. modif_p++;
  4188. } else if (modif_p[0] == 'm') {
  4189. month = value;
  4190. modif_p++;
  4191. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4192. year = value;
  4193. modif_p++;
  4194. } else if (modif_p[0] != '\0') {
  4195. modif_p++;
  4196. }
  4197. }
  4198. }
  4199. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4200. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  4201. return -1;
  4202. }
  4203. // check player name
  4204. if (strlen(atcmd_player_name) < 4) {
  4205. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4206. return -1;
  4207. } else if (strlen(atcmd_player_name) > 23) {
  4208. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4209. return -1;
  4210. } else {
  4211. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4212. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4213. }
  4214. return 0;
  4215. }
  4216. /*==========================================
  4217. * charunblock command (usage: charunblock <player_name>)
  4218. *------------------------------------------
  4219. */
  4220. int atcommand_char_unblock(
  4221. const int fd, struct map_session_data* sd,
  4222. const char* command, const char* message)
  4223. {
  4224. nullpo_retr(-1, sd);
  4225. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4226. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4227. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4228. return -1;
  4229. }
  4230. // check player name
  4231. if (strlen(atcmd_player_name) < 4) {
  4232. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4233. return -1;
  4234. } else if (strlen(atcmd_player_name) > 23) {
  4235. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4236. return -1;
  4237. } else {
  4238. // send answer to login server via char-server
  4239. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4240. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4241. }
  4242. return 0;
  4243. }
  4244. /*==========================================
  4245. * charunban command (usage: charunban <player_name>)
  4246. *------------------------------------------
  4247. */
  4248. int atcommand_char_unban(
  4249. const int fd, struct map_session_data* sd,
  4250. const char* command, const char* message)
  4251. {
  4252. nullpo_retr(-1, sd);
  4253. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4254. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4255. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4256. return -1;
  4257. }
  4258. // check player name
  4259. if (strlen(atcmd_player_name) < 4) {
  4260. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4261. return -1;
  4262. } else if (strlen(atcmd_player_name) > 23) {
  4263. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4264. return -1;
  4265. } else {
  4266. // send answer to login server via char-server
  4267. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4268. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4269. }
  4270. return 0;
  4271. }
  4272. /*==========================================
  4273. *
  4274. *------------------------------------------
  4275. */
  4276. int atcommand_night(
  4277. const int fd, struct map_session_data* sd,
  4278. const char* command, const char* message)
  4279. {
  4280. nullpo_retr(-1, sd);
  4281. if (night_flag != 1) {
  4282. map_night_timer(night_timer_tid, 0, 0, 1);
  4283. } else {
  4284. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  4285. return -1;
  4286. }
  4287. return 0;
  4288. }
  4289. /*==========================================
  4290. *
  4291. *------------------------------------------
  4292. */
  4293. int atcommand_day(
  4294. const int fd, struct map_session_data* sd,
  4295. const char* command, const char* message)
  4296. {
  4297. nullpo_retr(-1, sd);
  4298. if (night_flag != 0) {
  4299. map_day_timer(day_timer_tid, 0, 0, 1);
  4300. } else {
  4301. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  4302. return -1;
  4303. }
  4304. return 0;
  4305. }
  4306. /*==========================================
  4307. *
  4308. *------------------------------------------
  4309. */
  4310. int atcommand_doom(
  4311. const int fd, struct map_session_data* sd,
  4312. const char* command, const char* message)
  4313. {
  4314. struct map_session_data *pl_sd, **pl_allsd;
  4315. int i, users;
  4316. nullpo_retr(-1, sd);
  4317. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4318. pl_allsd = map_getallusers(&users);
  4319. for(i = 0; i < users; i++) {
  4320. 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
  4321. status_kill(&pl_sd->bl);
  4322. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4323. }
  4324. }
  4325. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4326. return 0;
  4327. }
  4328. /*==========================================
  4329. *
  4330. *------------------------------------------
  4331. */
  4332. int atcommand_doommap(
  4333. const int fd, struct map_session_data* sd,
  4334. const char* command, const char* message)
  4335. {
  4336. struct map_session_data *pl_sd, **pl_allsd;
  4337. int i, users;
  4338. nullpo_retr(-1, sd);
  4339. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4340. pl_allsd = map_getallusers(&users);
  4341. for (i = 0; i < users; i++) {
  4342. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4343. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4344. {
  4345. status_kill(&pl_sd->bl);
  4346. // clif_specialeffect(&pl_sd->bl,450,1);
  4347. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4348. }
  4349. }
  4350. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4351. return 0;
  4352. }
  4353. /*==========================================
  4354. *
  4355. *------------------------------------------
  4356. */
  4357. static void atcommand_raise_sub(struct map_session_data* sd)
  4358. {
  4359. if (!sd->state.auth || !status_isdead(&sd->bl))
  4360. return;
  4361. if(!status_revive(&sd->bl, 100, 100))
  4362. return;
  4363. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4364. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  4365. }
  4366. /*==========================================
  4367. *
  4368. *------------------------------------------
  4369. */
  4370. int atcommand_raise(
  4371. const int fd, struct map_session_data* sd,
  4372. const char* command, const char* message)
  4373. {
  4374. int i, users;
  4375. struct map_session_data **all_sd;
  4376. nullpo_retr(-1, sd);
  4377. all_sd = map_getallusers(&users);
  4378. for (i = 0; i < users; i++) {
  4379. atcommand_raise_sub(all_sd[i]);
  4380. }
  4381. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4382. return 0;
  4383. }
  4384. /*==========================================
  4385. *
  4386. *------------------------------------------
  4387. */
  4388. int atcommand_raisemap(
  4389. const int fd, struct map_session_data* sd,
  4390. const char* command, const char* message)
  4391. {
  4392. struct map_session_data **pl_allsd;
  4393. int i, users;
  4394. nullpo_retr(-1, sd);
  4395. pl_allsd = map_getallusers(&users);
  4396. for (i = 0; i < users; i++) {
  4397. if (sd->bl.m == pl_allsd[i]->bl.m)
  4398. atcommand_raise_sub(pl_allsd[i]);
  4399. }
  4400. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4401. return 0;
  4402. }
  4403. /*==========================================
  4404. *
  4405. *------------------------------------------
  4406. */
  4407. int atcommand_kick(
  4408. const int fd, struct map_session_data* sd,
  4409. const char* command, const char* message)
  4410. {
  4411. struct map_session_data *pl_sd;
  4412. nullpo_retr(-1, sd);
  4413. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4414. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4415. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4416. return -1;
  4417. }
  4418. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4419. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4420. clif_GM_kick(sd, pl_sd, 1);
  4421. else {
  4422. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4423. return -1;
  4424. }
  4425. } else {
  4426. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4427. return -1;
  4428. }
  4429. return 0;
  4430. }
  4431. /*==========================================
  4432. *
  4433. *------------------------------------------
  4434. */
  4435. int atcommand_kickall(
  4436. const int fd, struct map_session_data* sd,
  4437. const char* command, const char* message)
  4438. {
  4439. struct map_session_data *pl_sd, **pl_allsd;
  4440. int i, users;
  4441. nullpo_retr(-1, sd);
  4442. pl_allsd = map_getallusers(&users);
  4443. for (i = 0; i < users; i++) {
  4444. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4445. if (sd->status.account_id != pl_sd->status.account_id)
  4446. clif_GM_kick(sd, pl_sd, 0);
  4447. }
  4448. }
  4449. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  4450. return 0;
  4451. }
  4452. /*==========================================
  4453. *
  4454. *------------------------------------------
  4455. */
  4456. int atcommand_allskill(
  4457. const int fd, struct map_session_data* sd,
  4458. const char* command, const char* message)
  4459. {
  4460. nullpo_retr(-1, sd);
  4461. pc_allskillup(sd); // all skills
  4462. sd->status.skill_point = 0; // 0 skill points
  4463. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4464. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  4465. return 0;
  4466. }
  4467. /*==========================================
  4468. *
  4469. *------------------------------------------
  4470. */
  4471. int atcommand_questskill(
  4472. const int fd, struct map_session_data* sd,
  4473. const char* command, const char* message)
  4474. {
  4475. int skill_id;
  4476. nullpo_retr(-1, sd);
  4477. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4478. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4479. return -1;
  4480. }
  4481. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4482. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4483. if (pc_checkskill(sd, skill_id) == 0) {
  4484. pc_skill(sd, skill_id, 1, 0);
  4485. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  4486. } else {
  4487. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  4488. return -1;
  4489. }
  4490. } else {
  4491. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4492. return -1;
  4493. }
  4494. } else {
  4495. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4496. return -1;
  4497. }
  4498. return 0;
  4499. }
  4500. /*==========================================
  4501. *
  4502. *------------------------------------------
  4503. */
  4504. int atcommand_lostskill(
  4505. const int fd, struct map_session_data* sd,
  4506. const char* command, const char* message)
  4507. {
  4508. int skill_id;
  4509. nullpo_retr(-1, sd);
  4510. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4511. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4512. return -1;
  4513. }
  4514. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4515. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4516. if (pc_checkskill(sd, skill_id) > 0) {
  4517. sd->status.skill[skill_id].lv = 0;
  4518. sd->status.skill[skill_id].flag = 0;
  4519. clif_skillinfoblock(sd);
  4520. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  4521. } else {
  4522. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  4523. return -1;
  4524. }
  4525. } else {
  4526. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4527. return -1;
  4528. }
  4529. } else {
  4530. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4531. return -1;
  4532. }
  4533. return 0;
  4534. }
  4535. /*==========================================
  4536. *
  4537. *------------------------------------------
  4538. */
  4539. int atcommand_spiritball(
  4540. const int fd, struct map_session_data* sd,
  4541. const char* command, const char* message)
  4542. {
  4543. int number;
  4544. nullpo_retr(-1, sd);
  4545. if (!message || !*message || (number = atoi(message)) < 0) {
  4546. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4547. return -1;
  4548. }
  4549. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4550. if (number > 500)
  4551. number = 500;
  4552. if (number >= 0 && number <= 0x7FFF) {
  4553. if (sd->spiritball != number || number > 499) {
  4554. if (sd->spiritball > 0)
  4555. pc_delspiritball(sd, sd->spiritball, 1);
  4556. sd->spiritball = number;
  4557. clif_spiritball(sd);
  4558. // no message, player can look the difference
  4559. if (number > 1000)
  4560. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4561. } else {
  4562. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  4563. return -1;
  4564. }
  4565. } else {
  4566. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4567. return -1;
  4568. }
  4569. return 0;
  4570. }
  4571. /*==========================================
  4572. *
  4573. *------------------------------------------
  4574. */
  4575. int atcommand_party(
  4576. const int fd, struct map_session_data* sd,
  4577. const char* command, const char* message)
  4578. {
  4579. char party[NAME_LENGTH];
  4580. nullpo_retr(-1, sd);
  4581. memset(party, '\0', sizeof(party));
  4582. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4583. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4584. return -1;
  4585. }
  4586. party_create(sd, party, 0, 0);
  4587. return 0;
  4588. }
  4589. /*==========================================
  4590. *
  4591. *------------------------------------------
  4592. */
  4593. int atcommand_guild(
  4594. const int fd, struct map_session_data* sd,
  4595. const char* command, const char* message)
  4596. {
  4597. char guild[NAME_LENGTH];
  4598. int prev;
  4599. nullpo_retr(-1, sd);
  4600. memset(guild, '\0', sizeof(guild));
  4601. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4602. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4603. return -1;
  4604. }
  4605. prev = battle_config.guild_emperium_check;
  4606. battle_config.guild_emperium_check = 0;
  4607. guild_create(sd, guild);
  4608. battle_config.guild_emperium_check = prev;
  4609. return 0;
  4610. }
  4611. /*==========================================
  4612. *
  4613. *------------------------------------------
  4614. */
  4615. int atcommand_agitstart(
  4616. const int fd, struct map_session_data* sd,
  4617. const char* command, const char* message)
  4618. {
  4619. nullpo_retr(-1, sd);
  4620. if (agit_flag == 1) {
  4621. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  4622. return -1;
  4623. }
  4624. agit_flag = 1;
  4625. guild_agit_start();
  4626. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  4627. return 0;
  4628. }
  4629. /*==========================================
  4630. *
  4631. *------------------------------------------
  4632. */
  4633. int atcommand_agitend(
  4634. const int fd, struct map_session_data* sd,
  4635. const char* command, const char* message)
  4636. {
  4637. nullpo_retr(-1, sd);
  4638. if (agit_flag == 0) {
  4639. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  4640. return -1;
  4641. }
  4642. agit_flag = 0;
  4643. guild_agit_end();
  4644. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  4645. return 0;
  4646. }
  4647. /*==========================================
  4648. * @mapexitでマップサーバーを終了させる
  4649. *------------------------------------------
  4650. */
  4651. int atcommand_mapexit(
  4652. const int fd, struct map_session_data* sd,
  4653. const char* command, const char* message)
  4654. {
  4655. struct map_session_data *pl_sd, **pl_allsd;
  4656. int i, users;
  4657. nullpo_retr(-1, sd);
  4658. pl_allsd = map_getallusers(&users);
  4659. for (i = 0; i < users; i++) {
  4660. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4661. clif_GM_kick(sd, pl_sd, 0);
  4662. }
  4663. clif_GM_kick(sd, sd, 0);
  4664. flush_fifos();
  4665. runflag = 0;
  4666. return 0;
  4667. }
  4668. /*==========================================
  4669. * idsearch <part_of_name>: revrited by [Yor]
  4670. *------------------------------------------
  4671. */
  4672. int atcommand_idsearch(
  4673. const int fd, struct map_session_data* sd,
  4674. const char* command, const char* message)
  4675. {
  4676. char item_name[100];
  4677. unsigned int i, match;
  4678. struct item_data *item_array[MAX_SEARCH];
  4679. nullpo_retr(-1, sd);
  4680. memset(item_name, '\0', sizeof(item_name));
  4681. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4682. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4683. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4684. return -1;
  4685. }
  4686. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  4687. clif_displaymessage(fd, atcmd_output);
  4688. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4689. if (match > MAX_SEARCH) {
  4690. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  4691. clif_displaymessage(fd, atcmd_output);
  4692. match = MAX_SEARCH;
  4693. }
  4694. for(i = 0; i < match; i++) {
  4695. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4696. clif_displaymessage(fd, atcmd_output);
  4697. }
  4698. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  4699. clif_displaymessage(fd, atcmd_output);
  4700. return 0;
  4701. }
  4702. /*==========================================
  4703. * Recall All Characters Online To Your Location
  4704. *------------------------------------------
  4705. */
  4706. int atcommand_recallall(
  4707. const int fd, struct map_session_data* sd,
  4708. const char* command, const char* message)
  4709. {
  4710. struct map_session_data *pl_sd, **pl_allsd;
  4711. int i;
  4712. int count, users;
  4713. nullpo_retr(-1, sd);
  4714. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4715. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4716. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4717. return -1;
  4718. }
  4719. count = 0;
  4720. pl_allsd = map_getallusers(&users);
  4721. for (i = 0; i < users; i++) {
  4722. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4723. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4724. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4725. count++;
  4726. else {
  4727. if (pc_isdead(pl_sd)) { //Wake them up
  4728. pc_setstand(pl_sd);
  4729. pc_setrestartvalue(pl_sd,1);
  4730. }
  4731. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4732. }
  4733. }
  4734. }
  4735. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4736. if (count) {
  4737. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4738. clif_displaymessage(fd, atcmd_output);
  4739. }
  4740. return 0;
  4741. }
  4742. /*==========================================
  4743. * Recall online characters of a guild to your location
  4744. *------------------------------------------
  4745. */
  4746. int atcommand_guildrecall(
  4747. const int fd, struct map_session_data* sd,
  4748. const char* command, const char* message)
  4749. {
  4750. struct map_session_data *pl_sd, **pl_allsd;
  4751. int i, users, count;
  4752. char guild_name[NAME_LENGTH];
  4753. struct guild *g;
  4754. nullpo_retr(-1, sd);
  4755. memset(guild_name, '\0', sizeof(guild_name));
  4756. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4757. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4758. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4759. return -1;
  4760. }
  4761. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4762. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4763. return -1;
  4764. }
  4765. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4766. (g = guild_search(atoi(message))) != NULL) {
  4767. count = 0;
  4768. pl_allsd = map_getallusers(&users);
  4769. for (i = 0; i < users; i++) {
  4770. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4771. pl_sd->status.guild_id == g->guild_id) {
  4772. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4773. continue; //Skip GMs greater than you.
  4774. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4775. count++;
  4776. else
  4777. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4778. }
  4779. }
  4780. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  4781. clif_displaymessage(fd, atcmd_output);
  4782. if (count) {
  4783. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4784. clif_displaymessage(fd, atcmd_output);
  4785. }
  4786. } else {
  4787. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4788. return -1;
  4789. }
  4790. return 0;
  4791. }
  4792. /*==========================================
  4793. * Recall online characters of a party to your location
  4794. *------------------------------------------
  4795. */
  4796. int atcommand_partyrecall(
  4797. const int fd, struct map_session_data* sd,
  4798. const char* command, const char* message)
  4799. {
  4800. int i;
  4801. struct map_session_data *pl_sd, **pl_allsd;
  4802. char party_name[NAME_LENGTH];
  4803. struct party_data *p;
  4804. int count, users;
  4805. nullpo_retr(-1, sd);
  4806. memset(party_name, '\0', sizeof(party_name));
  4807. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4808. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4809. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4810. return -1;
  4811. }
  4812. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4813. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4814. return -1;
  4815. }
  4816. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4817. (p = party_search(atoi(message))) != NULL) {
  4818. count = 0;
  4819. pl_allsd = map_getallusers(&users);
  4820. for (i = 0; i < users; i++) {
  4821. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4822. pl_sd->status.party_id == p->party.party_id) {
  4823. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4824. continue; //Skip GMs greater than you.
  4825. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4826. count++;
  4827. else
  4828. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4829. }
  4830. }
  4831. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  4832. clif_displaymessage(fd, atcmd_output);
  4833. if (count) {
  4834. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4835. clif_displaymessage(fd, atcmd_output);
  4836. }
  4837. } else {
  4838. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4839. return -1;
  4840. }
  4841. return 0;
  4842. }
  4843. /*==========================================
  4844. *
  4845. *------------------------------------------
  4846. */
  4847. int atcommand_reloaditemdb(
  4848. const int fd, struct map_session_data* sd,
  4849. const char* command, const char* message)
  4850. {
  4851. nullpo_retr(-1, sd);
  4852. itemdb_reload();
  4853. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  4854. return 0;
  4855. }
  4856. /*==========================================
  4857. *
  4858. *------------------------------------------
  4859. */
  4860. int atcommand_reloadmobdb(
  4861. const int fd, struct map_session_data* sd,
  4862. const char* command, const char* message)
  4863. {
  4864. nullpo_retr(-1, sd);
  4865. mob_reload();
  4866. read_petdb();
  4867. merc_reload();
  4868. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  4869. return 0;
  4870. }
  4871. /*==========================================
  4872. *
  4873. *------------------------------------------
  4874. */
  4875. int atcommand_reloadskilldb(
  4876. const int fd, struct map_session_data* sd,
  4877. const char* command, const char* message)
  4878. {
  4879. nullpo_retr(-1, sd);
  4880. skill_reload();
  4881. merc_skill_reload();
  4882. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  4883. return 0;
  4884. }
  4885. /*==========================================
  4886. * @reloadatcommand
  4887. * atcommand_athena.conf のリロード
  4888. *------------------------------------------
  4889. */
  4890. int
  4891. atcommand_reloadatcommand(
  4892. const int fd, struct map_session_data* sd,
  4893. const char* command, const char* message)
  4894. {
  4895. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4896. clif_displaymessage(fd, msg_txt(254));
  4897. return 0;
  4898. }
  4899. /*==========================================
  4900. * @reloadbattleconf
  4901. * battle_athena.conf のリロード
  4902. *------------------------------------------
  4903. */
  4904. int
  4905. atcommand_reloadbattleconf(
  4906. const int fd, struct map_session_data* sd,
  4907. const char* command, const char* message)
  4908. {
  4909. struct Battle_Config prev_config;
  4910. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4911. battle_config_read(BATTLE_CONF_FILENAME);
  4912. if (memcmp(&prev_config.item_rate_mvp,
  4913. &battle_config.item_rate_mvp,
  4914. sizeof(battle_config.item_rate_mvp)+
  4915. sizeof(battle_config.item_rate_common)+
  4916. sizeof(battle_config.item_rate_common_boss)+
  4917. sizeof(battle_config.item_rate_card)+
  4918. sizeof(battle_config.item_rate_card_boss)+
  4919. sizeof(battle_config.item_rate_equip)+
  4920. sizeof(battle_config.item_rate_equip_boss)+
  4921. sizeof(battle_config.item_rate_heal)+
  4922. sizeof(battle_config.item_rate_heal_boss)+
  4923. sizeof(battle_config.item_rate_use)+
  4924. sizeof(battle_config.item_rate_use_boss)+
  4925. sizeof(battle_config.item_rate_treasure)+
  4926. sizeof(battle_config.item_rate_adddrop)+
  4927. sizeof(battle_config.logarithmic_drops)+
  4928. sizeof(battle_config.item_drop_common_min)+
  4929. sizeof(battle_config.item_drop_common_max)+
  4930. sizeof(battle_config.item_drop_card_min)+
  4931. sizeof(battle_config.item_drop_card_max)+
  4932. sizeof(battle_config.item_drop_equip_min)+
  4933. sizeof(battle_config.item_drop_equip_max)+
  4934. sizeof(battle_config.item_drop_mvp_min)+
  4935. sizeof(battle_config.item_drop_mvp_max)+
  4936. sizeof(battle_config.item_drop_heal_min)+
  4937. sizeof(battle_config.item_drop_heal_max)+
  4938. sizeof(battle_config.item_drop_use_min)+
  4939. sizeof(battle_config.item_drop_use_max)+
  4940. sizeof(battle_config.item_drop_treasure_min)+
  4941. sizeof(battle_config.item_drop_treasure_max)
  4942. ) != 0)
  4943. { //Drop rates changed.
  4944. mob_reload(); //Needed as well so rate changes take effect.
  4945. #ifndef TXT_ONLY
  4946. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4947. #endif
  4948. }
  4949. clif_displaymessage(fd, msg_txt(255));
  4950. return 0;
  4951. }
  4952. /*==========================================
  4953. * @reloadstatusdb
  4954. * job_db1.txt job_db2.txt job_db2-2.txt
  4955. * refine_db.txt size_fix.txt
  4956. * のリロード
  4957. *------------------------------------------
  4958. */
  4959. int
  4960. atcommand_reloadstatusdb(
  4961. const int fd, struct map_session_data* sd,
  4962. const char* command, const char* message)
  4963. {
  4964. status_readdb();
  4965. clif_displaymessage(fd, msg_txt(256));
  4966. return 0;
  4967. }
  4968. /*==========================================
  4969. * @reloadpcdb
  4970. * exp.txt skill_tree.txt attr_fix.txt
  4971. * のリロード
  4972. *------------------------------------------
  4973. */
  4974. int
  4975. atcommand_reloadpcdb(
  4976. const int fd, struct map_session_data* sd,
  4977. const char* command, const char* message)
  4978. {
  4979. pc_readdb();
  4980. clif_displaymessage(fd, msg_txt(257));
  4981. return 0;
  4982. }
  4983. /*==========================================
  4984. * @reloadmotd [Valaris]
  4985. * Reloads motd.txt
  4986. *------------------------------------------
  4987. */
  4988. int
  4989. atcommand_reloadmotd(
  4990. const int fd, struct map_session_data* sd,
  4991. const char* command, const char* message)
  4992. {
  4993. pc_read_motd();
  4994. clif_displaymessage(fd, msg_txt(268));
  4995. return 0;
  4996. }
  4997. /*==========================================
  4998. *
  4999. *------------------------------------------
  5000. */
  5001. int atcommand_reloadscript(
  5002. const int fd, struct map_session_data* sd,
  5003. const char* command, const char* message)
  5004. {
  5005. nullpo_retr(-1, sd);
  5006. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  5007. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  5008. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  5009. flush_fifos();
  5010. //do_init_npc();
  5011. script_reload();
  5012. npc_reload();
  5013. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  5014. return 0;
  5015. }
  5016. /*==========================================
  5017. *
  5018. *------------------------------------------
  5019. */
  5020. int atcommand_reloadgmdb( // by [Yor]
  5021. const int fd, struct map_session_data* sd,
  5022. const char* command, const char* message)
  5023. {
  5024. nullpo_retr(-1, sd);
  5025. chrif_reloadGMdb();
  5026. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  5027. return 0;
  5028. }
  5029. /*==========================================
  5030. * @mapinfo <map name> [0-3] by MC_Cameri
  5031. * => Shows information about the map [map name]
  5032. * 0 = no additional information
  5033. * 1 = Show users in that map and their location
  5034. * 2 = Shows NPCs in that map
  5035. * 3 = Shows the shops/chats in that map (not implemented)
  5036. *------------------------------------------
  5037. */
  5038. int atcommand_mapinfo(
  5039. const int fd, struct map_session_data* sd,
  5040. const char* command, const char* message)
  5041. {
  5042. struct map_session_data *pl_sd, **pl_allsd;
  5043. struct npc_data *nd = NULL;
  5044. struct chat_data *cd = NULL;
  5045. char direction[12];
  5046. int m_id, i, chat_num, users, list = 0;
  5047. unsigned short m_index;
  5048. nullpo_retr(-1, sd);
  5049. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5050. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5051. memset(direction, '\0', sizeof(direction));
  5052. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  5053. if (list < 0 || list > 3) {
  5054. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5055. return -1;
  5056. }
  5057. if (atcmd_player_name[0] == '\0') {
  5058. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  5059. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  5060. m_id = map_mapindex2mapid(sd->mapindex);
  5061. } else {
  5062. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  5063. strcat(atcmd_player_name, ".gat");
  5064. m_id = map_mapname2mapid(atcmd_player_name);
  5065. }
  5066. if (m_id < 0) {
  5067. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5068. return -1;
  5069. }
  5070. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  5071. clif_displaymessage(fd, "------ Map Info ------");
  5072. chat_num = 0;
  5073. pl_allsd = map_getallusers(&users);
  5074. for (i = 0; i < users; i++) {
  5075. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5076. chat_num++;
  5077. }
  5078. }
  5079. 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);
  5080. clif_displaymessage(fd, atcmd_output);
  5081. if (map[m_id].flag.alias)
  5082. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  5083. clif_displaymessage(fd, "------ Map Flags ------");
  5084. strcpy(atcmd_output,"PvP Flags: ");
  5085. if (map[m_id].flag.pvp)
  5086. strcat(atcmd_output, "Pvp ON | ");
  5087. if (map[m_id].flag.pvp_noguild)
  5088. strcat(atcmd_output, "NoGuild | ");
  5089. if (map[m_id].flag.pvp_noparty)
  5090. strcat(atcmd_output, "NoParty | ");
  5091. if (map[m_id].flag.pvp_nightmaredrop)
  5092. strcat(atcmd_output, "NightmareDrop | ");
  5093. if (map[m_id].flag.pvp_nocalcrank)
  5094. strcat(atcmd_output, "NoCalcRank | ");
  5095. clif_displaymessage(fd, atcmd_output);
  5096. strcpy(atcmd_output,"GvG Flags: ");
  5097. if (map[m_id].flag.gvg)
  5098. strcat(atcmd_output, "GvG ON | ");
  5099. if (map[m_id].flag.gvg_dungeon)
  5100. strcat(atcmd_output, "GvG Dungeon | ");
  5101. if (map[m_id].flag.gvg_castle)
  5102. strcat(atcmd_output, "GvG Castle | ");
  5103. if (map[m_id].flag.gvg_noparty)
  5104. strcat(atcmd_output, "NoParty | ");
  5105. clif_displaymessage(fd, atcmd_output);
  5106. strcpy(atcmd_output,"Teleport Flags: ");
  5107. if (map[m_id].flag.noteleport)
  5108. strcat(atcmd_output, "NoTeleport | ");
  5109. if (map[m_id].flag.monster_noteleport)
  5110. strcat(atcmd_output, "Monster NoTeleport | ");
  5111. if (map[m_id].flag.nowarp)
  5112. strcat(atcmd_output, "NoWarp | ");
  5113. if (map[m_id].flag.nowarpto)
  5114. strcat(atcmd_output, "NoWarpTo | ");
  5115. if (map[m_id].flag.noreturn)
  5116. strcat(atcmd_output, "NoReturn | ");
  5117. if (map[m_id].flag.nogo)
  5118. strcat(atcmd_output, "NoGo | ");
  5119. if (map[m_id].flag.nomemo)
  5120. strcat(atcmd_output, "NoMemo | ");
  5121. clif_displaymessage(fd, atcmd_output);
  5122. 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");
  5123. clif_displaymessage(fd, atcmd_output);
  5124. if (map[m_id].flag.nosave) {
  5125. if (!map[m_id].save.map)
  5126. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  5127. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  5128. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  5129. else
  5130. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  5131. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  5132. clif_displaymessage(fd, atcmd_output);
  5133. }
  5134. strcpy(atcmd_output,"Weather Flags: ");
  5135. if (map[m_id].flag.snow)
  5136. strcat(atcmd_output, "Snow | ");
  5137. if (map[m_id].flag.fog)
  5138. strcat(atcmd_output, "Fog | ");
  5139. if (map[m_id].flag.sakura)
  5140. strcat(atcmd_output, "Sakura | ");
  5141. if (map[m_id].flag.clouds)
  5142. strcat(atcmd_output, "Clouds | ");
  5143. if (map[m_id].flag.clouds2)
  5144. strcat(atcmd_output, "Clouds2 | ");
  5145. if (map[m_id].flag.fireworks)
  5146. strcat(atcmd_output, "Fireworks | ");
  5147. if (map[m_id].flag.leaves)
  5148. strcat(atcmd_output, "Leaves | ");
  5149. if (map[m_id].flag.rain)
  5150. strcat(atcmd_output, "Rain | ");
  5151. if (map[m_id].flag.indoors)
  5152. strcat(atcmd_output, "Indoors | ");
  5153. if (map[m_id].flag.nightenabled)
  5154. strcat(atcmd_output, "Displays Night | ");
  5155. clif_displaymessage(fd, atcmd_output);
  5156. strcpy(atcmd_output,"Other Flags: ");
  5157. if (map[m_id].flag.nobranch)
  5158. strcat(atcmd_output, "NoBranch | ");
  5159. if (map[m_id].flag.notrade)
  5160. strcat(atcmd_output, "NoTrade | ");
  5161. if (map[m_id].flag.novending)
  5162. strcat(atcmd_output, "NoVending | ");
  5163. if (map[m_id].flag.nodrop)
  5164. strcat(atcmd_output, "NoDrop | ");
  5165. if (map[m_id].flag.noskill)
  5166. strcat(atcmd_output, "NoSkill | ");
  5167. if (map[m_id].flag.noicewall)
  5168. strcat(atcmd_output, "NoIcewall | ");
  5169. clif_displaymessage(fd, atcmd_output);
  5170. strcpy(atcmd_output,"Other Flags: ");
  5171. if (map[m_id].nocommand)
  5172. strcat(atcmd_output, "NoCommand | ");
  5173. if (map[m_id].flag.nobaseexp)
  5174. strcat(atcmd_output, "NoBaseEXP | ");
  5175. if (map[m_id].flag.nojobexp)
  5176. strcat(atcmd_output, "NoJobEXP | ");
  5177. if (map[m_id].flag.nomobloot)
  5178. strcat(atcmd_output, "NoMobLoot | ");
  5179. if (map[m_id].flag.nomvploot)
  5180. strcat(atcmd_output, "NoMVPLoot | ");
  5181. if (map[m_id].flag.partylock)
  5182. strcat(atcmd_output, "PartyLock | ");
  5183. if (map[m_id].flag.guildlock)
  5184. strcat(atcmd_output, "GuildLock | ");
  5185. clif_displaymessage(fd, atcmd_output);
  5186. switch (list) {
  5187. case 0:
  5188. // Do nothing. It's list 0, no additional display.
  5189. break;
  5190. case 1:
  5191. clif_displaymessage(fd, "----- Players in Map -----");
  5192. for (i = 0; i < users; i++) {
  5193. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5194. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5195. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5196. clif_displaymessage(fd, atcmd_output);
  5197. }
  5198. }
  5199. break;
  5200. case 2:
  5201. clif_displaymessage(fd, "----- NPCs in Map -----");
  5202. for (i = 0; i < map[m_id].npc_num;) {
  5203. nd = map[m_id].npc[i];
  5204. switch(nd->ud.dir) {
  5205. case 0: strcpy(direction, "North"); break;
  5206. case 1: strcpy(direction, "North West"); break;
  5207. case 2: strcpy(direction, "West"); break;
  5208. case 3: strcpy(direction, "South West"); break;
  5209. case 4: strcpy(direction, "South"); break;
  5210. case 5: strcpy(direction, "South East"); break;
  5211. case 6: strcpy(direction, "East"); break;
  5212. case 7: strcpy(direction, "North East"); break;
  5213. case 9: strcpy(direction, "North"); break;
  5214. default: strcpy(direction, "Unknown"); break;
  5215. }
  5216. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5217. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5218. clif_displaymessage(fd, atcmd_output);
  5219. }
  5220. break;
  5221. case 3:
  5222. clif_displaymessage(fd, "----- Chats in Map -----");
  5223. for (i = 0; i < users; i++) {
  5224. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5225. pl_sd->mapindex == m_index &&
  5226. cd->usersd[0] == pl_sd) {
  5227. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5228. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5229. clif_displaymessage(fd, atcmd_output);
  5230. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5231. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5232. clif_displaymessage(fd, atcmd_output);
  5233. }
  5234. }
  5235. break;
  5236. default: // normally impossible to arrive here
  5237. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5238. return -1;
  5239. break;
  5240. }
  5241. return 0;
  5242. }
  5243. /*==========================================
  5244. *
  5245. *------------------------------------------
  5246. */
  5247. int atcommand_mount_peco(
  5248. const int fd, struct map_session_data* sd,
  5249. const char* command, const char* message)
  5250. {
  5251. nullpo_retr(-1, sd);
  5252. if (!pc_isriding(sd)) { // if actually no peco
  5253. if (pc_checkskill(sd, KN_RIDING)) {
  5254. pc_setoption(sd, sd->sc.option | 0x0020);
  5255. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  5256. } else {
  5257. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  5258. return -1;
  5259. }
  5260. } else { //Dismount
  5261. pc_setoption(sd, sd->sc.option & ~0x0020);
  5262. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  5263. }
  5264. return 0;
  5265. }
  5266. /*==========================================
  5267. *
  5268. *------------------------------------------
  5269. */
  5270. int atcommand_char_mount_peco(
  5271. const int fd, struct map_session_data* sd,
  5272. const char* command, const char* message)
  5273. {
  5274. struct map_session_data *pl_sd;
  5275. nullpo_retr(-1, sd);
  5276. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5277. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5278. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5279. return -1;
  5280. }
  5281. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5282. if (!pc_isriding(pl_sd)) { // if actually no peco
  5283. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5284. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5285. clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
  5286. } else {
  5287. clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
  5288. return -1;
  5289. }
  5290. } else { //Dismount
  5291. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5292. clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
  5293. }
  5294. } else {
  5295. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5296. return -1;
  5297. }
  5298. return 0;
  5299. }
  5300. /*==========================================
  5301. *Spy Commands by Syrus22
  5302. *------------------------------------------
  5303. */
  5304. int atcommand_guildspy(
  5305. const int fd, struct map_session_data* sd,
  5306. const char* command, const char* message)
  5307. {
  5308. char guild_name[NAME_LENGTH];
  5309. struct guild *g;
  5310. nullpo_retr(-1, sd);
  5311. memset(guild_name, '\0', sizeof(guild_name));
  5312. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5313. if (!enable_spy)
  5314. {
  5315. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5316. return -1;
  5317. }
  5318. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5319. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5320. return -1;
  5321. }
  5322. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5323. (g = guild_search(atoi(message))) != NULL) {
  5324. if (sd->guildspy == g->guild_id) {
  5325. sd->guildspy = 0;
  5326. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  5327. clif_displaymessage(fd, atcmd_output);
  5328. } else {
  5329. sd->guildspy = g->guild_id;
  5330. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  5331. clif_displaymessage(fd, atcmd_output);
  5332. }
  5333. } else {
  5334. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  5335. return -1;
  5336. }
  5337. return 0;
  5338. }
  5339. /*==========================================
  5340. *
  5341. *------------------------------------------
  5342. */
  5343. int atcommand_partyspy(
  5344. const int fd, struct map_session_data* sd,
  5345. const char* command, const char* message)
  5346. {
  5347. char party_name[NAME_LENGTH];
  5348. struct party_data *p;
  5349. nullpo_retr(-1, sd);
  5350. memset(party_name, '\0', sizeof(party_name));
  5351. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5352. if (!enable_spy)
  5353. {
  5354. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5355. return -1;
  5356. }
  5357. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5358. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5359. return -1;
  5360. }
  5361. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5362. (p = party_search(atoi(message))) != NULL) {
  5363. if (sd->partyspy == p->party.party_id) {
  5364. sd->partyspy = 0;
  5365. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  5366. clif_displaymessage(fd, atcmd_output);
  5367. } else {
  5368. sd->partyspy = p->party.party_id;
  5369. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  5370. clif_displaymessage(fd, atcmd_output);
  5371. }
  5372. } else {
  5373. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  5374. return -1;
  5375. }
  5376. return 0;
  5377. }
  5378. /*==========================================
  5379. * @repairall [Valaris]
  5380. *------------------------------------------
  5381. */
  5382. int atcommand_repairall(
  5383. const int fd, struct map_session_data* sd,
  5384. const char* command, const char* message)
  5385. {
  5386. int count, i;
  5387. nullpo_retr(-1, sd);
  5388. count = 0;
  5389. for (i = 0; i < MAX_INVENTORY; i++) {
  5390. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5391. sd->status.inventory[i].attribute = 0;
  5392. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5393. count++;
  5394. }
  5395. }
  5396. if (count > 0) {
  5397. clif_misceffect(&sd->bl, 3);
  5398. clif_equiplist(sd);
  5399. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  5400. } else {
  5401. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  5402. return -1;
  5403. }
  5404. return 0;
  5405. }
  5406. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5407. int atcommand_nuke(
  5408. const int fd, struct map_session_data* sd,
  5409. const char* command, const char* message)
  5410. {
  5411. struct map_session_data *pl_sd;
  5412. nullpo_retr(-1, sd);
  5413. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5414. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5415. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5416. return -1;
  5417. }
  5418. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5419. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5420. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5421. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  5422. } else {
  5423. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5424. return -1;
  5425. }
  5426. } else {
  5427. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5428. return -1;
  5429. }
  5430. return 0;
  5431. }
  5432. /*==========================================
  5433. * @tonpc
  5434. *------------------------------------------
  5435. */
  5436. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5437. const char* command, const char* message)
  5438. {
  5439. char npcname[NAME_LENGTH];
  5440. struct npc_data *nd;
  5441. nullpo_retr(-1, sd);
  5442. memset(npcname, 0, sizeof(npcname));
  5443. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5444. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5445. return -1;
  5446. }
  5447. if ((nd = npc_name2id(npcname)) != NULL) {
  5448. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5449. clif_displaymessage(fd, msg_txt(0)); // Warped.
  5450. else
  5451. return -1;
  5452. } else {
  5453. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5454. return -1;
  5455. }
  5456. return 0;
  5457. }
  5458. /*==========================================
  5459. *
  5460. *------------------------------------------
  5461. */
  5462. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5463. const char* command, const char* message)
  5464. {
  5465. char NPCname[NAME_LENGTH];
  5466. nullpo_retr(-1, sd);
  5467. memset(NPCname, '\0', sizeof(NPCname));
  5468. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5469. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5470. return -1;
  5471. }
  5472. if (npc_name2id(NPCname) != NULL) {
  5473. npc_enable(NPCname, 1);
  5474. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  5475. } else {
  5476. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5477. return -1;
  5478. }
  5479. return 0;
  5480. }
  5481. /*==========================================
  5482. *
  5483. *------------------------------------------
  5484. */
  5485. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5486. const char* command, const char* message)
  5487. {
  5488. char NPCname[NAME_LENGTH];
  5489. nullpo_retr(-1, sd);
  5490. memset(NPCname, '\0', sizeof(NPCname));
  5491. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5492. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  5493. return -1;
  5494. }
  5495. if (npc_name2id(NPCname) != NULL) {
  5496. npc_enable(NPCname, 0);
  5497. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5498. } else {
  5499. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5500. return -1;
  5501. }
  5502. return 0;
  5503. }
  5504. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5505. const char* command, const char* message)
  5506. {
  5507. FILE *fp;
  5508. if (!message || !*message) {
  5509. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5510. return -1;
  5511. }
  5512. // check if script file exists
  5513. if ((fp = fopen(message, "r")) == NULL) {
  5514. clif_displaymessage(fd, msg_txt(261));
  5515. return -1;
  5516. }
  5517. fclose(fp);
  5518. // add to list of script sources and run it
  5519. npc_addsrcfile((char *)message);
  5520. npc_parsesrcfile((char *)message);
  5521. clif_displaymessage(fd, msg_txt(262));
  5522. return 0;
  5523. }
  5524. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5525. const char* command, const char* message)
  5526. {
  5527. struct npc_data *nd;
  5528. char NPCname[NAME_LENGTH];
  5529. nullpo_retr(-1, sd);
  5530. memset(NPCname, '\0', sizeof(NPCname));
  5531. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5532. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5533. return -1;
  5534. }
  5535. if ((nd = npc_name2id(NPCname)) != NULL) {
  5536. npc_unload_duplicates(nd);
  5537. npc_unload(nd);
  5538. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5539. } else {
  5540. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5541. return -1;
  5542. }
  5543. return 0;
  5544. }
  5545. /*==========================================
  5546. * time in txt for time command (by [Yor])
  5547. *------------------------------------------
  5548. */
  5549. char * txt_time(unsigned int duration) {
  5550. int days, hours, minutes, seconds;
  5551. char temp[256];
  5552. static char temp1[256];
  5553. memset(temp, '\0', sizeof(temp));
  5554. memset(temp1, '\0', sizeof(temp1));
  5555. days = duration / (60 * 60 * 24);
  5556. duration = duration - (60 * 60 * 24 * days);
  5557. hours = duration / (60 * 60);
  5558. duration = duration - (60 * 60 * hours);
  5559. minutes = duration / 60;
  5560. seconds = duration - (60 * minutes);
  5561. if (days < 2)
  5562. sprintf(temp, msg_txt(219), days); // %d day
  5563. else
  5564. sprintf(temp, msg_txt(220), days); // %d days
  5565. if (hours < 2)
  5566. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  5567. else
  5568. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  5569. if (minutes < 2)
  5570. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  5571. else
  5572. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  5573. if (seconds < 2)
  5574. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  5575. else
  5576. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  5577. return temp1;
  5578. }
  5579. /*==========================================
  5580. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5581. * Calculation management of GM modification (@day/@night GM commands) is done
  5582. *------------------------------------------
  5583. */
  5584. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5585. const char* command, const char* message)
  5586. {
  5587. struct TimerData * timer_data;
  5588. struct TimerData * timer_data2;
  5589. time_t time_server; // variable for number of seconds (used with time() function)
  5590. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5591. char temp[256];
  5592. nullpo_retr(-1, sd);
  5593. memset(temp, '\0', sizeof(temp));
  5594. time(&time_server); // get time in seconds since 1/1/1970
  5595. datetime = localtime(&time_server); // convert seconds in structure
  5596. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5597. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  5598. clif_displaymessage(fd, temp);
  5599. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5600. if (night_flag == 0)
  5601. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5602. else
  5603. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5604. } else if (battle_config.night_duration == 0)
  5605. if (night_flag == 1) { // we start with night
  5606. timer_data = get_timer(day_timer_tid);
  5607. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5608. clif_displaymessage(fd, temp);
  5609. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  5610. } else
  5611. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5612. else if (battle_config.day_duration == 0)
  5613. if (night_flag == 0) { // we start with day
  5614. timer_data = get_timer(night_timer_tid);
  5615. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5616. clif_displaymessage(fd, temp);
  5617. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  5618. } else
  5619. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5620. else {
  5621. if (night_flag == 0) {
  5622. timer_data = get_timer(night_timer_tid);
  5623. timer_data2 = get_timer(day_timer_tid);
  5624. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5625. clif_displaymessage(fd, temp);
  5626. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5627. 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.
  5628. else
  5629. 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.
  5630. clif_displaymessage(fd, temp);
  5631. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5632. clif_displaymessage(fd, temp);
  5633. } else {
  5634. timer_data = get_timer(day_timer_tid);
  5635. timer_data2 = get_timer(night_timer_tid);
  5636. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5637. clif_displaymessage(fd, temp);
  5638. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5639. 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.
  5640. else
  5641. 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.
  5642. clif_displaymessage(fd, temp);
  5643. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5644. clif_displaymessage(fd, temp);
  5645. }
  5646. }
  5647. return 0;
  5648. }
  5649. /*==========================================
  5650. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5651. * removes <quantity> item from a character
  5652. * item can be equiped or not.
  5653. * Inspired from a old command created by RoVeRT
  5654. *------------------------------------------
  5655. */
  5656. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5657. const char* command, const char* message)
  5658. {
  5659. struct map_session_data *pl_sd;
  5660. char item_name[100];
  5661. int i, number = 0, item_id, item_position, count;
  5662. struct item_data *item_data;
  5663. nullpo_retr(-1, sd);
  5664. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5665. memset(item_name, '\0', sizeof(item_name));
  5666. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5667. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5668. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5669. return -1;
  5670. }
  5671. item_id = 0;
  5672. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5673. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5674. item_id = item_data->nameid;
  5675. if (item_id > 500) {
  5676. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5677. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5678. item_position = pc_search_inventory(pl_sd, item_id);
  5679. if (item_position >= 0) {
  5680. count = 0;
  5681. for(i = 0; i < number && item_position >= 0; i++) {
  5682. //Logs (A)dmins items [Lupus]
  5683. if(log_config.enable_logs&0x400)
  5684. log_pick_pc(pl_sd, "A", pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5685. pc_delitem(pl_sd, item_position, 1, 0);
  5686. count++;
  5687. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5688. }
  5689. sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
  5690. clif_displaymessage(pl_sd->fd, atcmd_output);
  5691. if (number == count)
  5692. sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
  5693. else
  5694. sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5695. clif_displaymessage(fd, atcmd_output);
  5696. } else {
  5697. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  5698. return -1;
  5699. }
  5700. } else {
  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. } else {
  5705. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5706. return -1;
  5707. }
  5708. } else {
  5709. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  5710. return -1;
  5711. }
  5712. return 0;
  5713. }
  5714. //Added by Coltaro
  5715. //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...).
  5716. //Well, using time_t could still work but for some reason that looks like more coding x_x
  5717. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) {
  5718. const int factor_year = 518400; //12*30*24*60 = 518400
  5719. const int factor_month = 43200; //30*24*60 = 43200
  5720. const int factor_day = 1440; //24*60 = 1440
  5721. const int factor_hour = 60;
  5722. *year = jailtime/factor_year;
  5723. jailtime -= *year*factor_year;
  5724. *month = jailtime/factor_month;
  5725. jailtime -= *month*factor_month;
  5726. *day = jailtime/factor_day;
  5727. jailtime -= *day*factor_day;
  5728. *hour = jailtime/factor_hour;
  5729. jailtime -= *hour*factor_hour;
  5730. *minute = jailtime;
  5731. *year = *year > 0? *year : 0;
  5732. *month = *month > 0? *month : 0;
  5733. *day = *day > 0? *day : 0;
  5734. *hour = *hour > 0? *hour : 0;
  5735. *minute = *minute > 0? *minute : 0;
  5736. return;
  5737. }
  5738. /*==========================================
  5739. * @jail <char_name> by [Yor]
  5740. * Special warp! No check with nowarp and nowarpto flag
  5741. *------------------------------------------
  5742. */
  5743. int atcommand_jail(
  5744. const int fd, struct map_session_data* sd,
  5745. const char* command, const char* message)
  5746. {
  5747. struct map_session_data *pl_sd;
  5748. int x, y;
  5749. unsigned short m_index;
  5750. nullpo_retr(-1, sd);
  5751. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5752. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5753. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5754. return -1;
  5755. }
  5756. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5757. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5758. return -1;
  5759. }
  5760. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5761. { // you can jail only lower or same GM
  5762. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5763. return -1;
  5764. }
  5765. if (pl_sd->mapindex == mapindex_name2id(MAP_JAIL))
  5766. { //Already jailed
  5767. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5768. return -1;
  5769. }
  5770. switch(rand() % 2) { //Jail Locations
  5771. case 0:
  5772. m_index = mapindex_name2id(MAP_JAIL);
  5773. x = 24;
  5774. y = 75;
  5775. break;
  5776. default:
  5777. m_index = mapindex_name2id(MAP_JAIL);
  5778. x = 49;
  5779. y = 75;
  5780. break;
  5781. }
  5782. if (pc_setpos(pl_sd, m_index, x, y, 3)) {
  5783. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5784. return -1;
  5785. }
  5786. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5787. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5788. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5789. return 0;
  5790. }
  5791. /*==========================================
  5792. * @unjail/@discharge <char_name> by [Yor]
  5793. * Special warp! No check with nowarp and nowarpto flag
  5794. *------------------------------------------
  5795. */
  5796. int atcommand_unjail(
  5797. const int fd, struct map_session_data* sd,
  5798. const char* command, const char* message)
  5799. {
  5800. struct map_session_data *pl_sd;
  5801. unsigned short m_index;
  5802. int x=0, y=0;
  5803. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5804. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5805. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5806. return -1;
  5807. }
  5808. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5809. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5810. return -1;
  5811. }
  5812. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5813. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5814. return -1;
  5815. }
  5816. if (pl_sd->mapindex != mapindex_name2id(MAP_JAIL)) {
  5817. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5818. return -1;
  5819. }
  5820. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5821. { //Retrieve return map.
  5822. m_index = pl_sd->sc.data[SC_JAILED].val3;
  5823. x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
  5824. y = pl_sd->sc.data[SC_JAILED].val4>>16;
  5825. status_change_end(&pl_sd->bl,SC_JAILED,-1);
  5826. } else
  5827. m_index = mapindex_name2id(MAP_PRONTERA);
  5828. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
  5829. pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
  5830. ) { //Send to Prontera is saved SC map fails.
  5831. pc_setsavepoint(pl_sd, m_index, x, y);
  5832. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5833. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5834. } else {
  5835. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5836. return -1;
  5837. }
  5838. return 0;
  5839. }
  5840. int atcommand_jailfor(
  5841. const int fd, struct map_session_data* sd,
  5842. const char* command, const char* message)
  5843. {
  5844. struct map_session_data *pl_sd = NULL;
  5845. int year, month, day, hour, minute, value;
  5846. char * modif_p;
  5847. int jailtime = 0,x,y;
  5848. short m_index = 0;
  5849. nullpo_retr(-1, sd);
  5850. if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5851. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5852. return -1;
  5853. }
  5854. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5855. modif_p = atcmd_output;
  5856. year = month = day = hour = minute = 0;
  5857. while (modif_p[0] != '\0') {
  5858. value = atoi(modif_p);
  5859. if (value == 0)
  5860. modif_p++;
  5861. else {
  5862. if (modif_p[0] == '-' || modif_p[0] == '+')
  5863. modif_p++;
  5864. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5865. modif_p++;
  5866. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  5867. minute = value;
  5868. modif_p = modif_p + 2;
  5869. } else if (modif_p[0] == 'h') {
  5870. hour = value;
  5871. modif_p++;
  5872. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5873. day = value;
  5874. modif_p++;
  5875. } else if (modif_p[0] == 'm') {
  5876. month = value;
  5877. modif_p++;
  5878. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5879. year = value;
  5880. modif_p++;
  5881. } else if (modif_p[0] != '\0') {
  5882. modif_p++;
  5883. }
  5884. }
  5885. }
  5886. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5887. clif_displaymessage(fd, "Invalid time for jail command.");
  5888. return -1;
  5889. }
  5890. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5891. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5892. return -1;
  5893. }
  5894. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5895. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5896. return -1;
  5897. }
  5898. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5899. if(jailtime==0) {
  5900. clif_displaymessage(fd, "Invalid time for jail command.");
  5901. return -1;
  5902. }
  5903. //Added by Coltaro
  5904. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5905. { //Update the player's jail time
  5906. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  5907. if (jailtime <= 0) {
  5908. jailtime = 0;
  5909. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5910. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5911. } else {
  5912. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5913. 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
  5914. clif_displaymessage(pl_sd->fd, atcmd_output);
  5915. 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
  5916. clif_displaymessage(fd, atcmd_output);
  5917. }
  5918. } else if (jailtime < 0) {
  5919. clif_displaymessage(fd, "Invalid time for jail command.");
  5920. return -1;
  5921. }
  5922. //Jail locations, add more as you wish.
  5923. switch(rand()%2)
  5924. {
  5925. case 1: //Jail #1
  5926. m_index = mapindex_name2id(MAP_JAIL);
  5927. x = 49; y = 75;
  5928. break;
  5929. default: //Default Jail
  5930. m_index = mapindex_name2id(MAP_JAIL);
  5931. x = 24; y = 75;
  5932. break;
  5933. }
  5934. 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).
  5935. return 0;
  5936. }
  5937. //By Coltaro
  5938. int atcommand_jailtime(
  5939. const int fd, struct map_session_data* sd,
  5940. const char* command, const char* message)
  5941. {
  5942. int year, month, day, hour, minute;
  5943. nullpo_retr(-1, sd);
  5944. if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5945. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5946. return -1;
  5947. }
  5948. 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?)
  5949. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5950. return -1;
  5951. }
  5952. //Get remaining jail time
  5953. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5954. 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
  5955. clif_displaymessage(fd, atcmd_output);
  5956. return 0;
  5957. }
  5958. //By Coltaro
  5959. int atcommand_charjailtime(
  5960. const int fd, struct map_session_data* sd,
  5961. const char* command, const char* message)
  5962. {
  5963. struct map_session_data* pl_sd;
  5964. int year, month, day, hour, minute;
  5965. nullpo_retr(-1, sd);
  5966. if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
  5967. clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
  5968. return -1;
  5969. }
  5970. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5971. if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
  5972. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5973. clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
  5974. return -1;
  5975. }
  5976. 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?)
  5977. clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
  5978. return -1;
  5979. }
  5980. //Get remaining jail time
  5981. get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5982. sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
  5983. clif_displaymessage(fd, atcmd_output);
  5984. } else {
  5985. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
  5986. return -1;
  5987. }
  5988. } else {
  5989. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5990. return -1;
  5991. }
  5992. return 0;
  5993. }
  5994. /*==========================================
  5995. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5996. *------------------------------------------
  5997. */
  5998. int atcommand_disguise(
  5999. const int fd, struct map_session_data* sd,
  6000. const char* command, const char* message)
  6001. {
  6002. int id = 0;
  6003. nullpo_retr(-1, sd);
  6004. if (!message || !*message) {
  6005. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  6006. return -1;
  6007. }
  6008. if ((id = atoi(message)) > 0)
  6009. { //Acquired an ID
  6010. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  6011. id = 0; //Invalid id for either mobs or npcs.
  6012. } else { //Acquired a Name
  6013. if ((id = mobdb_searchname(message)) == 0)
  6014. {
  6015. struct npc_data* nd = npc_name2id(message);
  6016. if (nd != NULL)
  6017. id = nd->n;
  6018. }
  6019. }
  6020. if (id == 0)
  6021. { // Monster/NPC name/id hasn't been found.
  6022. clif_displaymessage(fd, msg_txt(123));
  6023. return -1;
  6024. }
  6025. pc_disguise(sd, id);
  6026. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  6027. return 0;
  6028. }
  6029. /*==========================================
  6030. * DisguiseAll
  6031. *------------------------------------------
  6032. */
  6033. int atcommand_disguiseall(
  6034. const int fd, struct map_session_data* sd,
  6035. const char* command, const char* message)
  6036. {
  6037. int mob_id=0, i=0, users;
  6038. struct map_session_data *pl_sd, **pl_allsd;
  6039. nullpo_retr(-1, sd);
  6040. if (!message || !*message) {
  6041. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  6042. return -1;
  6043. }
  6044. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  6045. mob_id = atoi(message);
  6046. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  6047. pl_allsd = map_getallusers(&users);
  6048. for(i=0; i < users; i++) {
  6049. if((pl_sd = pl_allsd[i]))
  6050. pc_disguise(pl_sd, mob_id);
  6051. }
  6052. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  6053. } else {
  6054. return -1;
  6055. }
  6056. return 0;
  6057. }
  6058. /*==========================================
  6059. * @undisguise by [Yor]
  6060. *------------------------------------------
  6061. */
  6062. int atcommand_undisguise(
  6063. const int fd, struct map_session_data* sd,
  6064. const char* command, const char* message)
  6065. {
  6066. nullpo_retr(-1, sd);
  6067. if (sd->disguise) {
  6068. pc_disguise(sd, 0);
  6069. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  6070. } else {
  6071. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  6072. return -1;
  6073. }
  6074. return 0;
  6075. }
  6076. /*==========================================
  6077. * UndisguiseAll
  6078. *------------------------------------------
  6079. */
  6080. int atcommand_undisguiseall(
  6081. const int fd, struct map_session_data* sd,
  6082. const char* command, const char* message)
  6083. {
  6084. struct map_session_data *pl_sd, **pl_allsd;
  6085. int i, users;
  6086. nullpo_retr(-1, sd);
  6087. pl_allsd = map_getallusers(&users);
  6088. for(i=0; i < users; i++) {
  6089. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  6090. pc_disguise(pl_sd, 0);
  6091. }
  6092. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  6093. return 0;
  6094. }
  6095. /*==========================================
  6096. * @exp by [Skotlex]
  6097. *------------------------------------------
  6098. */
  6099. int atcommand_exp(
  6100. const int fd, struct map_session_data* sd,
  6101. const char* command, const char* message)
  6102. {
  6103. char output[200];
  6104. double nextb, nextj;
  6105. nullpo_retr(-1, sd);
  6106. memset(output, '\0', sizeof(output));
  6107. nextb = pc_nextbaseexp(sd);
  6108. if (nextb)
  6109. nextb = sd->status.base_exp*100.0/nextb;
  6110. nextj = pc_nextjobexp(sd);
  6111. if (nextj)
  6112. nextj = sd->status.job_exp*100.0/nextj;
  6113. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  6114. clif_displaymessage(fd, output);
  6115. return 0;
  6116. }
  6117. /*==========================================
  6118. * @broadcast by [Valaris]
  6119. *------------------------------------------
  6120. */
  6121. int atcommand_broadcast(
  6122. const int fd, struct map_session_data* sd,
  6123. const char* command, const char* message)
  6124. {
  6125. nullpo_retr(-1, sd);
  6126. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6127. if (!message || !*message) {
  6128. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  6129. return -1;
  6130. }
  6131. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  6132. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  6133. return 0;
  6134. }
  6135. /*==========================================
  6136. * @localbroadcast by [Valaris]
  6137. *------------------------------------------
  6138. */
  6139. int atcommand_localbroadcast(
  6140. const int fd, struct map_session_data* sd,
  6141. const char* command, const char* message)
  6142. {
  6143. nullpo_retr(-1, sd);
  6144. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6145. if (!message || !*message) {
  6146. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  6147. return -1;
  6148. }
  6149. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  6150. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  6151. return 0;
  6152. }
  6153. /*==========================================
  6154. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  6155. *------------------------------------------
  6156. */
  6157. int atcommand_chardisguise(
  6158. const int fd, struct map_session_data* sd,
  6159. const char* command, const char* message)
  6160. {
  6161. int mob_id;
  6162. char mob_name[NAME_LENGTH];
  6163. struct map_session_data* pl_sd;
  6164. nullpo_retr(-1, sd);
  6165. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6166. memset(mob_name, '\0', sizeof(mob_name));
  6167. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  6168. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  6169. return -1;
  6170. }
  6171. if ((mob_id = atoi(mob_name)) > 0)
  6172. { //Acquired an ID
  6173. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  6174. mob_id = 0; //Invalid id for either mobs or npcs.
  6175. } else { //Acquired a Name
  6176. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  6177. {
  6178. struct npc_data* nd = npc_name2id(mob_name);
  6179. if (nd != NULL)
  6180. mob_id = nd->n;
  6181. }
  6182. }
  6183. if (mob_id == 0)
  6184. {
  6185. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  6186. return -1;
  6187. }
  6188. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6189. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  6190. pc_disguise(pl_sd, mob_id);
  6191. clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
  6192. } else {
  6193. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6194. return -1;
  6195. }
  6196. } else {
  6197. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6198. return -1;
  6199. }
  6200. return 0;
  6201. }
  6202. /*==========================================
  6203. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  6204. *------------------------------------------
  6205. */
  6206. int atcommand_charundisguise(
  6207. const int fd, struct map_session_data* sd,
  6208. const char* command, const char* message)
  6209. {
  6210. struct map_session_data* pl_sd;
  6211. nullpo_retr(-1, sd);
  6212. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6213. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6214. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  6215. return -1;
  6216. }
  6217. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6218. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  6219. if (pl_sd->disguise)
  6220. pc_disguise(pl_sd, 0);
  6221. else {
  6222. clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
  6223. return -1;
  6224. }
  6225. } else {
  6226. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6227. return -1;
  6228. }
  6229. } else {
  6230. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6231. return -1;
  6232. }
  6233. return 0;
  6234. }
  6235. /*==========================================
  6236. * @email <actual@email> <new@email> by [Yor]
  6237. *------------------------------------------
  6238. */
  6239. int atcommand_email(
  6240. const int fd, struct map_session_data* sd,
  6241. const char* command, const char* message)
  6242. {
  6243. char actual_email[100];
  6244. char new_email[100];
  6245. nullpo_retr(-1, sd);
  6246. memset(actual_email, '\0', sizeof(actual_email));
  6247. memset(new_email, '\0', sizeof(new_email));
  6248. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  6249. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  6250. return -1;
  6251. }
  6252. if (e_mail_check(actual_email) == 0) {
  6253. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  6254. return -1;
  6255. } else if (e_mail_check(new_email) == 0) {
  6256. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  6257. return -1;
  6258. } else if (strcmpi(new_email, "a@a.com") == 0) {
  6259. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  6260. return -1;
  6261. } else if (strcmpi(actual_email, new_email) == 0) {
  6262. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  6263. return -1;
  6264. } else {
  6265. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  6266. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  6267. }
  6268. return 0;
  6269. }
  6270. /*==========================================
  6271. *@effect
  6272. *------------------------------------------
  6273. */
  6274. int atcommand_effect(
  6275. const int fd, struct map_session_data* sd,
  6276. const char* command, const char* message)
  6277. {
  6278. int type = 0, flag = 0;
  6279. nullpo_retr(-1, sd);
  6280. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  6281. clif_displaymessage(fd, "Please, enter a type and a send flag (usage: @effect <type> <flag>).");
  6282. return -1;
  6283. }
  6284. clif_specialeffect(&sd->bl, type, flag);
  6285. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  6286. return 0;
  6287. }
  6288. /*==========================================
  6289. * @charcartlist <character>: Displays the items list of a player's cart.
  6290. *------------------------------------------
  6291. */
  6292. int
  6293. atcommand_character_cart_list(
  6294. const int fd, struct map_session_data* sd,
  6295. const char* command, const char* message)
  6296. {
  6297. char outputtmp[200];
  6298. struct map_session_data *pl_sd;
  6299. struct item_data *item_data, *item_temp;
  6300. int i, j, count, counter, counter2;
  6301. nullpo_retr(-1, sd);
  6302. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6303. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6304. memset(outputtmp, '\0', sizeof(outputtmp));
  6305. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6306. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6307. return -1;
  6308. }
  6309. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6310. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6311. counter = 0;
  6312. count = 0;
  6313. for (i = 0; i < MAX_CART; i++) {
  6314. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6315. counter = counter + pl_sd->status.cart[i].amount;
  6316. count++;
  6317. if (count == 1) {
  6318. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6319. clif_displaymessage(fd, atcmd_output);
  6320. }
  6321. if (pl_sd->status.cart[i].refine)
  6322. 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);
  6323. else
  6324. 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);
  6325. clif_displaymessage(fd, atcmd_output);
  6326. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6327. counter2 = 0;
  6328. for (j = 0; j < item_data->slot; j++) {
  6329. if (pl_sd->status.cart[i].card[j]) {
  6330. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6331. if (atcmd_output[0] == '\0')
  6332. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6333. else
  6334. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6335. strcat(atcmd_output, outputtmp);
  6336. }
  6337. }
  6338. }
  6339. if (atcmd_output[0] != '\0') {
  6340. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6341. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6342. clif_displaymessage(fd, atcmd_output);
  6343. }
  6344. }
  6345. }
  6346. if (count == 0)
  6347. clif_displaymessage(fd, "No item found in the cart of this player.");
  6348. else {
  6349. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6350. clif_displaymessage(fd, atcmd_output);
  6351. }
  6352. } else {
  6353. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6354. return -1;
  6355. }
  6356. } else {
  6357. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6358. return -1;
  6359. }
  6360. return 0;
  6361. }
  6362. /*==========================================
  6363. * @killer by MouseJstr
  6364. * enable killing players even when not in pvp
  6365. *------------------------------------------
  6366. */
  6367. int
  6368. atcommand_killer(
  6369. const int fd, struct map_session_data* sd,
  6370. const char* command, const char* message)
  6371. {
  6372. nullpo_retr(-1, sd);
  6373. sd->state.killer = !sd->state.killer;
  6374. if(sd->state.killer)
  6375. clif_displaymessage(fd, msg_txt(241));
  6376. else
  6377. clif_displaymessage(fd, msg_txt(287));
  6378. return 0;
  6379. }
  6380. /*==========================================
  6381. * @killable by MouseJstr
  6382. * enable other people killing you
  6383. *------------------------------------------
  6384. */
  6385. int
  6386. atcommand_killable(
  6387. const int fd, struct map_session_data* sd,
  6388. const char* command, const char* message)
  6389. {
  6390. nullpo_retr(-1, sd);
  6391. sd->state.killable = !sd->state.killable;
  6392. if(sd->state.killable)
  6393. clif_displaymessage(fd, msg_txt(242));
  6394. else
  6395. clif_displaymessage(fd, msg_txt(288));
  6396. return 0;
  6397. }
  6398. /*==========================================
  6399. * @charkillable by MouseJstr
  6400. * enable another player to be killed
  6401. *------------------------------------------
  6402. */
  6403. int
  6404. atcommand_charkillable(
  6405. const int fd, struct map_session_data* sd,
  6406. const char* command, const char* message)
  6407. {
  6408. struct map_session_data *pl_sd = NULL;
  6409. nullpo_retr(-1, sd);
  6410. if (!message || !*message)
  6411. return -1;
  6412. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6413. return -1;
  6414. pl_sd->state.killable = !pl_sd->state.killable;
  6415. if(pl_sd->state.killable)
  6416. clif_displaymessage(fd, msg_txt(289));
  6417. else
  6418. clif_displaymessage(fd, msg_txt(290));
  6419. return 0;
  6420. }
  6421. /*==========================================
  6422. * @skillon by MouseJstr
  6423. * turn skills on for the map
  6424. *------------------------------------------
  6425. */
  6426. int
  6427. atcommand_skillon(
  6428. const int fd, struct map_session_data* sd,
  6429. const char* command, const char* message)
  6430. {
  6431. nullpo_retr(-1, sd);
  6432. map[sd->bl.m].flag.noskill = 0;
  6433. clif_displaymessage(fd, msg_txt(244));
  6434. return 0;
  6435. }
  6436. /*==========================================
  6437. * @skilloff by MouseJstr
  6438. * Turn skills off on the map
  6439. *------------------------------------------
  6440. */
  6441. int
  6442. atcommand_skilloff(
  6443. const int fd, struct map_session_data* sd,
  6444. const char* command, const char* message)
  6445. {
  6446. nullpo_retr(-1, sd);
  6447. map[sd->bl.m].flag.noskill = 1;
  6448. clif_displaymessage(fd, msg_txt(243));
  6449. return 0;
  6450. }
  6451. /*==========================================
  6452. * @npcmove by MouseJstr
  6453. *
  6454. * move a npc
  6455. *------------------------------------------
  6456. */
  6457. int
  6458. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6459. const char* command, const char* message)
  6460. {
  6461. int x = 0, y = 0, m;
  6462. struct npc_data *nd = 0;
  6463. nullpo_retr(-1, sd);
  6464. if (!message || !*message)
  6465. return -1;
  6466. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6467. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6468. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6469. return -1;
  6470. }
  6471. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6472. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6473. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6474. return -1;
  6475. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6476. return -1; //Not on a map.
  6477. if (x < 0) x = 0;
  6478. else if (x >= map[m].xs) x = map[m].xs-1;
  6479. if (y < 0) y = 0;
  6480. else if (y >= map[m].ys) y = map[m].ys-1;
  6481. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6482. map_moveblock(&nd->bl, x, y, gettick());
  6483. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6484. return 0;
  6485. }
  6486. /*==========================================
  6487. * @addwarp by MouseJstr
  6488. *
  6489. * Create a new static warp point.
  6490. *------------------------------------------
  6491. */
  6492. int
  6493. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6494. const char* command, const char* message)
  6495. {
  6496. char w1[64], w3[64], w4[64];
  6497. int x,y,ret;
  6498. nullpo_retr(-1, sd);
  6499. if (!message || !*message)
  6500. return -1;
  6501. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6502. return -1;
  6503. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6504. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6505. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6506. ret = npc_parse_warp(w1, "warp", w3, w4);
  6507. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6508. clif_displaymessage(fd, atcmd_output);
  6509. return ret;
  6510. }
  6511. /*==========================================
  6512. * @follow by [MouseJstr]
  6513. *
  6514. * Follow a player .. staying no more then 5 spaces away
  6515. *------------------------------------------
  6516. */
  6517. int
  6518. atcommand_follow(const int fd, struct map_session_data* sd,
  6519. const char* command, const char* message)
  6520. {
  6521. struct map_session_data *pl_sd = NULL;
  6522. nullpo_retr(-1, sd);
  6523. if (!message || !*message) {
  6524. if (sd->followtarget == -1)
  6525. return -1;
  6526. pc_stop_following (sd);
  6527. clif_displaymessage(fd, "Follow mode OFF.");
  6528. return 0;
  6529. }
  6530. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6531. if (sd->followtarget == pl_sd->bl.id) {
  6532. pc_stop_following (sd);
  6533. clif_displaymessage(fd, "Follow mode OFF.");
  6534. } else {
  6535. pc_follow(sd, pl_sd->bl.id);
  6536. clif_displaymessage(fd, "Follow mode ON.");
  6537. }
  6538. return 0;
  6539. } else {
  6540. clif_displaymessage(fd, "Character not found.");
  6541. return -1;
  6542. }
  6543. return 1;
  6544. }
  6545. /*==========================================
  6546. * @dropall by [MouseJstr]
  6547. *
  6548. * Drop all your possession on the ground
  6549. *------------------------------------------
  6550. */
  6551. int
  6552. atcommand_dropall(const int fd, struct map_session_data* sd,
  6553. const char* command, const char* message)
  6554. {
  6555. int i;
  6556. nullpo_retr(-1, sd);
  6557. for (i = 0; i < MAX_INVENTORY; i++) {
  6558. if (sd->status.inventory[i].amount) {
  6559. if(sd->status.inventory[i].equip != 0)
  6560. pc_unequipitem(sd, i, 3);
  6561. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6562. }
  6563. }
  6564. return 0;
  6565. }
  6566. /*==========================================
  6567. * @chardropall by [MouseJstr]
  6568. *
  6569. * Throw all the characters possessions on the ground. Normally
  6570. * done in response to them being disrespectful of a GM
  6571. *------------------------------------------
  6572. */
  6573. int
  6574. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6575. const char* command, const char* message)
  6576. {
  6577. int i;
  6578. struct map_session_data *pl_sd = NULL;
  6579. nullpo_retr(-1, sd);
  6580. if (!message || !*message)
  6581. return -1;
  6582. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6583. return -1;
  6584. for (i = 0; i < MAX_INVENTORY; i++) {
  6585. if (pl_sd->status.inventory[i].amount) {
  6586. if(pl_sd->status.inventory[i].equip != 0)
  6587. pc_unequipitem(pl_sd, i, 3);
  6588. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6589. }
  6590. }
  6591. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6592. clif_displaymessage(fd, "It is done");
  6593. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6594. return 0;
  6595. }
  6596. /*==========================================
  6597. * @storeall by [MouseJstr]
  6598. *
  6599. * Put everything into storage to simplify your inventory to make
  6600. * debugging easie
  6601. *------------------------------------------
  6602. */
  6603. int
  6604. atcommand_storeall(const int fd, struct map_session_data* sd,
  6605. const char* command, const char* message)
  6606. {
  6607. int i;
  6608. nullpo_retr(-1, sd);
  6609. if (sd->state.storage_flag != 1)
  6610. { //Open storage.
  6611. switch (storage_storageopen(sd)) {
  6612. case 2: //Try again
  6613. clif_displaymessage(fd, "run this command again..");
  6614. return 0;
  6615. case 1: //Failure
  6616. clif_displaymessage(fd, "You can't open the storage currently.");
  6617. return -1;
  6618. }
  6619. }
  6620. for (i = 0; i < MAX_INVENTORY; i++) {
  6621. if (sd->status.inventory[i].amount) {
  6622. if(sd->status.inventory[i].equip != 0)
  6623. pc_unequipitem(sd, i, 3);
  6624. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6625. }
  6626. }
  6627. storage_storageclose(sd);
  6628. clif_displaymessage(fd, "It is done");
  6629. return 0;
  6630. }
  6631. /*==========================================
  6632. * @charstoreall by [MouseJstr]
  6633. *
  6634. * A way to screw with players who piss you off
  6635. *------------------------------------------
  6636. */
  6637. int
  6638. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6639. const char* command, const char* message)
  6640. {
  6641. int i;
  6642. struct map_session_data *pl_sd = NULL;
  6643. nullpo_retr(-1, sd);
  6644. if (!message || !*message)
  6645. return -1;
  6646. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6647. return -1;
  6648. if (pl_sd->state.storage_flag != 1)
  6649. { //Open storage.
  6650. switch (storage_storageopen(pl_sd)) {
  6651. case 2: //Try again
  6652. clif_displaymessage(fd, "Had to open the characters storage window...");
  6653. clif_displaymessage(fd, "run this command again..");
  6654. return 0;
  6655. case 1: //Failure
  6656. clif_displaymessage(fd, "The character currently can't use the storage.");
  6657. return 1;
  6658. }
  6659. }
  6660. for (i = 0; i < MAX_INVENTORY; i++) {
  6661. if (pl_sd->status.inventory[i].amount) {
  6662. if(pl_sd->status.inventory[i].equip != 0)
  6663. pc_unequipitem(pl_sd, i, 3);
  6664. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6665. }
  6666. }
  6667. storage_storageclose(pl_sd);
  6668. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6669. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6670. clif_displaymessage(pl_sd->fd, " -- the management");
  6671. clif_displaymessage(fd, "It is done");
  6672. return 0;
  6673. }
  6674. /*==========================================
  6675. * @skillid by [MouseJstr]
  6676. *
  6677. * lookup a skill by name
  6678. *------------------------------------------
  6679. */
  6680. int
  6681. atcommand_skillid(const int fd, struct map_session_data* sd,
  6682. const char* command, const char* message)
  6683. {
  6684. int skillen, idx;
  6685. nullpo_retr(-1, sd);
  6686. if (!message || !*message)
  6687. return -1;
  6688. skillen = strlen(message);
  6689. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6690. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6691. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6692. {
  6693. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6694. clif_displaymessage(fd, atcmd_output);
  6695. }
  6696. }
  6697. return 0;
  6698. }
  6699. /*==========================================
  6700. * @useskill by [MouseJstr]
  6701. *
  6702. * A way of using skills without having to find them in the skills menu
  6703. *------------------------------------------
  6704. */
  6705. int
  6706. atcommand_useskill(const int fd, struct map_session_data* sd,
  6707. const char* command, const char* message)
  6708. {
  6709. struct map_session_data *pl_sd = NULL;
  6710. struct block_list *bl;
  6711. int skillnum;
  6712. int skilllv;
  6713. char target[255];
  6714. nullpo_retr(-1, sd);
  6715. if (!message || !*message)
  6716. return -1;
  6717. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6718. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6719. return -1;
  6720. }
  6721. if((pl_sd=map_nick2sd(target)) == NULL) {
  6722. return -1;
  6723. }
  6724. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  6725. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  6726. bl = &sd->hd->bl;
  6727. else
  6728. bl = &sd->bl;
  6729. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6730. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6731. else
  6732. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  6733. return 0;
  6734. }
  6735. /*==========================================
  6736. * @skilltree by [MouseJstr]
  6737. *
  6738. * prints the skill tree for a player required to get to a skill
  6739. *------------------------------------------
  6740. */
  6741. int
  6742. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6743. const char* command, const char* message)
  6744. {
  6745. struct map_session_data *pl_sd = NULL;
  6746. int skillnum, skillidx = -1;
  6747. int meets = 1, j, c=0;
  6748. char target[NAME_LENGTH], *tbl;
  6749. struct skill_tree_entry *ent;
  6750. nullpo_retr(-1, sd);
  6751. if (!message || !*message)
  6752. return -1;
  6753. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6754. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6755. return -1;
  6756. }
  6757. if((pl_sd=map_nick2sd(target)) == NULL)
  6758. return -1;
  6759. c = pc_calc_skilltree_normalize_job(pl_sd);
  6760. c = pc_mapid2jobid(c, pl_sd->status.sex);
  6761. tbl = job_name(c);
  6762. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6763. tbl, pc_checkskill(pl_sd, 1));
  6764. clif_displaymessage(fd, atcmd_output);
  6765. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6766. if (skill_tree[c][j].id == skillnum) {
  6767. skillidx = j;
  6768. break;
  6769. }
  6770. }
  6771. if (skillidx == -1) {
  6772. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6773. clif_displaymessage(fd, atcmd_output);
  6774. return 0;
  6775. }
  6776. ent = &skill_tree[c][skillidx];
  6777. for(j=0;j<5;j++)
  6778. if( ent->need[j].id &&
  6779. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6780. {
  6781. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6782. sprintf(atcmd_output, "player requires level %d of skill %s",
  6783. ent->need[j].lv, desc);
  6784. clif_displaymessage(fd, atcmd_output);
  6785. meets = 0;
  6786. }
  6787. if (meets == 1) {
  6788. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6789. clif_displaymessage(fd, atcmd_output);
  6790. }
  6791. return 0;
  6792. }
  6793. // Hand a ring with partners name on it to this char
  6794. void getring (struct map_session_data *sd)
  6795. {
  6796. int flag,item_id = 0;
  6797. struct item item_tmp;
  6798. if(sd->status.sex==0)
  6799. item_id = 2635;
  6800. else
  6801. item_id = 2634;
  6802. memset(&item_tmp,0,sizeof(item_tmp));
  6803. item_tmp.nameid=item_id;
  6804. item_tmp.identify=1;
  6805. item_tmp.card[0]=255;
  6806. item_tmp.card[2]=sd->status.partner_id;
  6807. item_tmp.card[3]=sd->status.partner_id >> 16;
  6808. //Logs (A)dmins items [Lupus]
  6809. if(log_config.enable_logs&0x400)
  6810. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  6811. if((flag = pc_additem(sd,&item_tmp,1))) {
  6812. clif_additem(sd,0,0,flag);
  6813. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6814. }
  6815. }
  6816. /*==========================================
  6817. * @marry by [MouseJstr], fixed by Lupus
  6818. *
  6819. * Marry two players
  6820. *------------------------------------------
  6821. */
  6822. int
  6823. atcommand_marry(const int fd, struct map_session_data* sd,
  6824. const char* command, const char* message)
  6825. {
  6826. struct map_session_data *pl_sd1 = NULL;
  6827. struct map_session_data *pl_sd2 = NULL;
  6828. char player1[128], player2[128]; //Length used for return error msgs
  6829. nullpo_retr(-1, sd);
  6830. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6831. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6832. return -1;
  6833. }
  6834. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6835. sprintf(player2, "Cannot find player '%s' online", player1);
  6836. clif_displaymessage(fd, player2);
  6837. return -1;
  6838. }
  6839. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6840. sprintf(player1, "Cannot find player '%s' online", player2);
  6841. clif_displaymessage(fd, player1);
  6842. return -1;
  6843. }
  6844. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6845. clif_displaymessage(fd, "They are married.. wish them well");
  6846. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6847. // Auto-give named rings (Aru)
  6848. getring (pl_sd1);
  6849. getring (pl_sd2);
  6850. return 0;
  6851. }
  6852. return -1;
  6853. }
  6854. /*==========================================
  6855. * @divorce by [MouseJstr], fixed by [Lupus]
  6856. *
  6857. * divorce two players
  6858. *------------------------------------------
  6859. */
  6860. int
  6861. atcommand_divorce(const int fd, struct map_session_data* sd,
  6862. const char* command, const char* message)
  6863. {
  6864. struct map_session_data *pl_sd = NULL;
  6865. nullpo_retr(-1, sd);
  6866. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6867. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6868. return -1;
  6869. }
  6870. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6871. if (pc_divorce(pl_sd) != 0) {
  6872. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6873. clif_displaymessage(fd, atcmd_output);
  6874. return -1;
  6875. } else {
  6876. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6877. clif_displaymessage(fd, atcmd_output);
  6878. return 0;
  6879. }
  6880. }
  6881. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6882. clif_displaymessage(fd, atcmd_output);
  6883. return -1;
  6884. }
  6885. #ifdef DMALLOC
  6886. unsigned long dmark_;
  6887. int
  6888. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6889. const char* command, const char* message)
  6890. {
  6891. dmark_ = dmalloc_mark();
  6892. clif_displaymessage(fd, "debug mark set");
  6893. return 0;
  6894. }
  6895. int
  6896. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6897. const char* command, const char* message)
  6898. {
  6899. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6900. dmark_ = dmalloc_mark();
  6901. clif_displaymessage(fd, "malloc changes logged");
  6902. return 0;
  6903. }
  6904. #endif
  6905. /*==========================================
  6906. * @grind by [MouseJstr]
  6907. *------------------------------------------
  6908. */
  6909. int
  6910. atcommand_grind(const int fd, struct map_session_data* sd,
  6911. const char* command, const char* message)
  6912. {
  6913. struct map_session_data *pl_sd = NULL;
  6914. int skillnum;
  6915. int inf;
  6916. char target[NAME_LENGTH];
  6917. nullpo_retr(-1, sd);
  6918. if (!message || !*message)
  6919. return -1;
  6920. if(sscanf(message, "%23s", target) != 1) {
  6921. clif_displaymessage(fd, "Usage: @grind <target>");
  6922. return -1;
  6923. }
  6924. if((pl_sd=map_nick2sd(target)) == NULL)
  6925. return -1;
  6926. for (skillnum = 1; skillnum < 500; skillnum++) {
  6927. sd->status.sp = sd->status.max_sp;
  6928. atcommand_alive(fd, sd, command, message);
  6929. inf = skill_get_inf(skillnum);
  6930. if (inf & INF_GROUND_SKILL)
  6931. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6932. else if (!(inf & INF_SUPPORT_SKILL))
  6933. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6934. }
  6935. return 0;
  6936. }
  6937. /*==========================================
  6938. * @grind2 by [MouseJstr]
  6939. *------------------------------------------
  6940. */
  6941. int
  6942. atcommand_grind2(const int fd, struct map_session_data* sd,
  6943. const char* command, const char* message)
  6944. {
  6945. int i;
  6946. short x, y;
  6947. for (i = 1000; i < MAX_MOB_DB; i++) {
  6948. if (!mobdb_checkid(i))
  6949. continue;
  6950. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6951. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6952. }
  6953. return 0;
  6954. }
  6955. /*==========================================
  6956. * @changelook by [Celest]
  6957. *------------------------------------------
  6958. */
  6959. int
  6960. atcommand_changelook(const int fd, struct map_session_data* sd,
  6961. const char* command, const char* message)
  6962. {
  6963. int i, j = 0, k = 0;
  6964. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6965. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6966. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6967. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6968. return -1;
  6969. } else if (i == 2) {
  6970. if (j < 1) j = 1;
  6971. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6972. j = pos[j - 1];
  6973. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6974. k = j; // swap
  6975. j = LOOK_HEAD_TOP;
  6976. }
  6977. clif_changelook(&sd->bl,j,k);
  6978. return 0;
  6979. }
  6980. /*==========================================
  6981. *Turns on/off Autotrade for a specific player
  6982. *------------------------------------------
  6983. *by durf (changed by Lupus)
  6984. */
  6985. int
  6986. atcommand_autotrade(
  6987. const int fd, struct map_session_data* sd,
  6988. const char* command, const char* message)
  6989. {
  6990. nullpo_retr(-1, sd);
  6991. if (sd->vender_id) //check if player's vending
  6992. {
  6993. sd->state.autotrade = 1;
  6994. clif_authfail_fd(fd, 15);
  6995. }
  6996. else
  6997. {
  6998. //"You should be vending to use @Autotrade."
  6999. clif_displaymessage(fd, msg_txt(549));
  7000. }
  7001. return 0;
  7002. }
  7003. /*==========================================
  7004. * Changes Master of your Guild to a specified guild member
  7005. *------------------------------------------
  7006. *by durf (changed by Lupus)
  7007. */
  7008. int
  7009. atcommand_changegm(
  7010. const int fd, struct map_session_data* sd,
  7011. const char* command, const char* message)
  7012. {
  7013. struct guild *g;
  7014. struct map_session_data *pl_sd;
  7015. nullpo_retr(-1, sd);
  7016. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  7017. {
  7018. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  7019. return -1;
  7020. }
  7021. if (strlen(message)==0)
  7022. {
  7023. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  7024. return -1;
  7025. }
  7026. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  7027. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  7028. return -1;
  7029. }
  7030. guild_gm_change(sd->status.guild_id, pl_sd);
  7031. return 0;
  7032. }
  7033. /*==========================================
  7034. *Changes the leader of a party.
  7035. *------------------------------------------
  7036. *by Skotlex
  7037. */
  7038. int
  7039. atcommand_changeleader(
  7040. const int fd, struct map_session_data* sd,
  7041. const char* command, const char* message)
  7042. {
  7043. struct party_data *p;
  7044. struct map_session_data *pl_sd;
  7045. int mi, pl_mi;
  7046. nullpo_retr(-1, sd);
  7047. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  7048. { //Need to be a party leader.
  7049. clif_displaymessage(fd, msg_txt(282));
  7050. return -1;
  7051. }
  7052. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  7053. if (mi == MAX_PARTY)
  7054. return -1; //Shouldn't happen
  7055. if (!p->party.member[mi].leader)
  7056. { //Need to be a party leader.
  7057. clif_displaymessage(fd, msg_txt(282));
  7058. return -1;
  7059. }
  7060. if (strlen(message)==0)
  7061. {
  7062. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  7063. return -1;
  7064. }
  7065. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  7066. clif_displaymessage(fd, msg_txt(283));
  7067. return -1;
  7068. }
  7069. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  7070. if (pl_mi == MAX_PARTY)
  7071. return -1; //Shouldn't happen
  7072. //Change leadership.
  7073. p->party.member[mi].leader = 0;
  7074. if (p->data[mi].sd->fd)
  7075. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  7076. p->party.member[pl_mi].leader = 1;
  7077. if (p->data[pl_mi].sd->fd)
  7078. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  7079. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  7080. //Update info.
  7081. clif_party_main_info(p,-1);
  7082. clif_party_info(p,-1);
  7083. return 0;
  7084. }
  7085. /*==========================================
  7086. * Used to change the item share setting of a party.
  7087. *------------------------------------------
  7088. *by Skotlex
  7089. */
  7090. int
  7091. atcommand_partyoption(
  7092. const int fd, struct map_session_data* sd,
  7093. const char* command, const char* message)
  7094. {
  7095. struct party_data *p;
  7096. int mi, option;
  7097. char w1[15], w2[15];
  7098. nullpo_retr(-1, sd);
  7099. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  7100. {
  7101. clif_displaymessage(fd, msg_txt(282));
  7102. return -1;
  7103. }
  7104. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  7105. if (mi == MAX_PARTY)
  7106. return -1; //Shouldn't happen
  7107. if (!p->party.member[mi].leader)
  7108. {
  7109. clif_displaymessage(fd, msg_txt(282));
  7110. return -1;
  7111. }
  7112. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  7113. {
  7114. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  7115. return -1;
  7116. }
  7117. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  7118. option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
  7119. //Change item share type.
  7120. if (option != p->party.item)
  7121. party_changeoption(sd, p->party.exp, option);
  7122. else
  7123. clif_displaymessage(fd, msg_txt(286));
  7124. return 0;
  7125. }
  7126. /*==========================================
  7127. *Turns on/off AutoLoot for a specific player
  7128. *------------------------------------------
  7129. *by Upa-Kun
  7130. */
  7131. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7132. {
  7133. int rate;
  7134. double drate;
  7135. nullpo_retr(-1, sd);
  7136. // autoloot command without value
  7137. if(!message || !*message)
  7138. {
  7139. if (sd->state.autoloot)
  7140. rate = 0;
  7141. else
  7142. rate = 10000;
  7143. } else {
  7144. drate = atof(message);
  7145. rate = (int)(drate*100);
  7146. }
  7147. if (rate < 0) rate = 0;
  7148. if (rate > 10000) rate = 10000;
  7149. sd->state.autoloot = rate;
  7150. if (sd->state.autoloot) {
  7151. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  7152. clif_displaymessage(fd, atcmd_output);
  7153. }else
  7154. clif_displaymessage(fd, "Autoloot is now off.");
  7155. return 0;
  7156. }
  7157. /*==========================================
  7158. * It is made to rain.
  7159. *------------------------------------------
  7160. */
  7161. int
  7162. atcommand_rain(
  7163. const int fd, struct map_session_data* sd,
  7164. const char* command, const char* message)
  7165. {
  7166. nullpo_retr(-1, sd);
  7167. if (map[sd->bl.m].flag.rain) {
  7168. map[sd->bl.m].flag.rain=0;
  7169. clif_weather(sd->bl.m);
  7170. clif_displaymessage(fd, "The rain has stopped.");
  7171. } else {
  7172. map[sd->bl.m].flag.rain=1;
  7173. clif_weather(sd->bl.m);
  7174. clif_displaymessage(fd, "It is made to rain.");
  7175. }
  7176. return 0;
  7177. }
  7178. /*==========================================
  7179. * It is made to snow.
  7180. *------------------------------------------
  7181. */
  7182. int
  7183. atcommand_snow(
  7184. const int fd, struct map_session_data* sd,
  7185. const char* command, const char* message)
  7186. {
  7187. nullpo_retr(-1, sd);
  7188. if (map[sd->bl.m].flag.snow) {
  7189. map[sd->bl.m].flag.snow=0;
  7190. clif_weather(sd->bl.m);
  7191. clif_displaymessage(fd, "Snow has stopped falling.");
  7192. } else {
  7193. map[sd->bl.m].flag.snow=1;
  7194. clif_weather(sd->bl.m);
  7195. clif_displaymessage(fd, "It is made to snow.");
  7196. }
  7197. return 0;
  7198. }
  7199. /*==========================================
  7200. * Cherry tree snowstorm is made to fall. (Sakura)
  7201. *------------------------------------------
  7202. */
  7203. int
  7204. atcommand_sakura(
  7205. const int fd, struct map_session_data* sd,
  7206. const char* command, const char* message)
  7207. {
  7208. nullpo_retr(-1, sd);
  7209. if (map[sd->bl.m].flag.sakura) {
  7210. map[sd->bl.m].flag.sakura=0;
  7211. clif_weather(sd->bl.m);
  7212. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  7213. } else {
  7214. map[sd->bl.m].flag.sakura=1;
  7215. clif_weather(sd->bl.m);
  7216. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  7217. }
  7218. return 0;
  7219. }
  7220. /*==========================================
  7221. * Clouds appear.
  7222. *------------------------------------------
  7223. */
  7224. int
  7225. atcommand_clouds(
  7226. const int fd, struct map_session_data* sd,
  7227. const char* command, const char* message)
  7228. {
  7229. nullpo_retr(-1, sd);
  7230. if (map[sd->bl.m].flag.clouds) {
  7231. map[sd->bl.m].flag.clouds=0;
  7232. clif_weather(sd->bl.m);
  7233. clif_displaymessage(fd, "The clouds has disappear.");
  7234. } else {
  7235. map[sd->bl.m].flag.clouds=1;
  7236. clif_weather(sd->bl.m);
  7237. clif_displaymessage(fd, "Clouds appear.");
  7238. }
  7239. return 0;
  7240. }
  7241. /*==========================================
  7242. * Different type of clouds using effect 516
  7243. *------------------------------------------
  7244. */
  7245. int
  7246. atcommand_clouds2(
  7247. const int fd, struct map_session_data* sd,
  7248. const char* command, const char* message)
  7249. {
  7250. nullpo_retr(-1, sd);
  7251. if (map[sd->bl.m].flag.clouds2) {
  7252. map[sd->bl.m].flag.clouds2=0;
  7253. clif_weather(sd->bl.m);
  7254. clif_displaymessage(fd, "The alternative clouds disappear.");
  7255. } else {
  7256. map[sd->bl.m].flag.clouds2=1;
  7257. clif_weather(sd->bl.m);
  7258. clif_displaymessage(fd, "Alternative clouds appear.");
  7259. }
  7260. return 0;
  7261. }
  7262. /*==========================================
  7263. * Fog hangs over.
  7264. *------------------------------------------
  7265. */
  7266. int
  7267. atcommand_fog(
  7268. const int fd, struct map_session_data* sd,
  7269. const char* command, const char* message)
  7270. {
  7271. nullpo_retr(-1, sd);
  7272. if (map[sd->bl.m].flag.fog) {
  7273. map[sd->bl.m].flag.fog=0;
  7274. clif_weather(sd->bl.m);
  7275. clif_displaymessage(fd, "The fog has gone.");
  7276. } else {
  7277. map[sd->bl.m].flag.fog=1;
  7278. clif_weather(sd->bl.m);
  7279. clif_displaymessage(fd, "Fog hangs over.");
  7280. }
  7281. return 0;
  7282. }
  7283. /*==========================================
  7284. * Fallen leaves fall.
  7285. *------------------------------------------
  7286. */
  7287. int
  7288. atcommand_leaves(
  7289. const int fd, struct map_session_data* sd,
  7290. const char* command, const char* message)
  7291. {
  7292. nullpo_retr(-1, sd);
  7293. if (map[sd->bl.m].flag.leaves) {
  7294. map[sd->bl.m].flag.leaves=0;
  7295. clif_weather(sd->bl.m);
  7296. clif_displaymessage(fd, "Leaves no longer fall.");
  7297. } else {
  7298. map[sd->bl.m].flag.leaves=1;
  7299. clif_weather(sd->bl.m);
  7300. clif_displaymessage(fd, "Fallen leaves fall.");
  7301. }
  7302. return 0;
  7303. }
  7304. /*==========================================
  7305. * Fireworks appear.
  7306. *------------------------------------------
  7307. */
  7308. int
  7309. atcommand_fireworks(
  7310. const int fd, struct map_session_data* sd,
  7311. const char* command, const char* message)
  7312. {
  7313. nullpo_retr(-1, sd);
  7314. if (map[sd->bl.m].flag.fireworks) {
  7315. map[sd->bl.m].flag.fireworks=0;
  7316. clif_weather(sd->bl.m);
  7317. clif_displaymessage(fd, "Fireworks are ended.");
  7318. } else {
  7319. map[sd->bl.m].flag.fireworks=1;
  7320. clif_weather(sd->bl.m);
  7321. clif_displaymessage(fd, "Fireworks are launched.");
  7322. }
  7323. return 0;
  7324. }
  7325. /*==========================================
  7326. * Clearing Weather Effects by Dexity
  7327. *------------------------------------------
  7328. */
  7329. int
  7330. atcommand_clearweather(
  7331. const int fd, struct map_session_data* sd,
  7332. const char* command, const char* message)
  7333. {
  7334. nullpo_retr(-1, sd);
  7335. map[sd->bl.m].flag.rain=0;
  7336. map[sd->bl.m].flag.snow=0;
  7337. map[sd->bl.m].flag.sakura=0;
  7338. map[sd->bl.m].flag.clouds=0;
  7339. map[sd->bl.m].flag.clouds2=0;
  7340. map[sd->bl.m].flag.fog=0;
  7341. map[sd->bl.m].flag.fireworks=0;
  7342. map[sd->bl.m].flag.leaves=0;
  7343. clif_weather(sd->bl.m);
  7344. clif_displaymessage(fd, msg_txt(291));
  7345. return 0;
  7346. }
  7347. /*===============================================================
  7348. * Sound Command - plays a sound for everyone! [Codemaster]
  7349. *---------------------------------------------------------------
  7350. */
  7351. int
  7352. atcommand_sound(
  7353. const int fd, struct map_session_data *sd,
  7354. const char *command, const char *message)
  7355. {
  7356. char sound_file[100];
  7357. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  7358. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  7359. return -1;
  7360. }
  7361. memset(sound_file, '\0', sizeof(sound_file));
  7362. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  7363. return -1;
  7364. if(strstr(sound_file, ".wav") == NULL)
  7365. strcat(sound_file, ".wav");
  7366. clif_soundeffectall(&sd->bl, sound_file,0,2);
  7367. return 0;
  7368. }
  7369. /*==========================================
  7370. * MOB Search
  7371. *------------------------------------------
  7372. */
  7373. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  7374. {
  7375. int mob_id,fd;
  7376. static int number=0;
  7377. struct mob_data *md;
  7378. nullpo_retr(0, bl);
  7379. if(!ap){
  7380. number=0;
  7381. return 0;
  7382. }
  7383. mob_id = va_arg(ap,int);
  7384. fd = va_arg(ap,int);
  7385. md = (struct mob_data *)bl;
  7386. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7387. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7388. ++number,bl->x, bl->y,md->name);
  7389. clif_displaymessage(fd, atcmd_output);
  7390. }
  7391. return 0;
  7392. }
  7393. int atcommand_mobsearch(
  7394. const int fd, struct map_session_data* sd,
  7395. const char* command, const char* message)
  7396. {
  7397. char mob_name[100];
  7398. int mob_id,map_id = 0;
  7399. nullpo_retr(-1, sd);
  7400. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7401. return -1;
  7402. if ((mob_id = atoi(mob_name)) == 0)
  7403. mob_id = mobdb_searchname(mob_name);
  7404. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7405. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7406. clif_displaymessage(fd, atcmd_output);
  7407. return 0;
  7408. }
  7409. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7410. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7411. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7412. map_id = sd->bl.m;
  7413. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7414. mob_name, mapindex_id2name(sd->mapindex));
  7415. clif_displaymessage(fd, atcmd_output);
  7416. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7417. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7418. return 0;
  7419. }
  7420. /*==========================================
  7421. * ドロップアイテムの掃除
  7422. *------------------------------------------
  7423. */
  7424. /*==========================================
  7425. * cleanmap
  7426. *------------------------------------------
  7427. */
  7428. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7429. {
  7430. nullpo_retr(0, bl);
  7431. map_clearflooritem(bl->id);
  7432. return 0;
  7433. }
  7434. int
  7435. atcommand_cleanmap(
  7436. const int fd, struct map_session_data* sd,
  7437. const char* command, const char* message)
  7438. {
  7439. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7440. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7441. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7442. BL_ITEM);
  7443. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7444. return 0;
  7445. }
  7446. /*==========================================
  7447. * NPC/PETに話させる
  7448. *------------------------------------------
  7449. */
  7450. int
  7451. atcommand_npctalk(
  7452. const int fd, struct map_session_data* sd,
  7453. const char* command, const char* message)
  7454. {
  7455. char name[NAME_LENGTH],mes[100],temp[100];
  7456. struct npc_data *nd;
  7457. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7458. return -1;
  7459. if (!(nd = npc_name2id(name)))
  7460. return -1;
  7461. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7462. clif_message(&nd->bl, temp);
  7463. return 0;
  7464. }
  7465. int
  7466. atcommand_pettalk(
  7467. const int fd, struct map_session_data* sd,
  7468. const char* command, const char* message)
  7469. {
  7470. char mes[100],temp[100];
  7471. struct pet_data *pd;
  7472. nullpo_retr(-1, sd);
  7473. if(!sd->status.pet_id || !(pd=sd->pd))
  7474. return -1;
  7475. if (sd->sc.count && //no "chatting" while muted.
  7476. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7477. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7478. return -1;
  7479. if (sscanf(message, "%99[^\n]", mes) < 1)
  7480. return -1;
  7481. snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
  7482. clif_message(&pd->bl, temp);
  7483. return 0;
  7484. }
  7485. /*==========================================
  7486. * @users
  7487. * サーバー内の人数マップを表示させる
  7488. * 手抜きのため汚くなっているのは仕様です。
  7489. *------------------------------------------
  7490. */
  7491. static struct dbt *users_db = NULL;
  7492. static int users_all;
  7493. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7494. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7495. users_all++;
  7496. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7497. return 0;
  7498. }
  7499. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7500. char buf[256];
  7501. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7502. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7503. clif_displaymessage(sd->fd,buf);
  7504. return 0;
  7505. }
  7506. int
  7507. atcommand_users(
  7508. const int fd, struct map_session_data* sd,
  7509. const char* command, const char* message)
  7510. {
  7511. char buf[256];
  7512. users_all = 0;
  7513. users_db->clear(users_db, NULL);
  7514. clif_foreachclient(atcommand_users_sub1);
  7515. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7516. sprintf(buf,"all : %d",users_all);
  7517. clif_displaymessage(fd,buf);
  7518. return 0;
  7519. }
  7520. int
  7521. atcommand_reset(
  7522. const int fd, struct map_session_data* sd,
  7523. const char* command, const char* message)
  7524. {
  7525. pc_resetstate(sd);
  7526. pc_resetskill(sd,1);
  7527. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  7528. clif_displaymessage(fd, atcmd_output);
  7529. return 0;
  7530. }
  7531. /*==========================================
  7532. *
  7533. *------------------------------------------
  7534. */
  7535. int
  7536. atcommand_summon(
  7537. const int fd, struct map_session_data* sd,
  7538. const char* command, const char* message)
  7539. {
  7540. char name[NAME_LENGTH];
  7541. int mob_id = 0;
  7542. int duration = 0;
  7543. struct mob_data *md;
  7544. unsigned int tick=gettick();
  7545. nullpo_retr(-1, sd);
  7546. if (!message || !*message)
  7547. return -1;
  7548. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7549. return -1;
  7550. if (duration < 1)
  7551. duration =1;
  7552. else if (duration > 60)
  7553. duration =60;
  7554. if ((mob_id = atoi(name)) == 0)
  7555. mob_id = mobdb_searchname(name);
  7556. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7557. return -1;
  7558. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7559. if(md){
  7560. md->master_id=sd->bl.id;
  7561. md->special_state.ai=1;
  7562. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  7563. clif_misceffect2(&md->bl,344);
  7564. mob_spawn(md);
  7565. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7566. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7567. }
  7568. return 0;
  7569. }
  7570. /*==========================================
  7571. * @adjcmdlvl by [MouseJstr]
  7572. *
  7573. * Temp adjust the GM level required to use a GM command
  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_adjcmdlvl(
  7581. const int fd, struct map_session_data* sd,
  7582. const char* command, const char* message)
  7583. {
  7584. int i, newlev;
  7585. char cmd[100];
  7586. nullpo_retr(-1, sd);
  7587. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7588. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7589. return -1;
  7590. }
  7591. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7592. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7593. atcommand_info[i].level = newlev;
  7594. clif_displaymessage(fd, "@command level changed.");
  7595. return 0;
  7596. }
  7597. clif_displaymessage(fd, "@command not found.");
  7598. return -1;
  7599. }
  7600. /*==========================================
  7601. * @adjgmlvl by [MouseJstr]
  7602. *
  7603. * Create a temp GM
  7604. *
  7605. * Used during beta testing to allow players to use GM commands
  7606. * for short periods of time
  7607. *------------------------------------------
  7608. */
  7609. int
  7610. atcommand_adjgmlvl(
  7611. const int fd, struct map_session_data* sd,
  7612. const char* command, const char* message)
  7613. {
  7614. int newlev;
  7615. char user[NAME_LENGTH];
  7616. struct map_session_data *pl_sd;
  7617. nullpo_retr(-1, sd);
  7618. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7619. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7620. return -1;
  7621. }
  7622. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7623. return -1;
  7624. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7625. return 0;
  7626. }
  7627. /*==========================================
  7628. * @trade by [MouseJstr]
  7629. *
  7630. * Open a trade window with a remote player
  7631. *
  7632. * If I have to jump to a remote player one more time, I am
  7633. * gonna scream!
  7634. *------------------------------------------
  7635. */
  7636. int
  7637. atcommand_trade(
  7638. const int fd, struct map_session_data* sd,
  7639. const char* command, const char* message)
  7640. {
  7641. struct map_session_data *pl_sd = NULL;
  7642. nullpo_retr(-1, sd);
  7643. if (!message || !*message)
  7644. return -1;
  7645. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7646. trade_traderequest(sd, pl_sd);
  7647. return 0;
  7648. }
  7649. return -1;
  7650. }
  7651. /*==========================================
  7652. * @setbattleflag by [MouseJstr]
  7653. *
  7654. * set a battle_config flag without having to reboot
  7655. */
  7656. int
  7657. atcommand_setbattleflag(
  7658. const int fd, struct map_session_data* sd,
  7659. const char* command, const char* message)
  7660. {
  7661. char flag[128], value[128];
  7662. nullpo_retr(-1, sd);
  7663. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7664. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7665. return -1;
  7666. }
  7667. if (battle_set_value(flag, value) == 0)
  7668. clif_displaymessage(fd, "unknown battle_config flag");
  7669. else
  7670. clif_displaymessage(fd, "battle_config set as requested");
  7671. return 0;
  7672. }
  7673. /*===========================
  7674. * @unmute [Valaris]
  7675. *===========================
  7676. */
  7677. int atcommand_unmute(
  7678. const int fd, struct map_session_data* sd,
  7679. const char* command, const char* message)
  7680. {
  7681. struct map_session_data *pl_sd = NULL;
  7682. nullpo_retr(-1, sd);
  7683. if (!message || !*message)
  7684. return -1;
  7685. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7686. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7687. pl_sd->status.manner = 0;
  7688. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7689. clif_displaymessage(sd->fd,"Player unmuted");
  7690. }
  7691. else
  7692. clif_displaymessage(sd->fd,"Player is not muted");
  7693. }
  7694. return 0;
  7695. }
  7696. /*==========================================
  7697. * @uptime by MC Cameri
  7698. *------------------------------------------
  7699. */
  7700. int
  7701. atcommand_uptime(
  7702. const int fd, struct map_session_data* sd,
  7703. const char* command, const char* message)
  7704. {
  7705. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7706. minute = 60, days = 0, hours = 0, minutes = 0;
  7707. nullpo_retr(-1, sd);
  7708. seconds = get_uptime();
  7709. days = seconds/day;
  7710. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7711. hours = seconds/hour;
  7712. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7713. minutes = seconds/minute;
  7714. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7715. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  7716. clif_displaymessage(fd, atcmd_output);
  7717. return 0;
  7718. }
  7719. /*==========================================
  7720. * @changesex <sex>
  7721. * => Changes one's sex. Argument sex can be
  7722. * 0 or 1, m or f, male or female.
  7723. *------------------------------------------
  7724. */
  7725. int
  7726. atcommand_changesex(
  7727. const int fd, struct map_session_data* sd,
  7728. const char* command, const char* message)
  7729. {
  7730. nullpo_retr(-1, sd);
  7731. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7732. return 0;
  7733. }
  7734. /*================================================
  7735. * @mute - Mutes a player for a set amount of time
  7736. *------------------------------------------------
  7737. */
  7738. int atcommand_mute(
  7739. const int fd, struct map_session_data* sd,
  7740. const char* command, const char* message)
  7741. {
  7742. struct map_session_data *pl_sd = NULL;
  7743. int manner;
  7744. nullpo_retr(-1, sd);
  7745. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7746. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7747. return -1;
  7748. }
  7749. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7750. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7751. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7752. return -1;
  7753. }
  7754. clif_GM_silence(sd, pl_sd, 0);
  7755. pl_sd->status.manner -= manner;
  7756. if(pl_sd->status.manner < 0)
  7757. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7758. }
  7759. else {
  7760. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7761. return -1;
  7762. }
  7763. return 0;
  7764. }
  7765. /*==========================================
  7766. * @refresh (like @jumpto <<yourself>>)
  7767. *------------------------------------------
  7768. */
  7769. int atcommand_refresh(
  7770. const int fd, struct map_session_data* sd,
  7771. const char* command, const char* message)
  7772. {
  7773. nullpo_retr(-1, sd);
  7774. clif_refresh(sd);
  7775. return 0;
  7776. }
  7777. /*==========================================
  7778. * @petid <part of pet name>
  7779. * => Displays a list of matching pets.
  7780. *------------------------------------------
  7781. */
  7782. int
  7783. atcommand_petid(const int fd, struct map_session_data* sd,
  7784. const char* command, const char* message)
  7785. {
  7786. char searchtext[100];
  7787. char temp0[100];
  7788. char temp1[100];
  7789. int cnt = 0, i = 0;
  7790. nullpo_retr(-1, sd);
  7791. if (!message || !*message)
  7792. return -1;
  7793. if (sscanf(message, "%99s", searchtext) < 1)
  7794. return -1;
  7795. estr_lower(searchtext);
  7796. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7797. clif_displaymessage(fd,temp0);
  7798. while (i < MAX_PET_DB) {
  7799. strcpy(temp1,pet_db[i].name);
  7800. strcpy(temp1, estr_lower(temp1));
  7801. strcpy(temp0,pet_db[i].jname);
  7802. strcpy(temp0, estr_lower(temp1));
  7803. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7804. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7805. pet_db[i].jname);
  7806. if (cnt >= 100) { // Only if there are custom pets
  7807. clif_displaymessage(fd, "Be more specific, can't send more than"
  7808. " 100 results.");
  7809. } else {
  7810. clif_displaymessage(fd, temp0);
  7811. }
  7812. cnt++;
  7813. }
  7814. i++;
  7815. }
  7816. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7817. clif_displaymessage(fd, temp0);
  7818. return 0;
  7819. }
  7820. /*==========================================
  7821. * @identify
  7822. * => GM's magnifier.
  7823. *------------------------------------------
  7824. */
  7825. int
  7826. atcommand_identify(
  7827. const int fd, struct map_session_data* sd,
  7828. const char* command, const char* message)
  7829. {
  7830. int i,num;
  7831. nullpo_retr(-1, sd);
  7832. for(i=num=0;i<MAX_INVENTORY;i++){
  7833. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7834. num++;
  7835. }
  7836. }
  7837. if (num > 0) {
  7838. clif_item_identify_list(sd);
  7839. } else {
  7840. clif_displaymessage(fd,"There are no items to appraise.");
  7841. }
  7842. return 0;
  7843. }
  7844. /*==========================================
  7845. * @gmotd (Global MOTD)
  7846. * by davidsiaw :P
  7847. *------------------------------------------
  7848. */
  7849. int
  7850. atcommand_gmotd(
  7851. const int fd, struct map_session_data* sd,
  7852. const char* command, const char* message)
  7853. {
  7854. char buf[256];
  7855. FILE *fp;
  7856. nullpo_retr(-1, sd);
  7857. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7858. while (fgets(buf, 250, fp) != NULL){
  7859. int i;
  7860. for( i=0; buf[i]; i++){
  7861. if( buf[i]=='\r' || buf[i]=='\n'){
  7862. buf[i]=0;
  7863. break;
  7864. }
  7865. }
  7866. intif_GMmessage(buf,strlen(buf)+1,8);
  7867. }
  7868. fclose(fp);
  7869. }
  7870. return 0;
  7871. }
  7872. int atcommand_misceffect(
  7873. const int fd, struct map_session_data* sd,
  7874. const char* command, const char* message)
  7875. {
  7876. int effect = 0;
  7877. nullpo_retr(-1, sd);
  7878. if (!message || !*message)
  7879. return -1;
  7880. if (sscanf(message, "%d", &effect) < 1)
  7881. return -1;
  7882. clif_misceffect(&sd->bl,effect);
  7883. return 0;
  7884. }
  7885. /*==========================================
  7886. * Jump to a player by PID number
  7887. * Original by Dino9021
  7888. * Added in by nsstrunks
  7889. *------------------------------------------
  7890. */
  7891. int atcommand_jumptoid(
  7892. const int fd, struct map_session_data* sd,
  7893. const char* command, const char* message)
  7894. {
  7895. int cid=0;
  7896. struct map_session_data *pl_sd;
  7897. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7898. if (!message || (cid = atoi(message)) == 0) {
  7899. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7900. return -1;
  7901. }
  7902. pl_sd = map_charid2sd(cid);
  7903. if (!pl_sd) {
  7904. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7905. return -1;
  7906. }
  7907. if (map[pl_sd->bl.m].flag.nowarpto &&
  7908. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7909. {
  7910. clif_displaymessage(fd, msg_txt(247));
  7911. return -1;
  7912. }
  7913. if (map[sd->bl.m].flag.nowarp &&
  7914. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7915. {
  7916. clif_displaymessage(fd, msg_txt(248));
  7917. return -1;
  7918. }
  7919. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7920. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7921. clif_displaymessage(fd, atcmd_output);
  7922. return 0;
  7923. }
  7924. /*==========================================
  7925. * Jump to a player by PID number
  7926. * Original by Dino9021
  7927. * Added in by nsstrunks
  7928. *------------------------------------------
  7929. */
  7930. int atcommand_jumptoid2(
  7931. const int fd, struct map_session_data* sd,
  7932. const char* command, const char* message)
  7933. {
  7934. int aid=0;
  7935. struct map_session_data *pl_sd;
  7936. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7937. if (!message || (aid = atoi(message)) == 0) {
  7938. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7939. return -1;
  7940. }
  7941. pl_sd = map_id2sd(aid);
  7942. if (!pl_sd) {
  7943. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7944. return -1;
  7945. }
  7946. if (map[pl_sd->bl.m].flag.nowarpto &&
  7947. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7948. {
  7949. clif_displaymessage(fd, msg_txt(247));
  7950. return -1;
  7951. }
  7952. if (map[sd->bl.m].flag.nowarp &&
  7953. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7954. {
  7955. clif_displaymessage(fd, msg_txt(248));
  7956. return -1;
  7957. }
  7958. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7959. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7960. clif_displaymessage(fd, atcmd_output);
  7961. return 0;
  7962. }
  7963. /*==========================================
  7964. * Recall a player by PID number
  7965. * Original by Dino9021
  7966. * Added in by nsstrunks
  7967. *------------------------------------------
  7968. */
  7969. int atcommand_recallid(
  7970. const int fd, struct map_session_data* sd,
  7971. const char* command, const char* message)
  7972. {
  7973. int cid=0;
  7974. struct map_session_data *pl_sd;
  7975. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7976. if (!message || (cid = atoi(message)) == 0) {
  7977. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7978. return -1;
  7979. }
  7980. pl_sd = map_charid2sd(cid);
  7981. if (!pl_sd) {
  7982. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7983. return -1;
  7984. }
  7985. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can recall only lower or same level
  7986. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7987. return -1;
  7988. }
  7989. if (map[pl_sd->bl.m].flag.nowarpto &&
  7990. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7991. {
  7992. clif_displaymessage(fd, msg_txt(247));
  7993. return -1;
  7994. }
  7995. if (map[sd->bl.m].flag.nowarp &&
  7996. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7997. {
  7998. clif_displaymessage(fd, msg_txt(248));
  7999. return -1;
  8000. }
  8001. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  8002. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  8003. clif_displaymessage(fd, atcmd_output);
  8004. return 0;
  8005. }
  8006. /*==========================================
  8007. * Recall a player by PID number
  8008. * Original by Dino9021
  8009. * Added in by nsstrunks
  8010. *------------------------------------------
  8011. */
  8012. int atcommand_recallid2(
  8013. const int fd, struct map_session_data* sd,
  8014. const char* command, const char* message)
  8015. {
  8016. int aid=0;
  8017. struct map_session_data *pl_sd;
  8018. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8019. if (!message || (aid = atoi(message)) == 0) {
  8020. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  8021. return -1;
  8022. }
  8023. pl_sd = map_id2sd(aid);
  8024. if (!pl_sd) {
  8025. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  8026. return -1;
  8027. }
  8028. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8029. { // you can recall only lower or same level
  8030. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8031. return -1;
  8032. }
  8033. if (map[pl_sd->bl.m].flag.nowarpto &&
  8034. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  8035. {
  8036. clif_displaymessage(fd, msg_txt(247));
  8037. return -1;
  8038. }
  8039. if (map[sd->bl.m].flag.nowarp &&
  8040. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  8041. {
  8042. clif_displaymessage(fd, msg_txt(248));
  8043. return -1;
  8044. }
  8045. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  8046. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  8047. clif_displaymessage(fd, atcmd_output);
  8048. return 0;
  8049. }
  8050. /*==========================================
  8051. * Kick a player by PID number
  8052. * Original by Dino9021
  8053. * Added in by nsstrunks
  8054. *------------------------------------------
  8055. */
  8056. int atcommand_kickid(
  8057. const int fd, struct map_session_data* sd,
  8058. const char* command, const char* message)
  8059. {
  8060. struct map_session_data *pl_sd;
  8061. int cid=0;
  8062. if (!message || (cid = atoi(message)) == 0) {
  8063. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  8064. return -1;
  8065. }
  8066. pl_sd = map_charid2sd(cid);
  8067. if (!pl_sd) {
  8068. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8069. return -1;
  8070. }
  8071. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8072. { // you can kick only lower or same gm level
  8073. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8074. return -1;
  8075. }
  8076. clif_GM_kick(sd, pl_sd, 1);
  8077. return 0;
  8078. }
  8079. /*==========================================
  8080. * Kick a player by PID number
  8081. * Original by Dino9021
  8082. * Added in by nsstrunks
  8083. *------------------------------------------
  8084. */
  8085. int atcommand_kickid2(
  8086. const int fd, struct map_session_data* sd,
  8087. const char* command, const char* message)
  8088. {
  8089. struct map_session_data *pl_sd;
  8090. int aid=0;
  8091. if (!message || (aid = atoi(message)) == 0) {
  8092. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  8093. return -1;
  8094. }
  8095. pl_sd = map_id2sd(aid);
  8096. if (!pl_sd) {
  8097. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8098. return -1;
  8099. }
  8100. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8101. { // you can kick only lower or same gm level
  8102. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8103. return -1;
  8104. }
  8105. clif_GM_kick(sd, pl_sd, 1);
  8106. return 0;
  8107. }
  8108. /*==========================================
  8109. * Revive a player by PID number
  8110. * Original by Dino9021
  8111. * Added in by nsstrunks
  8112. *------------------------------------------
  8113. */
  8114. int atcommand_reviveid(
  8115. const int fd, struct map_session_data* sd,
  8116. const char* command, const char* message)
  8117. {
  8118. int cid=0;
  8119. struct map_session_data *pl_sd;
  8120. if (!message || (cid = atoi(message)) == 0) {
  8121. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  8122. return -1;
  8123. }
  8124. pl_sd = map_charid2sd(cid);
  8125. if (!pl_sd) {
  8126. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8127. return -1;
  8128. }
  8129. if(!status_revive(&pl_sd->bl, 100, 100))
  8130. return -1;
  8131. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  8132. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  8133. return 0;
  8134. }
  8135. /*==========================================
  8136. * Revive a player by PID number
  8137. * Original by Dino9021
  8138. * Added in by nsstrunks
  8139. *------------------------------------------
  8140. */
  8141. int atcommand_reviveid2(
  8142. const int fd, struct map_session_data* sd,
  8143. const char* command, const char* message)
  8144. {
  8145. int aid=0;
  8146. struct map_session_data *pl_sd;
  8147. if (!message || (aid = atoi(message)) == 0) {
  8148. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  8149. return -1;
  8150. }
  8151. pl_sd = map_id2sd(aid);
  8152. if(!pl_sd) {
  8153. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8154. return -1;
  8155. }
  8156. if(!status_revive(&pl_sd->bl, 100, 100))
  8157. return -1;
  8158. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  8159. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  8160. return 0;
  8161. }
  8162. /*==========================================
  8163. * Kill a player by PID number
  8164. * Original by Dino9021
  8165. * Added in by nsstrunks
  8166. *------------------------------------------
  8167. */
  8168. int atcommand_killid(
  8169. const int fd, struct map_session_data* sd,
  8170. const char* command, const char* message)
  8171. {
  8172. int cid=0;
  8173. struct map_session_data *pl_sd;
  8174. if (!message || (cid = atoi(message)) == 0) {
  8175. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  8176. return -1;
  8177. }
  8178. pl_sd = map_charid2sd(cid);
  8179. if (!pl_sd) {
  8180. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8181. return -1;
  8182. }
  8183. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8184. { // you can kill only lower or same level
  8185. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8186. return -1;
  8187. }
  8188. status_kill(&pl_sd->bl);
  8189. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  8190. return 0;
  8191. }
  8192. /*==========================================
  8193. * Kill a player by PID number
  8194. * Original by Dino9021
  8195. * Added in by nsstrunks
  8196. *------------------------------------------
  8197. */
  8198. int atcommand_killid2(
  8199. const int fd, struct map_session_data* sd,
  8200. const char* command, const char* message)
  8201. {
  8202. int aid=0;
  8203. struct map_session_data *pl_sd;
  8204. if (!message || (aid = atoi(message)) == 0) {
  8205. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  8206. return -1;
  8207. }
  8208. pl_sd = map_id2sd(aid);
  8209. if (!pl_sd) {
  8210. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8211. return -1;
  8212. }
  8213. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8214. { // you can kill only lower or same level
  8215. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8216. return -1;
  8217. }
  8218. status_kill(&pl_sd->bl);
  8219. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  8220. return 0;
  8221. }
  8222. /*==========================================
  8223. * Make a player killable, by PID
  8224. * Original by Dino9021
  8225. * Added in by nsstrunks
  8226. *------------------------------------------
  8227. */
  8228. int
  8229. atcommand_charkillableid(
  8230. const int fd, struct map_session_data* sd,
  8231. const char* command, const char* message)
  8232. {
  8233. struct map_session_data *pl_sd = NULL;
  8234. int cid=0;
  8235. if (!message || (cid = atoi(message)) == 0) {
  8236. clif_displaymessage(fd, "Please, enter a player CID.");
  8237. return -1;
  8238. }
  8239. pl_sd = map_charid2sd(cid);
  8240. if (!pl_sd) {
  8241. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8242. return -1;
  8243. }
  8244. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8245. {
  8246. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8247. return -1;
  8248. }
  8249. pl_sd->state.killable = !pl_sd->state.killable;
  8250. if(pl_sd->state.killable)
  8251. clif_displaymessage(fd, msg_txt(289));
  8252. else
  8253. clif_displaymessage(fd, msg_txt(290));
  8254. return 0;
  8255. }
  8256. /*==========================================
  8257. * Make a player killable, by PID
  8258. * Original by Dino9021
  8259. * Added in by nsstrunks
  8260. *------------------------------------------
  8261. */
  8262. int
  8263. atcommand_charkillableid2(
  8264. const int fd, struct map_session_data* sd,
  8265. const char* command, const char* message)
  8266. {
  8267. struct map_session_data *pl_sd = NULL;
  8268. int aid=0;
  8269. if (!message || (aid = atoi(message)) == 0) {
  8270. clif_displaymessage(fd, "Please, enter a player AID.");
  8271. return -1;
  8272. }
  8273. pl_sd = map_id2sd(aid);
  8274. if (!pl_sd) {
  8275. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8276. return -1;
  8277. }
  8278. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8279. {
  8280. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8281. return -1;
  8282. }
  8283. pl_sd->state.killable = !pl_sd->state.killable;
  8284. if(pl_sd->state.killable)
  8285. clif_displaymessage(fd, msg_txt(289));
  8286. else
  8287. clif_displaymessage(fd, msg_txt(290));
  8288. return 0;
  8289. }
  8290. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8291. /*==========================================
  8292. * Mail System commands by [Valaris]
  8293. *------------------------------------------
  8294. */
  8295. int atcommand_listmail(
  8296. const int fd, struct map_session_data* sd,
  8297. const char* command, const char* message)
  8298. {
  8299. if(!mail_server_enable)
  8300. return 0;
  8301. nullpo_retr(-1, sd);
  8302. if(strlen(command)==12)
  8303. mail_check(sd,3);
  8304. else if(strlen(command)==9)
  8305. mail_check(sd,2);
  8306. else
  8307. mail_check(sd,1);
  8308. return 0;
  8309. }
  8310. int atcommand_readmail(
  8311. const int fd, struct map_session_data* sd,
  8312. const char* command, const char* message)
  8313. {
  8314. int index;
  8315. if(!mail_server_enable)
  8316. return 0;
  8317. nullpo_retr(-1, sd);
  8318. if (!message || !*message) {
  8319. clif_displaymessage(sd->fd,"You must specify a message number.");
  8320. return 0;
  8321. }
  8322. index = atoi(message);
  8323. if (index < 1) {
  8324. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8325. return 0;
  8326. }
  8327. if(strlen(command)==11)
  8328. mail_delete(sd,index);
  8329. else
  8330. mail_read(sd,index);
  8331. return 0;
  8332. }
  8333. int atcommand_sendmail(
  8334. const int fd, struct map_session_data* sd,
  8335. const char* command, const char* message)
  8336. {
  8337. char name[NAME_LENGTH],text[80];
  8338. if(!mail_server_enable)
  8339. return 0;
  8340. nullpo_retr(-1, sd);
  8341. if (!message || !*message) {
  8342. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8343. return 0;
  8344. }
  8345. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8346. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8347. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8348. return 0;
  8349. }
  8350. if(strlen(command)==17)
  8351. mail_send(sd,name,text,1);
  8352. else
  8353. mail_send(sd,name,text,0);
  8354. return 0;
  8355. }
  8356. /*==========================================
  8357. * Refresh online command for SQL [Valaris]
  8358. * Will refresh and check online column of
  8359. * players and set correctly.
  8360. *------------------------------------------
  8361. */
  8362. int atcommand_refreshonline(
  8363. const int fd, struct map_session_data* sd,
  8364. const char* command, const char* message)
  8365. {
  8366. send_users_tochar(-1, gettick(), 0, 0);
  8367. return 0;
  8368. }
  8369. #endif /* end sql only */
  8370. /*==========================================
  8371. * Show Monster DB Info v 1.0
  8372. * originally by [Lupus] eAthena
  8373. *------------------------------------------
  8374. */
  8375. int atcommand_mobinfo(
  8376. const int fd, struct map_session_data* sd,
  8377. const char* command, const char* message)
  8378. {
  8379. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8380. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8381. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8382. char atcmd_output2[200];
  8383. struct item_data *item_data;
  8384. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8385. int count;
  8386. int i, j, k;
  8387. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8388. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8389. if (!message || !*message) {
  8390. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8391. return -1;
  8392. }
  8393. // If monster identifier/name argument is a name
  8394. if ((i = mobdb_checkid(atoi(message))))
  8395. {
  8396. mob_array[0] = mob_db(i);
  8397. count = 1;
  8398. } else
  8399. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8400. if (!count) {
  8401. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  8402. return -1;
  8403. }
  8404. if (count > MAX_SEARCH) {
  8405. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8406. clif_displaymessage(fd, atcmd_output);
  8407. count = MAX_SEARCH;
  8408. }
  8409. for (k = 0; k < count; k++) {
  8410. mob = mob_array[k];
  8411. // stats
  8412. if (mob->mexp)
  8413. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  8414. else
  8415. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  8416. clif_displaymessage(fd, atcmd_output);
  8417. 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);
  8418. clif_displaymessage(fd, atcmd_output);
  8419. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  8420. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  8421. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  8422. clif_displaymessage(fd, atcmd_output);
  8423. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  8424. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  8425. mob->range2 , mob->range3, msize[mob->status.size],
  8426. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  8427. clif_displaymessage(fd, atcmd_output);
  8428. // drops
  8429. clif_displaymessage(fd, " Drops:");
  8430. strcpy(atcmd_output, " ");
  8431. j = 0;
  8432. for (i = 0; i < MAX_MOB_DROP; i++) {
  8433. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8434. continue;
  8435. if (item_data->slot)
  8436. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  8437. else
  8438. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  8439. strcat(atcmd_output, atcmd_output2);
  8440. if (++j % 3 == 0) {
  8441. clif_displaymessage(fd, atcmd_output);
  8442. strcpy(atcmd_output, " ");
  8443. }
  8444. }
  8445. if (j == 0)
  8446. clif_displaymessage(fd, "This monster has no drops.");
  8447. else if (j % 3 != 0)
  8448. clif_displaymessage(fd, atcmd_output);
  8449. // mvp
  8450. if (mob->mexp) {
  8451. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8452. clif_displaymessage(fd, atcmd_output);
  8453. strcpy(atcmd_output, " MVP Items:");
  8454. j = 0;
  8455. for (i = 0; i < 3; i++) {
  8456. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8457. continue;
  8458. if (mob->mvpitem[i].p > 0) {
  8459. j++;
  8460. if (j == 1)
  8461. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8462. else
  8463. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8464. strcat(atcmd_output, atcmd_output2);
  8465. }
  8466. }
  8467. if (j == 0)
  8468. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8469. else
  8470. clif_displaymessage(fd, atcmd_output);
  8471. }
  8472. }
  8473. return 0;
  8474. }
  8475. /*=========================================
  8476. * @showmobs by KarLaeda
  8477. * => For 5 sec displays the mobs on minimap
  8478. *------------------------------------------
  8479. */
  8480. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  8481. {
  8482. struct map_session_data *sd;
  8483. if (!session[id] || (sd = session[id]->session_data) == NULL)
  8484. return 0;
  8485. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  8486. return 1;
  8487. }
  8488. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  8489. {
  8490. int mob_id,fd;
  8491. struct map_session_data* sd;
  8492. static int number=0;
  8493. struct mob_data *md;
  8494. if(!ap){
  8495. number=0;
  8496. return 0;
  8497. }
  8498. mob_id = va_arg(ap,int);
  8499. fd = va_arg(ap,int);
  8500. sd = va_arg(ap,struct map_session_data*);
  8501. md = (struct mob_data *)bl;
  8502. if(md->special_state.ai || md->master_id)
  8503. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  8504. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  8505. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  8506. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  8507. }
  8508. return 0;
  8509. }
  8510. int atcommand_showmobs(
  8511. const int fd, struct map_session_data* sd,
  8512. const char* command, const char* message)
  8513. {
  8514. char mob_name[100];
  8515. int mob_id,map_id = 0;
  8516. nullpo_retr(-1, sd);
  8517. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  8518. return -1;
  8519. if ((mob_id = atoi(mob_name)) == 0)
  8520. mob_id = mobdb_searchname(mob_name);
  8521. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  8522. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  8523. clif_displaymessage(fd, atcmd_output);
  8524. return 0;
  8525. }
  8526. // Uncomment the following line to show mini-bosses & MVP.
  8527. //#define SHOW_MVP
  8528. #ifndef SHOW_MVP
  8529. if(mob_db(mob_id)->status.mode&MD_BOSS){
  8530. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  8531. clif_displaymessage(fd, atcmd_output);
  8532. return 0;
  8533. }
  8534. #endif
  8535. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  8536. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  8537. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  8538. map_id = sd->bl.m;
  8539. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  8540. mob_name, mapindex_id2name(sd->mapindex));
  8541. clif_displaymessage(fd, atcmd_output);
  8542. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  8543. atshowmobs_sub(&sd->bl,0);
  8544. return 0;
  8545. }
  8546. /*==========================================
  8547. * homunculus level up [orn]
  8548. *------------------------------------------
  8549. */
  8550. int atcommand_homlevel(
  8551. const int fd, struct map_session_data* sd,
  8552. const char* command, const char* message)
  8553. {
  8554. TBL_HOM * hd;
  8555. int level = 0, i = 0;
  8556. nullpo_retr(-1, sd);
  8557. if (!message || !*message)
  8558. return -1;
  8559. if ( !merc_is_hom_active(sd->hd) )
  8560. return 1 ;
  8561. level = atoi(message);
  8562. hd = sd->hd;
  8563. for (i = 1; i <= level && hd->exp_next; i++){
  8564. hd->homunculus.exp += hd->exp_next;
  8565. merc_hom_levelup(hd);
  8566. }
  8567. status_calc_homunculus(hd,0);
  8568. status_percent_heal(&hd->bl, 100, 100);
  8569. clif_misceffect2(&hd->bl,568);
  8570. return 0;
  8571. }
  8572. /*==========================================
  8573. * homunculus evolution H [orn]
  8574. *------------------------------------------
  8575. */
  8576. int atcommand_homevolution(
  8577. const int fd, struct map_session_data* sd,
  8578. const char* command, const char* message)
  8579. {
  8580. nullpo_retr(-1, sd);
  8581. if (sd->hd && sd->hd->homunculusDB->evo_class)
  8582. {
  8583. merc_hom_evolution(sd->hd) ;
  8584. }
  8585. return 0;
  8586. }
  8587. /*==========================================
  8588. * call choosen homunculus [orn]
  8589. *------------------------------------------
  8590. */
  8591. int
  8592. atcommand_makehomun(
  8593. const int fd, struct map_session_data* sd,
  8594. const char* command, const char* message)
  8595. {
  8596. int homunid;
  8597. nullpo_retr(-1, sd);
  8598. if(sscanf(message, "%d", &homunid)<1)
  8599. return -1;
  8600. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  8601. return -1;
  8602. if(sd->status.hom_id == 0)
  8603. {
  8604. merc_create_homunculus_request(sd,homunid);
  8605. }
  8606. else
  8607. {
  8608. clif_displaymessage(fd,msg_txt(450));
  8609. }
  8610. return 0;
  8611. }
  8612. /*==========================================
  8613. * modify homunculus intimacy [orn]
  8614. *------------------------------------------
  8615. */
  8616. int atcommand_homfriendly(
  8617. const int fd, struct map_session_data* sd,
  8618. const char* command, const char* message)
  8619. {
  8620. int friendly = 0;
  8621. nullpo_retr(-1, sd);
  8622. if (!message || !*message)
  8623. return -1;
  8624. friendly = atoi(message);
  8625. if (merc_is_hom_active(sd->hd)) {
  8626. if (friendly > 0 && friendly <= 1000) {
  8627. sd->hd->homunculus.intimacy = friendly * 100 ;
  8628. clif_send_homdata(sd,SP_INTIMATE,friendly);
  8629. } else {
  8630. return -1;
  8631. }
  8632. }
  8633. return 0;
  8634. }
  8635. /*==========================================
  8636. * modify homunculus hunger [orn]
  8637. *------------------------------------------
  8638. */
  8639. int atcommand_homhungry(
  8640. const int fd, struct map_session_data* sd,
  8641. const char* command, const char* message)
  8642. {
  8643. int hungry = 0;
  8644. nullpo_retr(-1, sd);
  8645. if (!message || !*message)
  8646. return -1;
  8647. hungry = atoi(message);
  8648. if (sd->status.hom_id > 0 && sd->hd) {
  8649. struct homun_data *hd = sd->hd;
  8650. if (hungry >= 0 && hungry <= 100) {
  8651. hd->homunculus.hunger = hungry;
  8652. clif_send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger);
  8653. } else {
  8654. return -1;
  8655. }
  8656. }
  8657. return 0;
  8658. }
  8659. /*==========================================
  8660. * modify homunculus hunger [orn]
  8661. *------------------------------------------
  8662. */
  8663. int atcommand_homtalk(
  8664. const int fd, struct map_session_data* sd,
  8665. const char* command, const char* message)
  8666. {
  8667. char mes[100],temp[100];
  8668. nullpo_retr(-1, sd);
  8669. if(!merc_is_hom_active(sd->hd))
  8670. return -1;
  8671. if (sscanf(message, "%99[^\n]", mes) < 1)
  8672. return -1;
  8673. snprintf(temp, sizeof temp ,"%s : %s",sd->hd->homunculus.name,mes);
  8674. clif_message(&sd->hd->bl, temp);
  8675. return 0;
  8676. }
  8677. /*==========================================
  8678. * Show homunculus stats
  8679. *------------------------------------------
  8680. */
  8681. int atcommand_hominfo(
  8682. const int fd, struct map_session_data* sd,
  8683. const char* command, const char* message)
  8684. {
  8685. struct homun_data *hd;
  8686. struct status_data *status;
  8687. nullpo_retr(-1, sd);
  8688. if(!merc_is_hom_active(sd->hd))
  8689. return -1;
  8690. hd = sd->hd;
  8691. status = status_get_status_data(&hd->bl);
  8692. clif_displaymessage(fd, "Homunculus stats :");
  8693. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  8694. status->hp, status->max_hp, status->sp, status->max_sp);
  8695. clif_displaymessage(fd, atcmd_output);
  8696. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  8697. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  8698. clif_displaymessage(fd, atcmd_output);
  8699. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  8700. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  8701. clif_displaymessage(fd, atcmd_output);
  8702. snprintf(atcmd_output, sizeof(atcmd_output) ,
  8703. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  8704. status->str, status->agi, status->vit,
  8705. status->int_, status->dex, status->luk);
  8706. clif_displaymessage(fd, atcmd_output);
  8707. return 0;
  8708. }
  8709. int atcommand_homstats(
  8710. const int fd, struct map_session_data* sd,
  8711. const char* command, const char* message)
  8712. {
  8713. struct homun_data *hd;
  8714. struct homunculus_db *db;
  8715. struct s_homunculus *hom;
  8716. int lv;
  8717. nullpo_retr(-1, sd);
  8718. if(!merc_is_hom_active(sd->hd))
  8719. return -1;
  8720. hd = sd->hd;
  8721. hom = &hd->homunculus;
  8722. db = hd->homunculusDB;
  8723. lv = hom->level;
  8724. snprintf(atcmd_output, sizeof(atcmd_output) ,
  8725. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  8726. clif_displaymessage(fd, atcmd_output);
  8727. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)",
  8728. hom->max_hp, lv*db->gminHP, lv*db->gmaxHP);
  8729. clif_displaymessage(fd, atcmd_output);
  8730. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)",
  8731. hom->max_sp, lv*db->gminSP, lv*db->gmaxSP);
  8732. clif_displaymessage(fd, atcmd_output);
  8733. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)",
  8734. hom->str/10, lv*db->gminSTR/10, lv*db->gmaxSTR/10);
  8735. clif_displaymessage(fd, atcmd_output);
  8736. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)",
  8737. hom->agi/10, lv*db->gminAGI/10, lv*db->gmaxAGI/10);
  8738. clif_displaymessage(fd, atcmd_output);
  8739. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)",
  8740. hom->vit/10, lv*db->gminVIT/10, lv*db->gmaxVIT/10);
  8741. clif_displaymessage(fd, atcmd_output);
  8742. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)",
  8743. hom->int_/10, lv*db->gminINT/10, lv*db->gmaxINT/10);
  8744. clif_displaymessage(fd, atcmd_output);
  8745. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)",
  8746. hom->dex/10, lv*db->gminDEX/10, lv*db->gmaxDEX/10);
  8747. clif_displaymessage(fd, atcmd_output);
  8748. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)",
  8749. hom->luk/10, lv*db->gminLUK/10, lv*db->gmaxLUK/10);
  8750. clif_displaymessage(fd, atcmd_output);
  8751. return 0;
  8752. }
  8753. /*==========================================
  8754. * Show Items DB Info v 1.0
  8755. * originally by [Lupus] eAthena
  8756. *------------------------------------------
  8757. */
  8758. int atcommand_iteminfo(
  8759. const int fd, struct map_session_data* sd,
  8760. const char* command, const char* message)
  8761. {
  8762. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8763. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8764. struct item_data *item_data, *item_array[MAX_SEARCH];
  8765. int i, count = 1;
  8766. if (!message || !*message) {
  8767. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8768. return -1;
  8769. }
  8770. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8771. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8772. if (!count) {
  8773. clif_displaymessage(fd, "Item not found.");
  8774. return -1;
  8775. }
  8776. if (count > MAX_SEARCH) {
  8777. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8778. clif_displaymessage(fd, atcmd_output);
  8779. count = MAX_SEARCH;
  8780. }
  8781. for (i = 0; i < count; i++) {
  8782. item_data = item_array[i];
  8783. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8784. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  8785. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8786. (item_data->script==NULL)? "None" : "With script"
  8787. );
  8788. clif_displaymessage(fd, atcmd_output);
  8789. 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. );
  8790. clif_displaymessage(fd, atcmd_output);
  8791. if (item_data->maxchance == 10000)
  8792. strcpy(atcmd_output, " - Available in the shops only");
  8793. else if (item_data->maxchance)
  8794. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8795. else
  8796. strcpy(atcmd_output, " - Monsters don't drop this item");
  8797. clif_displaymessage(fd, atcmd_output);
  8798. }
  8799. return 0;
  8800. }
  8801. /*==========================================
  8802. * Show who drops the item.
  8803. *------------------------------------------
  8804. */
  8805. int atcommand_whodrops(
  8806. const int fd, struct map_session_data* sd,
  8807. const char* command, const char* message)
  8808. {
  8809. struct item_data *item_data, *item_array[MAX_SEARCH];
  8810. int i,j, count = 1;
  8811. if (!message || !*message) {
  8812. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8813. return -1;
  8814. }
  8815. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8816. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8817. if (!count) {
  8818. clif_displaymessage(fd, "Item not found.");
  8819. return -1;
  8820. }
  8821. if (count > MAX_SEARCH) {
  8822. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8823. clif_displaymessage(fd, atcmd_output);
  8824. count = MAX_SEARCH;
  8825. }
  8826. for (i = 0; i < count; i++) {
  8827. item_data = item_array[i];
  8828. sprintf(atcmd_output, "Item: '%s'[%d]",
  8829. item_data->jname,item_data->slot);
  8830. clif_displaymessage(fd, atcmd_output);
  8831. if (item_data->mob[0].chance == 0) {
  8832. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8833. clif_displaymessage(fd, atcmd_output);
  8834. } else {
  8835. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8836. clif_displaymessage(fd, atcmd_output);
  8837. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8838. {
  8839. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8840. clif_displaymessage(fd, atcmd_output);
  8841. }
  8842. }
  8843. }
  8844. return 0;
  8845. }
  8846. /*==========================================
  8847. * @adopt by [Veider]
  8848. *
  8849. * adopt a novice
  8850. *------------------------------------------
  8851. */
  8852. int
  8853. atcommand_adopt(const int fd, struct map_session_data* sd,
  8854. const char* command, const char* message)
  8855. {
  8856. struct map_session_data *pl_sd1 = NULL;
  8857. struct map_session_data *pl_sd2 = NULL;
  8858. struct map_session_data *pl_sd3 = NULL;
  8859. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8860. nullpo_retr(-1, sd);
  8861. if (!message || !*message)
  8862. return -1;
  8863. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8864. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8865. return -1;
  8866. }
  8867. if (battle_config.etc_log)
  8868. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8869. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8870. sprintf(player2, "Cannot find player %s online", player1);
  8871. clif_displaymessage(fd, player2);
  8872. return -1;
  8873. }
  8874. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8875. sprintf(player1, "Cannot find player %s online", player2);
  8876. clif_displaymessage(fd, player1);
  8877. return -1;
  8878. }
  8879. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8880. sprintf(player1, "Cannot find player %s online", player3);
  8881. clif_displaymessage(fd, player1);
  8882. return -1;
  8883. }
  8884. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8885. clif_displaymessage(fd, "They are too young to be parents!");
  8886. return -1;
  8887. }
  8888. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8889. clif_displaymessage(fd, "They are family.. wish them luck");
  8890. return 0;
  8891. }
  8892. else
  8893. return -1;
  8894. }
  8895. int atcommand_version(
  8896. const int fd, struct map_session_data* sd,
  8897. const char* command, const char* message)
  8898. {
  8899. const char * revision;
  8900. if ((revision = get_svn_revision()) != 0) {
  8901. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8902. clif_displaymessage(fd,atcmd_output);
  8903. } else
  8904. clif_displaymessage(fd,"Cannot determine SVN revision");
  8905. return 0;
  8906. }
  8907. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8908. {
  8909. int time, id;
  8910. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8911. if (pl_sd == NULL)
  8912. return 0;
  8913. id = va_arg(ap, int);
  8914. time = va_arg(ap, int);
  8915. if (id != bl->id && !pc_isGM(pl_sd)) {
  8916. pl_sd->status.manner -= time;
  8917. if (pl_sd->status.manner < 0)
  8918. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8919. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8920. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8921. }
  8922. return 0;
  8923. }
  8924. /*==========================================
  8925. * @mutearea by MouseJstr
  8926. *------------------------------------------
  8927. */
  8928. int atcommand_mutearea(
  8929. const int fd, struct map_session_data* sd,
  8930. const char* command, const char* message)
  8931. {
  8932. int time;
  8933. nullpo_retr(0, sd);
  8934. time = atoi(message);
  8935. if (!time)
  8936. time = 15; // 15 minutes default
  8937. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8938. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8939. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8940. return 0;
  8941. }
  8942. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8943. {
  8944. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8945. if (bl == NULL)
  8946. return 0;
  8947. if (!pc_isGM(pl_sd))
  8948. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8949. return 0;
  8950. }
  8951. /*==========================================
  8952. * @shuffle by MouseJstr
  8953. *------------------------------------------
  8954. */
  8955. int atcommand_shuffle(
  8956. const int fd, struct map_session_data* sd,
  8957. const char* command, const char* message)
  8958. {
  8959. nullpo_retr(0, sd);
  8960. if (strcmp(message, "area")== 0) {
  8961. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8962. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8963. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8964. } else if (strcmp(message, "map")== 0) {
  8965. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8966. } else if (strcmp(message, "world") == 0) {
  8967. struct map_session_data **pl_allsd;
  8968. int i, users;
  8969. pl_allsd = map_getallusers(&users);
  8970. for (i = 0; i < users; i++)
  8971. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8972. } else
  8973. clif_displaymessage(fd, "options are area, map, or world");
  8974. return 0;
  8975. }
  8976. int atcommand_rates(
  8977. const int fd, struct map_session_data* sd,
  8978. const char* command, const char* message)
  8979. {
  8980. char buf[255];
  8981. nullpo_retr(0, sd);
  8982. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8983. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8984. clif_displaymessage(fd, buf);
  8985. return 0;
  8986. }
  8987. /*==========================================
  8988. * @me by lordalfa
  8989. * => Displays the OUTPUT string on top of
  8990. * the Visible players Heads.
  8991. *------------------------------------------
  8992. */
  8993. int atcommand_me(
  8994. const int fd, struct map_session_data* sd,
  8995. const char* command, const char* message)
  8996. {
  8997. char tempmes[200];
  8998. nullpo_retr(-1, sd);
  8999. memset(tempmes, '\0', sizeof(tempmes));
  9000. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9001. if (sd->sc.count && //no "chatting" while muted.
  9002. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  9003. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  9004. return -1;
  9005. if (!message || !*message) {
  9006. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  9007. return -1;
  9008. }
  9009. sscanf(message, "%199[^\n]", tempmes);
  9010. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  9011. clif_disp_overhead(sd, atcmd_output);
  9012. return 0;
  9013. }
  9014. /*==========================================
  9015. * @size
  9016. * => Resize your character sprite. [Valaris]
  9017. *------------------------------------------
  9018. */
  9019. int atcommand_size(
  9020. const int fd, struct map_session_data* sd,
  9021. const char* command, const char* message)
  9022. {
  9023. int size=0;
  9024. nullpo_retr(-1, sd);
  9025. if (!message || !*message)
  9026. return -1;
  9027. if (sscanf(message,"%d", &size) < 1)
  9028. return -1;
  9029. if(sd->state.size) {
  9030. sd->state.size=0;
  9031. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  9032. }
  9033. if(size==1) {
  9034. sd->state.size=1;
  9035. clif_specialeffect(&sd->bl,420,AREA);
  9036. } else if(size==2) {
  9037. sd->state.size=2;
  9038. clif_specialeffect(&sd->bl,422,AREA);
  9039. }
  9040. return 0;
  9041. }
  9042. /*==========================================
  9043. * @monsterignore
  9044. * => Makes monsters ignore you. [Valaris]
  9045. *------------------------------------------
  9046. */
  9047. int atcommand_monsterignore(
  9048. const int fd, struct map_session_data* sd,
  9049. const char* command, const char* message)
  9050. {
  9051. nullpo_retr(-1, sd);
  9052. if (!sd->state.monster_ignore) {
  9053. sd->state.monster_ignore = 1;
  9054. clif_displaymessage(sd->fd, "You are now inmune to attacks.");
  9055. } else {
  9056. sd->state.monster_ignore = 0;
  9057. clif_displaymessage(sd->fd, "Returned to normal state.");
  9058. }
  9059. return 0;
  9060. }
  9061. /*==========================================
  9062. * @fakename
  9063. * => Gives your character a fake name. [Valaris]
  9064. *------------------------------------------
  9065. */
  9066. int atcommand_fakename(
  9067. const int fd, struct map_session_data* sd,
  9068. const char* command, const char* message)
  9069. {
  9070. char name[NAME_LENGTH];
  9071. nullpo_retr(-1, sd);
  9072. if((!message || !*message) && strlen(sd->fakename) > 1) {
  9073. sd->fakename[0]='\0';
  9074. clif_charnameack(0, &sd->bl);
  9075. clif_displaymessage(sd->fd,"Returned to real name.");
  9076. return 0;
  9077. }
  9078. if (!message || !*message) {
  9079. clif_displaymessage(sd->fd,"You must enter a name.");
  9080. return 0;
  9081. }
  9082. if (sscanf(message, "%23[^\n]", name) < 1) {
  9083. return 0;
  9084. }
  9085. if(strlen(name) < 2) {
  9086. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  9087. return 0;
  9088. }
  9089. memcpy(sd->fakename,name,NAME_LENGTH-1);
  9090. clif_charnameack(0, &sd->bl);
  9091. clif_displaymessage(sd->fd,"Fake name enabled.");
  9092. return 0;
  9093. }
  9094. /*==========================================
  9095. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  9096. * => Shows information about the map flags [map name]
  9097. * Also set flags
  9098. *------------------------------------------
  9099. */
  9100. int atcommand_mapflag(
  9101. const int fd, struct map_session_data* sd,
  9102. const char* command, const char* message)
  9103. {
  9104. // WIP
  9105. return 0;
  9106. }
  9107. /*===================================
  9108. * Remove some messages
  9109. *-----------------------------------
  9110. */
  9111. int atcommand_showexp(
  9112. const int fd, struct map_session_data* sd,
  9113. const char* command, const char* message)
  9114. {
  9115. if (sd->state.showexp) {
  9116. sd->state.showexp = 0;
  9117. clif_displaymessage(fd, "Gained exp will not be shown.");
  9118. return 0;
  9119. }
  9120. sd->state.showexp = 1;
  9121. clif_displaymessage(fd, "Gained exp is now shown");
  9122. return 0;
  9123. }
  9124. int atcommand_showzeny(
  9125. const int fd, struct map_session_data* sd,
  9126. const char* command, const char* message)
  9127. {
  9128. if (sd->state.showzeny) {
  9129. sd->state.showzeny = 0;
  9130. clif_displaymessage(fd, "Gained zeny will not be shown.");
  9131. return 0;
  9132. }
  9133. sd->state.showzeny = 1;
  9134. clif_displaymessage(fd, "Gained zeny is now shown");
  9135. return 0;
  9136. }
  9137. int atcommand_showdelay(
  9138. const int fd, struct map_session_data* sd,
  9139. const char* command, const char* message)
  9140. {
  9141. if (sd->state.showdelay) {
  9142. sd->state.showdelay = 0;
  9143. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  9144. return 0;
  9145. }
  9146. sd->state.showdelay = 1;
  9147. clif_displaymessage(fd, "Skill delay failures are shown now.");
  9148. return 0;
  9149. }
  9150. /*==========================================
  9151. * Duel organizing functions [LuzZza]
  9152. *
  9153. * @duel [limit|nick] - create a duel
  9154. * @invite <nick> - invite player
  9155. * @accept - accept invitation
  9156. * @reject - reject invitation
  9157. * @leave - leave duel
  9158. *------------------------------------------
  9159. */
  9160. int atcommand_invite(
  9161. const int fd, struct map_session_data* sd,
  9162. const char* command, const char* message)
  9163. {
  9164. unsigned int did = sd->duel_group;
  9165. struct map_session_data *target_sd = map_nick2sd((char *)message);
  9166. if(did <= 0) {
  9167. // "Duel: @invite without @duel."
  9168. clif_displaymessage(fd, msg_txt(350));
  9169. return 0;
  9170. }
  9171. if(duel_list[did].max_players_limit > 0 &&
  9172. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  9173. // "Duel: Limit of players is reached."
  9174. clif_displaymessage(fd, msg_txt(351));
  9175. return 0;
  9176. }
  9177. if(target_sd == NULL) {
  9178. // "Duel: Player not found."
  9179. clif_displaymessage(fd, msg_txt(352));
  9180. return 0;
  9181. }
  9182. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9183. // "Duel: Player already in duel."
  9184. clif_displaymessage(fd, msg_txt(353));
  9185. return 0;
  9186. }
  9187. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  9188. {
  9189. sprintf(atcmd_output, msg_txt(364), message);
  9190. clif_displaymessage(fd, atcmd_output);
  9191. return 0;
  9192. }
  9193. duel_invite(did, sd, target_sd);
  9194. // "Duel: Invitation has been sent."
  9195. clif_displaymessage(fd, msg_txt(354));
  9196. return 0;
  9197. }
  9198. int atcommand_duel(
  9199. const int fd, struct map_session_data* sd,
  9200. const char* command, const char* message)
  9201. {
  9202. char output[256];
  9203. unsigned int maxpl=0, newduel;
  9204. struct map_session_data *target_sd;
  9205. /* // Commnted because it can be disabled in at-comms conf.
  9206. if(!battle_config.duel_enable) {
  9207. clif_displaymessage(fd, "Duel: duel is disable.");
  9208. return 0;
  9209. }
  9210. */
  9211. if(sd->duel_group > 0) {
  9212. duel_showinfo(sd->duel_group, sd);
  9213. return 0;
  9214. }
  9215. if(sd->duel_invite > 0) {
  9216. // "Duel: @duel without @reject."
  9217. clif_displaymessage(fd, msg_txt(355));
  9218. return 0;
  9219. }
  9220. if(!duel_checktime(sd)) {
  9221. // "Duel: You can take part in duel only one time per %d minutes."
  9222. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9223. clif_displaymessage(fd, output);
  9224. return 0;
  9225. }
  9226. if(strlen(message) > 0) {
  9227. if(sscanf(message, "%d", &maxpl) >= 1) {
  9228. if(maxpl < 2 || maxpl > 65535) {
  9229. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  9230. return 0;
  9231. }
  9232. duel_create(sd, maxpl);
  9233. } else {
  9234. target_sd = map_nick2sd((char *)message);
  9235. if(target_sd != NULL) {
  9236. if((newduel = duel_create(sd, 2)) != -1) {
  9237. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9238. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  9239. return 0;
  9240. }
  9241. duel_invite(newduel, sd, target_sd);
  9242. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  9243. }
  9244. } else {
  9245. // "Duel: Player not found."
  9246. clif_displaymessage(fd, msg_txt(352));
  9247. return 0;
  9248. }
  9249. }
  9250. } else
  9251. duel_create(sd, 0);
  9252. return 0;
  9253. }
  9254. int atcommand_leave(
  9255. const int fd, struct map_session_data* sd,
  9256. const char* command, const char* message)
  9257. {
  9258. if(sd->duel_group <= 0) {
  9259. // "Duel: @leave without @duel."
  9260. clif_displaymessage(fd, msg_txt(358));
  9261. return 0;
  9262. }
  9263. duel_leave(sd->duel_group, sd);
  9264. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  9265. return 0;
  9266. }
  9267. int atcommand_accept(
  9268. const int fd, struct map_session_data* sd,
  9269. const char* command, const char* message)
  9270. {
  9271. char output[256];
  9272. if(!duel_checktime(sd)) {
  9273. // "Duel: You can take part in duel only one time per %d minutes."
  9274. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9275. clif_displaymessage(fd, output);
  9276. return 0;
  9277. }
  9278. if(sd->duel_invite <= 0) {
  9279. // "Duel: @accept without invititation."
  9280. clif_displaymessage(fd, msg_txt(360));
  9281. return 0;
  9282. }
  9283. duel_accept(sd->duel_invite, sd);
  9284. // "Duel: Invitation has been accepted."
  9285. clif_displaymessage(fd, msg_txt(361));
  9286. return 0;
  9287. }
  9288. int atcommand_reject(
  9289. const int fd, struct map_session_data* sd,
  9290. const char* command, const char* message)
  9291. {
  9292. if(sd->duel_invite <= 0) {
  9293. // "Duel: @reject without invititation."
  9294. clif_displaymessage(fd, msg_txt(362));
  9295. return 0;
  9296. }
  9297. duel_reject(sd->duel_invite, sd);
  9298. // "Duel: Invitation has been rejected."
  9299. clif_displaymessage(fd, msg_txt(363));
  9300. return 0;
  9301. }
  9302. /*===================================
  9303. * Away message (@away, @aw) [LuzZza]
  9304. *-----------------------------------
  9305. */
  9306. int atcommand_away(
  9307. const int fd, struct map_session_data* sd,
  9308. const char* command, const char* message)
  9309. {
  9310. if(strlen(message) > 0) {
  9311. if(strlen(message) > 128)
  9312. return -1;
  9313. strcpy(sd->away_message, message);
  9314. //"Away automessage has been activated."
  9315. clif_displaymessage(fd, msg_txt(546));
  9316. } else {
  9317. if(strlen(sd->away_message) > 0) {
  9318. sd->away_message[0] = 0;
  9319. //"Away automessage has been disabled."
  9320. clif_displaymessage(fd, msg_txt(547));
  9321. return 0;
  9322. }
  9323. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  9324. clif_displaymessage(fd, msg_txt(548));
  9325. }
  9326. return 0;
  9327. }
  9328. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  9329. int atcommand_clone(
  9330. const int fd, struct map_session_data* sd,
  9331. const char* command, const char* message)
  9332. {
  9333. int x=0,y=0,flag=0,master=0,i=0;
  9334. struct map_session_data *pl_sd=NULL;
  9335. if (!message || !*message) {
  9336. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  9337. return 0;
  9338. }
  9339. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  9340. clif_displaymessage(fd, msg_txt(3));
  9341. return 0;
  9342. }
  9343. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  9344. clif_displaymessage(fd, msg_txt(126));
  9345. return 0;
  9346. }
  9347. if (strcmpi(command, "@clone") == 0)
  9348. flag = 1;
  9349. else if (strcmpi(command, "@slaveclone") == 0) {
  9350. flag = 2;
  9351. master = sd->bl.id;
  9352. if (battle_config.atc_slave_clone_limit
  9353. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  9354. clif_displaymessage(fd, msg_txt(127));
  9355. return 0;
  9356. }
  9357. }
  9358. do {
  9359. x = sd->bl.x + (rand() % 10 - 5);
  9360. y = sd->bl.y + (rand() % 10 - 5);
  9361. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  9362. if (i >= 10) {
  9363. x = sd->bl.x;
  9364. y = sd->bl.y;
  9365. }
  9366. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  9367. clif_displaymessage(fd, msg_txt(128+flag*2));
  9368. return 0;
  9369. }
  9370. clif_displaymessage(fd, msg_txt(129+flag*2));
  9371. return 0;
  9372. }
  9373. /*===================================
  9374. * Main chat [LuzZza]
  9375. * Usage: @main <on|off|message>
  9376. *-----------------------------------
  9377. */
  9378. int atcommand_main(
  9379. const int fd, struct map_session_data* sd,
  9380. const char* command, const char* message)
  9381. {
  9382. if(strlen(message) > 0) {
  9383. if(strcmpi(message, "on") == 0) {
  9384. if(!sd->state.mainchat) {
  9385. sd->state.mainchat = 1;
  9386. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  9387. } else {
  9388. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  9389. }
  9390. } else if(strcmpi(message, "off") == 0) {
  9391. if(sd->state.mainchat) {
  9392. sd->state.mainchat = 0;
  9393. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  9394. } else {
  9395. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  9396. }
  9397. } else {
  9398. if(!sd->state.mainchat) {
  9399. sd->state.mainchat = 1;
  9400. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  9401. }
  9402. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  9403. clif_displaymessage(fd, msg_txt(387));
  9404. return -1;
  9405. }
  9406. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  9407. // I use 0xFE000000 color for signalizing that this message is
  9408. // main chat message. 0xFE000000 is invalid color, same using
  9409. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  9410. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  9411. }
  9412. } else {
  9413. if(sd->state.mainchat)
  9414. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  9415. clif_displaymessage(fd, msg_txt(384));
  9416. else
  9417. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  9418. clif_displaymessage(fd, msg_txt(385));
  9419. }
  9420. return 0;
  9421. }
  9422. /*=====================================
  9423. * Autorejecting Invites/Deals [LuzZza]
  9424. * Usage: @noask
  9425. *-------------------------------------
  9426. */
  9427. int atcommand_noask(
  9428. const int fd, struct map_session_data* sd,
  9429. const char* command, const char* message)
  9430. {
  9431. if(sd->state.noask) {
  9432. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  9433. sd->state.noask = 0;
  9434. } else {
  9435. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  9436. sd->state.noask = 1;
  9437. }
  9438. return 0;
  9439. }
  9440. /*=====================================
  9441. * Send a @request message to all GMs of lowest_gm_level.
  9442. * Usage: @request <petition>
  9443. *-------------------------------------
  9444. */
  9445. int atcommand_request(
  9446. const int fd, struct map_session_data* sd,
  9447. const char* command, const char* message)
  9448. {
  9449. if (!message || !*message) {
  9450. clif_displaymessage(sd->fd,msg_txt(277));
  9451. return -1;
  9452. }
  9453. sprintf(atcmd_output, msg_txt(278), message);
  9454. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  9455. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  9456. clif_displaymessage(sd->fd,msg_txt(279));
  9457. return 0;
  9458. }
  9459. void do_init_atcommand() {
  9460. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  9461. duel_count = 0;
  9462. memset(&duel_list[0], 0, sizeof(duel_list));
  9463. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  9464. return;
  9465. }
  9466. void do_final_atcommand() {
  9467. users_db->destroy(users_db,NULL);
  9468. }