atcommand.c 325 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include <limits.h>
  9. #include "../common/socket.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/mmo.h"
  13. #include "../common/core.h"
  14. #include "../common/showmsg.h"
  15. #include "atcommand.h"
  16. #include "log.h"
  17. #include "clif.h"
  18. #include "chrif.h"
  19. #include "intif.h"
  20. #include "itemdb.h"
  21. #include "map.h"
  22. #include "pc.h"
  23. #include "status.h"
  24. #include "skill.h"
  25. #include "mob.h"
  26. #include "pet.h"
  27. #include "mercenary.h" //[orn]
  28. #include "battle.h"
  29. #include "party.h"
  30. #include "guild.h"
  31. #include "script.h"
  32. #include "npc.h"
  33. #include "trade.h"
  34. #include "unit.h"
  35. #ifndef TXT_ONLY
  36. #include "mail.h"
  37. #endif
  38. static char command_symbol = '@'; // first char of the commands (by [Yor])
  39. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  40. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  41. ACMD_FUNC(broadcast);
  42. ACMD_FUNC(localbroadcast);
  43. ACMD_FUNC(rura);
  44. ACMD_FUNC(where);
  45. ACMD_FUNC(jumpto);
  46. ACMD_FUNC(jump);
  47. ACMD_FUNC(who);
  48. ACMD_FUNC(who2);
  49. ACMD_FUNC(who3);
  50. ACMD_FUNC(whomap);
  51. ACMD_FUNC(whomap2);
  52. ACMD_FUNC(whomap3);
  53. ACMD_FUNC(whogm); // by Yor
  54. ACMD_FUNC(whozeny); // [Valaris]
  55. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  56. ACMD_FUNC(save);
  57. ACMD_FUNC(load);
  58. ACMD_FUNC(speed);
  59. ACMD_FUNC(charspeed);
  60. ACMD_FUNC(storage);
  61. ACMD_FUNC(guildstorage);
  62. ACMD_FUNC(option);
  63. ACMD_FUNC(hide);
  64. ACMD_FUNC(jobchange);
  65. ACMD_FUNC(die);
  66. ACMD_FUNC(kill);
  67. ACMD_FUNC(alive);
  68. ACMD_FUNC(kami);
  69. ACMD_FUNC(heal);
  70. ACMD_FUNC(item);
  71. ACMD_FUNC(item2);
  72. ACMD_FUNC(itemreset);
  73. ACMD_FUNC(baselevelup);
  74. ACMD_FUNC(joblevelup);
  75. ACMD_FUNC(help);
  76. ACMD_FUNC(help2);
  77. ACMD_FUNC(gm);
  78. ACMD_FUNC(pvpoff);
  79. ACMD_FUNC(pvpon);
  80. ACMD_FUNC(gvgoff);
  81. ACMD_FUNC(gvgon);
  82. ACMD_FUNC(model);
  83. ACMD_FUNC(go);
  84. ACMD_FUNC(monster);
  85. ACMD_FUNC(monstersmall);
  86. ACMD_FUNC(monsterbig);
  87. ACMD_FUNC(spawn);
  88. ACMD_FUNC(killmonster);
  89. ACMD_FUNC(killmonster2);
  90. ACMD_FUNC(refine);
  91. ACMD_FUNC(produce);
  92. ACMD_FUNC(memo);
  93. ACMD_FUNC(gat);
  94. ACMD_FUNC(packet);
  95. ACMD_FUNC(waterlevel);
  96. ACMD_FUNC(statuspoint);
  97. ACMD_FUNC(skillpoint);
  98. ACMD_FUNC(zeny);
  99. ACMD_FUNC(param);
  100. ACMD_FUNC(guildlevelup);
  101. ACMD_FUNC(makeegg);
  102. ACMD_FUNC(hatch);
  103. ACMD_FUNC(petfriendly);
  104. ACMD_FUNC(pethungry);
  105. ACMD_FUNC(petrename);
  106. ACMD_FUNC(recall);
  107. ACMD_FUNC(recallall);
  108. ACMD_FUNC(revive);
  109. ACMD_FUNC(night);
  110. ACMD_FUNC(day);
  111. ACMD_FUNC(doom);
  112. ACMD_FUNC(doommap);
  113. ACMD_FUNC(raise);
  114. ACMD_FUNC(raisemap);
  115. ACMD_FUNC(kick);
  116. ACMD_FUNC(kickall);
  117. ACMD_FUNC(allskill);
  118. ACMD_FUNC(questskill);
  119. ACMD_FUNC(lostskill);
  120. ACMD_FUNC(spiritball);
  121. ACMD_FUNC(party);
  122. ACMD_FUNC(guild);
  123. ACMD_FUNC(agitstart);
  124. ACMD_FUNC(agitend);
  125. ACMD_FUNC(reloaditemdb);
  126. ACMD_FUNC(reloadmobdb);
  127. ACMD_FUNC(reloadskilldb);
  128. ACMD_FUNC(reloadscript);
  129. ACMD_FUNC(reloadgmdb); // by Yor
  130. ACMD_FUNC(reloadatcommand);
  131. ACMD_FUNC(reloadbattleconf);
  132. ACMD_FUNC(reloadstatusdb);
  133. ACMD_FUNC(reloadpcdb);
  134. ACMD_FUNC(reloadmotd); // [Valaris]
  135. ACMD_FUNC(mapexit);
  136. ACMD_FUNC(idsearch);
  137. ACMD_FUNC(mapinfo);
  138. ACMD_FUNC(dye); //** by fritz
  139. ACMD_FUNC(hair_style); //** by fritz
  140. ACMD_FUNC(hair_color); //** by fritz
  141. ACMD_FUNC(stat_all); //** by fritz
  142. ACMD_FUNC(char_block); // by Yor
  143. ACMD_FUNC(char_ban); // by Yor
  144. ACMD_FUNC(char_unblock); // by Yor
  145. ACMD_FUNC(char_unban); // by Yor
  146. ACMD_FUNC(mount_peco); // by Valaris
  147. ACMD_FUNC(char_mount_peco); // by Yor
  148. ACMD_FUNC(guildspy); // [Syrus22]
  149. ACMD_FUNC(partyspy); // [Syrus22]
  150. ACMD_FUNC(repairall); // [Valaris]
  151. ACMD_FUNC(guildrecall); // by Yor
  152. ACMD_FUNC(partyrecall); // by Yor
  153. ACMD_FUNC(nuke); // [Valaris]
  154. ACMD_FUNC(shownpc);
  155. ACMD_FUNC(hidenpc);
  156. ACMD_FUNC(loadnpc);
  157. ACMD_FUNC(unloadnpc);
  158. ACMD_FUNC(servertime); // by Yor
  159. ACMD_FUNC(chardelitem); // by Yor
  160. ACMD_FUNC(jail); // by Yor
  161. ACMD_FUNC(unjail); // by Yor
  162. ACMD_FUNC(jailfor); // Alias Meruru
  163. ACMD_FUNC(jailtime); // Coltaro
  164. ACMD_FUNC(charjailtime); // Coltaro
  165. ACMD_FUNC(disguise); // [Valaris]
  166. ACMD_FUNC(undisguise); // by Yor
  167. ACMD_FUNC(chardisguise); // Kalaspuff
  168. ACMD_FUNC(charundisguise); // Kalaspuff
  169. ACMD_FUNC(email); // by Yor
  170. ACMD_FUNC(effect);//by Apple
  171. ACMD_FUNC(character_cart_list); // by Yor
  172. ACMD_FUNC(addwarp); // by MouseJstr
  173. ACMD_FUNC(follow); // by MouseJstr
  174. ACMD_FUNC(skillon); // by MouseJstr
  175. ACMD_FUNC(skilloff); // by MouseJstr
  176. ACMD_FUNC(killer); // by MouseJstr
  177. ACMD_FUNC(npcmove); // by MouseJstr
  178. ACMD_FUNC(killable); // by MouseJstr
  179. ACMD_FUNC(charkillable); // by MouseJstr
  180. ACMD_FUNC(dropall); // by MouseJstr
  181. ACMD_FUNC(chardropall); // by MouseJstr
  182. ACMD_FUNC(storeall); // by MouseJstr
  183. ACMD_FUNC(charstoreall); // by MouseJstr
  184. ACMD_FUNC(skillid); // by MouseJstr
  185. ACMD_FUNC(useskill); // by MouseJstr
  186. ACMD_FUNC(summon);
  187. ACMD_FUNC(rain);
  188. ACMD_FUNC(snow);
  189. ACMD_FUNC(sakura);
  190. ACMD_FUNC(clouds);
  191. ACMD_FUNC(clouds2); // [Valaris]
  192. ACMD_FUNC(fog);
  193. ACMD_FUNC(fireworks);
  194. ACMD_FUNC(leaves);
  195. ACMD_FUNC(adjgmlvl); // by MouseJstr
  196. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  197. ACMD_FUNC(trade); // by MouseJstr
  198. ACMD_FUNC(send); // by davidsiaw
  199. ACMD_FUNC(setbattleflag); // by MouseJstr
  200. ACMD_FUNC(unmute); // [Valaris]
  201. ACMD_FUNC(clearweather); // Dexity
  202. ACMD_FUNC(uptime); // by MC Cameri
  203. ACMD_FUNC(changesex); // by MC Cameri
  204. ACMD_FUNC(mute); // celest
  205. ACMD_FUNC(refresh); // by MC Cameri
  206. ACMD_FUNC(petid); // by MC Cameri
  207. ACMD_FUNC(identify); // by MC Cameri
  208. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  209. ACMD_FUNC(misceffect); // by MC Cameri
  210. ACMD_FUNC(mobsearch);
  211. ACMD_FUNC(cleanmap);
  212. ACMD_FUNC(npctalk);
  213. ACMD_FUNC(pettalk);
  214. ACMD_FUNC(users);
  215. ACMD_FUNC(reset);
  216. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  217. #ifndef TXT_ONLY
  218. ACMD_FUNC(checkmail); // [Valaris]
  219. ACMD_FUNC(listmail); // [Valaris]
  220. ACMD_FUNC(listnewmail); // [Valaris]
  221. ACMD_FUNC(readmail); // [Valaris]
  222. ACMD_FUNC(sendmail); // [Valaris]
  223. ACMD_FUNC(sendprioritymail); // [Valaris]
  224. ACMD_FUNC(deletemail); // [Valaris]
  225. ACMD_FUNC(refreshonline); // [Valaris]
  226. #endif /* TXT_ONLY */
  227. ACMD_FUNC(skilltree); // by MouseJstr
  228. ACMD_FUNC(marry); // by MouseJstr
  229. ACMD_FUNC(divorce); // by MouseJstr
  230. ACMD_FUNC(grind); // by MouseJstr
  231. ACMD_FUNC(grind2); // by MouseJstr
  232. #ifdef DMALLOC
  233. ACMD_FUNC(dmstart); // by MouseJstr
  234. ACMD_FUNC(dmtick); // by MouseJstr
  235. #endif
  236. ACMD_FUNC(jumptoid); // by Dino9021
  237. ACMD_FUNC(jumptoid2); // by Dino9021
  238. ACMD_FUNC(recallid); // by Dino9021
  239. ACMD_FUNC(recallid2); // by Dino9021
  240. ACMD_FUNC(kickid); // by Dino9021
  241. ACMD_FUNC(kickid2); // by Dino9021
  242. ACMD_FUNC(reviveid); // by Dino9021
  243. ACMD_FUNC(reviveid2); // by Dino9021
  244. ACMD_FUNC(killid); // by Dino9021
  245. ACMD_FUNC(killid2); // by Dino9021
  246. ACMD_FUNC(charkillableid); // by Dino9021
  247. ACMD_FUNC(charkillableid2); // by Dino9021
  248. ACMD_FUNC(sound);
  249. ACMD_FUNC(undisguiseall);
  250. ACMD_FUNC(disguiseall);
  251. ACMD_FUNC(changelook);
  252. ACMD_FUNC(mobinfo); //by Lupus
  253. ACMD_FUNC(exp); // by Skotlex
  254. ACMD_FUNC(adopt); // by Veider
  255. ACMD_FUNC(version); // by Ancyker
  256. ACMD_FUNC(mutearea); // by MouseJstr
  257. ACMD_FUNC(shuffle); // by MouseJstr
  258. ACMD_FUNC(rates); // by MouseJstr
  259. ACMD_FUNC(iteminfo); // Lupus
  260. ACMD_FUNC(whodrops); //Skotlex
  261. ACMD_FUNC(mapflag); // Lupus
  262. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  263. ACMD_FUNC(monsterignore); // [Valaris]
  264. ACMD_FUNC(fakename); //[Valaris]
  265. ACMD_FUNC(size); //[Valaris]
  266. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  267. ACMD_FUNC(showzeny);
  268. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  269. ACMD_FUNC(autotrade);// durf
  270. ACMD_FUNC(changeleader);// [Skotlex]
  271. ACMD_FUNC(partyoption);// [Skotlex]
  272. ACMD_FUNC(changegm);// durf
  273. // Duel [LuzZza]
  274. ACMD_FUNC(invite);
  275. ACMD_FUNC(duel);
  276. ACMD_FUNC(leave);
  277. ACMD_FUNC(accept);
  278. ACMD_FUNC(reject);
  279. ACMD_FUNC(away); // LuzZza
  280. ACMD_FUNC(main); // LuzZza
  281. ACMD_FUNC(clone); // [Valaris]
  282. ACMD_FUNC(tonpc); // LuzZza
  283. ACMD_FUNC(commands); // [Skotlex]
  284. ACMD_FUNC(noask); //LuzZza
  285. ACMD_FUNC(request); //[Skotlex]
  286. ACMD_FUNC(homlevel); //[orn]
  287. ACMD_FUNC(homevolution); //[orn]
  288. ACMD_FUNC(makehomun); //[orn]
  289. ACMD_FUNC(homfriendly); //[orn]
  290. ACMD_FUNC(homhungry); //[orn]
  291. ACMD_FUNC(homtalk); //[orn]
  292. ACMD_FUNC(hominfo); //[Toms]
  293. /*==========================================
  294. *AtCommandInfo atcommand_info[]構造体の定義
  295. *------------------------------------------
  296. */
  297. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  298. // to set default level, read atcommand_athena.conf first please.
  299. static AtCommandInfo atcommand_info[] = {
  300. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  301. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  302. { AtCommand_Where, "@where", 1, atcommand_where },
  303. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  304. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  305. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  306. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  307. { AtCommand_Who, "@who", 20, atcommand_who },
  308. { AtCommand_Who, "@whois", 20, atcommand_who },
  309. { AtCommand_Who, "@w", 20, atcommand_who },
  310. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  311. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  312. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  313. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  314. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  315. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  316. { AtCommand_Save, "@save", 40, atcommand_save },
  317. { AtCommand_Load, "@return", 40, atcommand_load },
  318. { AtCommand_Load, "@load", 40, atcommand_load },
  319. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  320. { AtCommand_CharSpeed, "@charspeed", 40, atcommand_charspeed },
  321. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  322. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  323. { AtCommand_Option, "@option", 40, atcommand_option },
  324. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  325. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  326. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  327. { AtCommand_Die, "@die", 1, atcommand_die },
  328. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  329. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  330. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  331. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  332. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  333. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  334. { AtCommand_Item, "@item", 60, atcommand_item },
  335. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  336. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  337. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  338. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  339. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  340. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  341. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  342. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  343. { AtCommand_H, "@h", 20, atcommand_help },
  344. { AtCommand_Help, "@help", 20, atcommand_help },
  345. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  346. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  347. { AtCommand_GM, "@gm", 100,atcommand_gm },
  348. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  349. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  350. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  351. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  352. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  353. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  354. { AtCommand_Model, "@model", 20, atcommand_model },
  355. { AtCommand_Go, "@go", 10, atcommand_go },
  356. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  357. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  358. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  359. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  360. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  361. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  362. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  363. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  364. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  365. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  366. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  367. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  368. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  369. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  370. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  371. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  372. { AtCommand_Strength, "@str", 60, atcommand_param },
  373. { AtCommand_Agility, "@agi", 60, atcommand_param },
  374. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  375. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  376. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  377. { AtCommand_Luck, "@luk", 60, atcommand_param },
  378. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  379. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  380. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  381. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  382. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  383. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  384. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  385. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  386. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  387. { AtCommand_Night, "@night", 80, atcommand_night },
  388. { AtCommand_Day, "@day", 80, atcommand_day },
  389. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  390. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  391. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  392. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  393. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  394. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  395. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  396. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  397. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  398. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  399. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  400. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  401. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  402. { AtCommand_Party, "@party", 1, atcommand_party },
  403. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  404. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  405. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  406. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  407. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  408. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  409. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  410. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  411. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  412. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  413. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  414. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  415. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  416. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  417. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  418. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  419. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  420. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  421. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  422. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  423. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  424. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  425. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  426. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  427. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  428. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  429. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  430. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  431. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  432. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  433. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  434. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  435. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  436. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  437. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  438. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  439. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  440. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  441. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  442. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  443. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  444. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  445. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  446. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  447. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  448. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  449. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  450. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  451. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  452. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  453. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  454. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  455. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  456. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  457. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  458. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  459. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  460. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  461. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  462. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  463. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  464. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  465. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  466. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  467. { AtCommand_JailFor, "@jailfor", 20, atcommand_jailfor }, //Meruru
  468. { 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 ;))
  469. { AtCommand_CharJailTime, "@charjailtime", 20, atcommand_charjailtime },
  470. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  471. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  472. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  473. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  474. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  475. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  476. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  477. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  478. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  479. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  480. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  481. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  482. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  483. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  484. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  485. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  486. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  487. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  488. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  489. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  490. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  491. // { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
  492. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  493. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  494. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  495. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  496. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  497. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  498. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  499. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  500. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  501. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  502. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  503. { AtCommand_Send, "@send", 60, atcommand_send },
  504. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  505. { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
  506. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  507. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  508. { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken] <- why not? [Skotlex]
  509. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  510. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  511. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  512. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  513. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  514. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  515. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  516. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  517. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  518. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  519. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  520. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  521. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  522. { AtCommand_Users, "@users", 40, atcommand_users },
  523. { AtCommand_ResetState, "@reset", 40, atcommand_reset },
  524. #ifndef TXT_ONLY // sql-only commands
  525. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  526. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  527. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  528. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  529. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  530. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  531. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  532. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  533. #endif /* TXT_ONLY */
  534. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  535. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  536. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  537. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  538. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  539. #ifdef DMALLOC
  540. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  541. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  542. #endif
  543. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  544. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  545. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  546. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  547. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  548. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  549. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  550. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  551. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  552. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  553. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  554. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  555. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  556. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  557. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  558. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  559. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  560. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  561. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  562. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  563. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  564. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  565. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  566. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  567. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  568. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  569. { AtCommand_Version, "@version", 1, atcommand_version },
  570. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  571. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  572. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  573. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  574. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  575. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  576. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  577. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  578. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  579. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  580. { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
  581. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  582. { AtCommand_Size, "@size", 20, atcommand_size },
  583. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  584. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  585. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  586. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  587. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  588. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  589. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  590. { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
  591. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  592. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  593. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  594. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  595. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  596. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  597. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  598. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  599. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  600. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  601. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  602. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  603. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  604. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  605. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  606. { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
  607. { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
  608. { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
  609. { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
  610. { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
  611. { AtCommand_HomTalk, "@homtalk", 0, atcommand_homtalk },
  612. { AtCommand_HomInfo, "@hominfo", 0, atcommand_hominfo },
  613. // add new commands before this line
  614. { AtCommand_Unknown, NULL, 1, NULL }
  615. };
  616. /*=========================================
  617. * Generic variables
  618. *-----------------------------------------
  619. */
  620. char atcmd_output[200];
  621. char atcmd_player_name[100];
  622. char atcmd_temp[100];
  623. /*==========================================
  624. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  625. *------------------------------------------
  626. */
  627. char *estr_lower(char *str)
  628. {
  629. int i;
  630. for (i=0; str[i]; i++)
  631. if ((str[i] >= 65) && (str[i] <= 90))
  632. str[i] += 32;
  633. return str;
  634. }
  635. // compare function for sorting high to lowest
  636. int hightolow_compare (const void * a, const void * b)
  637. {
  638. return ( *(int*)b - *(int*)a );
  639. }
  640. // compare function for sorting lowest to highest
  641. int lowtohigh_compare (const void * a, const void * b)
  642. {
  643. return ( *(int*)a - *(int*)b );
  644. }
  645. //-----------------------------------------------------------
  646. // Return the message string of the specified number by [Yor]
  647. //-----------------------------------------------------------
  648. char * msg_txt(int msg_number) {
  649. if (msg_number >= 0 && msg_number < MAX_MSG &&
  650. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  651. return msg_table[msg_number];
  652. return "??";
  653. }
  654. //-----------------------------------------------------------
  655. // Returns Players title (from msg_athena.conf) [Lupus]
  656. //-----------------------------------------------------------
  657. char * player_title_txt(int level) {
  658. if (level < battle_config.title_lvl1)
  659. return ""; //w/o any titles
  660. if (level >= battle_config.title_lvl8)
  661. sprintf(atcmd_temp, msg_txt(332), level);
  662. else
  663. if (level >= battle_config.title_lvl7)
  664. sprintf(atcmd_temp, msg_txt(331), level);
  665. else
  666. if (level >= battle_config.title_lvl6)
  667. sprintf(atcmd_temp, msg_txt(330), level);
  668. else
  669. if (level >= battle_config.title_lvl5)
  670. sprintf(atcmd_temp, msg_txt(329), level);
  671. else
  672. if (level >= battle_config.title_lvl4)
  673. sprintf(atcmd_temp, msg_txt(328), level);
  674. else
  675. if (level >= battle_config.title_lvl3)
  676. sprintf(atcmd_temp, msg_txt(327), level);
  677. else
  678. if (level >= battle_config.title_lvl2)
  679. sprintf(atcmd_temp, msg_txt(326), level);
  680. else
  681. sprintf(atcmd_temp, msg_txt(325), level); //lvl1
  682. return atcmd_temp;
  683. }
  684. //------------------------------------------------------------
  685. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  686. //------------------------------------------------------------
  687. int e_mail_check(char *email) {
  688. char ch;
  689. char* last_arobas;
  690. // athena limits
  691. if (strlen(email) < 3 || strlen(email) > 39)
  692. return 0;
  693. // part of RFC limits (official reference of e-mail description)
  694. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  695. return 0;
  696. if (email[strlen(email)-1] == '.')
  697. return 0;
  698. last_arobas = strrchr(email, '@');
  699. if (strstr(last_arobas, "@.") != NULL ||
  700. strstr(last_arobas, "..") != NULL)
  701. return 0;
  702. for(ch = 1; ch < 32; ch++) {
  703. if (strchr(last_arobas, ch) != NULL) {
  704. return 0;
  705. break;
  706. }
  707. }
  708. if (strchr(last_arobas, ' ') != NULL ||
  709. strchr(last_arobas, ';') != NULL)
  710. return 0;
  711. // all correct
  712. return 1;
  713. }
  714. /*==========================================
  715. * get_atcommand_level @コマンドの必要レベルを取得
  716. *------------------------------------------
  717. */
  718. int get_atcommand_level(const AtCommandType type) {
  719. int i;
  720. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  721. if (atcommand_info[i].type == type)
  722. return atcommand_info[i].level;
  723. return 100; // 100: command can not be used
  724. }
  725. /*==========================================
  726. *is_atcommand @コマンドに存在するかどうか確認する
  727. *------------------------------------------
  728. */
  729. AtCommandType
  730. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  731. const char* str = message;
  732. int s_flag = 0;
  733. AtCommandInfo info;
  734. AtCommandType type;
  735. nullpo_retr(AtCommand_None, sd);
  736. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
  737. return AtCommand_Unknown;
  738. }
  739. if (!message || !*message)
  740. return AtCommand_None;
  741. memset(&info, 0, sizeof(info));
  742. str += strlen(sd->status.name);
  743. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  744. if (*str == ':')
  745. s_flag = 1;
  746. str++;
  747. }
  748. if (!*str)
  749. return AtCommand_None;
  750. if (map[sd->bl.m].flag.nocommand &&
  751. (gmlvl > 0? gmlvl:pc_isGM(sd)) < battle_config.gm_skilluncond)
  752. { //Command not allowed on this map.
  753. sprintf(atcmd_output, msg_txt(143));
  754. clif_displaymessage(fd, atcmd_output);
  755. return AtCommand_None;
  756. }
  757. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  758. if (type != AtCommand_None) {
  759. char command[100];
  760. const char* p = str;
  761. memset(command, '\0', sizeof(command));
  762. memset(atcmd_output, '\0', sizeof(atcmd_output));
  763. while (*p && !isspace(*p))
  764. p++;
  765. if (p - str >= sizeof(command)) // too long
  766. return AtCommand_Unknown;
  767. strncpy(command, str, p - str);
  768. while (isspace(*p))
  769. p++;
  770. if (type == AtCommand_Unknown || info.proc == NULL) {
  771. sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
  772. clif_displaymessage(fd, atcmd_output);
  773. } else {
  774. if (info.proc(fd, sd, command, p) != 0) {
  775. // Command can not be executed
  776. sprintf(atcmd_output, msg_txt(154), command); // %s failed.
  777. clif_displaymessage(fd, atcmd_output);
  778. }
  779. }
  780. return info.type;
  781. }
  782. return AtCommand_None;
  783. }
  784. /*==========================================
  785. *
  786. *------------------------------------------
  787. */
  788. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  789. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  790. if (!info)
  791. return AtCommand_None;
  792. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  793. return AtCommand_None;
  794. if (!p || !*p) {
  795. ShowError("at command message is empty\n");
  796. return AtCommand_None;
  797. }
  798. if (*p == command_symbol) { // check first char.
  799. char command[101];
  800. int i = 0;
  801. memset(info, 0, sizeof(AtCommandInfo));
  802. sscanf(p, "%100s", command);
  803. command[sizeof(command)-1] = '\0';
  804. while (atcommand_info[i].type != AtCommand_Unknown) {
  805. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  806. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  807. break;
  808. }
  809. i++;
  810. }
  811. if (atcommand_info[i].type == AtCommand_Unknown) {
  812. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  813. if (level == 0)
  814. return AtCommand_None;
  815. else
  816. return AtCommand_Unknown;
  817. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  818. log_atcommand(sd, message);
  819. }
  820. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  821. } else {
  822. return AtCommand_None;
  823. }
  824. return info->type;
  825. }
  826. /*==========================================
  827. * Read Message Data
  828. *------------------------------------------
  829. */
  830. int msg_config_read(const char *cfgName) {
  831. int msg_number;
  832. char line[1024], w1[1024], w2[1024];
  833. FILE *fp;
  834. static int called = 1;
  835. if ((fp = fopen(cfgName, "r")) == NULL) {
  836. ShowError("Messages file not found: %s\n", cfgName);
  837. return 1;
  838. }
  839. if ((--called) == 0)
  840. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  841. while(fgets(line, sizeof(line)-1, fp)) {
  842. if (line[0] == '/' && line[1] == '/')
  843. continue;
  844. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  845. if (strcmpi(w1, "import") == 0) {
  846. msg_config_read(w2);
  847. } else {
  848. msg_number = atoi(w1);
  849. if (msg_number >= 0 && msg_number < MAX_MSG) {
  850. if (msg_table[msg_number] != NULL)
  851. aFree(msg_table[msg_number]);
  852. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  853. strcpy(msg_table[msg_number],w2);
  854. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  855. }
  856. }
  857. }
  858. }
  859. fclose(fp);
  860. return 0;
  861. }
  862. /*==========================================
  863. * Cleanup Message Data
  864. *------------------------------------------
  865. */
  866. void do_final_msg (void) {
  867. int i;
  868. for (i = 0; i < MAX_MSG; i++)
  869. aFree(msg_table[i]);
  870. return;
  871. }
  872. /*==========================================
  873. *
  874. *------------------------------------------
  875. */
  876. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  877. int i;
  878. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  879. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  880. return &atcommand_info[i];
  881. return NULL;
  882. }
  883. /*==========================================
  884. *
  885. *------------------------------------------
  886. */
  887. int atcommand_config_read(const char *cfgName) {
  888. char line[1024], w1[1024], w2[1024];
  889. AtCommandInfo* p;
  890. FILE* fp;
  891. if ((fp = fopen(cfgName, "r")) == NULL) {
  892. ShowError("At commands configuration file not found: %s\n", cfgName);
  893. return 1;
  894. }
  895. while (fgets(line, sizeof(line)-1, fp)) {
  896. if (line[0] == '/' && line[1] == '/')
  897. continue;
  898. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  899. continue;
  900. p = get_atcommandinfo_byname(w1);
  901. if (p != NULL) {
  902. p->level = atoi(w2);
  903. if (p->level > 100)
  904. p->level = 100;
  905. else if (p->level < 0)
  906. p->level = 0;
  907. }
  908. if (strcmpi(w1, "import") == 0)
  909. atcommand_config_read(w2);
  910. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  911. w2[0] != '/' && // symbol of standard ragnarok GM commands
  912. w2[0] != '%' && // symbol of party chat speaking
  913. w2[0] != '$' && // symbol of guild chat
  914. w2[0] != '#') // symbol of charcommand
  915. command_symbol = w2[0];
  916. }
  917. fclose(fp);
  918. return 0;
  919. }
  920. /*==========================================
  921. * Duel organizing functions [LuzZza]
  922. *------------------------------------------
  923. */
  924. void duel_savetime(struct map_session_data* sd) {
  925. time_t timer;
  926. struct tm *t;
  927. time(&timer);
  928. t = localtime(&timer);
  929. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  930. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  931. return;
  932. }
  933. int duel_checktime(struct map_session_data* sd) {
  934. int diff;
  935. time_t timer;
  936. struct tm *t;
  937. time(&timer);
  938. t = localtime(&timer);
  939. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  940. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  941. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  942. }
  943. static int duel_showinfo_sub(struct map_session_data* sd,va_list va) {
  944. struct map_session_data *ssd = va_arg(va, struct map_session_data*);
  945. int *p = va_arg(va, int*);
  946. char output[256];
  947. if (sd->duel_group != ssd->duel_group) return 0;
  948. sprintf(output, " %d. %s", ++(*p), (unsigned char *)sd->status.name);
  949. clif_disp_onlyself(ssd, output, strlen(output));
  950. return 1;
  951. }
  952. int duel_showinfo(
  953. const unsigned int did, struct map_session_data* sd)
  954. {
  955. int p=0;
  956. char output[256];
  957. if(duel_list[did].max_players_limit > 0)
  958. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  959. did, duel_count,
  960. duel_list[did].members_count,
  961. duel_list[did].members_count + duel_list[did].invites_count,
  962. duel_list[did].max_players_limit);
  963. else
  964. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  965. did, duel_count,
  966. duel_list[did].members_count,
  967. duel_list[did].members_count + duel_list[did].invites_count);
  968. clif_disp_onlyself(sd, output, strlen(output));
  969. clif_foreachclient(duel_showinfo_sub, sd, &p);
  970. return 0;
  971. }
  972. int duel_create(
  973. struct map_session_data* sd, const unsigned int maxpl)
  974. {
  975. int i=1;
  976. char output[256];
  977. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  978. if(i == MAX_DUEL) return 0;
  979. duel_count++;
  980. sd->duel_group = i;
  981. duel_list[i].members_count++;
  982. duel_list[i].invites_count = 0;
  983. duel_list[i].max_players_limit = maxpl;
  984. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  985. clif_disp_onlyself(sd, output, strlen(output));
  986. clif_set0199(sd->fd, 1);
  987. //clif_misceffect2(&sd->bl, 159);
  988. return i;
  989. }
  990. int duel_invite(
  991. const unsigned int did, struct map_session_data* sd,
  992. struct map_session_data* target_sd)
  993. {
  994. char output[256];
  995. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  996. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  997. clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
  998. target_sd->duel_invite = did;
  999. duel_list[did].invites_count++;
  1000. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  1001. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  1002. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  1003. return 0;
  1004. }
  1005. static int duel_leave_sub(struct map_session_data* sd,va_list va) {
  1006. int did = va_arg(va, int);
  1007. if (sd->duel_invite == did)
  1008. sd->duel_invite = 0;
  1009. return 0;
  1010. }
  1011. int duel_leave(
  1012. const unsigned int did, struct map_session_data* sd)
  1013. {
  1014. char output[256];
  1015. // " <- Player %s has left duel --"
  1016. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  1017. clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
  1018. duel_list[did].members_count--;
  1019. if(duel_list[did].members_count == 0) {
  1020. clif_foreachclient(duel_leave_sub, did);
  1021. duel_count--;
  1022. }
  1023. sd->duel_group = 0;
  1024. duel_savetime(sd);
  1025. clif_set0199(sd->fd, 0);
  1026. return 0;
  1027. }
  1028. int duel_accept(
  1029. const unsigned int did, struct map_session_data* sd)
  1030. {
  1031. char output[256];
  1032. duel_list[did].members_count++;
  1033. sd->duel_group = sd->duel_invite;
  1034. duel_list[did].invites_count--;
  1035. sd->duel_invite = 0;
  1036. // " -> Player %s has accepted duel --"
  1037. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  1038. clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
  1039. clif_set0199(sd->fd, 1);
  1040. //clif_misceffect2(&sd->bl, 159);
  1041. return 0;
  1042. }
  1043. int duel_reject(
  1044. const unsigned int did, struct map_session_data* sd)
  1045. {
  1046. char output[256];
  1047. // " -- Player %s has rejected duel --"
  1048. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1049. clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
  1050. duel_list[did].invites_count--;
  1051. sd->duel_invite = 0;
  1052. return 0;
  1053. }
  1054. /*==========================================
  1055. // @ command processing functions
  1056. *------------------------------------------
  1057. */
  1058. /*==========================================
  1059. * @commands Lists available @ commands to you (code 98% from Meruru)
  1060. *------------------------------------------
  1061. */
  1062. int atcommand_commands(
  1063. const int fd, struct map_session_data* sd,
  1064. const char* command, const char* message)
  1065. {
  1066. char cz_line_buff[MESSAGE_SIZE+1];
  1067. register char *lpcz_cur = cz_line_buff;
  1068. register unsigned int ui_slen;
  1069. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  1070. memset(cz_line_buff,' ',MESSAGE_SIZE);
  1071. cz_line_buff[MESSAGE_SIZE] = 0;
  1072. clif_displaymessage(fd, msg_txt(273));
  1073. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  1074. {
  1075. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  1076. continue;
  1077. count++;
  1078. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  1079. //rember not <= bc we need null terminator
  1080. if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  1081. {
  1082. clif_displaymessage(fd,(char*)cz_line_buff);
  1083. lpcz_cur = cz_line_buff;
  1084. memset(cz_line_buff,' ',MESSAGE_SIZE);
  1085. cz_line_buff[MESSAGE_SIZE] = 0;
  1086. }
  1087. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  1088. lpcz_cur += ui_slen+(10-ui_slen%10);
  1089. }
  1090. clif_displaymessage(fd,(char*)cz_line_buff);
  1091. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  1092. clif_displaymessage(fd, atcmd_output);
  1093. return 0;
  1094. }
  1095. /*==========================================
  1096. * @send (used for testing packet sends from the client)
  1097. *------------------------------------------
  1098. */
  1099. int atcommand_send(
  1100. const int fd, struct map_session_data* sd,
  1101. const char* command, const char* message)
  1102. {
  1103. int i,type=0;
  1104. int info[20];
  1105. if (!message || !*message || sscanf(message, "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &type, &info[1], &info[2], &info[3], &info[4], &info[5], &info[6], &info[7], &info[8], &info[9], &info[10], &info[11], &info[12], &info[13], &info[14], &info[15], &info[16], &info[17], &info[18], &info[19], &info[20]) < 1) {
  1106. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1107. return -1;
  1108. }
  1109. if (type > 0 && type < MAX_PACKET_DB) {
  1110. switch (type)
  1111. {
  1112. case 0x209: {
  1113. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1114. WFIFOW(fd,0) = 0x209;
  1115. WFIFOW(fd,2) = 2;
  1116. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1117. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1118. break;
  1119. }
  1120. case 0x1b1:
  1121. case 0x1c2:
  1122. //case xxx:
  1123. // add others here
  1124. // break;
  1125. default: {
  1126. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1127. WFIFOW(fd,0) = type;
  1128. for(i=1;i<=sizeof(info);i++)
  1129. if(info[i])
  1130. WFIFOW(fd,i) = info[i];
  1131. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1132. break;
  1133. }
  1134. }
  1135. sprintf (atcmd_output, msg_txt(258), type, type);
  1136. clif_displaymessage(fd, atcmd_output);
  1137. } else {
  1138. clif_displaymessage(fd, msg_txt(259));
  1139. }
  1140. return 0;
  1141. }
  1142. // @rura
  1143. /*==========================================
  1144. *
  1145. *------------------------------------------
  1146. */
  1147. int atcommand_rura(
  1148. const int fd, struct map_session_data* sd,
  1149. const char* command, const char* message)
  1150. {
  1151. char map_name[MAP_NAME_LENGTH];
  1152. unsigned short mapindex;
  1153. int x = 0, y = 0;
  1154. int m = -1;
  1155. nullpo_retr(-1, sd);
  1156. memset(map_name, '\0', sizeof(map_name));
  1157. if (!message || !*message ||
  1158. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1159. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1160. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1161. return -1;
  1162. }
  1163. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1164. strcat(map_name, ".gat");
  1165. mapindex = mapindex_name2id(map_name);
  1166. if (mapindex)
  1167. m = map_mapindex2mapid(mapindex);
  1168. if (!mapindex || m < 0) {
  1169. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1170. return -1;
  1171. }
  1172. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) {
  1173. clif_displaymessage(fd, msg_txt(2));
  1174. x = y = 0; //Invalid cell, use random spot.
  1175. }
  1176. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1177. clif_displaymessage(fd, msg_txt(247));
  1178. return -1;
  1179. }
  1180. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1181. clif_displaymessage(fd, msg_txt(248));
  1182. return -1;
  1183. }
  1184. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1185. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1186. else {
  1187. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1188. return -1;
  1189. }
  1190. return 0;
  1191. }
  1192. /*==========================================
  1193. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1194. *------------------------------------------
  1195. */
  1196. int atcommand_where(
  1197. const int fd, struct map_session_data* sd,
  1198. const char* command, const char* message)
  1199. {
  1200. struct map_session_data *pl_sd = NULL;
  1201. int GM_level, pl_GM_level;
  1202. nullpo_retr(-1, sd);
  1203. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1204. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1205. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1206. return -1;
  1207. }
  1208. pl_sd = map_nick2sd(atcmd_player_name);
  1209. if (pl_sd == NULL)
  1210. return -1;
  1211. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1212. return -1;
  1213. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1214. pl_GM_level = pc_isGM(pl_sd);
  1215. if (battle_config.hide_GM_session) {
  1216. if(GM_level < pl_GM_level) {
  1217. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1218. return -1;
  1219. }
  1220. }
  1221. }
  1222. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1223. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1224. clif_displaymessage(fd, atcmd_output);
  1225. return 0;
  1226. }
  1227. /*==========================================
  1228. *
  1229. *------------------------------------------
  1230. */
  1231. int atcommand_jumpto(
  1232. const int fd, struct map_session_data* sd,
  1233. const char* command, const char* message)
  1234. {
  1235. struct map_session_data *pl_sd = NULL;
  1236. nullpo_retr(-1, sd);
  1237. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1238. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1239. return -1;
  1240. }
  1241. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1242. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1243. return -1;
  1244. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1245. return -1;
  1246. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1247. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1248. clif_displaymessage(fd, msg_txt(247));
  1249. return -1;
  1250. }
  1251. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1252. clif_displaymessage(fd, msg_txt(248));
  1253. return -1;
  1254. }
  1255. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1256. sprintf(atcmd_output, msg_txt(4), atcmd_player_name); // Jump to %s
  1257. clif_displaymessage(fd, atcmd_output);
  1258. } else {
  1259. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1260. return -1;
  1261. }
  1262. return 0;
  1263. }
  1264. /*==========================================
  1265. *
  1266. *------------------------------------------
  1267. */
  1268. int atcommand_jump(
  1269. const int fd, struct map_session_data* sd,
  1270. const char* command, const char* message)
  1271. {
  1272. int x = 0, y = 0;
  1273. nullpo_retr(-1, sd);
  1274. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1275. sscanf(message, "%d %d", &x, &y);
  1276. if (x <= 0) //If coordinates are 'wrong', random jump.
  1277. x = -1;
  1278. if (y <= 0)
  1279. y = -1;
  1280. 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)) {
  1281. clif_displaymessage(fd, msg_txt(248));
  1282. return -1;
  1283. }
  1284. pc_setpos(sd, sd->mapindex, x, y, 3);
  1285. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
  1286. clif_displaymessage(fd, atcmd_output);
  1287. return 0;
  1288. }
  1289. /*==========================================
  1290. * @who3 = Player name, his location
  1291. *------------------------------------------
  1292. */
  1293. int atcommand_who3(
  1294. const int fd, struct map_session_data* sd,
  1295. const char* command, const char* message)
  1296. {
  1297. char temp0[100];
  1298. struct map_session_data *pl_sd, **pl_allsd;
  1299. int i, j, count, users;
  1300. int pl_GM_level, GM_level;
  1301. char match_text[100];
  1302. char player_name[NAME_LENGTH];
  1303. nullpo_retr(-1, sd);
  1304. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1305. memset(match_text, '\0', sizeof(match_text));
  1306. memset(player_name, '\0', sizeof(player_name));
  1307. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1308. strcpy(match_text, "");
  1309. for (j = 0; match_text[j]; j++)
  1310. match_text[j] = tolower(match_text[j]);
  1311. count = 0;
  1312. GM_level = pc_isGM(sd);
  1313. pl_allsd = map_getallusers(&users);
  1314. for (i = 0; i < users; i++) {
  1315. if ((pl_sd = pl_allsd[i])) {
  1316. pl_GM_level = pc_isGM(pl_sd);
  1317. 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
  1318. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1319. for (j = 0; player_name[j]; j++)
  1320. player_name[j] = tolower(player_name[j]);
  1321. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1322. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1323. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1324. } else {
  1325. atcmd_output[0]=0;
  1326. }
  1327. //Player name
  1328. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1329. strcat(atcmd_output,temp0);
  1330. //Player title, if exists
  1331. if (pl_GM_level > 0) {
  1332. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1333. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1334. strcat(atcmd_output,temp0);
  1335. }
  1336. //Players Location: map x y
  1337. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1338. strcat(atcmd_output,temp0);
  1339. clif_displaymessage(fd, atcmd_output);
  1340. count++;
  1341. }
  1342. }
  1343. }
  1344. }
  1345. if (count == 0)
  1346. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1347. else if (count == 1)
  1348. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1349. else {
  1350. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1351. clif_displaymessage(fd, atcmd_output);
  1352. }
  1353. return 0;
  1354. }
  1355. /*==========================================
  1356. * Player name, BLevel, Job,
  1357. *------------------------------------------
  1358. */
  1359. int atcommand_who2(
  1360. const int fd, struct map_session_data* sd,
  1361. const char* command, const char* message)
  1362. {
  1363. char temp0[100];
  1364. struct map_session_data *pl_sd, **pl_allsd;
  1365. int i, j, count, users;
  1366. int pl_GM_level, GM_level;
  1367. char match_text[100];
  1368. char player_name[NAME_LENGTH];
  1369. nullpo_retr(-1, sd);
  1370. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1371. memset(match_text, '\0', sizeof(match_text));
  1372. memset(player_name, '\0', sizeof(player_name));
  1373. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1374. strcpy(match_text, "");
  1375. for (j = 0; match_text[j]; j++)
  1376. match_text[j] = tolower(match_text[j]);
  1377. count = 0;
  1378. GM_level = pc_isGM(sd);
  1379. pl_allsd = map_getallusers(&users);
  1380. for (i = 0; i < users; i++) {
  1381. if ((pl_sd = pl_allsd[i])) {
  1382. pl_GM_level = pc_isGM(pl_sd);
  1383. 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
  1384. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1385. for (j = 0; player_name[j]; j++)
  1386. player_name[j] = tolower(player_name[j]);
  1387. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1388. //Players Name
  1389. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1390. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1391. //Player title, if exists
  1392. if (pl_GM_level > 0) {
  1393. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1394. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1395. strcat(atcmd_output,temp0);
  1396. }
  1397. //Players Base Level / Job name
  1398. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1399. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1400. strcat(atcmd_output,temp0);
  1401. clif_displaymessage(fd, atcmd_output);
  1402. count++;
  1403. }
  1404. }
  1405. }
  1406. }
  1407. if (count == 0)
  1408. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1409. else if (count == 1)
  1410. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1411. else {
  1412. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1413. clif_displaymessage(fd, atcmd_output);
  1414. }
  1415. return 0;
  1416. }
  1417. /*==========================================
  1418. * Player name, Playrs Party / Guild name
  1419. *------------------------------------------
  1420. */
  1421. int atcommand_who(
  1422. const int fd, struct map_session_data* sd,
  1423. const char* command, const char* message)
  1424. {
  1425. char temp0[100];
  1426. struct map_session_data *pl_sd, **pl_allsd;
  1427. int i, j, count, users;
  1428. int pl_GM_level, GM_level;
  1429. char match_text[100];
  1430. char player_name[NAME_LENGTH];
  1431. struct guild *g;
  1432. struct party_data *p;
  1433. nullpo_retr(-1, sd);
  1434. memset(temp0, '\0', sizeof(temp0));
  1435. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1436. memset(match_text, '\0', sizeof(match_text));
  1437. memset(player_name, '\0', sizeof(player_name));
  1438. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1439. strcpy(match_text, "");
  1440. for (j = 0; match_text[j]; j++)
  1441. match_text[j] = tolower(match_text[j]);
  1442. count = 0;
  1443. GM_level = pc_isGM(sd);
  1444. pl_allsd = map_getallusers(&users);
  1445. for (i = 0; i < users; i++) {
  1446. if ((pl_sd = pl_allsd[i])) {
  1447. pl_GM_level = pc_isGM(pl_sd);
  1448. 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
  1449. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1450. for (j = 0; player_name[j]; j++)
  1451. player_name[j] = tolower(player_name[j]);
  1452. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1453. g = guild_search(pl_sd->status.guild_id);
  1454. p = party_search(pl_sd->status.party_id);
  1455. //Players Name
  1456. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1457. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1458. //Player title, if exists
  1459. if (pl_GM_level > 0) {
  1460. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1461. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1462. strcat(atcmd_output,temp0);
  1463. }
  1464. //Players Party if exists
  1465. if (p != NULL) {
  1466. //sprintf(temp0," | Party: '%s'", p->name);
  1467. sprintf(temp0, msg_txt(335), p->party.name);
  1468. strcat(atcmd_output,temp0);
  1469. }
  1470. //Players Guild if exists
  1471. if (g != NULL) {
  1472. //sprintf(temp0," | Guild: '%s'", g->name);
  1473. sprintf(temp0, msg_txt(336), g->name);
  1474. strcat(atcmd_output,temp0);
  1475. }
  1476. clif_displaymessage(fd, atcmd_output);
  1477. count++;
  1478. }
  1479. }
  1480. }
  1481. }
  1482. if (count == 0)
  1483. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1484. else if (count == 1)
  1485. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1486. else {
  1487. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1488. clif_displaymessage(fd, atcmd_output);
  1489. }
  1490. return 0;
  1491. }
  1492. /*==========================================
  1493. *
  1494. *------------------------------------------
  1495. */
  1496. int atcommand_whomap3(
  1497. const int fd, struct map_session_data* sd,
  1498. const char* command, const char* message)
  1499. {
  1500. struct map_session_data *pl_sd, **pl_allsd;
  1501. int i, count, users;
  1502. int pl_GM_level, GM_level;
  1503. int map_id;
  1504. char map_name[MAP_NAME_LENGTH];
  1505. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1506. memset(map_name, '\0', sizeof(map_name));
  1507. if (!message || !*message)
  1508. map_id = sd->bl.m;
  1509. else {
  1510. sscanf(message, "%15s", map_name);
  1511. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1512. strcat(map_name, ".gat");
  1513. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1514. map_id = sd->bl.m;
  1515. }
  1516. count = 0;
  1517. GM_level = pc_isGM(sd);
  1518. pl_allsd = map_getallusers(&users);
  1519. for (i = 0; i < users; i++) {
  1520. if ((pl_sd = pl_allsd[i])) {
  1521. pl_GM_level = pc_isGM(pl_sd);
  1522. 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
  1523. if (pl_sd->bl.m == map_id) {
  1524. if (pl_GM_level > 0)
  1525. 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);
  1526. else
  1527. 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);
  1528. clif_displaymessage(fd, atcmd_output);
  1529. count++;
  1530. }
  1531. }
  1532. }
  1533. }
  1534. if (count == 0)
  1535. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1536. else if (count == 1)
  1537. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1538. else {
  1539. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1540. }
  1541. clif_displaymessage(fd, atcmd_output);
  1542. return 0;
  1543. }
  1544. /*==========================================
  1545. *
  1546. *------------------------------------------
  1547. */
  1548. int atcommand_whomap2(
  1549. const int fd, struct map_session_data* sd,
  1550. const char* command, const char* message)
  1551. {
  1552. struct map_session_data *pl_sd, **pl_allsd;
  1553. int i, count, users;
  1554. int pl_GM_level, GM_level;
  1555. int map_id = 0;
  1556. char map_name[MAP_NAME_LENGTH];
  1557. nullpo_retr(-1, sd);
  1558. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1559. memset(map_name, '\0', sizeof(map_name));
  1560. if (!message || !*message)
  1561. map_id = sd->bl.m;
  1562. else {
  1563. sscanf(message, "%15s", map_name);
  1564. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1565. strcat(map_name, ".gat");
  1566. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1567. map_id = sd->bl.m;
  1568. }
  1569. count = 0;
  1570. GM_level = pc_isGM(sd);
  1571. pl_allsd = map_getallusers(&users);
  1572. for (i = 0; i < users; i++) {
  1573. if ((pl_sd = pl_allsd[i])) {
  1574. pl_GM_level = pc_isGM(pl_sd);
  1575. 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
  1576. if (pl_sd->bl.m == map_id) {
  1577. if (pl_GM_level > 0)
  1578. 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);
  1579. else
  1580. 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);
  1581. clif_displaymessage(fd, atcmd_output);
  1582. count++;
  1583. }
  1584. }
  1585. }
  1586. }
  1587. if (count == 0)
  1588. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1589. else if (count == 1)
  1590. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1591. else {
  1592. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1593. }
  1594. clif_displaymessage(fd, atcmd_output);
  1595. return 0;
  1596. }
  1597. /*==========================================
  1598. *
  1599. *------------------------------------------
  1600. */
  1601. int atcommand_whomap(
  1602. const int fd, struct map_session_data* sd,
  1603. const char* command, const char* message)
  1604. {
  1605. char temp0[100];
  1606. char temp1[100];
  1607. struct map_session_data *pl_sd, **pl_allsd;
  1608. int i, count, users;
  1609. int pl_GM_level, GM_level;
  1610. int map_id = 0;
  1611. char map_name[MAP_NAME_LENGTH];
  1612. struct guild *g;
  1613. struct party_data *p;
  1614. nullpo_retr(-1, sd);
  1615. memset(temp0, '\0', sizeof(temp0));
  1616. memset(temp1, '\0', sizeof(temp1));
  1617. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1618. memset(map_name, '\0', sizeof(map_name));
  1619. if (!message || !*message)
  1620. map_id = sd->bl.m;
  1621. else {
  1622. sscanf(message, "%15s", map_name);
  1623. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1624. strcat(map_name, ".gat");
  1625. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1626. map_id = sd->bl.m;
  1627. }
  1628. count = 0;
  1629. GM_level = pc_isGM(sd);
  1630. pl_allsd = map_getallusers(&users);
  1631. for (i = 0; i < users; i++) {
  1632. if ((pl_sd = pl_allsd[i])) {
  1633. pl_GM_level = pc_isGM(pl_sd);
  1634. 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
  1635. if (pl_sd->bl.m == map_id) {
  1636. g = guild_search(pl_sd->status.guild_id);
  1637. if (g == NULL)
  1638. sprintf(temp1, "None");
  1639. else
  1640. sprintf(temp1, "%s", g->name);
  1641. p = party_search(pl_sd->status.party_id);
  1642. if (p == NULL)
  1643. sprintf(temp0, "None");
  1644. else
  1645. sprintf(temp0, "%s", p->party.name);
  1646. if (pl_GM_level > 0)
  1647. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1648. else
  1649. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1650. clif_displaymessage(fd, atcmd_output);
  1651. count++;
  1652. }
  1653. }
  1654. }
  1655. }
  1656. if (count == 0)
  1657. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1658. else if (count == 1)
  1659. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1660. else {
  1661. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1662. }
  1663. clif_displaymessage(fd, atcmd_output);
  1664. return 0;
  1665. }
  1666. /*==========================================
  1667. *
  1668. *------------------------------------------
  1669. */
  1670. int atcommand_whogm(
  1671. const int fd, struct map_session_data* sd,
  1672. const char* command, const char* message)
  1673. {
  1674. char temp0[100];
  1675. char temp1[100];
  1676. struct map_session_data *pl_sd, **pl_allsd;
  1677. int i, j, count, users;
  1678. int pl_GM_level, GM_level;
  1679. char match_text[100];
  1680. char player_name[NAME_LENGTH];
  1681. struct guild *g;
  1682. struct party_data *p;
  1683. nullpo_retr(-1, sd);
  1684. memset(temp0, '\0', sizeof(temp0));
  1685. memset(temp1, '\0', sizeof(temp1));
  1686. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1687. memset(match_text, '\0', sizeof(match_text));
  1688. memset(player_name, '\0', sizeof(player_name));
  1689. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1690. strcpy(match_text, "");
  1691. for (j = 0; match_text[j]; j++)
  1692. match_text[j] = tolower(match_text[j]);
  1693. count = 0;
  1694. GM_level = pc_isGM(sd);
  1695. pl_allsd = map_getallusers(&users);
  1696. for (i = 0; i < users; i++) {
  1697. if ((pl_sd = pl_allsd[i])) {
  1698. pl_GM_level = pc_isGM(pl_sd);
  1699. if (pl_GM_level > 0) {
  1700. 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
  1701. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1702. for (j = 0; player_name[j]; j++)
  1703. player_name[j] = tolower(player_name[j]);
  1704. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1705. 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);
  1706. clif_displaymessage(fd, atcmd_output);
  1707. 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);
  1708. clif_displaymessage(fd, atcmd_output);
  1709. g = guild_search(pl_sd->status.guild_id);
  1710. if (g == NULL)
  1711. sprintf(temp1, "None");
  1712. else
  1713. sprintf(temp1, "%s", g->name);
  1714. p = party_search(pl_sd->status.party_id);
  1715. if (p == NULL)
  1716. sprintf(temp0, "None");
  1717. else
  1718. sprintf(temp0, "%s", p->party.name);
  1719. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1720. clif_displaymessage(fd, atcmd_output);
  1721. count++;
  1722. }
  1723. }
  1724. }
  1725. }
  1726. }
  1727. if (count == 0)
  1728. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1729. else if (count == 1)
  1730. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1731. else {
  1732. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1733. clif_displaymessage(fd, atcmd_output);
  1734. }
  1735. return 0;
  1736. }
  1737. int atcommand_whozeny(
  1738. const int fd, struct map_session_data* sd,
  1739. const char* command, const char* message)
  1740. {
  1741. struct map_session_data *pl_sd, **pl_allsd;
  1742. int i, j, count,c, users;
  1743. char match_text[100];
  1744. char player_name[NAME_LENGTH];
  1745. int *zeny;
  1746. int *counted;
  1747. nullpo_retr(-1, sd);
  1748. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1749. memset(match_text, '\0', sizeof(match_text));
  1750. memset(player_name, '\0', sizeof(player_name));
  1751. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1752. strcpy(match_text, "");
  1753. for (j = 0; match_text[j]; j++)
  1754. match_text[j] = tolower(match_text[j]);
  1755. count = 0;
  1756. pl_allsd = map_getallusers(&users);
  1757. if (users < 1)
  1758. {
  1759. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1760. return 0;
  1761. }
  1762. zeny = (int *)aMallocA(users*sizeof(int));
  1763. counted = (int *)aMallocA(users*sizeof(int));
  1764. for (i = 0; i < users; i++) {
  1765. if ((pl_sd = pl_allsd[i])) {
  1766. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1767. for (j = 0; player_name[j]; j++)
  1768. player_name[j] = tolower(player_name[j]);
  1769. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1770. zeny[count]=pl_sd->status.zeny;
  1771. counted[i]=0;
  1772. count++;
  1773. }
  1774. }
  1775. }
  1776. qsort(zeny, count, sizeof(int), hightolow_compare);
  1777. for (c = 0; c < count && c < 50; c++) {
  1778. if(!zeny[c])
  1779. continue;
  1780. for (i = 0; i < users; i++) {
  1781. if(!zeny[c])
  1782. continue;
  1783. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1784. if(pl_sd->status.zeny==zeny[c]) {
  1785. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1786. clif_displaymessage(fd, atcmd_output);
  1787. zeny[c]=0;
  1788. counted[i]=1;
  1789. }
  1790. }
  1791. }
  1792. }
  1793. if (count == 0)
  1794. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1795. else if (count == 1)
  1796. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1797. else {
  1798. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1799. clif_displaymessage(fd, atcmd_output);
  1800. }
  1801. aFree(zeny);
  1802. aFree(counted);
  1803. return 0;
  1804. }
  1805. // cause random emote on all online players [Valaris]
  1806. int atcommand_happyhappyjoyjoy(
  1807. const int fd, struct map_session_data* sd,
  1808. const char* command, const char* message)
  1809. {
  1810. struct map_session_data *pl_sd, **pl_allsd;
  1811. int i,e, users;
  1812. nullpo_retr(-1, sd);
  1813. pl_allsd = map_getallusers(&users);
  1814. for (i = 0; i < users; i++) {
  1815. if ((pl_sd = pl_allsd[i])) {
  1816. e=rand()%40;
  1817. if(e==34)
  1818. e = 0;
  1819. clif_emotion(&pl_sd->bl,e);
  1820. }
  1821. }
  1822. return 0;
  1823. }
  1824. /*==========================================
  1825. *
  1826. *------------------------------------------
  1827. */
  1828. int atcommand_save(
  1829. const int fd, struct map_session_data* sd,
  1830. const char* command, const char* message)
  1831. {
  1832. nullpo_retr(-1, sd);
  1833. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1834. if (sd->status.pet_id > 0 && sd->pd)
  1835. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1836. chrif_save(sd,0);
  1837. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  1838. return 0;
  1839. }
  1840. /*==========================================
  1841. *
  1842. *------------------------------------------
  1843. */
  1844. int atcommand_load(
  1845. const int fd, struct map_session_data* sd,
  1846. const char* command, const char* message)
  1847. {
  1848. int m;
  1849. nullpo_retr(-1, sd);
  1850. m = map_mapindex2mapid(sd->status.save_point.map);
  1851. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1852. clif_displaymessage(fd, msg_txt(249));
  1853. return -1;
  1854. }
  1855. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1856. clif_displaymessage(fd, msg_txt(248));
  1857. return -1;
  1858. }
  1859. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1860. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1861. return 0;
  1862. }
  1863. /*==========================================
  1864. *
  1865. *------------------------------------------
  1866. */
  1867. int atcommand_speed(
  1868. const int fd, struct map_session_data* sd,
  1869. const char* command, const char* message)
  1870. {
  1871. int speed;
  1872. nullpo_retr(-1, sd);
  1873. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1874. if (!message || !*message) {
  1875. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1876. clif_displaymessage(fd, atcmd_output);
  1877. return -1;
  1878. }
  1879. speed = atoi(message);
  1880. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1881. sd->base_status.speed = speed;
  1882. status_calc_bl(&sd->bl, SCB_SPEED);
  1883. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1884. } else {
  1885. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1886. clif_displaymessage(fd, atcmd_output);
  1887. return -1;
  1888. }
  1889. return 0;
  1890. }
  1891. /*==========================================
  1892. *
  1893. *------------------------------------------
  1894. */
  1895. int atcommand_charspeed(
  1896. const int fd, struct map_session_data* sd,
  1897. const char* command, const char* message)
  1898. {
  1899. struct map_session_data *pl_sd;
  1900. int speed;
  1901. nullpo_retr(-1, sd);
  1902. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1903. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1904. if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
  1905. sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1906. clif_displaymessage(fd, atcmd_output);
  1907. return -1;
  1908. }
  1909. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  1910. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1911. return -1;
  1912. }
  1913. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1914. { //GM level check
  1915. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1916. return -1;
  1917. }
  1918. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1919. pl_sd->base_status.speed = speed;
  1920. status_calc_bl(&pl_sd->bl, SCB_SPEED);
  1921. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1922. if(pl_sd->fd)
  1923. clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
  1924. } else {
  1925. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1926. clif_displaymessage(fd, atcmd_output);
  1927. return -1;
  1928. }
  1929. return 0;
  1930. }
  1931. /*==========================================
  1932. *
  1933. *------------------------------------------
  1934. */
  1935. int atcommand_storage(
  1936. const int fd, struct map_session_data* sd,
  1937. const char* command, const char* message)
  1938. {
  1939. struct storage *stor; //changes from Freya/Yor
  1940. nullpo_retr(-1, sd);
  1941. if (sd->state.storage_flag) {
  1942. clif_displaymessage(fd, msg_txt(250));
  1943. return -1;
  1944. }
  1945. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1946. clif_displaymessage(fd, msg_txt(250));
  1947. return -1;
  1948. }
  1949. storage_storageopen(sd);
  1950. return 0;
  1951. }
  1952. /*==========================================
  1953. *
  1954. *------------------------------------------
  1955. */
  1956. int atcommand_guildstorage(
  1957. const int fd, struct map_session_data* sd,
  1958. const char* command, const char* message)
  1959. {
  1960. struct storage *stor; //changes from Freya/Yor
  1961. nullpo_retr(-1, sd);
  1962. if (sd->status.guild_id > 0) {
  1963. if (sd->state.storage_flag) {
  1964. clif_displaymessage(fd, msg_txt(251));
  1965. return -1;
  1966. }
  1967. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1968. clif_displaymessage(fd, msg_txt(251));
  1969. return -1;
  1970. }
  1971. storage_guild_storageopen(sd);
  1972. } else {
  1973. clif_displaymessage(fd, msg_txt(252));
  1974. return -1;
  1975. }
  1976. return 0;
  1977. }
  1978. /*==========================================
  1979. *
  1980. *------------------------------------------
  1981. */
  1982. int atcommand_option(
  1983. const int fd, struct map_session_data* sd,
  1984. const char* command, const char* message)
  1985. {
  1986. int param1 = 0, param2 = 0, param3 = 0;
  1987. nullpo_retr(-1, sd);
  1988. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1989. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1990. return -1;
  1991. }
  1992. sd->sc.opt1 = param1;
  1993. sd->sc.opt2 = param2;
  1994. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1995. clif_cartlist(sd);
  1996. clif_updatestatus(sd, SP_CARTINFO);
  1997. }
  1998. pc_setoption(sd, param3);
  1999. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  2000. return 0;
  2001. }
  2002. /*==========================================
  2003. *
  2004. *------------------------------------------
  2005. */
  2006. int atcommand_hide(
  2007. const int fd, struct map_session_data* sd,
  2008. const char* command, const char* message)
  2009. {
  2010. nullpo_retr(-1, sd);
  2011. if (sd->sc.option & OPTION_INVISIBLE) {
  2012. sd->sc.option &= ~OPTION_INVISIBLE;
  2013. if (sd->disguise)
  2014. status_set_viewdata(&sd->bl, sd->disguise);
  2015. else
  2016. status_set_viewdata(&sd->bl, sd->status.class_);
  2017. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  2018. } else {
  2019. sd->sc.option |= OPTION_INVISIBLE;
  2020. sd->vd.class_ = INVISIBLE_CLASS;
  2021. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  2022. }
  2023. clif_changeoption(&sd->bl);
  2024. return 0;
  2025. }
  2026. /*==========================================
  2027. * 転職する upperを指定すると転生や養子にもなれる
  2028. *------------------------------------------
  2029. */
  2030. int atcommand_jobchange(
  2031. const int fd, struct map_session_data* sd,
  2032. const char* command, const char* message)
  2033. {
  2034. int job = 0, upper = 0;
  2035. nullpo_retr(-1, sd);
  2036. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  2037. int i, found = 0;
  2038. const struct { char name[16]; int id; } jobs[] = {
  2039. { "novice", 0 },
  2040. { "swordsman", 1 },
  2041. { "mage", 2 },
  2042. { "archer", 3 },
  2043. { "acolyte", 4 },
  2044. { "merchant", 5 },
  2045. { "thief", 6 },
  2046. { "knight", 7 },
  2047. { "priest", 8 },
  2048. { "priestess", 8 },
  2049. { "wizard", 9 },
  2050. { "blacksmith", 10 },
  2051. { "hunter", 11 },
  2052. { "assassin", 12 },
  2053. { "crusader", 14 },
  2054. { "monk", 15 },
  2055. { "sage", 16 },
  2056. { "rogue", 17 },
  2057. { "alchemist", 18 },
  2058. { "bard", 19 },
  2059. { "dancer", 20 },
  2060. { "super novice", 23 },
  2061. { "supernovice", 23 },
  2062. { "gunslinger", 24 },
  2063. { "gunner", 24 },
  2064. { "ninja", 25 },
  2065. { "high novice", 4001 },
  2066. { "swordsman high", 4002 },
  2067. { "mage high", 4003 },
  2068. { "archer high", 4004 },
  2069. { "acolyte high", 4005 },
  2070. { "merchant high", 4006 },
  2071. { "thief high", 4007 },
  2072. { "lord knight", 4008 },
  2073. { "high priest", 4009 },
  2074. { "high priestess", 4009 },
  2075. { "high wizard", 4010 },
  2076. { "whitesmith", 4011 },
  2077. { "sniper", 4012 },
  2078. { "assassin cross", 4013 },
  2079. { "paladin", 4015 },
  2080. { "champion", 4016 },
  2081. { "professor", 4017 },
  2082. { "stalker", 4018 },
  2083. { "creator", 4019 },
  2084. { "clown", 4020 },
  2085. { "gypsy", 4021 },
  2086. { "baby novice", 4023 },
  2087. { "baby swordsman", 4024 },
  2088. { "baby mage", 4025 },
  2089. { "baby archer", 4026 },
  2090. { "baby acolyte", 4027 },
  2091. { "baby merchant", 4028 },
  2092. { "baby thief", 4029 },
  2093. { "baby knight", 4030 },
  2094. { "baby priest", 4031 },
  2095. { "baby priestess", 4031 },
  2096. { "baby wizard", 4032 },
  2097. { "baby blacksmith",4033 },
  2098. { "baby hunter", 4034 },
  2099. { "baby assassin", 4035 },
  2100. { "baby crusader", 4037 },
  2101. { "baby monk", 4038 },
  2102. { "baby sage", 4039 },
  2103. { "baby rogue", 4040 },
  2104. { "baby alchemist", 4041 },
  2105. { "baby bard", 4042 },
  2106. { "baby dancer", 4043 },
  2107. { "super baby", 4045 },
  2108. { "taekwon", 4046 },
  2109. { "taekwon boy", 4046 },
  2110. { "taekwon girl", 4046 },
  2111. { "star gladiator", 4047 },
  2112. { "soul linker", 4049 },
  2113. };
  2114. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2115. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2116. job = jobs[i].id;
  2117. upper = 0;
  2118. found = 1;
  2119. break;
  2120. }
  2121. }
  2122. if (!found) {
  2123. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2124. return -1;
  2125. }
  2126. }
  2127. if (job == 37 ||job == 45)
  2128. return 0;
  2129. if ((job >= 0 && job < MAX_PC_CLASS))
  2130. {
  2131. int j;
  2132. for (j=0; j < MAX_INVENTORY; j++) {
  2133. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2134. pc_unequipitem(sd, j, 3);
  2135. }
  2136. if (pc_jobchange(sd, job, upper) == 0)
  2137. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  2138. else {
  2139. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  2140. return -1;
  2141. }
  2142. } else {
  2143. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2144. return -1;
  2145. }
  2146. return 0;
  2147. }
  2148. /*==========================================
  2149. *
  2150. *------------------------------------------
  2151. */
  2152. int atcommand_die(
  2153. const int fd, struct map_session_data* sd,
  2154. const char* command, const char* message)
  2155. {
  2156. nullpo_retr(-1, sd);
  2157. clif_specialeffect(&sd->bl,450,SELF);
  2158. status_kill(&sd->bl);
  2159. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  2160. return 0;
  2161. }
  2162. /*==========================================
  2163. *
  2164. *------------------------------------------
  2165. */
  2166. int atcommand_kill(
  2167. const int fd, struct map_session_data* sd,
  2168. const char* command, const char* message)
  2169. {
  2170. struct map_session_data *pl_sd;
  2171. nullpo_retr(-1, sd);
  2172. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2173. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2174. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2175. return -1;
  2176. }
  2177. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2178. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2179. status_kill(&pl_sd->bl);
  2180. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  2181. } else {
  2182. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2183. return -1;
  2184. }
  2185. } else {
  2186. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2187. return -1;
  2188. }
  2189. return 0;
  2190. }
  2191. /*==========================================
  2192. *
  2193. *------------------------------------------
  2194. */
  2195. int atcommand_alive(
  2196. const int fd, struct map_session_data* sd,
  2197. const char* command, const char* message)
  2198. {
  2199. nullpo_retr(-1, sd);
  2200. if (!status_revive(&sd->bl, 100, 100))
  2201. return -1;
  2202. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2203. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  2204. return 0;
  2205. }
  2206. /*==========================================
  2207. * +kamic [LuzZza]
  2208. *------------------------------------------
  2209. */
  2210. int atcommand_kami(
  2211. const int fd, struct map_session_data* sd,
  2212. const char* command, const char* message)
  2213. {
  2214. unsigned long color=0;
  2215. nullpo_retr(-1, sd);
  2216. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2217. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2218. if (!message || !*message) {
  2219. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2220. return -1;
  2221. }
  2222. sscanf(message, "%199[^\n]", atcmd_output);
  2223. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2224. } else {
  2225. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2226. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2227. return -1;
  2228. }
  2229. if(color > 0xFFFFFF) {
  2230. clif_displaymessage(fd, "Invalid color.");
  2231. return -1;
  2232. }
  2233. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2234. }
  2235. return 0;
  2236. }
  2237. /*==========================================
  2238. *
  2239. *------------------------------------------
  2240. */
  2241. int atcommand_heal(
  2242. const int fd, struct map_session_data* sd,
  2243. const char* command, const char* message)
  2244. {
  2245. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2246. nullpo_retr(-1, sd);
  2247. sscanf(message, "%d %d", &hp, &sp);
  2248. if (hp == 0 && sp == 0) {
  2249. if (!status_percent_heal(&sd->bl, 100, 100))
  2250. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2251. else
  2252. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2253. return 0;
  2254. }
  2255. if(hp > 0 && sp >= 0) {
  2256. if(!status_heal(&sd->bl, hp, sp, 0))
  2257. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2258. else
  2259. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2260. return 0;
  2261. }
  2262. if(hp < 0 && sp <= 0) {
  2263. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2264. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2265. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2266. return 0;
  2267. }
  2268. //Opposing signs.
  2269. if (hp) {
  2270. if (hp > 0)
  2271. status_heal(&sd->bl, hp, 0, 0);
  2272. else {
  2273. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2274. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2275. }
  2276. }
  2277. if (sp) {
  2278. if (sp > 0)
  2279. status_heal(&sd->bl, 0, sp, 0);
  2280. else
  2281. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2282. }
  2283. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2284. return 0;
  2285. }
  2286. /*==========================================
  2287. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2288. *------------------------------------------
  2289. */
  2290. int atcommand_item(
  2291. const int fd, struct map_session_data* sd,
  2292. const char* command, const char* message)
  2293. {
  2294. char item_name[100];
  2295. int number = 0, item_id, flag;
  2296. struct item item_tmp;
  2297. struct item_data *item_data;
  2298. int get_count, i;
  2299. nullpo_retr(-1, sd);
  2300. memset(item_name, '\0', sizeof(item_name));
  2301. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2302. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2303. return -1;
  2304. }
  2305. if (number <= 0)
  2306. number = 1;
  2307. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2308. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2309. {
  2310. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2311. return -1;
  2312. }
  2313. item_id = item_data->nameid;
  2314. get_count = number;
  2315. //Check if it's stackable.
  2316. if (!itemdb_isstackable2(item_data))
  2317. get_count = 1;
  2318. for (i = 0; i < number; i += get_count) {
  2319. // if not pet egg
  2320. if (!pet_create_egg(sd, item_id)) {
  2321. memset(&item_tmp, 0, sizeof(item_tmp));
  2322. item_tmp.nameid = item_id;
  2323. item_tmp.identify = 1;
  2324. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2325. clif_additem(sd, 0, 0, flag);
  2326. }
  2327. }
  2328. //Logs (A)dmins items [Lupus]
  2329. if(log_config.enable_logs&0x400)
  2330. log_pick(sd, "A", 0, item_id, number, NULL);
  2331. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2332. return 0;
  2333. }
  2334. /*==========================================
  2335. *
  2336. *------------------------------------------
  2337. */
  2338. int atcommand_item2(
  2339. const int fd, struct map_session_data* sd,
  2340. const char* command, const char* message)
  2341. {
  2342. struct item item_tmp;
  2343. struct item_data *item_data;
  2344. char item_name[100];
  2345. int item_id, number = 0;
  2346. int identify = 0, refine = 0, attr = 0;
  2347. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2348. int flag;
  2349. int loop, get_count, i;
  2350. nullpo_retr(-1, sd);
  2351. memset(item_name, '\0', sizeof(item_name));
  2352. 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) {
  2353. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2354. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2355. return -1;
  2356. }
  2357. if (number <= 0)
  2358. number = 1;
  2359. item_id = 0;
  2360. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2361. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2362. item_id = item_data->nameid;
  2363. if (item_id > 500) {
  2364. loop = 1;
  2365. get_count = number;
  2366. if (item_data->type == 4 || item_data->type == 5 ||
  2367. item_data->type == 7 || item_data->type == 8) {
  2368. loop = number;
  2369. get_count = 1;
  2370. if (item_data->type == 7) {
  2371. identify = 1;
  2372. refine = 0;
  2373. }
  2374. if (item_data->type == 8)
  2375. refine = 0;
  2376. if (refine > 10)
  2377. refine = 10;
  2378. } else {
  2379. identify = 1;
  2380. refine = attr = 0;
  2381. }
  2382. for (i = 0; i < loop; i++) {
  2383. memset(&item_tmp, 0, sizeof(item_tmp));
  2384. item_tmp.nameid = item_id;
  2385. item_tmp.identify = identify;
  2386. item_tmp.refine = refine;
  2387. item_tmp.attribute = attr;
  2388. item_tmp.card[0] = c1;
  2389. item_tmp.card[1] = c2;
  2390. item_tmp.card[2] = c3;
  2391. item_tmp.card[3] = c4;
  2392. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2393. clif_additem(sd, 0, 0, flag);
  2394. }
  2395. //Logs (A)dmins items [Lupus]
  2396. if(log_config.enable_logs&0x400)
  2397. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2398. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2399. } else {
  2400. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2401. return -1;
  2402. }
  2403. return 0;
  2404. }
  2405. /*==========================================
  2406. *
  2407. *------------------------------------------
  2408. */
  2409. int atcommand_itemreset(
  2410. const int fd, struct map_session_data* sd,
  2411. const char* command, const char* message)
  2412. {
  2413. int i;
  2414. nullpo_retr(-1, sd);
  2415. for (i = 0; i < MAX_INVENTORY; i++) {
  2416. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2417. //Logs (A)dmins items [Lupus]
  2418. if(log_config.enable_logs&0x400)
  2419. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2420. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2421. }
  2422. }
  2423. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  2424. return 0;
  2425. }
  2426. /*==========================================
  2427. * Atcommand @lvlup
  2428. *------------------------------------------
  2429. */
  2430. int atcommand_baselevelup(
  2431. const int fd, struct map_session_data* sd,
  2432. const char* command, const char* message)
  2433. {
  2434. int level=0, i=0, status_point=0;
  2435. nullpo_retr(-1, sd);
  2436. level = atoi(message);
  2437. if (!message || !*message || !level) {
  2438. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2439. return -1;
  2440. }
  2441. if (level > 0) {
  2442. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2443. clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
  2444. return -1;
  2445. } /* End Addition */
  2446. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2447. level = pc_maxbaselv(sd) - sd->status.base_level;
  2448. for (i = 1; i <= level; i++)
  2449. status_point += (sd->status.base_level + i + 14) / 5;
  2450. if (sd->status.status_point > USHRT_MAX - status_point)
  2451. sd->status.status_point = USHRT_MAX;
  2452. else
  2453. sd->status.status_point += status_point;
  2454. sd->status.base_level += (unsigned int)level;
  2455. clif_updatestatus(sd, SP_BASELEVEL);
  2456. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2457. clif_updatestatus(sd, SP_STATUSPOINT);
  2458. status_calc_pc(sd, 0);
  2459. status_percent_heal(&sd->bl, 100, 100);
  2460. clif_misceffect(&sd->bl, 0);
  2461. clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
  2462. } else {
  2463. if (sd->status.base_level == 1) {
  2464. clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
  2465. return -1;
  2466. }
  2467. level*=-1;
  2468. if ((unsigned int)level >= sd->status.base_level)
  2469. level = sd->status.base_level-1;
  2470. if (sd->status.status_point > 0) {
  2471. for (i = 0; i > -level; i--)
  2472. status_point += (sd->status.base_level + i + 14) / 5;
  2473. if (sd->status.status_point < status_point)
  2474. pc_resetstate(sd);
  2475. if (sd->status.status_point < status_point)
  2476. sd->status.status_point = 0;
  2477. else
  2478. sd->status.status_point -= status_point;
  2479. clif_updatestatus(sd, SP_STATUSPOINT);
  2480. } /* to add: remove status points from stats */
  2481. sd->status.base_level -= (unsigned int)level;
  2482. clif_updatestatus(sd, SP_BASELEVEL);
  2483. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2484. status_calc_pc(sd, 0);
  2485. clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
  2486. }
  2487. return 0;
  2488. }
  2489. /*==========================================
  2490. *
  2491. *------------------------------------------
  2492. */
  2493. int atcommand_joblevelup(
  2494. const int fd, struct map_session_data* sd,
  2495. const char* command, const char* message)
  2496. {
  2497. int level=0;
  2498. nullpo_retr(-1, sd);
  2499. level = atoi(message);
  2500. if (!message || !*message || !level) {
  2501. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2502. return -1;
  2503. }
  2504. if (level > 0) {
  2505. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2506. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  2507. return -1;
  2508. }
  2509. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2510. level = pc_maxjoblv(sd) - sd->status.job_level;
  2511. sd->status.job_level += (unsigned int)level;
  2512. clif_updatestatus(sd, SP_JOBLEVEL);
  2513. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2514. if (sd->status.skill_point > USHRT_MAX - level)
  2515. sd->status.skill_point = USHRT_MAX;
  2516. else
  2517. sd->status.skill_point += level;
  2518. clif_updatestatus(sd, SP_SKILLPOINT);
  2519. status_calc_pc(sd, 0);
  2520. clif_misceffect(&sd->bl, 1);
  2521. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  2522. } else {
  2523. if (sd->status.job_level == 1) {
  2524. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  2525. return -1;
  2526. }
  2527. level *=-1;
  2528. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2529. level = sd->status.job_level-1;
  2530. sd->status.job_level -= (unsigned int)level;
  2531. clif_updatestatus(sd, SP_JOBLEVEL);
  2532. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2533. if (sd->status.skill_point < level)
  2534. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2535. if (sd->status.skill_point < level)
  2536. sd->status.skill_point = 0;
  2537. else
  2538. sd->status.skill_point -= level;
  2539. clif_updatestatus(sd, SP_SKILLPOINT);
  2540. status_calc_pc(sd, 0);
  2541. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  2542. }
  2543. return 0;
  2544. }
  2545. /*==========================================
  2546. * @help
  2547. *------------------------------------------
  2548. */
  2549. int atcommand_help(
  2550. const int fd, struct map_session_data* sd,
  2551. const char* command, const char* message)
  2552. {
  2553. char buf[2048], w1[2048], w2[2048];
  2554. int i, gm_level;
  2555. FILE* fp;
  2556. nullpo_retr(-1, sd);
  2557. memset(buf, '\0', sizeof(buf));
  2558. if ((fp = fopen(help_txt, "r")) != NULL) {
  2559. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2560. gm_level = pc_isGM(sd);
  2561. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2562. if (buf[0] == '/' && buf[1] == '/')
  2563. continue;
  2564. for (i = 0; buf[i] != '\0'; i++) {
  2565. if (buf[i] == '\r' || buf[i] == '\n') {
  2566. buf[i] = '\0';
  2567. break;
  2568. }
  2569. }
  2570. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2571. clif_displaymessage(fd, buf);
  2572. else if (gm_level >= atoi(w1))
  2573. clif_displaymessage(fd, w2);
  2574. }
  2575. fclose(fp);
  2576. } else {
  2577. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2578. return -1;
  2579. }
  2580. return 0;
  2581. }
  2582. /*==========================================
  2583. * @help2 - Char commands [Kayla]
  2584. *------------------------------------------
  2585. */
  2586. int atcommand_help2(
  2587. const int fd, struct map_session_data* sd,
  2588. const char* command, const char* message)
  2589. {
  2590. char buf[2048], w1[2048], w2[2048];
  2591. int i, gm_level;
  2592. FILE* fp;
  2593. nullpo_retr(-1, sd);
  2594. memset(buf, '\0', sizeof(buf));
  2595. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2596. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2597. gm_level = pc_isGM(sd);
  2598. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2599. if (buf[0] == '/' && buf[1] == '/')
  2600. continue;
  2601. for (i = 0; buf[i] != '\0'; i++) {
  2602. if (buf[i] == '\r' || buf[i] == '\n') {
  2603. buf[i] = '\0';
  2604. break;
  2605. }
  2606. }
  2607. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2608. clif_displaymessage(fd, buf);
  2609. else if (gm_level >= atoi(w1))
  2610. clif_displaymessage(fd, w2);
  2611. }
  2612. fclose(fp);
  2613. } else {
  2614. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2615. return -1;
  2616. }
  2617. return 0;
  2618. }
  2619. /*==========================================
  2620. * @gm
  2621. *------------------------------------------
  2622. */
  2623. int atcommand_gm(
  2624. const int fd, struct map_session_data* sd,
  2625. const char* command, const char* message)
  2626. {
  2627. char password[100];
  2628. nullpo_retr(-1, sd);
  2629. memset(password, '\0', sizeof(password));
  2630. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2631. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2632. return -1;
  2633. }
  2634. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2635. clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
  2636. return -1;
  2637. } else
  2638. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2639. return 0;
  2640. }
  2641. /*==========================================
  2642. *
  2643. *------------------------------------------
  2644. */
  2645. int atcommand_pvpoff(
  2646. const int fd, struct map_session_data* sd,
  2647. const char* command, const char* message)
  2648. {
  2649. struct map_session_data *pl_sd, **pl_allsd;
  2650. int i, users;
  2651. nullpo_retr(-1, sd);
  2652. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2653. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2654. return -1;
  2655. }
  2656. if (map[sd->bl.m].flag.pvp) {
  2657. map[sd->bl.m].flag.pvp = 0;
  2658. clif_send0199(sd->bl.m, 0);
  2659. pl_allsd = map_getallusers(&users);
  2660. for (i = 0; i < users; i++) { //人数分ループ
  2661. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2662. clif_pvpset(pl_sd, 0, 0, 2);
  2663. if (pl_sd->pvp_timer != -1) {
  2664. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2665. pl_sd->pvp_timer = -1;
  2666. }
  2667. }
  2668. }
  2669. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2670. } else {
  2671. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2672. return -1;
  2673. }
  2674. return 0;
  2675. }
  2676. /*==========================================
  2677. *
  2678. *------------------------------------------
  2679. */
  2680. int atcommand_pvpon(
  2681. const int fd, struct map_session_data* sd,
  2682. const char* command, const char* message)
  2683. {
  2684. struct map_session_data *pl_sd, **pl_allsd;
  2685. int i, users;
  2686. nullpo_retr(-1, sd);
  2687. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2688. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2689. return -1;
  2690. }
  2691. if (!map[sd->bl.m].flag.pvp) {
  2692. map[sd->bl.m].flag.pvp = 1;
  2693. clif_send0199(sd->bl.m, 1);
  2694. pl_allsd = map_getallusers(&users);
  2695. for (i = 0; i < users; i++) {
  2696. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2697. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2698. pl_sd->pvp_rank = 0;
  2699. pl_sd->pvp_lastusers = 0;
  2700. pl_sd->pvp_point = 5;
  2701. pl_sd->pvp_won = 0;
  2702. pl_sd->pvp_lost = 0;
  2703. }
  2704. }
  2705. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2706. } else {
  2707. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2708. return -1;
  2709. }
  2710. return 0;
  2711. }
  2712. /*==========================================
  2713. *
  2714. *------------------------------------------
  2715. */
  2716. int atcommand_gvgoff(
  2717. const int fd, struct map_session_data* sd,
  2718. const char* command, const char* message)
  2719. {
  2720. nullpo_retr(-1, sd);
  2721. if (map[sd->bl.m].flag.gvg) {
  2722. map[sd->bl.m].flag.gvg = 0;
  2723. clif_send0199(sd->bl.m, 0);
  2724. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2725. } else {
  2726. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2727. return -1;
  2728. }
  2729. return 0;
  2730. }
  2731. /*==========================================
  2732. *
  2733. *------------------------------------------
  2734. */
  2735. int atcommand_gvgon(
  2736. const int fd, struct map_session_data* sd,
  2737. const char* command, const char* message)
  2738. {
  2739. nullpo_retr(-1, sd);
  2740. if (!map[sd->bl.m].flag.gvg) {
  2741. map[sd->bl.m].flag.gvg = 1;
  2742. clif_send0199(sd->bl.m, 3);
  2743. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2744. } else {
  2745. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2746. return -1;
  2747. }
  2748. return 0;
  2749. }
  2750. /*==========================================
  2751. *
  2752. *------------------------------------------
  2753. */
  2754. int atcommand_model(
  2755. const int fd, struct map_session_data* sd,
  2756. const char* command, const char* message)
  2757. {
  2758. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2759. nullpo_retr(-1, sd);
  2760. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2761. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2762. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2763. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2764. clif_displaymessage(fd, atcmd_output);
  2765. return -1;
  2766. }
  2767. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2768. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2769. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2770. /* Removed because this check is TOO strange. [Skotlex]
  2771. //秒フ色変更
  2772. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2773. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2774. //秒フ色未実装職の判定
  2775. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2776. return -1;
  2777. } else {
  2778. */
  2779. pc_changelook(sd, LOOK_HAIR, hair_style);
  2780. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2781. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2782. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2783. // }
  2784. } else {
  2785. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2786. return -1;
  2787. }
  2788. return 0;
  2789. }
  2790. /*==========================================
  2791. * @dye && @ccolor
  2792. *------------------------------------------
  2793. */
  2794. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2795. {
  2796. int cloth_color = 0;
  2797. nullpo_retr(-1, sd);
  2798. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2799. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2800. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2801. clif_displaymessage(fd, atcmd_output);
  2802. return -1;
  2803. }
  2804. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2805. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2806. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2807. } else {
  2808. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2809. return -1;
  2810. }
  2811. return 0;
  2812. }
  2813. /*==========================================
  2814. * @hairstyle && @hstyle
  2815. *------------------------------------------
  2816. */
  2817. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2818. {
  2819. int hair_style = 0;
  2820. nullpo_retr(-1, sd);
  2821. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2822. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2823. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2824. clif_displaymessage(fd, atcmd_output);
  2825. return -1;
  2826. }
  2827. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2828. /* Removed because this check is TOO strange. [Skotlex]
  2829. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2830. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2831. return -1;
  2832. } else {
  2833. */
  2834. pc_changelook(sd, LOOK_HAIR, hair_style);
  2835. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2836. // }
  2837. } else {
  2838. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2839. return -1;
  2840. }
  2841. return 0;
  2842. }
  2843. /*==========================================
  2844. * @charhairstyle by [MouseJstr]
  2845. *------------------------------------------
  2846. */
  2847. int
  2848. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2849. const char* command, const char* message)
  2850. {
  2851. nullpo_retr(-1, sd);
  2852. return 0;
  2853. }
  2854. /*==========================================
  2855. * @haircolor && @hcolor
  2856. *------------------------------------------
  2857. */
  2858. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2859. {
  2860. int hair_color = 0;
  2861. nullpo_retr(-1, sd);
  2862. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2863. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2864. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2865. clif_displaymessage(fd, atcmd_output);
  2866. return -1;
  2867. }
  2868. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2869. /* Removed for being such a strange check. [Skotlex]
  2870. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2871. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2872. return -1;
  2873. } else {
  2874. */
  2875. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2876. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2877. // }
  2878. } else {
  2879. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2880. return -1;
  2881. }
  2882. return 0;
  2883. }
  2884. /*==========================================
  2885. * @go [city_number or city_name] - Updated by Harbin
  2886. *------------------------------------------
  2887. */
  2888. int atcommand_go(
  2889. const int fd, struct map_session_data* sd,
  2890. const char* command, const char* message)
  2891. {
  2892. int i;
  2893. int town;
  2894. char map_name[MAP_NAME_LENGTH];
  2895. int m;
  2896. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2897. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2898. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2899. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2900. { MAP_PAYON, 162, 233 }, // 3=Payon
  2901. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2902. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2903. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2904. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2905. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2906. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2907. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2908. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2909. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2910. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2911. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2912. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2913. { MAP_JAIL, 23, 61 }, // 16=Prison
  2914. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2915. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2916. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2917. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2918. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2919. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2920. };
  2921. nullpo_retr(-1, sd);
  2922. if(map[sd->bl.m].flag.nogo) {
  2923. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2924. return 0;
  2925. }
  2926. memset(map_name, '\0', sizeof(map_name));
  2927. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2928. // get the number
  2929. town = atoi(message);
  2930. // if no value, display all value
  2931. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2932. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2933. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  2934. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2935. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2936. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2937. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2938. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2939. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2940. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2941. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2942. return -1;
  2943. } else {
  2944. // get possible name of the city and add .gat if not in the name
  2945. map_name[MAP_NAME_LENGTH-1] = '\0';
  2946. for (i = 0; map_name[i]; i++)
  2947. map_name[i] = tolower(map_name[i]);
  2948. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2949. strcat(map_name, ".gat");
  2950. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2951. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2952. town = 0;
  2953. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2954. town = 1;
  2955. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2956. town = 2;
  2957. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2958. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2959. town = 3;
  2960. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2961. town = 4;
  2962. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2963. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2964. town = 5;
  2965. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2966. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2967. town = 6;
  2968. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2969. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2970. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2971. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2972. town = 7;
  2973. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2974. town = 8;
  2975. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2976. town = 9;
  2977. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2978. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2979. town = 10;
  2980. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2981. town = 11;
  2982. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2983. town = 12;
  2984. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2985. town = 13;
  2986. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2987. town = 14;
  2988. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2989. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2990. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2991. town = 15;
  2992. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2993. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2994. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2995. town = 16;
  2996. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2997. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2998. town = 17;
  2999. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  3000. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  3001. town = 18;
  3002. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  3003. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  3004. town = 19;
  3005. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  3006. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  3007. town = 20;
  3008. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  3009. town = 21;
  3010. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  3011. town = 22;
  3012. }
  3013. if (town >= -3 && town <= -1) {
  3014. if (sd->status.memo_point[-town-1].map) {
  3015. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  3016. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3017. clif_displaymessage(fd, msg_txt(247));
  3018. return -1;
  3019. }
  3020. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3021. clif_displaymessage(fd, msg_txt(248));
  3022. return -1;
  3023. }
  3024. 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) {
  3025. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3026. } else {
  3027. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3028. return -1;
  3029. }
  3030. } else {
  3031. sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
  3032. clif_displaymessage(fd, atcmd_output);
  3033. return -1;
  3034. }
  3035. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  3036. m = map_mapname2mapid((char *)data[town].map);
  3037. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3038. clif_displaymessage(fd, msg_txt(247));
  3039. return -1;
  3040. }
  3041. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3042. clif_displaymessage(fd, msg_txt(248));
  3043. return -1;
  3044. }
  3045. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  3046. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3047. } else {
  3048. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3049. return -1;
  3050. }
  3051. } else { // if you arrive here, you have an error in town variable when reading of names
  3052. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  3053. return -1;
  3054. }
  3055. }
  3056. return 0;
  3057. }
  3058. /*==========================================
  3059. *
  3060. *------------------------------------------
  3061. */
  3062. int atcommand_monster(
  3063. const int fd, struct map_session_data* sd,
  3064. const char* command, const char* message)
  3065. {
  3066. char name[NAME_LENGTH];
  3067. char monster[NAME_LENGTH];
  3068. int mob_id;
  3069. int number = 0;
  3070. int count;
  3071. int i, k, range;
  3072. short mx, my;
  3073. nullpo_retr(-1, sd);
  3074. memset(name, '\0', sizeof(name));
  3075. memset(monster, '\0', sizeof(monster));
  3076. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3077. if (!message || !*message) {
  3078. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3079. return -1;
  3080. }
  3081. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3082. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3083. //All data can be left as it is.
  3084. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3085. //Here, it is possible name was not given and we are using monster for it.
  3086. if (count < 3) //Blank mob's name.
  3087. name[0] = '\0';
  3088. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3089. //All data can be left as it is.
  3090. } else if (sscanf(message, "%23s", monster) > 0) {
  3091. //As before, name may be already filled.
  3092. name[0] = '\0';
  3093. } else {
  3094. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3095. return -1;
  3096. }
  3097. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3098. mob_id = mobdb_checkid(atoi(monster));
  3099. if (mob_id == 0) {
  3100. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3101. return -1;
  3102. }
  3103. if (mob_id == MOBID_EMPERIUM) {
  3104. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  3105. return -1;
  3106. }
  3107. if (number <= 0)
  3108. number = 1;
  3109. if (strlen(name) < 1)
  3110. strcpy(name, "--ja--");
  3111. // 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
  3112. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3113. number = battle_config.atc_spawn_quantity_limit;
  3114. if (battle_config.etc_log)
  3115. 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);
  3116. count = 0;
  3117. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3118. for (i = 0; i < number; i++) {
  3119. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3120. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3121. count += (k != 0) ? 1 : 0;
  3122. }
  3123. if (count != 0)
  3124. if (number == count)
  3125. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  3126. else {
  3127. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  3128. clif_displaymessage(fd, atcmd_output);
  3129. }
  3130. else {
  3131. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3132. return -1;
  3133. }
  3134. return 0;
  3135. }
  3136. // small monster spawning [Valaris]
  3137. int atcommand_monstersmall(
  3138. const int fd, struct map_session_data* sd,
  3139. const char* command, const char* message) {
  3140. char name[NAME_LENGTH] = "";
  3141. char monster[NAME_LENGTH] = "";
  3142. int mob_id = 0;
  3143. int number = 0;
  3144. int x = 0;
  3145. int y = 0;
  3146. int count;
  3147. int i;
  3148. nullpo_retr(-1, sd);
  3149. if (!message || !*message) {
  3150. clif_displaymessage(fd, "Give a monster name/id please.");
  3151. return -1;
  3152. }
  3153. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3154. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3155. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3156. clif_displaymessage(fd, "Give a monster name/id please.");
  3157. return -1;
  3158. }
  3159. // If monster identifier/name argument is a name
  3160. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3161. mob_id = atoi(monster);
  3162. if (mob_id == 0) {
  3163. clif_displaymessage(fd, msg_txt(40));
  3164. return -1;
  3165. }
  3166. if (mob_id == MOBID_EMPERIUM) {
  3167. clif_displaymessage(fd, msg_txt(83));
  3168. return -1;
  3169. }
  3170. if (mobdb_checkid(mob_id) == 0) {
  3171. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3172. return -1;
  3173. }
  3174. if (number <= 0)
  3175. number = 1;
  3176. if (strlen(name) < 1)
  3177. strcpy(name, "--ja--");
  3178. // 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
  3179. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3180. number = battle_config.atc_spawn_quantity_limit;
  3181. count = 0;
  3182. for (i = 0; i < number; i++) {
  3183. int mx, my;
  3184. if (x <= 0)
  3185. mx = sd->bl.x + (rand() % 11 - 5);
  3186. else
  3187. mx = x;
  3188. if (y <= 0)
  3189. my = sd->bl.y + (rand() % 11 - 5);
  3190. else
  3191. my = y;
  3192. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3193. }
  3194. if (count != 0)
  3195. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3196. else
  3197. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3198. return 0;
  3199. }
  3200. // big monster spawning [Valaris]
  3201. int atcommand_monsterbig(
  3202. const int fd, struct map_session_data* sd,
  3203. const char* command, const char* message) {
  3204. char name[NAME_LENGTH] = "";
  3205. char monster[NAME_LENGTH] = "";
  3206. int mob_id = 0;
  3207. int number = 0;
  3208. int x = 0;
  3209. int y = 0;
  3210. int count;
  3211. int i;
  3212. nullpo_retr(-1, sd);
  3213. if (!message || !*message) {
  3214. clif_displaymessage(fd, "Give a monster name/id please.");
  3215. return -1;
  3216. }
  3217. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3218. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3219. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3220. clif_displaymessage(fd, "Give a monster name/id please.");
  3221. return -1;
  3222. }
  3223. // If monster identifier/name argument is a name
  3224. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3225. mob_id = atoi(monster);
  3226. if (mob_id == 0) {
  3227. clif_displaymessage(fd, msg_txt(40));
  3228. return -1;
  3229. }
  3230. if (mob_id == MOBID_EMPERIUM) {
  3231. clif_displaymessage(fd, msg_txt(83));
  3232. return -1;
  3233. }
  3234. if (mobdb_checkid(mob_id) == 0) {
  3235. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3236. return -1;
  3237. }
  3238. if (number <= 0)
  3239. number = 1;
  3240. if (strlen(name) < 1)
  3241. strcpy(name, "--ja--");
  3242. // 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
  3243. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3244. number = battle_config.atc_spawn_quantity_limit;
  3245. count = 0;
  3246. for (i = 0; i < number; i++) {
  3247. int mx, my;
  3248. if (x <= 0)
  3249. mx = sd->bl.x + (rand() % 11 - 5);
  3250. else
  3251. mx = x;
  3252. if (y <= 0)
  3253. my = sd->bl.y + (rand() % 11 - 5);
  3254. else
  3255. my = y;
  3256. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3257. }
  3258. if (count != 0)
  3259. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3260. else
  3261. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3262. return 0;
  3263. }
  3264. /*==========================================
  3265. *
  3266. *------------------------------------------
  3267. */
  3268. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3269. struct mob_data *md;
  3270. int flag;
  3271. nullpo_retr(0, ap);
  3272. nullpo_retr(0, md=(struct mob_data *)bl);
  3273. flag = va_arg(ap, int);
  3274. if (md->guardian_data)
  3275. return 0; //Do not touch WoE mobs!
  3276. if (flag)
  3277. status_kill(bl);
  3278. else //FIXME: Eh.. what exactly is the difference here?
  3279. status_kill(bl);
  3280. return 1;
  3281. }
  3282. void atcommand_killmonster_sub(
  3283. const int fd, struct map_session_data* sd, const char* message,
  3284. const int drop)
  3285. {
  3286. int map_id;
  3287. char map_name[MAP_NAME_LENGTH];
  3288. if (!sd) return;
  3289. memset(map_name, '\0', sizeof(map_name));
  3290. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3291. map_id = sd->bl.m;
  3292. else {
  3293. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3294. strcat(map_name, ".gat");
  3295. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3296. map_id = sd->bl.m;
  3297. }
  3298. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3299. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  3300. return;
  3301. }
  3302. /*==========================================
  3303. *
  3304. *------------------------------------------
  3305. */
  3306. int atcommand_killmonster(
  3307. const int fd, struct map_session_data* sd,
  3308. const char* command, const char* message)
  3309. {
  3310. if (!sd) return 0;
  3311. atcommand_killmonster_sub(fd, sd, message, 1);
  3312. return 0;
  3313. }
  3314. /*==========================================
  3315. *
  3316. *------------------------------------------
  3317. */
  3318. int atcommand_killmonster2(
  3319. const int fd, struct map_session_data* sd,
  3320. const char* command, const char* message)
  3321. {
  3322. if (!sd) return 0;
  3323. atcommand_killmonster_sub(fd, sd, message, 0);
  3324. return 0;
  3325. }
  3326. /*==========================================
  3327. *
  3328. *------------------------------------------
  3329. */
  3330. int atcommand_refine(
  3331. const int fd, struct map_session_data* sd,
  3332. const char* command, const char* message)
  3333. {
  3334. int i,j, position = 0, refine = 0, current_position, final_refine;
  3335. int count;
  3336. nullpo_retr(-1, sd);
  3337. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3338. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3339. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3340. return -1;
  3341. }
  3342. if (refine < -MAX_REFINE)
  3343. refine = -MAX_REFINE;
  3344. else if (refine > MAX_REFINE)
  3345. refine = MAX_REFINE;
  3346. else if (refine == 0)
  3347. refine = 1;
  3348. count = 0;
  3349. for (j = 0; j < EQI_MAX-1; j++) {
  3350. if ((i = sd->equip_index[j]) < 0)
  3351. continue;
  3352. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  3353. continue;
  3354. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  3355. continue;
  3356. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  3357. continue;
  3358. if(position && !(sd->status.inventory[i].equip & position))
  3359. continue;
  3360. final_refine = sd->status.inventory[i].refine + refine;
  3361. if (final_refine > MAX_REFINE)
  3362. final_refine = MAX_REFINE;
  3363. else if (final_refine < 0)
  3364. final_refine = 0;
  3365. if (sd->status.inventory[i].refine != final_refine) {
  3366. sd->status.inventory[i].refine = final_refine;
  3367. current_position = sd->status.inventory[i].equip;
  3368. pc_unequipitem(sd, i, 3);
  3369. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3370. clif_delitem(sd, i, 1);
  3371. clif_additem(sd, i, 1, 0);
  3372. pc_equipitem(sd, i, current_position);
  3373. clif_misceffect(&sd->bl, 3);
  3374. count++;
  3375. }
  3376. }
  3377. if (count == 0)
  3378. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  3379. else if (count == 1)
  3380. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  3381. else {
  3382. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  3383. clif_displaymessage(fd, atcmd_output);
  3384. }
  3385. return 0;
  3386. }
  3387. /*==========================================
  3388. *
  3389. *------------------------------------------
  3390. */
  3391. int atcommand_produce(
  3392. const int fd, struct map_session_data* sd,
  3393. const char* command, const char* message)
  3394. {
  3395. char item_name[100];
  3396. int item_id, attribute = 0, star = 0;
  3397. int flag = 0;
  3398. struct item_data *item_data;
  3399. struct item tmp_item;
  3400. nullpo_retr(-1, sd);
  3401. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3402. memset(item_name, '\0', sizeof(item_name));
  3403. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3404. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3405. return -1;
  3406. }
  3407. item_id = 0;
  3408. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  3409. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  3410. {
  3411. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  3412. clif_displaymessage(fd, atcmd_output);
  3413. return -1;
  3414. }
  3415. item_id = item_data->nameid;
  3416. if (itemdb_isequip2(item_data)) {
  3417. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3418. attribute = ATTRIBUTE_NORMAL;
  3419. if (star < MIN_STAR || star > MAX_STAR)
  3420. star = 0;
  3421. memset(&tmp_item, 0, sizeof tmp_item);
  3422. tmp_item.nameid = item_id;
  3423. tmp_item.amount = 1;
  3424. tmp_item.identify = 1;
  3425. tmp_item.card[0] = CARD0_FORGE;
  3426. tmp_item.card[1] = item_data->type==IT_WEAPON?
  3427. ((star*5) << 8) + attribute:0;
  3428. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3429. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3430. clif_produceeffect(sd, 0, item_id);
  3431. clif_misceffect(&sd->bl, 3);
  3432. //Logs (A)dmins items [Lupus]
  3433. if(log_config.enable_logs&0x400)
  3434. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3435. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3436. clif_additem(sd, 0, 0, flag);
  3437. } else {
  3438. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3439. clif_displaymessage(fd, atcmd_output);
  3440. return -1;
  3441. }
  3442. return 0;
  3443. }
  3444. /*==========================================
  3445. * Sub-function to display actual memo points
  3446. *------------------------------------------
  3447. */
  3448. void atcommand_memo_sub(struct map_session_data* sd) {
  3449. int i;
  3450. if (!sd) return;
  3451. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3452. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3453. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3454. if (sd->status.memo_point[i].map)
  3455. 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);
  3456. else
  3457. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  3458. clif_displaymessage(sd->fd, atcmd_output);
  3459. }
  3460. return;
  3461. }
  3462. /*==========================================
  3463. *
  3464. *------------------------------------------
  3465. */
  3466. int atcommand_memo(
  3467. const int fd, struct map_session_data* sd,
  3468. const char* command, const char* message)
  3469. {
  3470. int position = 0;
  3471. nullpo_retr(-1, sd);
  3472. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3473. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3474. atcommand_memo_sub(sd);
  3475. else {
  3476. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3477. 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)) {
  3478. clif_displaymessage(fd, msg_txt(253));
  3479. return -1;
  3480. }
  3481. if (sd->status.memo_point[position].map) {
  3482. 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).
  3483. clif_displaymessage(fd, atcmd_output);
  3484. }
  3485. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3486. sd->status.memo_point[position].x = sd->bl.x;
  3487. sd->status.memo_point[position].y = sd->bl.y;
  3488. clif_skill_memo(sd, 0);
  3489. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3490. clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
  3491. atcommand_memo_sub(sd);
  3492. } else {
  3493. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3494. clif_displaymessage(fd, atcmd_output);
  3495. atcommand_memo_sub(sd);
  3496. return -1;
  3497. }
  3498. }
  3499. return 0;
  3500. }
  3501. /*==========================================
  3502. *
  3503. *------------------------------------------
  3504. */
  3505. int atcommand_gat(
  3506. const int fd, struct map_session_data* sd,
  3507. const char* command, const char* message)
  3508. {
  3509. int y;
  3510. nullpo_retr(-1, sd);
  3511. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3512. for (y = 2; y >= -2; y--) {
  3513. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3514. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3515. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3516. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3517. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3518. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3519. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3520. clif_displaymessage(fd, atcmd_output);
  3521. }
  3522. return 0;
  3523. }
  3524. /*==========================================
  3525. *
  3526. *------------------------------------------
  3527. */
  3528. int atcommand_packet(
  3529. const int fd, struct map_session_data* sd,
  3530. const char* command, const char* message)
  3531. {
  3532. static int packet_mode = 0;
  3533. int i, x = 0, y = 0;
  3534. nullpo_retr(-1, sd);
  3535. if (strstr(command, "packetmode")) {
  3536. packet_mode = atoi(message);
  3537. clif_displaymessage(fd, "Packet mode changed.");
  3538. return 0;
  3539. }
  3540. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3541. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3542. return -1;
  3543. }
  3544. if (i == 1) y = 1;
  3545. switch (packet_mode)
  3546. {
  3547. case 0:
  3548. clif_status_change(&sd->bl, x, y);
  3549. break;
  3550. case 1:
  3551. sd->status.skill[sd->cloneskill_id].id=0;
  3552. sd->status.skill[sd->cloneskill_id].lv=0;
  3553. sd->status.skill[sd->cloneskill_id].flag=0;
  3554. sd->cloneskill_id = x;
  3555. sd->status.skill[x].id = x;
  3556. sd->status.skill[x].lv = skill_get_max(x);
  3557. sd->status.skill[x].flag = 13;//cloneskill flag
  3558. clif_skillinfoblock(sd);
  3559. break;
  3560. case 2:
  3561. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3562. case 3:
  3563. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3564. default:
  3565. break;
  3566. //added later
  3567. }
  3568. return 0;
  3569. }
  3570. /*==========================================
  3571. * @waterlevel [Skotlex]
  3572. *------------------------------------------
  3573. */
  3574. int atcommand_waterlevel(
  3575. const int fd, struct map_session_data* sd,
  3576. const char* command, const char* message)
  3577. {
  3578. int newlevel;
  3579. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3580. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3581. clif_displaymessage(fd, atcmd_output);
  3582. return 0;
  3583. }
  3584. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3585. if (newlevel > 0)
  3586. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3587. else
  3588. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3589. clif_displaymessage(fd, atcmd_output);
  3590. } else {
  3591. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3592. clif_displaymessage(fd, atcmd_output);
  3593. }
  3594. return 0;
  3595. }
  3596. /*==========================================
  3597. * @stpoint (Rewritten by [Yor])
  3598. *------------------------------------------
  3599. */
  3600. int atcommand_statuspoint(
  3601. const int fd, struct map_session_data* sd,
  3602. const char* command, const char* message)
  3603. {
  3604. int point, new_status_point;
  3605. if (!message || !*message || (point = atoi(message)) == 0) {
  3606. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3607. return -1;
  3608. }
  3609. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3610. new_status_point = USHRT_MAX;
  3611. else
  3612. if (point < 0 && sd->status.status_point < -point)
  3613. new_status_point = 0;
  3614. else
  3615. new_status_point = sd->status.status_point + point;
  3616. if (new_status_point != (int)sd->status.status_point) {
  3617. sd->status.status_point = (unsigned short)new_status_point;
  3618. clif_updatestatus(sd, SP_STATUSPOINT);
  3619. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  3620. } else {
  3621. if (point < 0)
  3622. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3623. else
  3624. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3625. return -1;
  3626. }
  3627. return 0;
  3628. }
  3629. /*==========================================
  3630. * @skpoint (Rewritten by [Yor])
  3631. *------------------------------------------
  3632. */
  3633. int atcommand_skillpoint(
  3634. const int fd, struct map_session_data* sd,
  3635. const char* command, const char* message)
  3636. {
  3637. int point, new_skill_point;
  3638. nullpo_retr(-1, sd);
  3639. if (!message || !*message || (point = atoi(message)) == 0) {
  3640. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3641. return -1;
  3642. }
  3643. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3644. new_skill_point = USHRT_MAX;
  3645. else if (point < 0 && sd->status.skill_point < -point)
  3646. new_skill_point = 0;
  3647. else
  3648. new_skill_point = sd->status.skill_point + point;
  3649. if (new_skill_point != (int)sd->status.skill_point) {
  3650. sd->status.skill_point = (unsigned short)new_skill_point;
  3651. clif_updatestatus(sd, SP_SKILLPOINT);
  3652. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  3653. } else {
  3654. if (point < 0)
  3655. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3656. else
  3657. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3658. return -1;
  3659. }
  3660. return 0;
  3661. }
  3662. /*==========================================
  3663. * @zeny (Rewritten by [Yor])
  3664. *------------------------------------------
  3665. */
  3666. int atcommand_zeny(
  3667. const int fd, struct map_session_data* sd,
  3668. const char* command, const char* message)
  3669. {
  3670. int zeny, new_zeny;
  3671. nullpo_retr(-1, sd);
  3672. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3673. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3674. return -1;
  3675. }
  3676. new_zeny = sd->status.zeny + zeny;
  3677. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3678. new_zeny = MAX_ZENY;
  3679. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3680. new_zeny = 0;
  3681. if (new_zeny != sd->status.zeny) {
  3682. sd->status.zeny = new_zeny;
  3683. clif_updatestatus(sd, SP_ZENY);
  3684. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  3685. } else {
  3686. if (zeny < 0)
  3687. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3688. else
  3689. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3690. return -1;
  3691. }
  3692. return 0;
  3693. }
  3694. /*==========================================
  3695. *
  3696. *------------------------------------------
  3697. */
  3698. int atcommand_param(
  3699. const int fd, struct map_session_data* sd,
  3700. const char* command, const char* message)
  3701. {
  3702. int index, value = 0, new_value, max;
  3703. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3704. short* status[6];
  3705. //we don't use direct initialization because it isn't part of the c standard.
  3706. nullpo_retr(-1, sd);
  3707. status[0] = &sd->status.str;
  3708. status[1] = &sd->status.agi;
  3709. status[2] = &sd->status.vit;
  3710. status[3] = &sd->status.int_;
  3711. status[4] = &sd->status.dex;
  3712. status[5] = &sd->status.luk;
  3713. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3714. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3715. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3716. clif_displaymessage(fd, atcmd_output);
  3717. return -1;
  3718. }
  3719. index = -1;
  3720. for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
  3721. if (strcmpi(command, param[index]) == 0)
  3722. break;
  3723. }
  3724. if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
  3725. // normaly impossible...
  3726. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3727. clif_displaymessage(fd, atcmd_output);
  3728. return -1;
  3729. }
  3730. max = pc_maxparameter(sd);
  3731. if (value > 0 && *status[index] > max - value)
  3732. new_value = max;
  3733. else if (value < 0 && *status[index] <= -value)
  3734. new_value = 1;
  3735. else
  3736. new_value = *status[index] + value;
  3737. if (new_value != (int)*status[index]) {
  3738. *status[index] = new_value;
  3739. clif_updatestatus(sd, SP_STR + index);
  3740. clif_updatestatus(sd, SP_USTR + index);
  3741. status_calc_pc(sd, 0);
  3742. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3743. } else {
  3744. if (value < 0)
  3745. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3746. else
  3747. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3748. return -1;
  3749. }
  3750. return 0;
  3751. }
  3752. /*==========================================
  3753. *
  3754. *------------------------------------------
  3755. */
  3756. //** Stat all by fritz (rewritten by [Yor])
  3757. int atcommand_stat_all(
  3758. const int fd, struct map_session_data* sd,
  3759. const char* command, const char* message)
  3760. {
  3761. int index, count, value = 0, max, new_value;
  3762. short* status[6];
  3763. //we don't use direct initialization because it isn't part of the c standard.
  3764. nullpo_retr(-1, sd);
  3765. status[0] = &sd->status.str;
  3766. status[1] = &sd->status.agi;
  3767. status[2] = &sd->status.vit;
  3768. status[3] = &sd->status.int_;
  3769. status[4] = &sd->status.dex;
  3770. status[5] = &sd->status.luk;
  3771. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3772. value = pc_maxparameter(sd);
  3773. count = 0;
  3774. max = pc_maxparameter(sd);
  3775. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3776. if (value > 0 && *status[index] > max - value)
  3777. new_value = max;
  3778. else if (value < 0 && *status[index] <= -value)
  3779. new_value = 1;
  3780. else
  3781. new_value = *status[index] +value;
  3782. if (new_value != (int)*status[index]) {
  3783. *status[index] = new_value;
  3784. clif_updatestatus(sd, SP_STR + index);
  3785. clif_updatestatus(sd, SP_USTR + index);
  3786. status_calc_pc(sd, 0);
  3787. count++;
  3788. }
  3789. }
  3790. if (count > 0) // if at least 1 stat modified
  3791. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3792. else {
  3793. if (value < 0)
  3794. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  3795. else
  3796. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  3797. return -1;
  3798. }
  3799. return 0;
  3800. }
  3801. /*==========================================
  3802. *
  3803. *------------------------------------------
  3804. */
  3805. int atcommand_guildlevelup(
  3806. const int fd, struct map_session_data* sd,
  3807. const char* command, const char* message)
  3808. {
  3809. int level = 0;
  3810. short added_level;
  3811. struct guild *guild_info;
  3812. nullpo_retr(-1, sd);
  3813. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3814. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3815. return -1;
  3816. }
  3817. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3818. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3819. return -1;
  3820. }
  3821. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3822. clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3823. return -1;
  3824. }
  3825. added_level = (short)level;
  3826. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3827. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3828. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3829. added_level = 1 - guild_info->guild_lv;
  3830. if (added_level != 0) {
  3831. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3832. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3833. } else {
  3834. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3835. return -1;
  3836. }
  3837. return 0;
  3838. }
  3839. /*==========================================
  3840. *
  3841. *------------------------------------------
  3842. */
  3843. int atcommand_makeegg(
  3844. const int fd, struct map_session_data* sd,
  3845. const char* command, const char* message)
  3846. {
  3847. struct item_data *item_data;
  3848. int id, pet_id;
  3849. nullpo_retr(-1, sd);
  3850. if (!message || !*message) {
  3851. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3852. return -1;
  3853. }
  3854. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3855. id = item_data->nameid;
  3856. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3857. id = atoi(message);
  3858. pet_id = search_petDB_index(id, PET_CLASS);
  3859. if (pet_id < 0)
  3860. pet_id = search_petDB_index(id, PET_EGG);
  3861. if (pet_id >= 0) {
  3862. sd->catch_target_class = pet_db[pet_id].class_;
  3863. intif_create_pet(
  3864. sd->status.account_id, sd->status.char_id,
  3865. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3866. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3867. 100, 0, 1, pet_db[pet_id].jname);
  3868. } else {
  3869. clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
  3870. return -1;
  3871. }
  3872. return 0;
  3873. }
  3874. /*==========================================
  3875. *
  3876. *------------------------------------------
  3877. */
  3878. int atcommand_hatch(
  3879. const int fd, struct map_session_data* sd,
  3880. const char* command, const char* message)
  3881. {
  3882. nullpo_retr(-1, sd);
  3883. if (sd->status.pet_id <= 0)
  3884. clif_sendegg(sd);
  3885. else {
  3886. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3887. return -1;
  3888. }
  3889. return 0;
  3890. }
  3891. /*==========================================
  3892. *
  3893. *------------------------------------------
  3894. */
  3895. int atcommand_petfriendly(
  3896. const int fd, struct map_session_data* sd,
  3897. const char* command, const char* message)
  3898. {
  3899. int friendly;
  3900. struct pet_data *pd;
  3901. nullpo_retr(-1, sd);
  3902. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3903. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3904. return -1;
  3905. }
  3906. pd = sd->pd;
  3907. if (!pd) {
  3908. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3909. return -1;
  3910. }
  3911. if (friendly < 0 || friendly > 1000)
  3912. {
  3913. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3914. return -1;
  3915. }
  3916. if (friendly == pd->pet.intimate) {
  3917. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  3918. return -1;
  3919. }
  3920. pd->pet.intimate = friendly;
  3921. clif_send_petstatus(sd);
  3922. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  3923. return 0;
  3924. }
  3925. /*==========================================
  3926. *
  3927. *------------------------------------------
  3928. */
  3929. int atcommand_pethungry(
  3930. const int fd, struct map_session_data* sd,
  3931. const char* command, const char* message)
  3932. {
  3933. int hungry;
  3934. struct pet_data *pd;
  3935. nullpo_retr(-1, sd);
  3936. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3937. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3938. return -1;
  3939. }
  3940. pd = sd->pd;
  3941. if (!sd->status.pet_id || !pd) {
  3942. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3943. return -1;
  3944. }
  3945. if (hungry < 0 || hungry > 100) {
  3946. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3947. return -1;
  3948. }
  3949. if (hungry == pd->pet.hungry) {
  3950. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  3951. return -1;
  3952. }
  3953. pd->pet.hungry = hungry;
  3954. clif_send_petstatus(sd);
  3955. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  3956. return 0;
  3957. }
  3958. /*==========================================
  3959. *
  3960. *------------------------------------------
  3961. */
  3962. int atcommand_petrename(
  3963. const int fd, struct map_session_data* sd,
  3964. const char* command, const char* message)
  3965. {
  3966. struct pet_data *pd;
  3967. nullpo_retr(-1, sd);
  3968. if (!sd->status.pet_id || !sd->pd) {
  3969. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3970. return -1;
  3971. }
  3972. pd = sd->pd;
  3973. if (pd->pet.rename_flag) {
  3974. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  3975. return -1;
  3976. }
  3977. pd->pet.rename_flag = 0;
  3978. intif_save_petdata(sd->status.account_id, &pd->pet);
  3979. clif_send_petstatus(sd);
  3980. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  3981. return 0;
  3982. }
  3983. /*==========================================
  3984. *
  3985. *------------------------------------------
  3986. */
  3987. int
  3988. atcommand_recall(
  3989. const int fd, struct map_session_data* sd,
  3990. const char* command, const char* message)
  3991. {
  3992. struct map_session_data *pl_sd = NULL;
  3993. nullpo_retr(-1, sd);
  3994. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3995. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3996. return -1;
  3997. }
  3998. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3999. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  4000. return -1;
  4001. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  4002. return -1;
  4003. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4004. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4005. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4006. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4007. return -1;
  4008. }
  4009. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4010. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  4011. return -1;
  4012. }
  4013. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4014. sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
  4015. clif_displaymessage(fd, atcmd_output);
  4016. } else {
  4017. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4018. return -1;
  4019. }
  4020. } else {
  4021. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4022. return -1;
  4023. }
  4024. return 0;
  4025. }
  4026. /*==========================================
  4027. *
  4028. *------------------------------------------
  4029. */
  4030. int atcommand_revive(
  4031. const int fd, struct map_session_data* sd,
  4032. const char* command, const char* message)
  4033. {
  4034. struct map_session_data *pl_sd;
  4035. nullpo_retr(-1, sd);
  4036. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4037. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4038. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  4039. return -1;
  4040. }
  4041. pl_sd = map_nick2sd(atcmd_player_name);
  4042. if (!pl_sd) {
  4043. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4044. return -1;
  4045. }
  4046. if (!status_revive(&sd->bl, 100, 0))
  4047. return -1;
  4048. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4049. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  4050. return 0;
  4051. }
  4052. /*==========================================
  4053. * charblock command (usage: charblock <player_name>)
  4054. * This command do a definitiv ban on a player
  4055. *------------------------------------------
  4056. */
  4057. int atcommand_char_block(
  4058. const int fd, struct map_session_data* sd,
  4059. const char* command, const char* message)
  4060. {
  4061. nullpo_retr(-1, sd);
  4062. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4063. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4064. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4065. return -1;
  4066. }
  4067. // check player name
  4068. if (strlen(atcmd_player_name) < 4) {
  4069. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4070. return -1;
  4071. } else if (strlen(atcmd_player_name) > 23) {
  4072. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4073. return -1;
  4074. } else {
  4075. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4076. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4077. }
  4078. return 0;
  4079. }
  4080. /*==========================================
  4081. * charban command (usage: charban <time> <player_name>)
  4082. * This command do a limited ban on a player
  4083. * Time is done as follows:
  4084. * Adjustment value (-1, 1, +1, etc...)
  4085. * Modified element:
  4086. * a or y: year
  4087. * m: month
  4088. * j or d: day
  4089. * h: hour
  4090. * mn: minute
  4091. * s: second
  4092. * <example> @ban +1m-2mn1s-6y test_player
  4093. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4094. *------------------------------------------
  4095. */
  4096. int atcommand_char_ban(
  4097. const int fd, struct map_session_data* sd,
  4098. const char* command, const char* message)
  4099. {
  4100. char * modif_p;
  4101. int year, month, day, hour, minute, second, value;
  4102. nullpo_retr(-1, sd);
  4103. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4104. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4105. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4106. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4107. return -1;
  4108. }
  4109. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4110. modif_p = atcmd_output;
  4111. year = month = day = hour = minute = second = 0;
  4112. while (modif_p[0] != '\0') {
  4113. value = atoi(modif_p);
  4114. if (value == 0)
  4115. modif_p++;
  4116. else {
  4117. if (modif_p[0] == '-' || modif_p[0] == '+')
  4118. modif_p++;
  4119. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4120. modif_p++;
  4121. if (modif_p[0] == 's') {
  4122. second = value;
  4123. modif_p++;
  4124. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4125. minute = value;
  4126. modif_p = modif_p + 2;
  4127. } else if (modif_p[0] == 'h') {
  4128. hour = value;
  4129. modif_p++;
  4130. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4131. day = value;
  4132. modif_p++;
  4133. } else if (modif_p[0] == 'm') {
  4134. month = value;
  4135. modif_p++;
  4136. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4137. year = value;
  4138. modif_p++;
  4139. } else if (modif_p[0] != '\0') {
  4140. modif_p++;
  4141. }
  4142. }
  4143. }
  4144. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4145. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  4146. return -1;
  4147. }
  4148. // check player name
  4149. if (strlen(atcmd_player_name) < 4) {
  4150. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4151. return -1;
  4152. } else if (strlen(atcmd_player_name) > 23) {
  4153. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4154. return -1;
  4155. } else {
  4156. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4157. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4158. }
  4159. return 0;
  4160. }
  4161. /*==========================================
  4162. * charunblock command (usage: charunblock <player_name>)
  4163. *------------------------------------------
  4164. */
  4165. int atcommand_char_unblock(
  4166. const int fd, struct map_session_data* sd,
  4167. const char* command, const char* message)
  4168. {
  4169. nullpo_retr(-1, sd);
  4170. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4171. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4172. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4173. return -1;
  4174. }
  4175. // check player name
  4176. if (strlen(atcmd_player_name) < 4) {
  4177. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4178. return -1;
  4179. } else if (strlen(atcmd_player_name) > 23) {
  4180. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4181. return -1;
  4182. } else {
  4183. // send answer to login server via char-server
  4184. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4185. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4186. }
  4187. return 0;
  4188. }
  4189. /*==========================================
  4190. * charunban command (usage: charunban <player_name>)
  4191. *------------------------------------------
  4192. */
  4193. int atcommand_char_unban(
  4194. const int fd, struct map_session_data* sd,
  4195. const char* command, const char* message)
  4196. {
  4197. nullpo_retr(-1, sd);
  4198. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4199. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4200. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  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. // send answer to login server via char-server
  4212. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4213. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4214. }
  4215. return 0;
  4216. }
  4217. /*==========================================
  4218. *
  4219. *------------------------------------------
  4220. */
  4221. int atcommand_night(
  4222. const int fd, struct map_session_data* sd,
  4223. const char* command, const char* message)
  4224. {
  4225. nullpo_retr(-1, sd);
  4226. if (night_flag != 1) {
  4227. map_night_timer(night_timer_tid, 0, 0, 1);
  4228. } else {
  4229. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  4230. return -1;
  4231. }
  4232. return 0;
  4233. }
  4234. /*==========================================
  4235. *
  4236. *------------------------------------------
  4237. */
  4238. int atcommand_day(
  4239. const int fd, struct map_session_data* sd,
  4240. const char* command, const char* message)
  4241. {
  4242. nullpo_retr(-1, sd);
  4243. if (night_flag != 0) {
  4244. map_day_timer(day_timer_tid, 0, 0, 1);
  4245. } else {
  4246. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  4247. return -1;
  4248. }
  4249. return 0;
  4250. }
  4251. /*==========================================
  4252. *
  4253. *------------------------------------------
  4254. */
  4255. int atcommand_doom(
  4256. const int fd, struct map_session_data* sd,
  4257. const char* command, const char* message)
  4258. {
  4259. struct map_session_data *pl_sd, **pl_allsd;
  4260. int i, users;
  4261. nullpo_retr(-1, sd);
  4262. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4263. pl_allsd = map_getallusers(&users);
  4264. for(i = 0; i < users; i++) {
  4265. 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
  4266. status_kill(&pl_sd->bl);
  4267. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4268. }
  4269. }
  4270. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4271. return 0;
  4272. }
  4273. /*==========================================
  4274. *
  4275. *------------------------------------------
  4276. */
  4277. int atcommand_doommap(
  4278. const int fd, struct map_session_data* sd,
  4279. const char* command, const char* message)
  4280. {
  4281. struct map_session_data *pl_sd, **pl_allsd;
  4282. int i, users;
  4283. nullpo_retr(-1, sd);
  4284. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4285. pl_allsd = map_getallusers(&users);
  4286. for (i = 0; i < users; i++) {
  4287. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4288. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4289. {
  4290. status_kill(&pl_sd->bl);
  4291. // clif_specialeffect(&pl_sd->bl,450,1);
  4292. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4293. }
  4294. }
  4295. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4296. return 0;
  4297. }
  4298. /*==========================================
  4299. *
  4300. *------------------------------------------
  4301. */
  4302. static void atcommand_raise_sub(struct map_session_data* sd)
  4303. {
  4304. if (!sd->state.auth || !status_isdead(&sd->bl))
  4305. return;
  4306. if(!status_revive(&sd->bl, 100, 100))
  4307. return;
  4308. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4309. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  4310. }
  4311. /*==========================================
  4312. *
  4313. *------------------------------------------
  4314. */
  4315. int atcommand_raise(
  4316. const int fd, struct map_session_data* sd,
  4317. const char* command, const char* message)
  4318. {
  4319. int i, users;
  4320. struct map_session_data **all_sd;
  4321. nullpo_retr(-1, sd);
  4322. all_sd = map_getallusers(&users);
  4323. for (i = 0; i < users; i++) {
  4324. atcommand_raise_sub(all_sd[i]);
  4325. }
  4326. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4327. return 0;
  4328. }
  4329. /*==========================================
  4330. *
  4331. *------------------------------------------
  4332. */
  4333. int atcommand_raisemap(
  4334. const int fd, struct map_session_data* sd,
  4335. const char* command, const char* message)
  4336. {
  4337. struct map_session_data **pl_allsd;
  4338. int i, users;
  4339. nullpo_retr(-1, sd);
  4340. pl_allsd = map_getallusers(&users);
  4341. for (i = 0; i < users; i++) {
  4342. if (sd->bl.m == pl_allsd[i]->bl.m)
  4343. atcommand_raise_sub(pl_allsd[i]);
  4344. }
  4345. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4346. return 0;
  4347. }
  4348. /*==========================================
  4349. *
  4350. *------------------------------------------
  4351. */
  4352. int atcommand_kick(
  4353. const int fd, struct map_session_data* sd,
  4354. const char* command, const char* message)
  4355. {
  4356. struct map_session_data *pl_sd;
  4357. nullpo_retr(-1, sd);
  4358. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4359. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4360. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4361. return -1;
  4362. }
  4363. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4364. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4365. clif_GM_kick(sd, pl_sd, 1);
  4366. else {
  4367. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4368. return -1;
  4369. }
  4370. } else {
  4371. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4372. return -1;
  4373. }
  4374. return 0;
  4375. }
  4376. /*==========================================
  4377. *
  4378. *------------------------------------------
  4379. */
  4380. int atcommand_kickall(
  4381. const int fd, struct map_session_data* sd,
  4382. const char* command, const char* message)
  4383. {
  4384. struct map_session_data *pl_sd, **pl_allsd;
  4385. int i, users;
  4386. nullpo_retr(-1, sd);
  4387. pl_allsd = map_getallusers(&users);
  4388. for (i = 0; i < users; i++) {
  4389. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4390. if (sd->status.account_id != pl_sd->status.account_id)
  4391. clif_GM_kick(sd, pl_sd, 0);
  4392. }
  4393. }
  4394. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  4395. return 0;
  4396. }
  4397. /*==========================================
  4398. *
  4399. *------------------------------------------
  4400. */
  4401. int atcommand_allskill(
  4402. const int fd, struct map_session_data* sd,
  4403. const char* command, const char* message)
  4404. {
  4405. nullpo_retr(-1, sd);
  4406. pc_allskillup(sd); // all skills
  4407. sd->status.skill_point = 0; // 0 skill points
  4408. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4409. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  4410. return 0;
  4411. }
  4412. /*==========================================
  4413. *
  4414. *------------------------------------------
  4415. */
  4416. int atcommand_questskill(
  4417. const int fd, struct map_session_data* sd,
  4418. const char* command, const char* message)
  4419. {
  4420. int skill_id;
  4421. nullpo_retr(-1, sd);
  4422. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4423. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4424. return -1;
  4425. }
  4426. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4427. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4428. if (pc_checkskill(sd, skill_id) == 0) {
  4429. pc_skill(sd, skill_id, 1, 0);
  4430. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  4431. } else {
  4432. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  4433. return -1;
  4434. }
  4435. } else {
  4436. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4437. return -1;
  4438. }
  4439. } else {
  4440. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4441. return -1;
  4442. }
  4443. return 0;
  4444. }
  4445. /*==========================================
  4446. *
  4447. *------------------------------------------
  4448. */
  4449. int atcommand_lostskill(
  4450. const int fd, struct map_session_data* sd,
  4451. const char* command, const char* message)
  4452. {
  4453. int skill_id;
  4454. nullpo_retr(-1, sd);
  4455. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4456. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4457. return -1;
  4458. }
  4459. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4460. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4461. if (pc_checkskill(sd, skill_id) > 0) {
  4462. sd->status.skill[skill_id].lv = 0;
  4463. sd->status.skill[skill_id].flag = 0;
  4464. clif_skillinfoblock(sd);
  4465. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  4466. } else {
  4467. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  4468. return -1;
  4469. }
  4470. } else {
  4471. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4472. return -1;
  4473. }
  4474. } else {
  4475. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4476. return -1;
  4477. }
  4478. return 0;
  4479. }
  4480. /*==========================================
  4481. *
  4482. *------------------------------------------
  4483. */
  4484. int atcommand_spiritball(
  4485. const int fd, struct map_session_data* sd,
  4486. const char* command, const char* message)
  4487. {
  4488. int number;
  4489. nullpo_retr(-1, sd);
  4490. if (!message || !*message || (number = atoi(message)) < 0) {
  4491. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4492. return -1;
  4493. }
  4494. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4495. if (number > 500)
  4496. number = 500;
  4497. if (number >= 0 && number <= 0x7FFF) {
  4498. if (sd->spiritball != number || number > 499) {
  4499. if (sd->spiritball > 0)
  4500. pc_delspiritball(sd, sd->spiritball, 1);
  4501. sd->spiritball = number;
  4502. clif_spiritball(sd);
  4503. // no message, player can look the difference
  4504. if (number > 1000)
  4505. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4506. } else {
  4507. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  4508. return -1;
  4509. }
  4510. } else {
  4511. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4512. return -1;
  4513. }
  4514. return 0;
  4515. }
  4516. /*==========================================
  4517. *
  4518. *------------------------------------------
  4519. */
  4520. int atcommand_party(
  4521. const int fd, struct map_session_data* sd,
  4522. const char* command, const char* message)
  4523. {
  4524. char party[NAME_LENGTH];
  4525. nullpo_retr(-1, sd);
  4526. memset(party, '\0', sizeof(party));
  4527. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4528. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4529. return -1;
  4530. }
  4531. party_create(sd, party, 0, 0);
  4532. return 0;
  4533. }
  4534. /*==========================================
  4535. *
  4536. *------------------------------------------
  4537. */
  4538. int atcommand_guild(
  4539. const int fd, struct map_session_data* sd,
  4540. const char* command, const char* message)
  4541. {
  4542. char guild[NAME_LENGTH];
  4543. int prev;
  4544. nullpo_retr(-1, sd);
  4545. memset(guild, '\0', sizeof(guild));
  4546. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4547. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4548. return -1;
  4549. }
  4550. prev = battle_config.guild_emperium_check;
  4551. battle_config.guild_emperium_check = 0;
  4552. guild_create(sd, guild);
  4553. battle_config.guild_emperium_check = prev;
  4554. return 0;
  4555. }
  4556. /*==========================================
  4557. *
  4558. *------------------------------------------
  4559. */
  4560. int atcommand_agitstart(
  4561. const int fd, struct map_session_data* sd,
  4562. const char* command, const char* message)
  4563. {
  4564. nullpo_retr(-1, sd);
  4565. if (agit_flag == 1) {
  4566. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  4567. return -1;
  4568. }
  4569. agit_flag = 1;
  4570. guild_agit_start();
  4571. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  4572. return 0;
  4573. }
  4574. /*==========================================
  4575. *
  4576. *------------------------------------------
  4577. */
  4578. int atcommand_agitend(
  4579. const int fd, struct map_session_data* sd,
  4580. const char* command, const char* message)
  4581. {
  4582. nullpo_retr(-1, sd);
  4583. if (agit_flag == 0) {
  4584. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  4585. return -1;
  4586. }
  4587. agit_flag = 0;
  4588. guild_agit_end();
  4589. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  4590. return 0;
  4591. }
  4592. /*==========================================
  4593. * @mapexitでマップサーバーを終了させる
  4594. *------------------------------------------
  4595. */
  4596. int atcommand_mapexit(
  4597. const int fd, struct map_session_data* sd,
  4598. const char* command, const char* message)
  4599. {
  4600. struct map_session_data *pl_sd, **pl_allsd;
  4601. int i, users;
  4602. nullpo_retr(-1, sd);
  4603. pl_allsd = map_getallusers(&users);
  4604. for (i = 0; i < users; i++) {
  4605. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4606. clif_GM_kick(sd, pl_sd, 0);
  4607. }
  4608. clif_GM_kick(sd, sd, 0);
  4609. flush_fifos();
  4610. runflag = 0;
  4611. return 0;
  4612. }
  4613. /*==========================================
  4614. * idsearch <part_of_name>: revrited by [Yor]
  4615. *------------------------------------------
  4616. */
  4617. int atcommand_idsearch(
  4618. const int fd, struct map_session_data* sd,
  4619. const char* command, const char* message)
  4620. {
  4621. char item_name[100];
  4622. unsigned int i, match;
  4623. struct item_data *item_array[MAX_SEARCH];
  4624. nullpo_retr(-1, sd);
  4625. memset(item_name, '\0', sizeof(item_name));
  4626. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4627. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4628. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4629. return -1;
  4630. }
  4631. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  4632. clif_displaymessage(fd, atcmd_output);
  4633. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4634. if (match > MAX_SEARCH) {
  4635. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  4636. clif_displaymessage(fd, atcmd_output);
  4637. match = MAX_SEARCH;
  4638. }
  4639. for(i = 0; i < match; i++) {
  4640. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4641. clif_displaymessage(fd, atcmd_output);
  4642. }
  4643. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  4644. clif_displaymessage(fd, atcmd_output);
  4645. return 0;
  4646. }
  4647. /*==========================================
  4648. * Recall All Characters Online To Your Location
  4649. *------------------------------------------
  4650. */
  4651. int atcommand_recallall(
  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;
  4657. int count, users;
  4658. nullpo_retr(-1, sd);
  4659. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4660. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4661. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4662. return -1;
  4663. }
  4664. count = 0;
  4665. pl_allsd = map_getallusers(&users);
  4666. for (i = 0; i < users; i++) {
  4667. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4668. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4669. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4670. count++;
  4671. else {
  4672. if (pc_isdead(pl_sd)) { //Wake them up
  4673. pc_setstand(pl_sd);
  4674. pc_setrestartvalue(pl_sd,1);
  4675. }
  4676. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4677. }
  4678. }
  4679. }
  4680. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4681. if (count) {
  4682. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4683. clif_displaymessage(fd, atcmd_output);
  4684. }
  4685. return 0;
  4686. }
  4687. /*==========================================
  4688. * Recall online characters of a guild to your location
  4689. *------------------------------------------
  4690. */
  4691. int atcommand_guildrecall(
  4692. const int fd, struct map_session_data* sd,
  4693. const char* command, const char* message)
  4694. {
  4695. struct map_session_data *pl_sd, **pl_allsd;
  4696. int i, users, count;
  4697. char guild_name[NAME_LENGTH];
  4698. struct guild *g;
  4699. nullpo_retr(-1, sd);
  4700. memset(guild_name, '\0', sizeof(guild_name));
  4701. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4702. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4703. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4704. return -1;
  4705. }
  4706. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4707. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4708. return -1;
  4709. }
  4710. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4711. (g = guild_search(atoi(message))) != NULL) {
  4712. count = 0;
  4713. pl_allsd = map_getallusers(&users);
  4714. for (i = 0; i < users; i++) {
  4715. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4716. pl_sd->status.guild_id == g->guild_id) {
  4717. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4718. continue; //Skip GMs greater than you.
  4719. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4720. count++;
  4721. else
  4722. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4723. }
  4724. }
  4725. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  4726. clif_displaymessage(fd, atcmd_output);
  4727. if (count) {
  4728. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4729. clif_displaymessage(fd, atcmd_output);
  4730. }
  4731. } else {
  4732. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4733. return -1;
  4734. }
  4735. return 0;
  4736. }
  4737. /*==========================================
  4738. * Recall online characters of a party to your location
  4739. *------------------------------------------
  4740. */
  4741. int atcommand_partyrecall(
  4742. const int fd, struct map_session_data* sd,
  4743. const char* command, const char* message)
  4744. {
  4745. int i;
  4746. struct map_session_data *pl_sd, **pl_allsd;
  4747. char party_name[NAME_LENGTH];
  4748. struct party_data *p;
  4749. int count, users;
  4750. nullpo_retr(-1, sd);
  4751. memset(party_name, '\0', sizeof(party_name));
  4752. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4753. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4754. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4755. return -1;
  4756. }
  4757. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4758. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4759. return -1;
  4760. }
  4761. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4762. (p = party_search(atoi(message))) != NULL) {
  4763. count = 0;
  4764. pl_allsd = map_getallusers(&users);
  4765. for (i = 0; i < users; i++) {
  4766. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4767. pl_sd->status.party_id == p->party.party_id) {
  4768. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4769. continue; //Skip GMs greater than you.
  4770. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4771. count++;
  4772. else
  4773. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4774. }
  4775. }
  4776. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  4777. clif_displaymessage(fd, atcmd_output);
  4778. if (count) {
  4779. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4780. clif_displaymessage(fd, atcmd_output);
  4781. }
  4782. } else {
  4783. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4784. return -1;
  4785. }
  4786. return 0;
  4787. }
  4788. /*==========================================
  4789. *
  4790. *------------------------------------------
  4791. */
  4792. int atcommand_reloaditemdb(
  4793. const int fd, struct map_session_data* sd,
  4794. const char* command, const char* message)
  4795. {
  4796. nullpo_retr(-1, sd);
  4797. itemdb_reload();
  4798. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  4799. return 0;
  4800. }
  4801. /*==========================================
  4802. *
  4803. *------------------------------------------
  4804. */
  4805. int atcommand_reloadmobdb(
  4806. const int fd, struct map_session_data* sd,
  4807. const char* command, const char* message)
  4808. {
  4809. nullpo_retr(-1, sd);
  4810. mob_reload();
  4811. do_final_pet();
  4812. read_petdb();
  4813. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  4814. return 0;
  4815. }
  4816. /*==========================================
  4817. *
  4818. *------------------------------------------
  4819. */
  4820. int atcommand_reloadskilldb(
  4821. const int fd, struct map_session_data* sd,
  4822. const char* command, const char* message)
  4823. {
  4824. nullpo_retr(-1, sd);
  4825. skill_reload();
  4826. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  4827. return 0;
  4828. }
  4829. /*==========================================
  4830. * @reloadatcommand
  4831. * atcommand_athena.conf のリロード
  4832. *------------------------------------------
  4833. */
  4834. int
  4835. atcommand_reloadatcommand(
  4836. const int fd, struct map_session_data* sd,
  4837. const char* command, const char* message)
  4838. {
  4839. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4840. clif_displaymessage(fd, msg_txt(254));
  4841. return 0;
  4842. }
  4843. /*==========================================
  4844. * @reloadbattleconf
  4845. * battle_athena.conf のリロード
  4846. *------------------------------------------
  4847. */
  4848. int
  4849. atcommand_reloadbattleconf(
  4850. const int fd, struct map_session_data* sd,
  4851. const char* command, const char* message)
  4852. {
  4853. battle_config_read(BATTLE_CONF_FILENAME);
  4854. mob_reload(); //Needed as well so rate changes take effect.
  4855. clif_displaymessage(fd, msg_txt(255));
  4856. return 0;
  4857. }
  4858. /*==========================================
  4859. * @reloadstatusdb
  4860. * job_db1.txt job_db2.txt job_db2-2.txt
  4861. * refine_db.txt size_fix.txt
  4862. * のリロード
  4863. *------------------------------------------
  4864. */
  4865. int
  4866. atcommand_reloadstatusdb(
  4867. const int fd, struct map_session_data* sd,
  4868. const char* command, const char* message)
  4869. {
  4870. status_readdb();
  4871. clif_displaymessage(fd, msg_txt(256));
  4872. return 0;
  4873. }
  4874. /*==========================================
  4875. * @reloadpcdb
  4876. * exp.txt skill_tree.txt attr_fix.txt
  4877. * のリロード
  4878. *------------------------------------------
  4879. */
  4880. int
  4881. atcommand_reloadpcdb(
  4882. const int fd, struct map_session_data* sd,
  4883. const char* command, const char* message)
  4884. {
  4885. pc_readdb();
  4886. clif_displaymessage(fd, msg_txt(257));
  4887. return 0;
  4888. }
  4889. /*==========================================
  4890. * @reloadmotd [Valaris]
  4891. * Reloads motd.txt
  4892. *------------------------------------------
  4893. */
  4894. int
  4895. atcommand_reloadmotd(
  4896. const int fd, struct map_session_data* sd,
  4897. const char* command, const char* message)
  4898. {
  4899. pc_read_motd();
  4900. clif_displaymessage(fd, msg_txt(268));
  4901. return 0;
  4902. }
  4903. /*==========================================
  4904. *
  4905. *------------------------------------------
  4906. */
  4907. int atcommand_reloadscript(
  4908. const int fd, struct map_session_data* sd,
  4909. const char* command, const char* message)
  4910. {
  4911. nullpo_retr(-1, sd);
  4912. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4913. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4914. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4915. flush_fifos();
  4916. //do_init_npc();
  4917. script_reload();
  4918. npc_reload();
  4919. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  4920. return 0;
  4921. }
  4922. /*==========================================
  4923. *
  4924. *------------------------------------------
  4925. */
  4926. int atcommand_reloadgmdb( // by [Yor]
  4927. const int fd, struct map_session_data* sd,
  4928. const char* command, const char* message)
  4929. {
  4930. nullpo_retr(-1, sd);
  4931. chrif_reloadGMdb();
  4932. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  4933. return 0;
  4934. }
  4935. /*==========================================
  4936. * @mapinfo <map name> [0-3] by MC_Cameri
  4937. * => Shows information about the map [map name]
  4938. * 0 = no additional information
  4939. * 1 = Show users in that map and their location
  4940. * 2 = Shows NPCs in that map
  4941. * 3 = Shows the shops/chats in that map (not implemented)
  4942. *------------------------------------------
  4943. */
  4944. int atcommand_mapinfo(
  4945. const int fd, struct map_session_data* sd,
  4946. const char* command, const char* message)
  4947. {
  4948. struct map_session_data *pl_sd, **pl_allsd;
  4949. struct npc_data *nd = NULL;
  4950. struct chat_data *cd = NULL;
  4951. char direction[12];
  4952. int m_id, i, chat_num, users, list = 0;
  4953. unsigned short m_index;
  4954. nullpo_retr(-1, sd);
  4955. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4956. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4957. memset(direction, '\0', sizeof(direction));
  4958. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4959. if (list < 0 || list > 3) {
  4960. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4961. return -1;
  4962. }
  4963. if (atcmd_player_name[0] == '\0') {
  4964. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4965. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4966. m_id = map_mapindex2mapid(sd->mapindex);
  4967. } else {
  4968. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4969. strcat(atcmd_player_name, ".gat");
  4970. m_id = map_mapname2mapid(atcmd_player_name);
  4971. }
  4972. if (m_id < 0) {
  4973. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  4974. return -1;
  4975. }
  4976. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4977. clif_displaymessage(fd, "------ Map Info ------");
  4978. chat_num = 0;
  4979. pl_allsd = map_getallusers(&users);
  4980. for (i = 0; i < users; i++) {
  4981. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4982. chat_num++;
  4983. }
  4984. }
  4985. 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);
  4986. clif_displaymessage(fd, atcmd_output);
  4987. if (map[m_id].flag.alias)
  4988. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4989. clif_displaymessage(fd, "------ Map Flags ------");
  4990. strcpy(atcmd_output,"PvP Flags: ");
  4991. if (map[m_id].flag.pvp)
  4992. strcat(atcmd_output, "Pvp ON | ");
  4993. if (map[m_id].flag.pvp_noguild)
  4994. strcat(atcmd_output, "NoGuild | ");
  4995. if (map[m_id].flag.pvp_noparty)
  4996. strcat(atcmd_output, "NoParty | ");
  4997. if (map[m_id].flag.pvp_nightmaredrop)
  4998. strcat(atcmd_output, "NightmareDrop | ");
  4999. if (map[m_id].flag.pvp_nocalcrank)
  5000. strcat(atcmd_output, "NoCalcRank | ");
  5001. clif_displaymessage(fd, atcmd_output);
  5002. strcpy(atcmd_output,"GvG Flags: ");
  5003. if (map[m_id].flag.gvg)
  5004. strcat(atcmd_output, "GvG ON | ");
  5005. if (map[m_id].flag.gvg_dungeon)
  5006. strcat(atcmd_output, "GvG Dungeon | ");
  5007. if (map[m_id].flag.gvg_castle)
  5008. strcat(atcmd_output, "GvG Castle | ");
  5009. if (map[m_id].flag.gvg_noparty)
  5010. strcat(atcmd_output, "NoParty | ");
  5011. clif_displaymessage(fd, atcmd_output);
  5012. strcpy(atcmd_output,"Teleport Flags: ");
  5013. if (map[m_id].flag.noteleport)
  5014. strcat(atcmd_output, "NoTeleport | ");
  5015. if (map[m_id].flag.monster_noteleport)
  5016. strcat(atcmd_output, "Monster NoTeleport | ");
  5017. if (map[m_id].flag.nowarp)
  5018. strcat(atcmd_output, "NoWarp | ");
  5019. if (map[m_id].flag.nowarpto)
  5020. strcat(atcmd_output, "NoWarpTo | ");
  5021. if (map[m_id].flag.noreturn)
  5022. strcat(atcmd_output, "NoReturn | ");
  5023. if (map[m_id].flag.nogo)
  5024. strcat(atcmd_output, "NoGo | ");
  5025. if (map[m_id].flag.nomemo)
  5026. strcat(atcmd_output, "NoMemo | ");
  5027. clif_displaymessage(fd, atcmd_output);
  5028. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  5029. clif_displaymessage(fd, atcmd_output);
  5030. if (map[m_id].flag.nosave) {
  5031. if (!map[m_id].save.map)
  5032. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  5033. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  5034. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  5035. else
  5036. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  5037. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  5038. clif_displaymessage(fd, atcmd_output);
  5039. }
  5040. strcpy(atcmd_output,"Weather Flags: ");
  5041. if (map[m_id].flag.snow)
  5042. strcat(atcmd_output, "Snow | ");
  5043. if (map[m_id].flag.fog)
  5044. strcat(atcmd_output, "Fog | ");
  5045. if (map[m_id].flag.sakura)
  5046. strcat(atcmd_output, "Sakura | ");
  5047. if (map[m_id].flag.clouds)
  5048. strcat(atcmd_output, "Clouds | ");
  5049. if (map[m_id].flag.clouds2)
  5050. strcat(atcmd_output, "Clouds2 | ");
  5051. if (map[m_id].flag.fireworks)
  5052. strcat(atcmd_output, "Fireworks | ");
  5053. if (map[m_id].flag.leaves)
  5054. strcat(atcmd_output, "Leaves | ");
  5055. if (map[m_id].flag.rain)
  5056. strcat(atcmd_output, "Rain | ");
  5057. if (map[m_id].flag.indoors)
  5058. strcat(atcmd_output, "Indoors | ");
  5059. if (map[m_id].flag.nightenabled)
  5060. strcat(atcmd_output, "Displays Night | ");
  5061. clif_displaymessage(fd, atcmd_output);
  5062. strcpy(atcmd_output,"Other Flags: ");
  5063. if (map[m_id].flag.nobranch)
  5064. strcat(atcmd_output, "NoBranch | ");
  5065. if (map[m_id].flag.notrade)
  5066. strcat(atcmd_output, "NoTrade | ");
  5067. if (map[m_id].flag.novending)
  5068. strcat(atcmd_output, "NoVending | ");
  5069. if (map[m_id].flag.nodrop)
  5070. strcat(atcmd_output, "NoDrop | ");
  5071. if (map[m_id].flag.noskill)
  5072. strcat(atcmd_output, "NoSkill | ");
  5073. if (map[m_id].flag.noicewall)
  5074. strcat(atcmd_output, "NoIcewall | ");
  5075. clif_displaymessage(fd, atcmd_output);
  5076. strcpy(atcmd_output,"Other Flags: ");
  5077. if (map[m_id].flag.nocommand)
  5078. strcat(atcmd_output, "NoCommand | ");
  5079. if (map[m_id].flag.nobaseexp)
  5080. strcat(atcmd_output, "NoBaseEXP | ");
  5081. if (map[m_id].flag.nojobexp)
  5082. strcat(atcmd_output, "NoJobEXP | ");
  5083. if (map[m_id].flag.nomobloot)
  5084. strcat(atcmd_output, "NoMobLoot | ");
  5085. if (map[m_id].flag.nomvploot)
  5086. strcat(atcmd_output, "NoMVPLoot | ");
  5087. clif_displaymessage(fd, atcmd_output);
  5088. switch (list) {
  5089. case 0:
  5090. // Do nothing. It's list 0, no additional display.
  5091. break;
  5092. case 1:
  5093. clif_displaymessage(fd, "----- Players in Map -----");
  5094. for (i = 0; i < users; i++) {
  5095. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5096. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5097. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5098. clif_displaymessage(fd, atcmd_output);
  5099. }
  5100. }
  5101. break;
  5102. case 2:
  5103. clif_displaymessage(fd, "----- NPCs in Map -----");
  5104. for (i = 0; i < map[m_id].npc_num;) {
  5105. nd = map[m_id].npc[i];
  5106. switch(nd->ud.dir) {
  5107. case 0: strcpy(direction, "North"); break;
  5108. case 1: strcpy(direction, "North West"); break;
  5109. case 2: strcpy(direction, "West"); break;
  5110. case 3: strcpy(direction, "South West"); break;
  5111. case 4: strcpy(direction, "South"); break;
  5112. case 5: strcpy(direction, "South East"); break;
  5113. case 6: strcpy(direction, "East"); break;
  5114. case 7: strcpy(direction, "North East"); break;
  5115. case 9: strcpy(direction, "North"); break;
  5116. default: strcpy(direction, "Unknown"); break;
  5117. }
  5118. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5119. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5120. clif_displaymessage(fd, atcmd_output);
  5121. }
  5122. break;
  5123. case 3:
  5124. clif_displaymessage(fd, "----- Chats in Map -----");
  5125. for (i = 0; i < users; i++) {
  5126. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5127. pl_sd->mapindex == m_index &&
  5128. cd->usersd[0] == pl_sd) {
  5129. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5130. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5131. clif_displaymessage(fd, atcmd_output);
  5132. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5133. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5134. clif_displaymessage(fd, atcmd_output);
  5135. }
  5136. }
  5137. break;
  5138. default: // normally impossible to arrive here
  5139. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5140. return -1;
  5141. break;
  5142. }
  5143. return 0;
  5144. }
  5145. /*==========================================
  5146. *
  5147. *------------------------------------------
  5148. */
  5149. int atcommand_mount_peco(
  5150. const int fd, struct map_session_data* sd,
  5151. const char* command, const char* message)
  5152. {
  5153. nullpo_retr(-1, sd);
  5154. if (!pc_isriding(sd)) { // if actually no peco
  5155. if (pc_checkskill(sd, KN_RIDING)) {
  5156. pc_setoption(sd, sd->sc.option | 0x0020);
  5157. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  5158. } else {
  5159. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  5160. return -1;
  5161. }
  5162. } else { //Dismount
  5163. pc_setoption(sd, sd->sc.option & ~0x0020);
  5164. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  5165. }
  5166. return 0;
  5167. }
  5168. /*==========================================
  5169. *
  5170. *------------------------------------------
  5171. */
  5172. int atcommand_char_mount_peco(
  5173. const int fd, struct map_session_data* sd,
  5174. const char* command, const char* message)
  5175. {
  5176. struct map_session_data *pl_sd;
  5177. nullpo_retr(-1, sd);
  5178. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5179. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5180. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5181. return -1;
  5182. }
  5183. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5184. if (!pc_isriding(pl_sd)) { // if actually no peco
  5185. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5186. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5187. clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
  5188. } else {
  5189. clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
  5190. return -1;
  5191. }
  5192. } else { //Dismount
  5193. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5194. clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
  5195. }
  5196. } else {
  5197. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5198. return -1;
  5199. }
  5200. return 0;
  5201. }
  5202. /*==========================================
  5203. *Spy Commands by Syrus22
  5204. *------------------------------------------
  5205. */
  5206. int atcommand_guildspy(
  5207. const int fd, struct map_session_data* sd,
  5208. const char* command, const char* message)
  5209. {
  5210. char guild_name[NAME_LENGTH];
  5211. struct guild *g;
  5212. nullpo_retr(-1, sd);
  5213. memset(guild_name, '\0', sizeof(guild_name));
  5214. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5215. if (!enable_spy)
  5216. {
  5217. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5218. return -1;
  5219. }
  5220. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5221. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5222. return -1;
  5223. }
  5224. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5225. (g = guild_search(atoi(message))) != NULL) {
  5226. if (sd->guildspy == g->guild_id) {
  5227. sd->guildspy = 0;
  5228. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  5229. clif_displaymessage(fd, atcmd_output);
  5230. } else {
  5231. sd->guildspy = g->guild_id;
  5232. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  5233. clif_displaymessage(fd, atcmd_output);
  5234. }
  5235. } else {
  5236. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  5237. return -1;
  5238. }
  5239. return 0;
  5240. }
  5241. /*==========================================
  5242. *
  5243. *------------------------------------------
  5244. */
  5245. int atcommand_partyspy(
  5246. const int fd, struct map_session_data* sd,
  5247. const char* command, const char* message)
  5248. {
  5249. char party_name[NAME_LENGTH];
  5250. struct party_data *p;
  5251. nullpo_retr(-1, sd);
  5252. memset(party_name, '\0', sizeof(party_name));
  5253. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5254. if (!enable_spy)
  5255. {
  5256. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5257. return -1;
  5258. }
  5259. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5260. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5261. return -1;
  5262. }
  5263. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5264. (p = party_search(atoi(message))) != NULL) {
  5265. if (sd->partyspy == p->party.party_id) {
  5266. sd->partyspy = 0;
  5267. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  5268. clif_displaymessage(fd, atcmd_output);
  5269. } else {
  5270. sd->partyspy = p->party.party_id;
  5271. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  5272. clif_displaymessage(fd, atcmd_output);
  5273. }
  5274. } else {
  5275. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  5276. return -1;
  5277. }
  5278. return 0;
  5279. }
  5280. /*==========================================
  5281. * @repairall [Valaris]
  5282. *------------------------------------------
  5283. */
  5284. int atcommand_repairall(
  5285. const int fd, struct map_session_data* sd,
  5286. const char* command, const char* message)
  5287. {
  5288. int count, i;
  5289. nullpo_retr(-1, sd);
  5290. count = 0;
  5291. for (i = 0; i < MAX_INVENTORY; i++) {
  5292. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5293. sd->status.inventory[i].attribute = 0;
  5294. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5295. count++;
  5296. }
  5297. }
  5298. if (count > 0) {
  5299. clif_misceffect(&sd->bl, 3);
  5300. clif_equiplist(sd);
  5301. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  5302. } else {
  5303. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  5304. return -1;
  5305. }
  5306. return 0;
  5307. }
  5308. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5309. int atcommand_nuke(
  5310. const int fd, struct map_session_data* sd,
  5311. const char* command, const char* message)
  5312. {
  5313. struct map_session_data *pl_sd;
  5314. nullpo_retr(-1, sd);
  5315. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5316. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5317. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5318. return -1;
  5319. }
  5320. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5321. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5322. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5323. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  5324. } else {
  5325. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5326. return -1;
  5327. }
  5328. } else {
  5329. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5330. return -1;
  5331. }
  5332. return 0;
  5333. }
  5334. /*==========================================
  5335. * @tonpc
  5336. *------------------------------------------
  5337. */
  5338. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5339. const char* command, const char* message)
  5340. {
  5341. char npcname[NAME_LENGTH];
  5342. struct npc_data *nd;
  5343. nullpo_retr(-1, sd);
  5344. memset(npcname, 0, sizeof(npcname));
  5345. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5346. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5347. return -1;
  5348. }
  5349. if ((nd = npc_name2id(npcname)) != NULL) {
  5350. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5351. clif_displaymessage(fd, msg_txt(0)); // Warped.
  5352. else
  5353. return -1;
  5354. } else {
  5355. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5356. return -1;
  5357. }
  5358. return 0;
  5359. }
  5360. /*==========================================
  5361. *
  5362. *------------------------------------------
  5363. */
  5364. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5365. const char* command, const char* message)
  5366. {
  5367. char NPCname[NAME_LENGTH];
  5368. nullpo_retr(-1, sd);
  5369. memset(NPCname, '\0', sizeof(NPCname));
  5370. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5371. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5372. return -1;
  5373. }
  5374. if (npc_name2id(NPCname) != NULL) {
  5375. npc_enable(NPCname, 1);
  5376. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  5377. } else {
  5378. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5379. return -1;
  5380. }
  5381. return 0;
  5382. }
  5383. /*==========================================
  5384. *
  5385. *------------------------------------------
  5386. */
  5387. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5388. const char* command, const char* message)
  5389. {
  5390. char NPCname[NAME_LENGTH];
  5391. nullpo_retr(-1, sd);
  5392. memset(NPCname, '\0', sizeof(NPCname));
  5393. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5394. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5395. return -1;
  5396. }
  5397. if (npc_name2id(NPCname) != NULL) {
  5398. npc_enable(NPCname, 0);
  5399. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5400. } else {
  5401. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5402. return -1;
  5403. }
  5404. return 0;
  5405. }
  5406. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5407. const char* command, const char* message)
  5408. {
  5409. FILE *fp;
  5410. if (!message || !*message) {
  5411. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5412. return -1;
  5413. }
  5414. // check if script file exists
  5415. if ((fp = fopen(message, "r")) == NULL) {
  5416. clif_displaymessage(fd, msg_txt(261));
  5417. return -1;
  5418. }
  5419. fclose(fp);
  5420. // add to list of script sources and run it
  5421. npc_addsrcfile((char *)message);
  5422. npc_parsesrcfile((char *)message);
  5423. clif_displaymessage(fd, msg_txt(262));
  5424. return 0;
  5425. }
  5426. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5427. const char* command, const char* message)
  5428. {
  5429. struct npc_data *nd;
  5430. char NPCname[NAME_LENGTH];
  5431. nullpo_retr(-1, sd);
  5432. memset(NPCname, '\0', sizeof(NPCname));
  5433. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5434. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5435. return -1;
  5436. }
  5437. if ((nd = npc_name2id(NPCname)) != NULL) {
  5438. npc_unload(nd);
  5439. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5440. } else {
  5441. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5442. return -1;
  5443. }
  5444. return 0;
  5445. }
  5446. /*==========================================
  5447. * time in txt for time command (by [Yor])
  5448. *------------------------------------------
  5449. */
  5450. char * txt_time(unsigned int duration) {
  5451. int days, hours, minutes, seconds;
  5452. char temp[256];
  5453. static char temp1[256];
  5454. memset(temp, '\0', sizeof(temp));
  5455. memset(temp1, '\0', sizeof(temp1));
  5456. days = duration / (60 * 60 * 24);
  5457. duration = duration - (60 * 60 * 24 * days);
  5458. hours = duration / (60 * 60);
  5459. duration = duration - (60 * 60 * hours);
  5460. minutes = duration / 60;
  5461. seconds = duration - (60 * minutes);
  5462. if (days < 2)
  5463. sprintf(temp, msg_txt(219), days); // %d day
  5464. else
  5465. sprintf(temp, msg_txt(220), days); // %d days
  5466. if (hours < 2)
  5467. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  5468. else
  5469. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  5470. if (minutes < 2)
  5471. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  5472. else
  5473. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  5474. if (seconds < 2)
  5475. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  5476. else
  5477. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  5478. return temp1;
  5479. }
  5480. /*==========================================
  5481. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5482. * Calculation management of GM modification (@day/@night GM commands) is done
  5483. *------------------------------------------
  5484. */
  5485. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5486. const char* command, const char* message)
  5487. {
  5488. struct TimerData * timer_data;
  5489. struct TimerData * timer_data2;
  5490. time_t time_server; // variable for number of seconds (used with time() function)
  5491. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5492. char temp[256];
  5493. nullpo_retr(-1, sd);
  5494. memset(temp, '\0', sizeof(temp));
  5495. time(&time_server); // get time in seconds since 1/1/1970
  5496. datetime = localtime(&time_server); // convert seconds in structure
  5497. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5498. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  5499. clif_displaymessage(fd, temp);
  5500. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5501. if (night_flag == 0)
  5502. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5503. else
  5504. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5505. } else if (battle_config.night_duration == 0)
  5506. if (night_flag == 1) { // we start with night
  5507. timer_data = get_timer(day_timer_tid);
  5508. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5509. clif_displaymessage(fd, temp);
  5510. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  5511. } else
  5512. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5513. else if (battle_config.day_duration == 0)
  5514. if (night_flag == 0) { // we start with day
  5515. timer_data = get_timer(night_timer_tid);
  5516. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5517. clif_displaymessage(fd, temp);
  5518. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  5519. } else
  5520. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5521. else {
  5522. if (night_flag == 0) {
  5523. timer_data = get_timer(night_timer_tid);
  5524. timer_data2 = get_timer(day_timer_tid);
  5525. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5526. clif_displaymessage(fd, temp);
  5527. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5528. 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.
  5529. else
  5530. 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.
  5531. clif_displaymessage(fd, temp);
  5532. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5533. clif_displaymessage(fd, temp);
  5534. } else {
  5535. timer_data = get_timer(day_timer_tid);
  5536. timer_data2 = get_timer(night_timer_tid);
  5537. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5538. clif_displaymessage(fd, temp);
  5539. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5540. 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.
  5541. else
  5542. 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.
  5543. clif_displaymessage(fd, temp);
  5544. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5545. clif_displaymessage(fd, temp);
  5546. }
  5547. }
  5548. return 0;
  5549. }
  5550. /*==========================================
  5551. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5552. * removes <quantity> item from a character
  5553. * item can be equiped or not.
  5554. * Inspired from a old command created by RoVeRT
  5555. *------------------------------------------
  5556. */
  5557. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5558. const char* command, const char* message)
  5559. {
  5560. struct map_session_data *pl_sd;
  5561. char item_name[100];
  5562. int i, number = 0, item_id, item_position, count;
  5563. struct item_data *item_data;
  5564. nullpo_retr(-1, sd);
  5565. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5566. memset(item_name, '\0', sizeof(item_name));
  5567. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5568. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5569. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5570. return -1;
  5571. }
  5572. item_id = 0;
  5573. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5574. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5575. item_id = item_data->nameid;
  5576. if (item_id > 500) {
  5577. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5578. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5579. item_position = pc_search_inventory(pl_sd, item_id);
  5580. if (item_position >= 0) {
  5581. count = 0;
  5582. for(i = 0; i < number && item_position >= 0; i++) {
  5583. //Logs (A)dmins items [Lupus]
  5584. if(log_config.enable_logs&0x400)
  5585. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5586. pc_delitem(pl_sd, item_position, 1, 0);
  5587. count++;
  5588. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5589. }
  5590. sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
  5591. clif_displaymessage(pl_sd->fd, atcmd_output);
  5592. if (number == count)
  5593. sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
  5594. else
  5595. sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5596. clif_displaymessage(fd, atcmd_output);
  5597. } else {
  5598. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  5599. return -1;
  5600. }
  5601. } else {
  5602. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5603. return -1;
  5604. }
  5605. } else {
  5606. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5607. return -1;
  5608. }
  5609. } else {
  5610. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  5611. return -1;
  5612. }
  5613. return 0;
  5614. }
  5615. //Added by Coltaro
  5616. //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...).
  5617. //Well, using time_t could still work but for some reason that looks like more coding x_x
  5618. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) {
  5619. const int factor_year = 518400; //12*30*24*60 = 518400
  5620. const int factor_month = 43200; //30*24*60 = 43200
  5621. const int factor_day = 1440; //24*60 = 1440
  5622. const int factor_hour = 60;
  5623. *year = jailtime/factor_year;
  5624. jailtime -= *year*factor_year;
  5625. *month = jailtime/factor_month;
  5626. jailtime -= *month*factor_month;
  5627. *day = jailtime/factor_day;
  5628. jailtime -= *day*factor_day;
  5629. *hour = jailtime/factor_hour;
  5630. jailtime -= *hour*factor_hour;
  5631. *minute = jailtime;
  5632. *year = *year > 0? *year : 0;
  5633. *month = *month > 0? *month : 0;
  5634. *day = *day > 0? *day : 0;
  5635. *hour = *hour > 0? *hour : 0;
  5636. *minute = *minute > 0? *minute : 0;
  5637. return;
  5638. }
  5639. /*==========================================
  5640. * @jail <char_name> by [Yor]
  5641. * Special warp! No check with nowarp and nowarpto flag
  5642. *------------------------------------------
  5643. */
  5644. int atcommand_jail(
  5645. const int fd, struct map_session_data* sd,
  5646. const char* command, const char* message)
  5647. {
  5648. struct map_session_data *pl_sd;
  5649. int x, y;
  5650. unsigned short m_index;
  5651. nullpo_retr(-1, sd);
  5652. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5653. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5654. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5655. return -1;
  5656. }
  5657. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5658. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5659. return -1;
  5660. }
  5661. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5662. { // you can jail only lower or same GM
  5663. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5664. return -1;
  5665. }
  5666. if (pl_sd->mapindex == mapindex_name2id(MAP_JAIL))
  5667. { //Already jailed
  5668. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5669. return -1;
  5670. }
  5671. switch(rand() % 2) { //Jail Locations
  5672. case 0:
  5673. m_index = mapindex_name2id(MAP_JAIL);
  5674. x = 24;
  5675. y = 75;
  5676. break;
  5677. default:
  5678. m_index = mapindex_name2id(MAP_JAIL);
  5679. x = 49;
  5680. y = 75;
  5681. break;
  5682. }
  5683. if (pc_setpos(pl_sd, m_index, x, y, 3)) {
  5684. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5685. return -1;
  5686. }
  5687. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5688. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5689. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5690. return 0;
  5691. }
  5692. /*==========================================
  5693. * @unjail/@discharge <char_name> by [Yor]
  5694. * Special warp! No check with nowarp and nowarpto flag
  5695. *------------------------------------------
  5696. */
  5697. int atcommand_unjail(
  5698. const int fd, struct map_session_data* sd,
  5699. const char* command, const char* message)
  5700. {
  5701. struct map_session_data *pl_sd;
  5702. unsigned short m_index;
  5703. int x=0, y=0;
  5704. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5705. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5706. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5707. return -1;
  5708. }
  5709. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5710. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5711. return -1;
  5712. }
  5713. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5714. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5715. return -1;
  5716. }
  5717. if (pl_sd->mapindex != mapindex_name2id(MAP_JAIL)) {
  5718. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5719. return -1;
  5720. }
  5721. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5722. { //Retrieve return map.
  5723. m_index = pl_sd->sc.data[SC_JAILED].val3;
  5724. x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
  5725. y = pl_sd->sc.data[SC_JAILED].val4>>16;
  5726. status_change_end(&pl_sd->bl,SC_JAILED,-1);
  5727. } else
  5728. m_index = mapindex_name2id(MAP_PRONTERA);
  5729. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
  5730. pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
  5731. ) { //Send to Prontera is saved SC map fails.
  5732. pc_setsavepoint(pl_sd, m_index, x, y);
  5733. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5734. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5735. } else {
  5736. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5737. return -1;
  5738. }
  5739. return 0;
  5740. }
  5741. int atcommand_jailfor(
  5742. const int fd, struct map_session_data* sd,
  5743. const char* command, const char* message)
  5744. {
  5745. struct map_session_data *pl_sd = NULL;
  5746. int year, month, day, hour, minute, value;
  5747. char * modif_p;
  5748. int jailtime = 0,x,y;
  5749. short m_index = 0;
  5750. nullpo_retr(-1, sd);
  5751. if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5752. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5753. return -1;
  5754. }
  5755. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5756. modif_p = atcmd_output;
  5757. year = month = day = hour = minute = 0;
  5758. while (modif_p[0] != '\0') {
  5759. value = atoi(modif_p);
  5760. if (value == 0)
  5761. modif_p++;
  5762. else {
  5763. if (modif_p[0] == '-' || modif_p[0] == '+')
  5764. modif_p++;
  5765. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5766. modif_p++;
  5767. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  5768. minute = value;
  5769. modif_p = modif_p + 2;
  5770. } else if (modif_p[0] == 'h') {
  5771. hour = value;
  5772. modif_p++;
  5773. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5774. day = value;
  5775. modif_p++;
  5776. } else if (modif_p[0] == 'm') {
  5777. month = value;
  5778. modif_p++;
  5779. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5780. year = value;
  5781. modif_p++;
  5782. } else if (modif_p[0] != '\0') {
  5783. modif_p++;
  5784. }
  5785. }
  5786. }
  5787. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5788. clif_displaymessage(fd, "Invalid time for jail command.");
  5789. return -1;
  5790. }
  5791. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5792. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5793. return -1;
  5794. }
  5795. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5796. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5797. return -1;
  5798. }
  5799. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5800. if(jailtime==0) {
  5801. clif_displaymessage(fd, "Invalid time for jail command.");
  5802. return -1;
  5803. }
  5804. //Added by Coltaro
  5805. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5806. { //Update the player's jail time
  5807. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  5808. if (jailtime <= 0) {
  5809. jailtime = 0;
  5810. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5811. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5812. } else {
  5813. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5814. 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
  5815. clif_displaymessage(pl_sd->fd, atcmd_output);
  5816. 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
  5817. clif_displaymessage(fd, atcmd_output);
  5818. }
  5819. } else if (jailtime < 0) {
  5820. clif_displaymessage(fd, "Invalid time for jail command.");
  5821. return -1;
  5822. }
  5823. //Jail locations, add more as you wish.
  5824. switch(rand()%2)
  5825. {
  5826. case 1: //Jail #1
  5827. m_index = mapindex_name2id(MAP_JAIL);
  5828. x = 49; y = 75;
  5829. break;
  5830. default: //Default Jail
  5831. m_index = mapindex_name2id(MAP_JAIL);
  5832. x = 24; y = 75;
  5833. break;
  5834. }
  5835. 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).
  5836. return 0;
  5837. }
  5838. //By Coltaro
  5839. int atcommand_jailtime(
  5840. const int fd, struct map_session_data* sd,
  5841. const char* command, const char* message)
  5842. {
  5843. int year, month, day, hour, minute;
  5844. nullpo_retr(-1, sd);
  5845. if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5846. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5847. return -1;
  5848. }
  5849. 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?)
  5850. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5851. return -1;
  5852. }
  5853. //Get remaining jail time
  5854. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5855. 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
  5856. clif_displaymessage(fd, atcmd_output);
  5857. return 0;
  5858. }
  5859. //By Coltaro
  5860. int atcommand_charjailtime(
  5861. const int fd, struct map_session_data* sd,
  5862. const char* command, const char* message)
  5863. {
  5864. struct map_session_data* pl_sd;
  5865. int year, month, day, hour, minute;
  5866. nullpo_retr(-1, sd);
  5867. if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
  5868. clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
  5869. return -1;
  5870. }
  5871. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5872. if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
  5873. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5874. clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
  5875. return -1;
  5876. }
  5877. 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?)
  5878. clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
  5879. return -1;
  5880. }
  5881. //Get remaining jail time
  5882. get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5883. sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
  5884. clif_displaymessage(fd, atcmd_output);
  5885. } else {
  5886. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
  5887. return -1;
  5888. }
  5889. } else {
  5890. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5891. return -1;
  5892. }
  5893. return 0;
  5894. }
  5895. /*==========================================
  5896. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5897. *------------------------------------------
  5898. */
  5899. int atcommand_disguise(
  5900. const int fd, struct map_session_data* sd,
  5901. const char* command, const char* message)
  5902. {
  5903. int id = 0;
  5904. nullpo_retr(-1, sd);
  5905. if (!message || !*message) {
  5906. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5907. return -1;
  5908. }
  5909. if ((id = atoi(message)) > 0)
  5910. { //Acquired an ID
  5911. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5912. id = 0; //Invalid id for either mobs or npcs.
  5913. } else { //Acquired a Name
  5914. if ((id = mobdb_searchname(message)) == 0)
  5915. {
  5916. struct npc_data* nd = npc_name2id(message);
  5917. if (nd != NULL)
  5918. id = nd->n;
  5919. }
  5920. }
  5921. if (id == 0)
  5922. { // Monster/NPC name/id hasn't been found.
  5923. clif_displaymessage(fd, msg_txt(123));
  5924. return -1;
  5925. }
  5926. pc_disguise(sd, id);
  5927. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5928. return 0;
  5929. }
  5930. /*==========================================
  5931. * DisguiseAll
  5932. *------------------------------------------
  5933. */
  5934. int atcommand_disguiseall(
  5935. const int fd, struct map_session_data* sd,
  5936. const char* command, const char* message)
  5937. {
  5938. int mob_id=0, i=0, users;
  5939. struct map_session_data *pl_sd, **pl_allsd;
  5940. nullpo_retr(-1, sd);
  5941. if (!message || !*message) {
  5942. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5943. return -1;
  5944. }
  5945. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5946. mob_id = atoi(message);
  5947. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5948. pl_allsd = map_getallusers(&users);
  5949. for(i=0; i < users; i++) {
  5950. if((pl_sd = pl_allsd[i]))
  5951. pc_disguise(pl_sd, mob_id);
  5952. }
  5953. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5954. } else {
  5955. return -1;
  5956. }
  5957. return 0;
  5958. }
  5959. /*==========================================
  5960. * @undisguise by [Yor]
  5961. *------------------------------------------
  5962. */
  5963. int atcommand_undisguise(
  5964. const int fd, struct map_session_data* sd,
  5965. const char* command, const char* message)
  5966. {
  5967. nullpo_retr(-1, sd);
  5968. if (sd->disguise) {
  5969. pc_disguise(sd, 0);
  5970. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5971. } else {
  5972. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  5973. return -1;
  5974. }
  5975. return 0;
  5976. }
  5977. /*==========================================
  5978. * UndisguiseAll
  5979. *------------------------------------------
  5980. */
  5981. int atcommand_undisguiseall(
  5982. const int fd, struct map_session_data* sd,
  5983. const char* command, const char* message)
  5984. {
  5985. struct map_session_data *pl_sd, **pl_allsd;
  5986. int i, users;
  5987. nullpo_retr(-1, sd);
  5988. pl_allsd = map_getallusers(&users);
  5989. for(i=0; i < users; i++) {
  5990. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5991. pc_disguise(pl_sd, 0);
  5992. }
  5993. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5994. return 0;
  5995. }
  5996. /*==========================================
  5997. * @exp by [Skotlex]
  5998. *------------------------------------------
  5999. */
  6000. int atcommand_exp(
  6001. const int fd, struct map_session_data* sd,
  6002. const char* command, const char* message)
  6003. {
  6004. char output[200];
  6005. double nextb, nextj;
  6006. nullpo_retr(-1, sd);
  6007. memset(output, '\0', sizeof(output));
  6008. nextb = pc_nextbaseexp(sd);
  6009. if (nextb)
  6010. nextb = sd->status.base_exp*100.0/nextb;
  6011. nextj = pc_nextjobexp(sd);
  6012. if (nextj)
  6013. nextj = sd->status.job_exp*100.0/nextj;
  6014. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  6015. clif_displaymessage(fd, output);
  6016. return 0;
  6017. }
  6018. /*==========================================
  6019. * @broadcast by [Valaris]
  6020. *------------------------------------------
  6021. */
  6022. int atcommand_broadcast(
  6023. const int fd, struct map_session_data* sd,
  6024. const char* command, const char* message)
  6025. {
  6026. nullpo_retr(-1, sd);
  6027. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6028. if (!message || !*message) {
  6029. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  6030. return -1;
  6031. }
  6032. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  6033. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  6034. return 0;
  6035. }
  6036. /*==========================================
  6037. * @localbroadcast by [Valaris]
  6038. *------------------------------------------
  6039. */
  6040. int atcommand_localbroadcast(
  6041. const int fd, struct map_session_data* sd,
  6042. const char* command, const char* message)
  6043. {
  6044. nullpo_retr(-1, sd);
  6045. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6046. if (!message || !*message) {
  6047. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  6048. return -1;
  6049. }
  6050. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  6051. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  6052. return 0;
  6053. }
  6054. /*==========================================
  6055. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  6056. *------------------------------------------
  6057. */
  6058. int atcommand_chardisguise(
  6059. const int fd, struct map_session_data* sd,
  6060. const char* command, const char* message)
  6061. {
  6062. int mob_id;
  6063. char mob_name[NAME_LENGTH];
  6064. struct map_session_data* pl_sd;
  6065. nullpo_retr(-1, sd);
  6066. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6067. memset(mob_name, '\0', sizeof(mob_name));
  6068. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  6069. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  6070. return -1;
  6071. }
  6072. if ((mob_id = atoi(mob_name)) > 0)
  6073. { //Acquired an ID
  6074. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  6075. mob_id = 0; //Invalid id for either mobs or npcs.
  6076. } else { //Acquired a Name
  6077. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  6078. {
  6079. struct npc_data* nd = npc_name2id(mob_name);
  6080. if (nd != NULL)
  6081. mob_id = nd->n;
  6082. }
  6083. }
  6084. if (mob_id == 0)
  6085. {
  6086. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  6087. return -1;
  6088. }
  6089. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6090. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  6091. pc_disguise(pl_sd, mob_id);
  6092. clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
  6093. } else {
  6094. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6095. return -1;
  6096. }
  6097. } else {
  6098. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6099. return -1;
  6100. }
  6101. return 0;
  6102. }
  6103. /*==========================================
  6104. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  6105. *------------------------------------------
  6106. */
  6107. int atcommand_charundisguise(
  6108. const int fd, struct map_session_data* sd,
  6109. const char* command, const char* message)
  6110. {
  6111. struct map_session_data* pl_sd;
  6112. nullpo_retr(-1, sd);
  6113. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6114. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6115. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  6116. return -1;
  6117. }
  6118. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6119. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  6120. if (pl_sd->disguise)
  6121. pc_disguise(pl_sd, 0);
  6122. else {
  6123. clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
  6124. return -1;
  6125. }
  6126. } else {
  6127. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6128. return -1;
  6129. }
  6130. } else {
  6131. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6132. return -1;
  6133. }
  6134. return 0;
  6135. }
  6136. /*==========================================
  6137. * @email <actual@email> <new@email> by [Yor]
  6138. *------------------------------------------
  6139. */
  6140. int atcommand_email(
  6141. const int fd, struct map_session_data* sd,
  6142. const char* command, const char* message)
  6143. {
  6144. char actual_email[100];
  6145. char new_email[100];
  6146. nullpo_retr(-1, sd);
  6147. memset(actual_email, '\0', sizeof(actual_email));
  6148. memset(new_email, '\0', sizeof(new_email));
  6149. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  6150. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  6151. return -1;
  6152. }
  6153. if (e_mail_check(actual_email) == 0) {
  6154. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  6155. return -1;
  6156. } else if (e_mail_check(new_email) == 0) {
  6157. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  6158. return -1;
  6159. } else if (strcmpi(new_email, "a@a.com") == 0) {
  6160. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  6161. return -1;
  6162. } else if (strcmpi(actual_email, new_email) == 0) {
  6163. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  6164. return -1;
  6165. } else {
  6166. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  6167. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  6168. }
  6169. return 0;
  6170. }
  6171. /*==========================================
  6172. *@effect
  6173. *------------------------------------------
  6174. */
  6175. int atcommand_effect(
  6176. const int fd, struct map_session_data* sd,
  6177. const char* command, const char* message)
  6178. {
  6179. int type = 0, flag = 0;
  6180. nullpo_retr(-1, sd);
  6181. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  6182. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  6183. return -1;
  6184. }
  6185. clif_specialeffect(&sd->bl, type, flag);
  6186. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  6187. return 0;
  6188. }
  6189. /*==========================================
  6190. * @charcartlist <character>: Displays the items list of a player's cart.
  6191. *------------------------------------------
  6192. */
  6193. int
  6194. atcommand_character_cart_list(
  6195. const int fd, struct map_session_data* sd,
  6196. const char* command, const char* message)
  6197. {
  6198. char outputtmp[200];
  6199. struct map_session_data *pl_sd;
  6200. struct item_data *item_data, *item_temp;
  6201. int i, j, count, counter, counter2;
  6202. nullpo_retr(-1, sd);
  6203. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6204. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6205. memset(outputtmp, '\0', sizeof(outputtmp));
  6206. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6207. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6208. return -1;
  6209. }
  6210. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6211. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6212. counter = 0;
  6213. count = 0;
  6214. for (i = 0; i < MAX_CART; i++) {
  6215. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6216. counter = counter + pl_sd->status.cart[i].amount;
  6217. count++;
  6218. if (count == 1) {
  6219. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6220. clif_displaymessage(fd, atcmd_output);
  6221. }
  6222. if (pl_sd->status.cart[i].refine)
  6223. 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);
  6224. else
  6225. 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);
  6226. clif_displaymessage(fd, atcmd_output);
  6227. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6228. counter2 = 0;
  6229. for (j = 0; j < item_data->slot; j++) {
  6230. if (pl_sd->status.cart[i].card[j]) {
  6231. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6232. if (atcmd_output[0] == '\0')
  6233. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6234. else
  6235. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6236. strcat(atcmd_output, outputtmp);
  6237. }
  6238. }
  6239. }
  6240. if (atcmd_output[0] != '\0') {
  6241. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6242. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6243. clif_displaymessage(fd, atcmd_output);
  6244. }
  6245. }
  6246. }
  6247. if (count == 0)
  6248. clif_displaymessage(fd, "No item found in the cart of this player.");
  6249. else {
  6250. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6251. clif_displaymessage(fd, atcmd_output);
  6252. }
  6253. } else {
  6254. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6255. return -1;
  6256. }
  6257. } else {
  6258. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6259. return -1;
  6260. }
  6261. return 0;
  6262. }
  6263. /*==========================================
  6264. * @killer by MouseJstr
  6265. * enable killing players even when not in pvp
  6266. *------------------------------------------
  6267. */
  6268. int
  6269. atcommand_killer(
  6270. const int fd, struct map_session_data* sd,
  6271. const char* command, const char* message)
  6272. {
  6273. nullpo_retr(-1, sd);
  6274. sd->state.killer = !sd->state.killer;
  6275. if(sd->state.killer)
  6276. clif_displaymessage(fd, msg_txt(241));
  6277. else
  6278. clif_displaymessage(fd, msg_txt(287));
  6279. return 0;
  6280. }
  6281. /*==========================================
  6282. * @killable by MouseJstr
  6283. * enable other people killing you
  6284. *------------------------------------------
  6285. */
  6286. int
  6287. atcommand_killable(
  6288. const int fd, struct map_session_data* sd,
  6289. const char* command, const char* message)
  6290. {
  6291. nullpo_retr(-1, sd);
  6292. sd->state.killable = !sd->state.killable;
  6293. if(sd->state.killable)
  6294. clif_displaymessage(fd, msg_txt(242));
  6295. else
  6296. clif_displaymessage(fd, msg_txt(288));
  6297. return 0;
  6298. }
  6299. /*==========================================
  6300. * @charkillable by MouseJstr
  6301. * enable another player to be killed
  6302. *------------------------------------------
  6303. */
  6304. int
  6305. atcommand_charkillable(
  6306. const int fd, struct map_session_data* sd,
  6307. const char* command, const char* message)
  6308. {
  6309. struct map_session_data *pl_sd = NULL;
  6310. nullpo_retr(-1, sd);
  6311. if (!message || !*message)
  6312. return -1;
  6313. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6314. return -1;
  6315. pl_sd->state.killable = !pl_sd->state.killable;
  6316. if(pl_sd->state.killable)
  6317. clif_displaymessage(fd, msg_txt(289));
  6318. else
  6319. clif_displaymessage(fd, msg_txt(290));
  6320. return 0;
  6321. }
  6322. /*==========================================
  6323. * @skillon by MouseJstr
  6324. * turn skills on for the map
  6325. *------------------------------------------
  6326. */
  6327. int
  6328. atcommand_skillon(
  6329. const int fd, struct map_session_data* sd,
  6330. const char* command, const char* message)
  6331. {
  6332. nullpo_retr(-1, sd);
  6333. map[sd->bl.m].flag.noskill = 0;
  6334. clif_displaymessage(fd, msg_txt(244));
  6335. return 0;
  6336. }
  6337. /*==========================================
  6338. * @skilloff by MouseJstr
  6339. * Turn skills off on the map
  6340. *------------------------------------------
  6341. */
  6342. int
  6343. atcommand_skilloff(
  6344. const int fd, struct map_session_data* sd,
  6345. const char* command, const char* message)
  6346. {
  6347. nullpo_retr(-1, sd);
  6348. map[sd->bl.m].flag.noskill = 1;
  6349. clif_displaymessage(fd, msg_txt(243));
  6350. return 0;
  6351. }
  6352. /*==========================================
  6353. * @npcmove by MouseJstr
  6354. *
  6355. * move a npc
  6356. *------------------------------------------
  6357. */
  6358. int
  6359. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6360. const char* command, const char* message)
  6361. {
  6362. int x = 0, y = 0, m;
  6363. struct npc_data *nd = 0;
  6364. nullpo_retr(-1, sd);
  6365. if (!message || !*message)
  6366. return -1;
  6367. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6368. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6369. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6370. return -1;
  6371. }
  6372. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6373. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6374. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6375. return -1;
  6376. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6377. return -1; //Not on a map.
  6378. if (x < 0) x = 0;
  6379. else if (x >= map[m].xs) x = map[m].xs-1;
  6380. if (y < 0) y = 0;
  6381. else if (y >= map[m].ys) y = map[m].ys-1;
  6382. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6383. map_moveblock(&nd->bl, x, y, gettick());
  6384. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6385. return 0;
  6386. }
  6387. /*==========================================
  6388. * @addwarp by MouseJstr
  6389. *
  6390. * Create a new static warp point.
  6391. *------------------------------------------
  6392. */
  6393. int
  6394. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6395. const char* command, const char* message)
  6396. {
  6397. char w1[64], w3[64], w4[64];
  6398. int x,y,ret;
  6399. nullpo_retr(-1, sd);
  6400. if (!message || !*message)
  6401. return -1;
  6402. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6403. return -1;
  6404. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6405. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6406. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6407. ret = npc_parse_warp(w1, "warp", w3, w4);
  6408. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6409. clif_displaymessage(fd, atcmd_output);
  6410. return ret;
  6411. }
  6412. /*==========================================
  6413. * @follow by [MouseJstr]
  6414. *
  6415. * Follow a player .. staying no more then 5 spaces away
  6416. *------------------------------------------
  6417. */
  6418. int
  6419. atcommand_follow(const int fd, struct map_session_data* sd,
  6420. const char* command, const char* message)
  6421. {
  6422. struct map_session_data *pl_sd = NULL;
  6423. nullpo_retr(-1, sd);
  6424. if (!message || !*message) {
  6425. if (sd->followtarget == -1)
  6426. return -1;
  6427. pc_stop_following (sd);
  6428. clif_displaymessage(fd, "Follow mode OFF.");
  6429. return 0;
  6430. }
  6431. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6432. if (sd->followtarget == pl_sd->bl.id) {
  6433. pc_stop_following (sd);
  6434. clif_displaymessage(fd, "Follow mode OFF.");
  6435. } else {
  6436. pc_follow(sd, pl_sd->bl.id);
  6437. clif_displaymessage(fd, "Follow mode ON.");
  6438. }
  6439. return 0;
  6440. } else {
  6441. clif_displaymessage(fd, "Character not found.");
  6442. return -1;
  6443. }
  6444. return 1;
  6445. }
  6446. /*==========================================
  6447. * @dropall by [MouseJstr]
  6448. *
  6449. * Drop all your possession on the ground
  6450. *------------------------------------------
  6451. */
  6452. int
  6453. atcommand_dropall(const int fd, struct map_session_data* sd,
  6454. const char* command, const char* message)
  6455. {
  6456. int i;
  6457. nullpo_retr(-1, sd);
  6458. for (i = 0; i < MAX_INVENTORY; i++) {
  6459. if (sd->status.inventory[i].amount) {
  6460. if(sd->status.inventory[i].equip != 0)
  6461. pc_unequipitem(sd, i, 3);
  6462. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6463. }
  6464. }
  6465. return 0;
  6466. }
  6467. /*==========================================
  6468. * @chardropall by [MouseJstr]
  6469. *
  6470. * Throw all the characters possessions on the ground. Normally
  6471. * done in response to them being disrespectful of a GM
  6472. *------------------------------------------
  6473. */
  6474. int
  6475. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6476. const char* command, const char* message)
  6477. {
  6478. int i;
  6479. struct map_session_data *pl_sd = NULL;
  6480. nullpo_retr(-1, sd);
  6481. if (!message || !*message)
  6482. return -1;
  6483. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6484. return -1;
  6485. for (i = 0; i < MAX_INVENTORY; i++) {
  6486. if (pl_sd->status.inventory[i].amount) {
  6487. if(pl_sd->status.inventory[i].equip != 0)
  6488. pc_unequipitem(pl_sd, i, 3);
  6489. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6490. }
  6491. }
  6492. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6493. clif_displaymessage(fd, "It is done");
  6494. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6495. return 0;
  6496. }
  6497. /*==========================================
  6498. * @storeall by [MouseJstr]
  6499. *
  6500. * Put everything into storage to simplify your inventory to make
  6501. * debugging easie
  6502. *------------------------------------------
  6503. */
  6504. int
  6505. atcommand_storeall(const int fd, struct map_session_data* sd,
  6506. const char* command, const char* message)
  6507. {
  6508. int i;
  6509. nullpo_retr(-1, sd);
  6510. if (sd->state.storage_flag != 1)
  6511. { //Open storage.
  6512. switch (storage_storageopen(sd)) {
  6513. case 2: //Try again
  6514. clif_displaymessage(fd, "run this command again..");
  6515. return 0;
  6516. case 1: //Failure
  6517. clif_displaymessage(fd, "You can't open the storage currently.");
  6518. return 1;
  6519. }
  6520. }
  6521. for (i = 0; i < MAX_INVENTORY; i++) {
  6522. if (sd->status.inventory[i].amount) {
  6523. if(sd->status.inventory[i].equip != 0)
  6524. pc_unequipitem(sd, i, 3);
  6525. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6526. }
  6527. }
  6528. storage_storageclose(sd);
  6529. clif_displaymessage(fd, "It is done");
  6530. return 0;
  6531. }
  6532. /*==========================================
  6533. * @charstoreall by [MouseJstr]
  6534. *
  6535. * A way to screw with players who piss you off
  6536. *------------------------------------------
  6537. */
  6538. int
  6539. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6540. const char* command, const char* message)
  6541. {
  6542. int i;
  6543. struct map_session_data *pl_sd = NULL;
  6544. nullpo_retr(-1, sd);
  6545. if (!message || !*message)
  6546. return -1;
  6547. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6548. return -1;
  6549. if (pl_sd->state.storage_flag != 1)
  6550. { //Open storage.
  6551. switch (storage_storageopen(pl_sd)) {
  6552. case 2: //Try again
  6553. clif_displaymessage(fd, "Had to open the characters storage window...");
  6554. clif_displaymessage(fd, "run this command again..");
  6555. return 0;
  6556. case 1: //Failure
  6557. clif_displaymessage(fd, "The character currently can't use the storage.");
  6558. return 1;
  6559. }
  6560. }
  6561. for (i = 0; i < MAX_INVENTORY; i++) {
  6562. if (pl_sd->status.inventory[i].amount) {
  6563. if(pl_sd->status.inventory[i].equip != 0)
  6564. pc_unequipitem(pl_sd, i, 3);
  6565. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6566. }
  6567. }
  6568. storage_storageclose(pl_sd);
  6569. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6570. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6571. clif_displaymessage(pl_sd->fd, " -- the management");
  6572. clif_displaymessage(fd, "It is done");
  6573. return 0;
  6574. }
  6575. /*==========================================
  6576. * @skillid by [MouseJstr]
  6577. *
  6578. * lookup a skill by name
  6579. *------------------------------------------
  6580. */
  6581. int
  6582. atcommand_skillid(const int fd, struct map_session_data* sd,
  6583. const char* command, const char* message)
  6584. {
  6585. int skillen, idx;
  6586. nullpo_retr(-1, sd);
  6587. if (!message || !*message)
  6588. return -1;
  6589. skillen = strlen(message);
  6590. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6591. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6592. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6593. {
  6594. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6595. clif_displaymessage(fd, atcmd_output);
  6596. }
  6597. }
  6598. return 0;
  6599. }
  6600. /*==========================================
  6601. * @useskill by [MouseJstr]
  6602. *
  6603. * A way of using skills without having to find them in the skills menu
  6604. *------------------------------------------
  6605. */
  6606. int
  6607. atcommand_useskill(const int fd, struct map_session_data* sd,
  6608. const char* command, const char* message)
  6609. {
  6610. struct map_session_data *pl_sd = NULL;
  6611. struct block_list *bl;
  6612. int skillnum;
  6613. int skilllv;
  6614. char target[255];
  6615. nullpo_retr(-1, sd);
  6616. if (!message || !*message)
  6617. return -1;
  6618. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6619. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6620. return -1;
  6621. }
  6622. if((pl_sd=map_nick2sd(target)) == NULL) {
  6623. return -1;
  6624. }
  6625. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  6626. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  6627. bl = &sd->hd->bl;
  6628. else
  6629. bl = &sd->bl;
  6630. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6631. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6632. else
  6633. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  6634. return 0;
  6635. }
  6636. /*==========================================
  6637. * @skilltree by [MouseJstr]
  6638. *
  6639. * prints the skill tree for a player required to get to a skill
  6640. *------------------------------------------
  6641. */
  6642. int
  6643. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6644. const char* command, const char* message)
  6645. {
  6646. struct map_session_data *pl_sd = NULL;
  6647. int skillnum, skillidx = -1;
  6648. int meets = 1, j, c=0;
  6649. char target[NAME_LENGTH], *tbl;
  6650. struct skill_tree_entry *ent;
  6651. nullpo_retr(-1, sd);
  6652. if (!message || !*message)
  6653. return -1;
  6654. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6655. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6656. return -1;
  6657. }
  6658. if((pl_sd=map_nick2sd(target)) == NULL)
  6659. return -1;
  6660. c = pc_calc_skilltree_normalize_job(pl_sd);
  6661. c = pc_mapid2jobid(c, pl_sd->status.sex);
  6662. tbl = job_name(c);
  6663. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6664. tbl, pc_checkskill(pl_sd, 1));
  6665. clif_displaymessage(fd, atcmd_output);
  6666. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6667. if (skill_tree[c][j].id == skillnum) {
  6668. skillidx = j;
  6669. break;
  6670. }
  6671. }
  6672. if (skillidx == -1) {
  6673. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6674. clif_displaymessage(fd, atcmd_output);
  6675. return 0;
  6676. }
  6677. ent = &skill_tree[c][skillidx];
  6678. for(j=0;j<5;j++)
  6679. if( ent->need[j].id &&
  6680. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6681. {
  6682. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6683. sprintf(atcmd_output, "player requires level %d of skill %s",
  6684. ent->need[j].lv, desc);
  6685. clif_displaymessage(fd, atcmd_output);
  6686. meets = 0;
  6687. }
  6688. if (meets == 1) {
  6689. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6690. clif_displaymessage(fd, atcmd_output);
  6691. }
  6692. return 0;
  6693. }
  6694. // Hand a ring with partners name on it to this char
  6695. void getring (struct map_session_data *sd)
  6696. {
  6697. int flag,item_id = 0;
  6698. struct item item_tmp;
  6699. if(sd->status.sex==0)
  6700. item_id = 2635;
  6701. else
  6702. item_id = 2634;
  6703. memset(&item_tmp,0,sizeof(item_tmp));
  6704. item_tmp.nameid=item_id;
  6705. item_tmp.identify=1;
  6706. item_tmp.card[0]=255;
  6707. item_tmp.card[2]=sd->status.partner_id;
  6708. item_tmp.card[3]=sd->status.partner_id >> 16;
  6709. //Logs (A)dmins items [Lupus]
  6710. if(log_config.enable_logs&0x400)
  6711. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6712. if((flag = pc_additem(sd,&item_tmp,1))) {
  6713. clif_additem(sd,0,0,flag);
  6714. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6715. }
  6716. }
  6717. /*==========================================
  6718. * @marry by [MouseJstr], fixed by Lupus
  6719. *
  6720. * Marry two players
  6721. *------------------------------------------
  6722. */
  6723. int
  6724. atcommand_marry(const int fd, struct map_session_data* sd,
  6725. const char* command, const char* message)
  6726. {
  6727. struct map_session_data *pl_sd1 = NULL;
  6728. struct map_session_data *pl_sd2 = NULL;
  6729. char player1[128], player2[128]; //Length used for return error msgs
  6730. nullpo_retr(-1, sd);
  6731. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6732. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6733. return -1;
  6734. }
  6735. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6736. sprintf(player2, "Cannot find player '%s' online", player1);
  6737. clif_displaymessage(fd, player2);
  6738. return -1;
  6739. }
  6740. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6741. sprintf(player1, "Cannot find player '%s' online", player2);
  6742. clif_displaymessage(fd, player1);
  6743. return -1;
  6744. }
  6745. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6746. clif_displaymessage(fd, "They are married.. wish them well");
  6747. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6748. // Auto-give named rings (Aru)
  6749. getring (pl_sd1);
  6750. getring (pl_sd2);
  6751. return 0;
  6752. }
  6753. return -1;
  6754. }
  6755. /*==========================================
  6756. * @divorce by [MouseJstr], fixed by [Lupus]
  6757. *
  6758. * divorce two players
  6759. *------------------------------------------
  6760. */
  6761. int
  6762. atcommand_divorce(const int fd, struct map_session_data* sd,
  6763. const char* command, const char* message)
  6764. {
  6765. struct map_session_data *pl_sd = NULL;
  6766. nullpo_retr(-1, sd);
  6767. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6768. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6769. return -1;
  6770. }
  6771. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6772. if (pc_divorce(pl_sd) != 0) {
  6773. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6774. clif_displaymessage(fd, atcmd_output);
  6775. return -1;
  6776. } else {
  6777. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6778. clif_displaymessage(fd, atcmd_output);
  6779. return 0;
  6780. }
  6781. }
  6782. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6783. clif_displaymessage(fd, atcmd_output);
  6784. return -1;
  6785. }
  6786. #ifdef DMALLOC
  6787. unsigned long dmark_;
  6788. int
  6789. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6790. const char* command, const char* message)
  6791. {
  6792. dmark_ = dmalloc_mark();
  6793. clif_displaymessage(fd, "debug mark set");
  6794. return 0;
  6795. }
  6796. int
  6797. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6798. const char* command, const char* message)
  6799. {
  6800. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6801. dmark_ = dmalloc_mark();
  6802. clif_displaymessage(fd, "malloc changes logged");
  6803. return 0;
  6804. }
  6805. #endif
  6806. /*==========================================
  6807. * @grind by [MouseJstr]
  6808. *------------------------------------------
  6809. */
  6810. int
  6811. atcommand_grind(const int fd, struct map_session_data* sd,
  6812. const char* command, const char* message)
  6813. {
  6814. struct map_session_data *pl_sd = NULL;
  6815. int skillnum;
  6816. int inf;
  6817. char target[NAME_LENGTH];
  6818. nullpo_retr(-1, sd);
  6819. if (!message || !*message)
  6820. return -1;
  6821. if(sscanf(message, "%23s", target) != 1) {
  6822. clif_displaymessage(fd, "Usage: @grind <target>");
  6823. return -1;
  6824. }
  6825. if((pl_sd=map_nick2sd(target)) == NULL)
  6826. return -1;
  6827. for (skillnum = 1; skillnum < 500; skillnum++) {
  6828. sd->status.sp = sd->status.max_sp;
  6829. atcommand_alive(fd, sd, command, message);
  6830. inf = skill_get_inf(skillnum);
  6831. if (inf & INF_GROUND_SKILL)
  6832. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6833. else if (!(inf & INF_SUPPORT_SKILL))
  6834. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6835. }
  6836. return 0;
  6837. }
  6838. /*==========================================
  6839. * @grind2 by [MouseJstr]
  6840. *------------------------------------------
  6841. */
  6842. int
  6843. atcommand_grind2(const int fd, struct map_session_data* sd,
  6844. const char* command, const char* message)
  6845. {
  6846. int i;
  6847. short x, y;
  6848. for (i = 1000; i < MAX_MOB_DB; i++) {
  6849. if (!mobdb_checkid(i))
  6850. continue;
  6851. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6852. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6853. }
  6854. return 0;
  6855. }
  6856. /*==========================================
  6857. * @changelook by [Celest]
  6858. *------------------------------------------
  6859. */
  6860. int
  6861. atcommand_changelook(const int fd, struct map_session_data* sd,
  6862. const char* command, const char* message)
  6863. {
  6864. int i, j = 0, k = 0;
  6865. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6866. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6867. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6868. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6869. return -1;
  6870. } else if (i == 2) {
  6871. if (j < 1) j = 1;
  6872. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6873. j = pos[j - 1];
  6874. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6875. k = j; // swap
  6876. j = LOOK_HEAD_TOP;
  6877. }
  6878. clif_changelook(&sd->bl,j,k);
  6879. return 0;
  6880. }
  6881. /*==========================================
  6882. *Turns on/off Autotrade for a specific player
  6883. *------------------------------------------
  6884. *by durf (changed by Lupus)
  6885. */
  6886. int
  6887. atcommand_autotrade(
  6888. const int fd, struct map_session_data* sd,
  6889. const char* command, const char* message)
  6890. {
  6891. nullpo_retr(-1, sd);
  6892. if (sd->vender_id) //check if player's vending
  6893. {
  6894. sd->state.autotrade = 1;
  6895. clif_authfail_fd(fd, 15);
  6896. }
  6897. else
  6898. {
  6899. //"You should be vending to use @Autotrade."
  6900. clif_displaymessage(fd, msg_txt(549));
  6901. }
  6902. return 0;
  6903. }
  6904. /*==========================================
  6905. * Changes Master of your Guild to a specified guild member
  6906. *------------------------------------------
  6907. *by durf (changed by Lupus)
  6908. */
  6909. int
  6910. atcommand_changegm(
  6911. const int fd, struct map_session_data* sd,
  6912. const char* command, const char* message)
  6913. {
  6914. struct guild *g;
  6915. struct map_session_data *pl_sd;
  6916. nullpo_retr(-1, sd);
  6917. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6918. {
  6919. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6920. return -1;
  6921. }
  6922. if (strlen(message)==0)
  6923. {
  6924. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6925. return -1;
  6926. }
  6927. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6928. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6929. return -1;
  6930. }
  6931. guild_gm_change(sd->status.guild_id, pl_sd);
  6932. return 0;
  6933. }
  6934. /*==========================================
  6935. *Changes the leader of a party.
  6936. *------------------------------------------
  6937. *by Skotlex
  6938. */
  6939. int
  6940. atcommand_changeleader(
  6941. const int fd, struct map_session_data* sd,
  6942. const char* command, const char* message)
  6943. {
  6944. struct party_data *p;
  6945. struct map_session_data *pl_sd;
  6946. int mi, pl_mi;
  6947. nullpo_retr(-1, sd);
  6948. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6949. { //Need to be a party leader.
  6950. clif_displaymessage(fd, msg_txt(282));
  6951. return -1;
  6952. }
  6953. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6954. if (mi == MAX_PARTY)
  6955. return -1; //Shouldn't happen
  6956. if (!p->party.member[mi].leader)
  6957. { //Need to be a party leader.
  6958. clif_displaymessage(fd, msg_txt(282));
  6959. return -1;
  6960. }
  6961. if (strlen(message)==0)
  6962. {
  6963. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6964. return -1;
  6965. }
  6966. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6967. clif_displaymessage(fd, msg_txt(283));
  6968. return -1;
  6969. }
  6970. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  6971. if (pl_mi == MAX_PARTY)
  6972. return -1; //Shouldn't happen
  6973. //Change leadership.
  6974. p->party.member[mi].leader = 0;
  6975. if (p->data[mi].sd->fd)
  6976. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  6977. p->party.member[pl_mi].leader = 1;
  6978. if (p->data[pl_mi].sd->fd)
  6979. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  6980. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  6981. //Update info.
  6982. clif_party_main_info(p,-1);
  6983. clif_party_info(p,-1);
  6984. return 0;
  6985. }
  6986. /*==========================================
  6987. * Used to change the item share setting of a party.
  6988. *------------------------------------------
  6989. *by Skotlex
  6990. */
  6991. int
  6992. atcommand_partyoption(
  6993. const int fd, struct map_session_data* sd,
  6994. const char* command, const char* message)
  6995. {
  6996. struct party_data *p;
  6997. int mi, option;
  6998. char w1[15], w2[15];
  6999. nullpo_retr(-1, sd);
  7000. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  7001. {
  7002. clif_displaymessage(fd, msg_txt(282));
  7003. return -1;
  7004. }
  7005. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  7006. if (mi == MAX_PARTY)
  7007. return -1; //Shouldn't happen
  7008. if (!p->party.member[mi].leader)
  7009. {
  7010. clif_displaymessage(fd, msg_txt(282));
  7011. return -1;
  7012. }
  7013. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  7014. {
  7015. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  7016. return -1;
  7017. }
  7018. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  7019. option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
  7020. //Change item share type.
  7021. if (option != p->party.item)
  7022. party_changeoption(sd, p->party.exp, option);
  7023. else
  7024. clif_displaymessage(fd, msg_txt(286));
  7025. return 0;
  7026. }
  7027. /*==========================================
  7028. *Turns on/off AutoLoot for a specific player
  7029. *------------------------------------------
  7030. *by Upa-Kun
  7031. */
  7032. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7033. {
  7034. // autoloot command with value
  7035. int rate;
  7036. nullpo_retr(-1, sd);
  7037. // autoloot command without value
  7038. if(!message || !*message)
  7039. {
  7040. // autoloot on -> off
  7041. if(sd->state.autoloot)
  7042. {
  7043. clif_displaymessage(fd, "Autoloot is now off.");
  7044. sd->state.autoloot = 0;
  7045. return 0;
  7046. // autoloot off -> on
  7047. } else {
  7048. clif_displaymessage(fd, "Autoloot is now on.");
  7049. sd->state.autoloot = 10000;
  7050. return 0;
  7051. }
  7052. }
  7053. // get maximum droprate limit
  7054. rate = (int)(atof(message) * 100.);
  7055. // check for invalid value
  7056. if(rate > 10000)
  7057. {
  7058. clif_displaymessage(fd, "Invalid value. Choose value between 0 and 100.");
  7059. return 0;
  7060. }
  7061. // autoloot value is 0, turn autoloot off
  7062. if(rate == 0)
  7063. {
  7064. if(sd->state.autoloot == 0)
  7065. clif_displaymessage(fd, "Autoloot is already off.");
  7066. else {
  7067. clif_displaymessage(fd, "Autoloot is now off.");
  7068. sd->state.autoloot = 0;
  7069. }
  7070. return 0;
  7071. }
  7072. // autoloot value is 100, turn autoloot on
  7073. if(rate == 10000)
  7074. {
  7075. if(sd->state.autoloot == 10000)
  7076. clif_displaymessage(fd, "Autoloot is already on.");
  7077. else {
  7078. clif_displaymessage(fd, "Autoloot is now on.");
  7079. sd->state.autoloot = 10000;
  7080. }
  7081. return 0;
  7082. }
  7083. // autoloot value is between 0 and 100
  7084. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.", rate/100.);
  7085. clif_displaymessage(fd, atcmd_output);
  7086. sd->state.autoloot = rate;
  7087. return 0;
  7088. }
  7089. /*==========================================
  7090. * It is made to rain.
  7091. *------------------------------------------
  7092. */
  7093. int
  7094. atcommand_rain(
  7095. const int fd, struct map_session_data* sd,
  7096. const char* command, const char* message)
  7097. {
  7098. nullpo_retr(-1, sd);
  7099. if (map[sd->bl.m].flag.rain) {
  7100. map[sd->bl.m].flag.rain=0;
  7101. clif_weather(sd->bl.m);
  7102. clif_displaymessage(fd, "The rain has stopped.");
  7103. } else {
  7104. map[sd->bl.m].flag.rain=1;
  7105. clif_weather(sd->bl.m);
  7106. clif_displaymessage(fd, "It is made to rain.");
  7107. }
  7108. return 0;
  7109. }
  7110. /*==========================================
  7111. * It is made to snow.
  7112. *------------------------------------------
  7113. */
  7114. int
  7115. atcommand_snow(
  7116. const int fd, struct map_session_data* sd,
  7117. const char* command, const char* message)
  7118. {
  7119. nullpo_retr(-1, sd);
  7120. if (map[sd->bl.m].flag.snow) {
  7121. map[sd->bl.m].flag.snow=0;
  7122. clif_weather(sd->bl.m);
  7123. clif_displaymessage(fd, "Snow has stopped falling.");
  7124. } else {
  7125. map[sd->bl.m].flag.snow=1;
  7126. clif_weather(sd->bl.m);
  7127. clif_displaymessage(fd, "It is made to snow.");
  7128. }
  7129. return 0;
  7130. }
  7131. /*==========================================
  7132. * Cherry tree snowstorm is made to fall. (Sakura)
  7133. *------------------------------------------
  7134. */
  7135. int
  7136. atcommand_sakura(
  7137. const int fd, struct map_session_data* sd,
  7138. const char* command, const char* message)
  7139. {
  7140. nullpo_retr(-1, sd);
  7141. if (map[sd->bl.m].flag.sakura) {
  7142. map[sd->bl.m].flag.sakura=0;
  7143. clif_weather(sd->bl.m);
  7144. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  7145. } else {
  7146. map[sd->bl.m].flag.sakura=1;
  7147. clif_weather(sd->bl.m);
  7148. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  7149. }
  7150. return 0;
  7151. }
  7152. /*==========================================
  7153. * Clouds appear.
  7154. *------------------------------------------
  7155. */
  7156. int
  7157. atcommand_clouds(
  7158. const int fd, struct map_session_data* sd,
  7159. const char* command, const char* message)
  7160. {
  7161. nullpo_retr(-1, sd);
  7162. if (map[sd->bl.m].flag.clouds) {
  7163. map[sd->bl.m].flag.clouds=0;
  7164. clif_weather(sd->bl.m);
  7165. clif_displaymessage(fd, "The clouds has disappear.");
  7166. } else {
  7167. map[sd->bl.m].flag.clouds=1;
  7168. clif_weather(sd->bl.m);
  7169. clif_displaymessage(fd, "Clouds appear.");
  7170. }
  7171. return 0;
  7172. }
  7173. /*==========================================
  7174. * Different type of clouds using effect 516
  7175. *------------------------------------------
  7176. */
  7177. int
  7178. atcommand_clouds2(
  7179. const int fd, struct map_session_data* sd,
  7180. const char* command, const char* message)
  7181. {
  7182. nullpo_retr(-1, sd);
  7183. if (map[sd->bl.m].flag.clouds2) {
  7184. map[sd->bl.m].flag.clouds2=0;
  7185. clif_weather(sd->bl.m);
  7186. clif_displaymessage(fd, "The alternative clouds disappear.");
  7187. } else {
  7188. map[sd->bl.m].flag.clouds2=1;
  7189. clif_weather(sd->bl.m);
  7190. clif_displaymessage(fd, "Alternative clouds appear.");
  7191. }
  7192. return 0;
  7193. }
  7194. /*==========================================
  7195. * Fog hangs over.
  7196. *------------------------------------------
  7197. */
  7198. int
  7199. atcommand_fog(
  7200. const int fd, struct map_session_data* sd,
  7201. const char* command, const char* message)
  7202. {
  7203. nullpo_retr(-1, sd);
  7204. if (map[sd->bl.m].flag.fog) {
  7205. map[sd->bl.m].flag.fog=0;
  7206. clif_weather(sd->bl.m);
  7207. clif_displaymessage(fd, "The fog has gone.");
  7208. } else {
  7209. map[sd->bl.m].flag.fog=1;
  7210. clif_weather(sd->bl.m);
  7211. clif_displaymessage(fd, "Fog hangs over.");
  7212. }
  7213. return 0;
  7214. }
  7215. /*==========================================
  7216. * Fallen leaves fall.
  7217. *------------------------------------------
  7218. */
  7219. int
  7220. atcommand_leaves(
  7221. const int fd, struct map_session_data* sd,
  7222. const char* command, const char* message)
  7223. {
  7224. nullpo_retr(-1, sd);
  7225. if (map[sd->bl.m].flag.leaves) {
  7226. map[sd->bl.m].flag.leaves=0;
  7227. clif_weather(sd->bl.m);
  7228. clif_displaymessage(fd, "Leaves no longer fall.");
  7229. } else {
  7230. map[sd->bl.m].flag.leaves=1;
  7231. clif_weather(sd->bl.m);
  7232. clif_displaymessage(fd, "Fallen leaves fall.");
  7233. }
  7234. return 0;
  7235. }
  7236. /*==========================================
  7237. * Fireworks appear.
  7238. *------------------------------------------
  7239. */
  7240. int
  7241. atcommand_fireworks(
  7242. const int fd, struct map_session_data* sd,
  7243. const char* command, const char* message)
  7244. {
  7245. nullpo_retr(-1, sd);
  7246. if (map[sd->bl.m].flag.fireworks) {
  7247. map[sd->bl.m].flag.fireworks=0;
  7248. clif_weather(sd->bl.m);
  7249. clif_displaymessage(fd, "Fireworks are ended.");
  7250. } else {
  7251. map[sd->bl.m].flag.fireworks=1;
  7252. clif_weather(sd->bl.m);
  7253. clif_displaymessage(fd, "Fireworks are launched.");
  7254. }
  7255. return 0;
  7256. }
  7257. /*==========================================
  7258. * Clearing Weather Effects by Dexity
  7259. *------------------------------------------
  7260. */
  7261. int
  7262. atcommand_clearweather(
  7263. const int fd, struct map_session_data* sd,
  7264. const char* command, const char* message)
  7265. {
  7266. nullpo_retr(-1, sd);
  7267. map[sd->bl.m].flag.rain=0;
  7268. map[sd->bl.m].flag.snow=0;
  7269. map[sd->bl.m].flag.sakura=0;
  7270. map[sd->bl.m].flag.clouds=0;
  7271. map[sd->bl.m].flag.clouds2=0;
  7272. map[sd->bl.m].flag.fog=0;
  7273. map[sd->bl.m].flag.fireworks=0;
  7274. map[sd->bl.m].flag.leaves=0;
  7275. clif_weather(sd->bl.m);
  7276. return 0;
  7277. }
  7278. /*===============================================================
  7279. * Sound Command - plays a sound for everyone! [Codemaster]
  7280. *---------------------------------------------------------------
  7281. */
  7282. int
  7283. atcommand_sound(
  7284. const int fd, struct map_session_data *sd,
  7285. const char *command, const char *message)
  7286. {
  7287. char sound_file[100];
  7288. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  7289. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  7290. return -1;
  7291. }
  7292. memset(sound_file, '\0', sizeof(sound_file));
  7293. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  7294. return -1;
  7295. if(strstr(sound_file, ".wav") == NULL)
  7296. strcat(sound_file, ".wav");
  7297. clif_soundeffectall(&sd->bl, sound_file,0,2);
  7298. return 0;
  7299. }
  7300. /*==========================================
  7301. * MOB Search
  7302. *------------------------------------------
  7303. */
  7304. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  7305. {
  7306. int mob_id,fd;
  7307. static int number=0;
  7308. struct mob_data *md;
  7309. nullpo_retr(0, bl);
  7310. if(!ap){
  7311. number=0;
  7312. return 0;
  7313. }
  7314. mob_id = va_arg(ap,int);
  7315. fd = va_arg(ap,int);
  7316. md = (struct mob_data *)bl;
  7317. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7318. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7319. ++number,bl->x, bl->y,md->name);
  7320. clif_displaymessage(fd, atcmd_output);
  7321. }
  7322. return 0;
  7323. }
  7324. int atcommand_mobsearch(
  7325. const int fd, struct map_session_data* sd,
  7326. const char* command, const char* message)
  7327. {
  7328. char mob_name[100];
  7329. int mob_id,map_id = 0;
  7330. nullpo_retr(-1, sd);
  7331. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7332. return -1;
  7333. if ((mob_id = atoi(mob_name)) == 0)
  7334. mob_id = mobdb_searchname(mob_name);
  7335. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7336. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7337. clif_displaymessage(fd, atcmd_output);
  7338. return 0;
  7339. }
  7340. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7341. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7342. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7343. map_id = sd->bl.m;
  7344. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7345. mob_name, mapindex_id2name(sd->mapindex));
  7346. clif_displaymessage(fd, atcmd_output);
  7347. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7348. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7349. return 0;
  7350. }
  7351. /*==========================================
  7352. * ドロップアイテムの掃除
  7353. *------------------------------------------
  7354. */
  7355. /*==========================================
  7356. * cleanmap
  7357. *------------------------------------------
  7358. */
  7359. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7360. {
  7361. nullpo_retr(0, bl);
  7362. map_clearflooritem(bl->id);
  7363. return 0;
  7364. }
  7365. int
  7366. atcommand_cleanmap(
  7367. const int fd, struct map_session_data* sd,
  7368. const char* command, const char* message)
  7369. {
  7370. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7371. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7372. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7373. BL_ITEM);
  7374. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7375. return 0;
  7376. }
  7377. /*==========================================
  7378. * NPC/PETに話させる
  7379. *------------------------------------------
  7380. */
  7381. int
  7382. atcommand_npctalk(
  7383. const int fd, struct map_session_data* sd,
  7384. const char* command, const char* message)
  7385. {
  7386. char name[NAME_LENGTH],mes[100],temp[100];
  7387. struct npc_data *nd;
  7388. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7389. return -1;
  7390. if (!(nd = npc_name2id(name)))
  7391. return -1;
  7392. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7393. clif_message(&nd->bl, temp);
  7394. return 0;
  7395. }
  7396. int
  7397. atcommand_pettalk(
  7398. const int fd, struct map_session_data* sd,
  7399. const char* command, const char* message)
  7400. {
  7401. char mes[100],temp[100];
  7402. struct pet_data *pd;
  7403. nullpo_retr(-1, sd);
  7404. if(!sd->status.pet_id || !(pd=sd->pd))
  7405. return -1;
  7406. if (sd->sc.count && //no "chatting" while muted.
  7407. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7408. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7409. return -1;
  7410. if (sscanf(message, "%99[^\n]", mes) < 1)
  7411. return -1;
  7412. snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
  7413. clif_message(&pd->bl, temp);
  7414. return 0;
  7415. }
  7416. /*==========================================
  7417. * @users
  7418. * サーバー内の人数マップを表示させる
  7419. * 手抜きのため汚くなっているのは仕様です。
  7420. *------------------------------------------
  7421. */
  7422. static struct dbt *users_db = NULL;
  7423. static int users_all;
  7424. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7425. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7426. users_all++;
  7427. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7428. return 0;
  7429. }
  7430. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7431. char buf[256];
  7432. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7433. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7434. clif_displaymessage(sd->fd,buf);
  7435. return 0;
  7436. }
  7437. int
  7438. atcommand_users(
  7439. const int fd, struct map_session_data* sd,
  7440. const char* command, const char* message)
  7441. {
  7442. char buf[256];
  7443. users_all = 0;
  7444. users_db->clear(users_db, NULL);
  7445. clif_foreachclient(atcommand_users_sub1);
  7446. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7447. sprintf(buf,"all : %d",users_all);
  7448. clif_displaymessage(fd,buf);
  7449. return 0;
  7450. }
  7451. int
  7452. atcommand_reset(
  7453. const int fd, struct map_session_data* sd,
  7454. const char* command, const char* message)
  7455. {
  7456. pc_resetstate(sd);
  7457. pc_resetskill(sd,1);
  7458. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  7459. clif_displaymessage(fd, atcmd_output);
  7460. return 0;
  7461. }
  7462. /*==========================================
  7463. *
  7464. *------------------------------------------
  7465. */
  7466. int
  7467. atcommand_summon(
  7468. const int fd, struct map_session_data* sd,
  7469. const char* command, const char* message)
  7470. {
  7471. char name[NAME_LENGTH];
  7472. int mob_id = 0;
  7473. int id = 0;
  7474. int duration = 0;
  7475. struct mob_data *md;
  7476. unsigned int tick=gettick();
  7477. nullpo_retr(-1, sd);
  7478. if (!message || !*message)
  7479. return -1;
  7480. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7481. return -1;
  7482. if (duration < 1)
  7483. duration =1;
  7484. else if (duration > 60)
  7485. duration =60;
  7486. if ((mob_id = atoi(name)) == 0)
  7487. mob_id = mobdb_searchname(name);
  7488. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7489. return -1;
  7490. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7491. if(md){
  7492. md->master_id=sd->bl.id;
  7493. md->special_state.ai=1;
  7494. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7495. clif_misceffect2(&md->bl,344);
  7496. mob_spawn(md);
  7497. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7498. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7499. }
  7500. return 0;
  7501. }
  7502. /*==========================================
  7503. * @adjcmdlvl by [MouseJstr]
  7504. *
  7505. * Temp adjust the GM level required to use a GM command
  7506. *
  7507. * Used during beta testing to allow players to use GM commands
  7508. * for short periods of time
  7509. *------------------------------------------
  7510. */
  7511. int
  7512. atcommand_adjcmdlvl(
  7513. const int fd, struct map_session_data* sd,
  7514. const char* command, const char* message)
  7515. {
  7516. int i, newlev;
  7517. char cmd[100];
  7518. nullpo_retr(-1, sd);
  7519. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7520. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7521. return -1;
  7522. }
  7523. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7524. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7525. atcommand_info[i].level = newlev;
  7526. clif_displaymessage(fd, "@command level changed.");
  7527. return 0;
  7528. }
  7529. clif_displaymessage(fd, "@command not found.");
  7530. return -1;
  7531. }
  7532. /*==========================================
  7533. * @adjgmlvl by [MouseJstr]
  7534. *
  7535. * Create a temp GM
  7536. *
  7537. * Used during beta testing to allow players to use GM commands
  7538. * for short periods of time
  7539. *------------------------------------------
  7540. */
  7541. int
  7542. atcommand_adjgmlvl(
  7543. const int fd, struct map_session_data* sd,
  7544. const char* command, const char* message)
  7545. {
  7546. int newlev;
  7547. char user[NAME_LENGTH];
  7548. struct map_session_data *pl_sd;
  7549. nullpo_retr(-1, sd);
  7550. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7551. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7552. return -1;
  7553. }
  7554. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7555. return -1;
  7556. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7557. return 0;
  7558. }
  7559. /*==========================================
  7560. * @trade by [MouseJstr]
  7561. *
  7562. * Open a trade window with a remote player
  7563. *
  7564. * If I have to jump to a remote player one more time, I am
  7565. * gonna scream!
  7566. *------------------------------------------
  7567. */
  7568. int
  7569. atcommand_trade(
  7570. const int fd, struct map_session_data* sd,
  7571. const char* command, const char* message)
  7572. {
  7573. struct map_session_data *pl_sd = NULL;
  7574. nullpo_retr(-1, sd);
  7575. if (!message || !*message)
  7576. return -1;
  7577. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7578. trade_traderequest(sd, pl_sd);
  7579. return 0;
  7580. }
  7581. return -1;
  7582. }
  7583. /*==========================================
  7584. * @setbattleflag by [MouseJstr]
  7585. *
  7586. * set a battle_config flag without having to reboot
  7587. */
  7588. int
  7589. atcommand_setbattleflag(
  7590. const int fd, struct map_session_data* sd,
  7591. const char* command, const char* message)
  7592. {
  7593. char flag[128], value[128];
  7594. nullpo_retr(-1, sd);
  7595. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7596. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7597. return -1;
  7598. }
  7599. if (battle_set_value(flag, value) == 0)
  7600. clif_displaymessage(fd, "unknown battle_config flag");
  7601. else
  7602. clif_displaymessage(fd, "battle_config set as requested");
  7603. return 0;
  7604. }
  7605. /*===========================
  7606. * @unmute [Valaris]
  7607. *===========================
  7608. */
  7609. int atcommand_unmute(
  7610. const int fd, struct map_session_data* sd,
  7611. const char* command, const char* message)
  7612. {
  7613. struct map_session_data *pl_sd = NULL;
  7614. nullpo_retr(-1, sd);
  7615. if (!message || !*message)
  7616. return -1;
  7617. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7618. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7619. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7620. clif_displaymessage(sd->fd,"Player unmuted");
  7621. }
  7622. else
  7623. clif_displaymessage(sd->fd,"Player is not muted");
  7624. }
  7625. return 0;
  7626. }
  7627. /*==========================================
  7628. * @uptime by MC Cameri
  7629. *------------------------------------------
  7630. */
  7631. int
  7632. atcommand_uptime(
  7633. const int fd, struct map_session_data* sd,
  7634. const char* command, const char* message)
  7635. {
  7636. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7637. minute = 60, days = 0, hours = 0, minutes = 0;
  7638. nullpo_retr(-1, sd);
  7639. seconds = get_uptime();
  7640. days = seconds/day;
  7641. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7642. hours = seconds/hour;
  7643. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7644. minutes = seconds/minute;
  7645. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7646. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  7647. clif_displaymessage(fd, atcmd_output);
  7648. return 0;
  7649. }
  7650. /*==========================================
  7651. * @changesex <sex>
  7652. * => Changes one's sex. Argument sex can be
  7653. * 0 or 1, m or f, male or female.
  7654. *------------------------------------------
  7655. */
  7656. int
  7657. atcommand_changesex(
  7658. const int fd, struct map_session_data* sd,
  7659. const char* command, const char* message)
  7660. {
  7661. nullpo_retr(-1, sd);
  7662. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7663. return 0;
  7664. }
  7665. /*================================================
  7666. * @mute - Mutes a player for a set amount of time
  7667. *------------------------------------------------
  7668. */
  7669. int atcommand_mute(
  7670. const int fd, struct map_session_data* sd,
  7671. const char* command, const char* message)
  7672. {
  7673. struct map_session_data *pl_sd = NULL;
  7674. int manner;
  7675. nullpo_retr(-1, sd);
  7676. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7677. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7678. return -1;
  7679. }
  7680. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7681. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7682. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7683. return -1;
  7684. }
  7685. clif_GM_silence(sd, pl_sd, 0);
  7686. pl_sd->status.manner -= manner;
  7687. if(pl_sd->status.manner < 0)
  7688. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7689. }
  7690. else {
  7691. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7692. return -1;
  7693. }
  7694. return 0;
  7695. }
  7696. /*==========================================
  7697. * @refresh (like @jumpto <<yourself>>)
  7698. *------------------------------------------
  7699. */
  7700. int atcommand_refresh(
  7701. const int fd, struct map_session_data* sd,
  7702. const char* command, const char* message)
  7703. {
  7704. nullpo_retr(-1, sd);
  7705. clif_refresh(sd);
  7706. return 0;
  7707. }
  7708. /*==========================================
  7709. * @petid <part of pet name>
  7710. * => Displays a list of matching pets.
  7711. *------------------------------------------
  7712. */
  7713. int
  7714. atcommand_petid(const int fd, struct map_session_data* sd,
  7715. const char* command, const char* message)
  7716. {
  7717. char searchtext[100];
  7718. char temp0[100];
  7719. char temp1[100];
  7720. int cnt = 0, i = 0;
  7721. nullpo_retr(-1, sd);
  7722. if (!message || !*message)
  7723. return -1;
  7724. if (sscanf(message, "%99s", searchtext) < 1)
  7725. return -1;
  7726. estr_lower(searchtext);
  7727. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7728. clif_displaymessage(fd,temp0);
  7729. while (i < MAX_PET_DB) {
  7730. strcpy(temp1,pet_db[i].name);
  7731. strcpy(temp1, estr_lower(temp1));
  7732. strcpy(temp0,pet_db[i].jname);
  7733. strcpy(temp0, estr_lower(temp1));
  7734. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7735. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7736. pet_db[i].jname);
  7737. if (cnt >= 100) { // Only if there are custom pets
  7738. clif_displaymessage(fd, "Be more specific, can't send more than"
  7739. " 100 results.");
  7740. } else {
  7741. clif_displaymessage(fd, temp0);
  7742. }
  7743. cnt++;
  7744. }
  7745. i++;
  7746. }
  7747. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7748. clif_displaymessage(fd, temp0);
  7749. return 0;
  7750. }
  7751. /*==========================================
  7752. * @identify
  7753. * => GM's magnifier.
  7754. *------------------------------------------
  7755. */
  7756. int
  7757. atcommand_identify(
  7758. const int fd, struct map_session_data* sd,
  7759. const char* command, const char* message)
  7760. {
  7761. int i,num;
  7762. nullpo_retr(-1, sd);
  7763. for(i=num=0;i<MAX_INVENTORY;i++){
  7764. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7765. num++;
  7766. }
  7767. }
  7768. if (num > 0) {
  7769. clif_item_identify_list(sd);
  7770. } else {
  7771. clif_displaymessage(fd,"There are no items to appraise.");
  7772. }
  7773. return 0;
  7774. }
  7775. /*==========================================
  7776. * @gmotd (Global MOTD)
  7777. * by davidsiaw :P
  7778. *------------------------------------------
  7779. */
  7780. int
  7781. atcommand_gmotd(
  7782. const int fd, struct map_session_data* sd,
  7783. const char* command, const char* message)
  7784. {
  7785. char buf[256];
  7786. FILE *fp;
  7787. nullpo_retr(-1, sd);
  7788. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7789. while (fgets(buf, 250, fp) != NULL){
  7790. int i;
  7791. for( i=0; buf[i]; i++){
  7792. if( buf[i]=='\r' || buf[i]=='\n'){
  7793. buf[i]=0;
  7794. break;
  7795. }
  7796. }
  7797. intif_GMmessage(buf,strlen(buf)+1,8);
  7798. }
  7799. fclose(fp);
  7800. }
  7801. return 0;
  7802. }
  7803. int atcommand_misceffect(
  7804. const int fd, struct map_session_data* sd,
  7805. const char* command, const char* message)
  7806. {
  7807. int effect = 0;
  7808. nullpo_retr(-1, sd);
  7809. if (!message || !*message)
  7810. return -1;
  7811. if (sscanf(message, "%d", &effect) < 1)
  7812. return -1;
  7813. clif_misceffect(&sd->bl,effect);
  7814. return 0;
  7815. }
  7816. int charid2sessionid(int charid)
  7817. {
  7818. struct map_session_data *pl_sd = NULL;
  7819. pl_sd = map_charid2sd(charid);
  7820. if (pl_sd) return pl_sd->fd;
  7821. return 0;
  7822. }
  7823. int accountid2sessionid(int accountid)
  7824. {
  7825. struct map_session_data *pl_sd = NULL;
  7826. pl_sd = map_id2sd(accountid);
  7827. if (pl_sd) return pl_sd->fd;
  7828. return 0;
  7829. }
  7830. /*==========================================
  7831. * Jump to a player by PID number
  7832. * Original by Dino9021
  7833. * Added in by nsstrunks
  7834. *------------------------------------------
  7835. */
  7836. int atcommand_jumptoid(
  7837. const int fd, struct map_session_data* sd,
  7838. const char* command, const char* message)
  7839. {
  7840. int cid=0;
  7841. int session_id=0;
  7842. struct map_session_data *pl_sd;
  7843. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7844. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7845. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7846. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7847. return -1;
  7848. }
  7849. cid=atoi(message);
  7850. if ((session_id=charid2sessionid(cid))!=0)
  7851. {
  7852. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7853. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7854. clif_displaymessage(fd, msg_txt(247));
  7855. return -1;
  7856. }
  7857. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7858. clif_displaymessage(fd, msg_txt(248));
  7859. return -1;
  7860. }
  7861. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7862. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7863. clif_displaymessage(fd, atcmd_output);
  7864. } else {
  7865. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7866. return -1;
  7867. }
  7868. }
  7869. else
  7870. {
  7871. clif_displaymessage(fd,msg_txt(3));
  7872. }
  7873. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7874. return 0;
  7875. }
  7876. /*==========================================
  7877. * Jump to a player by PID number
  7878. * Original by Dino9021
  7879. * Added in by nsstrunks
  7880. *------------------------------------------
  7881. */
  7882. int atcommand_jumptoid2(
  7883. const int fd, struct map_session_data* sd,
  7884. const char* command, const char* message)
  7885. {
  7886. int aid=0;
  7887. int session_id=0;
  7888. struct map_session_data *pl_sd;
  7889. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7890. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7891. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7892. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7893. return -1;
  7894. }
  7895. aid=atoi(message);
  7896. if ((session_id=accountid2sessionid(aid))!=0)
  7897. {
  7898. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7899. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7900. clif_displaymessage(fd, msg_txt(247));
  7901. return -1;
  7902. }
  7903. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7904. clif_displaymessage(fd, msg_txt(248));
  7905. return -1;
  7906. }
  7907. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7908. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7909. clif_displaymessage(fd, atcmd_output);
  7910. } else {
  7911. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7912. return -1;
  7913. }
  7914. }
  7915. else
  7916. {
  7917. clif_displaymessage(fd,msg_txt(3));
  7918. }
  7919. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7920. return 0;
  7921. }
  7922. /*==========================================
  7923. * Recall a player by PID number
  7924. * Original by Dino9021
  7925. * Added in by nsstrunks
  7926. *------------------------------------------
  7927. */
  7928. int atcommand_recallid(
  7929. const int fd, struct map_session_data* sd,
  7930. const char* command, const char* message)
  7931. {
  7932. int cid=0;
  7933. int session_id=0;
  7934. struct map_session_data *pl_sd;
  7935. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7936. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7937. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7938. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7939. return -1;
  7940. }
  7941. cid=atoi(message);
  7942. if ((session_id=charid2sessionid(cid))!=0)
  7943. {
  7944. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7945. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7946. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7947. clif_displaymessage(fd, msg_txt(247));
  7948. return -1;
  7949. }
  7950. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7951. clif_displaymessage(fd, msg_txt(248));
  7952. return -1;
  7953. }
  7954. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7955. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  7956. clif_displaymessage(fd, atcmd_output);
  7957. } else {
  7958. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7959. return -1;
  7960. }
  7961. } else {
  7962. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7963. return -1;
  7964. }
  7965. }
  7966. else
  7967. {
  7968. clif_displaymessage(fd,msg_txt(3));
  7969. }
  7970. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7971. return 0;
  7972. }
  7973. /*==========================================
  7974. * Recall a player by PID number
  7975. * Original by Dino9021
  7976. * Added in by nsstrunks
  7977. *------------------------------------------
  7978. */
  7979. int atcommand_recallid2(
  7980. const int fd, struct map_session_data* sd,
  7981. const char* command, const char* message)
  7982. {
  7983. int aid=0;
  7984. int session_id=0;
  7985. struct map_session_data *pl_sd;
  7986. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7987. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7988. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7989. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7990. return -1;
  7991. }
  7992. aid=atoi(message);
  7993. if ((session_id=accountid2sessionid(aid))!=0)
  7994. {
  7995. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7996. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7997. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7998. clif_displaymessage(fd, msg_txt(247));
  7999. return -1;
  8000. }
  8001. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  8002. clif_displaymessage(fd, msg_txt(248));
  8003. return -1;
  8004. }
  8005. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  8006. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  8007. clif_displaymessage(fd, atcmd_output);
  8008. } else {
  8009. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8010. return -1;
  8011. }
  8012. } else {
  8013. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  8014. return -1;
  8015. }
  8016. }
  8017. else
  8018. {
  8019. clif_displaymessage(fd,msg_txt(3));
  8020. }
  8021. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8022. return 0;
  8023. }
  8024. /*==========================================
  8025. * Kick a player by PID number
  8026. * Original by Dino9021
  8027. * Added in by nsstrunks
  8028. *------------------------------------------
  8029. */
  8030. int atcommand_kickid(
  8031. const int fd, struct map_session_data* sd,
  8032. const char* command, const char* message)
  8033. {
  8034. struct map_session_data *pl_sd;
  8035. int cid=0;
  8036. int session_id=0;
  8037. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8038. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8039. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  8040. return -1;
  8041. }
  8042. cid=atoi(message);
  8043. if ((session_id=charid2sessionid(cid))!=0)
  8044. {
  8045. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8046. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  8047. clif_GM_kick(sd, pl_sd, 1);
  8048. else {
  8049. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8050. return -1;
  8051. }
  8052. } else {
  8053. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8054. return -1;
  8055. }
  8056. }
  8057. else
  8058. {
  8059. clif_displaymessage(fd,msg_txt(3));
  8060. }
  8061. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8062. return 0;
  8063. }
  8064. /*==========================================
  8065. * Kick a player by PID number
  8066. * Original by Dino9021
  8067. * Added in by nsstrunks
  8068. *------------------------------------------
  8069. */
  8070. int atcommand_kickid2(
  8071. const int fd, struct map_session_data* sd,
  8072. const char* command, const char* message)
  8073. {
  8074. struct map_session_data *pl_sd;
  8075. int aid=0;
  8076. int session_id=0;
  8077. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8078. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8079. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  8080. return -1;
  8081. }
  8082. aid=atoi(message);
  8083. if ((session_id=accountid2sessionid(aid))!=0)
  8084. {
  8085. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8086. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  8087. clif_GM_kick(sd, pl_sd, 1);
  8088. else {
  8089. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8090. return -1;
  8091. }
  8092. } else {
  8093. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8094. return -1;
  8095. }
  8096. }
  8097. else
  8098. {
  8099. clif_displaymessage(fd,msg_txt(3));
  8100. }
  8101. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8102. return 0;
  8103. }
  8104. /*==========================================
  8105. * Revive a player by PID number
  8106. * Original by Dino9021
  8107. * Added in by nsstrunks
  8108. *------------------------------------------
  8109. */
  8110. int atcommand_reviveid(
  8111. const int fd, struct map_session_data* sd,
  8112. const char* command, const char* message)
  8113. {
  8114. int cid=0;
  8115. int session_id=0;
  8116. struct map_session_data *pl_sd;
  8117. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8118. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8119. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  8120. return -1;
  8121. }
  8122. cid=atoi(message);
  8123. if ((session_id=charid2sessionid(cid))!=0)
  8124. {
  8125. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8126. pl_sd->status.hp = pl_sd->status.max_hp;
  8127. pc_setstand(pl_sd);
  8128. if (battle_config.pc_invincible_time > 0)
  8129. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  8130. clif_updatestatus(pl_sd, SP_HP);
  8131. clif_updatestatus(pl_sd, SP_SP);
  8132. clif_resurrection(&pl_sd->bl, 1);
  8133. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  8134. } else {
  8135. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8136. return -1;
  8137. }
  8138. }
  8139. else
  8140. {
  8141. clif_displaymessage(fd,msg_txt(3));
  8142. }
  8143. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8144. return 0;
  8145. }
  8146. /*==========================================
  8147. * Revive a player by PID number
  8148. * Original by Dino9021
  8149. * Added in by nsstrunks
  8150. *------------------------------------------
  8151. */
  8152. int atcommand_reviveid2(
  8153. const int fd, struct map_session_data* sd,
  8154. const char* command, const char* message)
  8155. {
  8156. int aid=0;
  8157. int session_id=0;
  8158. struct map_session_data *pl_sd;
  8159. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8160. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8161. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  8162. return -1;
  8163. }
  8164. aid=atoi(message);
  8165. if ((session_id=accountid2sessionid(aid))!=0)
  8166. {
  8167. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8168. pl_sd->status.hp = pl_sd->status.max_hp;
  8169. pc_setstand(pl_sd);
  8170. if (battle_config.pc_invincible_time > 0)
  8171. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  8172. clif_updatestatus(pl_sd, SP_HP);
  8173. clif_updatestatus(pl_sd, SP_SP);
  8174. clif_resurrection(&pl_sd->bl, 1);
  8175. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  8176. } else {
  8177. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8178. return -1;
  8179. }
  8180. }
  8181. else
  8182. {
  8183. clif_displaymessage(fd,msg_txt(3));
  8184. }
  8185. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8186. return 0;
  8187. }
  8188. /*==========================================
  8189. * Kill a player by PID number
  8190. * Original by Dino9021
  8191. * Added in by nsstrunks
  8192. *------------------------------------------
  8193. */
  8194. int atcommand_killid(
  8195. const int fd, struct map_session_data* sd,
  8196. const char* command, const char* message)
  8197. {
  8198. int cid=0;
  8199. int session_id=0;
  8200. struct map_session_data *pl_sd;
  8201. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8202. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8203. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  8204. return -1;
  8205. }
  8206. cid=atoi(message);
  8207. if ((session_id=charid2sessionid(cid))!=0)
  8208. {
  8209. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8210. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  8211. status_kill(&pl_sd->bl);
  8212. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  8213. } else {
  8214. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8215. return -1;
  8216. }
  8217. } else {
  8218. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8219. return -1;
  8220. }
  8221. }
  8222. else
  8223. {
  8224. clif_displaymessage(fd,msg_txt(3));
  8225. }
  8226. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8227. return 0;
  8228. }
  8229. /*==========================================
  8230. * Kill a player by PID number
  8231. * Original by Dino9021
  8232. * Added in by nsstrunks
  8233. *------------------------------------------
  8234. */
  8235. int atcommand_killid2(
  8236. const int fd, struct map_session_data* sd,
  8237. const char* command, const char* message)
  8238. {
  8239. int aid=0;
  8240. int session_id=0;
  8241. struct map_session_data *pl_sd;
  8242. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8243. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  8244. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  8245. return -1;
  8246. }
  8247. aid=atoi(message);
  8248. if ((session_id=accountid2sessionid(aid))!=0)
  8249. {
  8250. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  8251. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  8252. status_kill(&pl_sd->bl);
  8253. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  8254. } else {
  8255. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8256. return -1;
  8257. }
  8258. } else {
  8259. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8260. return -1;
  8261. }
  8262. }
  8263. else
  8264. {
  8265. clif_displaymessage(fd,msg_txt(3));
  8266. }
  8267. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8268. return 0;
  8269. }
  8270. /*==========================================
  8271. * Make a player killable, by PID
  8272. * Original by Dino9021
  8273. * Added in by nsstrunks
  8274. *------------------------------------------
  8275. */
  8276. int
  8277. atcommand_charkillableid(
  8278. const int fd, struct map_session_data* sd,
  8279. const char* command, const char* message)
  8280. {
  8281. struct map_session_data *pl_sd = NULL;
  8282. int cid=0;
  8283. int session_id=0;
  8284. if (!message || (cid = atoi(message)) == 0 || !*message)
  8285. return -1;
  8286. cid=atoi(message);
  8287. if ((session_id=charid2sessionid(cid))!=0)
  8288. {
  8289. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8290. return -1;
  8291. pl_sd->state.killable = !pl_sd->state.killable;
  8292. if(pl_sd->state.killable)
  8293. clif_displaymessage(fd, msg_txt(289));
  8294. else
  8295. clif_displaymessage(fd, msg_txt(290));
  8296. }
  8297. else
  8298. {
  8299. clif_displaymessage(fd,msg_txt(3));
  8300. }
  8301. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8302. return 0;
  8303. }
  8304. /*==========================================
  8305. * Make a player killable, by PID
  8306. * Original by Dino9021
  8307. * Added in by nsstrunks
  8308. *------------------------------------------
  8309. */
  8310. int
  8311. atcommand_charkillableid2(
  8312. const int fd, struct map_session_data* sd,
  8313. const char* command, const char* message)
  8314. {
  8315. struct map_session_data *pl_sd = NULL;
  8316. int aid=0;
  8317. int session_id=0;
  8318. if (!message || (aid = atoi(message)) == 0 || !*message)
  8319. return -1;
  8320. aid=atoi(message);
  8321. if ((session_id=accountid2sessionid(aid))!=0)
  8322. {
  8323. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8324. return -1;
  8325. pl_sd->state.killable = !pl_sd->state.killable;
  8326. if(pl_sd->state.killable)
  8327. clif_displaymessage(fd, msg_txt(289));
  8328. else
  8329. clif_displaymessage(fd, msg_txt(290));
  8330. }
  8331. else
  8332. {
  8333. clif_displaymessage(fd,msg_txt(3));
  8334. }
  8335. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8336. return 0;
  8337. }
  8338. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8339. /*==========================================
  8340. * Mail System commands by [Valaris]
  8341. *------------------------------------------
  8342. */
  8343. int atcommand_listmail(
  8344. const int fd, struct map_session_data* sd,
  8345. const char* command, const char* message)
  8346. {
  8347. if(!mail_server_enable)
  8348. return 0;
  8349. nullpo_retr(-1, sd);
  8350. if(strlen(command)==12)
  8351. mail_check(sd,3);
  8352. else if(strlen(command)==9)
  8353. mail_check(sd,2);
  8354. else
  8355. mail_check(sd,1);
  8356. return 0;
  8357. }
  8358. int atcommand_readmail(
  8359. const int fd, struct map_session_data* sd,
  8360. const char* command, const char* message)
  8361. {
  8362. int index;
  8363. if(!mail_server_enable)
  8364. return 0;
  8365. nullpo_retr(-1, sd);
  8366. if (!message || !*message) {
  8367. clif_displaymessage(sd->fd,"You must specify a message number.");
  8368. return 0;
  8369. }
  8370. index = atoi(message);
  8371. if (index < 1) {
  8372. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8373. return 0;
  8374. }
  8375. if(strlen(command)==11)
  8376. mail_delete(sd,index);
  8377. else
  8378. mail_read(sd,index);
  8379. return 0;
  8380. }
  8381. int atcommand_sendmail(
  8382. const int fd, struct map_session_data* sd,
  8383. const char* command, const char* message)
  8384. {
  8385. char name[NAME_LENGTH],text[80];
  8386. if(!mail_server_enable)
  8387. return 0;
  8388. nullpo_retr(-1, sd);
  8389. if (!message || !*message) {
  8390. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8391. return 0;
  8392. }
  8393. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8394. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8395. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8396. return 0;
  8397. }
  8398. if(strlen(command)==17)
  8399. mail_send(sd,name,text,1);
  8400. else
  8401. mail_send(sd,name,text,0);
  8402. return 0;
  8403. }
  8404. /*==========================================
  8405. * Refresh online command for SQL [Valaris]
  8406. * Will refresh and check online column of
  8407. * players and set correctly.
  8408. *------------------------------------------
  8409. */
  8410. int atcommand_refreshonline(
  8411. const int fd, struct map_session_data* sd,
  8412. const char* command, const char* message)
  8413. {
  8414. send_users_tochar(-1, gettick(), 0, 0);
  8415. return 0;
  8416. }
  8417. #endif /* end sql only */
  8418. /*==========================================
  8419. * Show Monster DB Info v 1.0
  8420. * originally by [Lupus] eAthena
  8421. *------------------------------------------
  8422. */
  8423. int atcommand_mobinfo(
  8424. const int fd, struct map_session_data* sd,
  8425. const char* command, const char* message)
  8426. {
  8427. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8428. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8429. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8430. char atcmd_output2[200];
  8431. struct item_data *item_data;
  8432. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8433. int count;
  8434. int i, j, k;
  8435. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8436. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8437. if (!message || !*message) {
  8438. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8439. return -1;
  8440. }
  8441. // If monster identifier/name argument is a name
  8442. if ((i = mobdb_checkid(atoi(message))))
  8443. {
  8444. mob_array[0] = mob_db(i);
  8445. count = 1;
  8446. } else
  8447. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8448. if (!count) {
  8449. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  8450. return -1;
  8451. }
  8452. if (count > MAX_SEARCH) {
  8453. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8454. clif_displaymessage(fd, atcmd_output);
  8455. count = MAX_SEARCH;
  8456. }
  8457. for (k = 0; k < count; k++) {
  8458. mob = mob_array[k];
  8459. // stats
  8460. if (mob->mexp)
  8461. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  8462. else
  8463. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  8464. clif_displaymessage(fd, atcmd_output);
  8465. 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);
  8466. clif_displaymessage(fd, atcmd_output);
  8467. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  8468. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  8469. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  8470. clif_displaymessage(fd, atcmd_output);
  8471. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  8472. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  8473. mob->range2 , mob->range3, msize[mob->status.size],
  8474. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  8475. clif_displaymessage(fd, atcmd_output);
  8476. // drops
  8477. clif_displaymessage(fd, " Drops:");
  8478. strcpy(atcmd_output, " ");
  8479. j = 0;
  8480. for (i = 0; i < MAX_MOB_DROP; i++) {
  8481. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8482. continue;
  8483. if (item_data->slot)
  8484. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  8485. else
  8486. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  8487. strcat(atcmd_output, atcmd_output2);
  8488. if (++j % 3 == 0) {
  8489. clif_displaymessage(fd, atcmd_output);
  8490. strcpy(atcmd_output, " ");
  8491. }
  8492. }
  8493. if (j == 0)
  8494. clif_displaymessage(fd, "This monster has no drops.");
  8495. else if (j % 3 != 0)
  8496. clif_displaymessage(fd, atcmd_output);
  8497. // mvp
  8498. if (mob->mexp) {
  8499. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8500. clif_displaymessage(fd, atcmd_output);
  8501. strcpy(atcmd_output, " MVP Items:");
  8502. j = 0;
  8503. for (i = 0; i < 3; i++) {
  8504. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8505. continue;
  8506. if (mob->mvpitem[i].p > 0) {
  8507. j++;
  8508. if (j == 1)
  8509. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8510. else
  8511. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8512. strcat(atcmd_output, atcmd_output2);
  8513. }
  8514. }
  8515. if (j == 0)
  8516. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8517. else
  8518. clif_displaymessage(fd, atcmd_output);
  8519. }
  8520. }
  8521. return 0;
  8522. }
  8523. /*==========================================
  8524. * homunculus level up [orn]
  8525. *------------------------------------------
  8526. */
  8527. int atcommand_homlevel(
  8528. const int fd, struct map_session_data* sd,
  8529. const char* command, const char* message)
  8530. {
  8531. TBL_HOM * hd;
  8532. int level = 0, i = 0;
  8533. nullpo_retr(-1, sd);
  8534. if (!message || !*message)
  8535. return -1;
  8536. if ( !merc_is_hom_active(sd->hd) )
  8537. return 1 ;
  8538. level = atoi(message);
  8539. hd = sd->hd;
  8540. for (i = 1; i <= level && hd->exp_next; i++){
  8541. sd->homunculus.exp += hd->exp_next;
  8542. merc_hom_levelup(hd);
  8543. }
  8544. status_calc_homunculus(hd,0);
  8545. status_percent_heal(&hd->bl, 100, 100);
  8546. clif_misceffect2(&hd->bl,568);
  8547. return 0;
  8548. }
  8549. /*==========================================
  8550. * homunculus evolution H [orn]
  8551. *------------------------------------------
  8552. */
  8553. int atcommand_homevolution(
  8554. const int fd, struct map_session_data* sd,
  8555. const char* command, const char* message)
  8556. {
  8557. nullpo_retr(-1, sd);
  8558. if (sd->hd && sd->hd->homunculusDB->evo_class)
  8559. {
  8560. merc_hom_evolution(sd->hd) ;
  8561. }
  8562. return 0;
  8563. }
  8564. /*==========================================
  8565. * call choosen homunculus [orn]
  8566. *------------------------------------------
  8567. */
  8568. int
  8569. atcommand_makehomun(
  8570. const int fd, struct map_session_data* sd,
  8571. const char* command, const char* message)
  8572. {
  8573. int homunid;
  8574. nullpo_retr(-1, sd);
  8575. if(sscanf(message, "%d", &homunid)<1)
  8576. return -1;
  8577. if( homunid < 6001 || homunid > 6016 )
  8578. return -1;
  8579. if(sd->status.hom_id == 0)
  8580. {
  8581. merc_create_homunculus(sd,homunid);
  8582. }
  8583. else
  8584. {
  8585. clif_displaymessage(fd,msg_txt(450));
  8586. }
  8587. return 0;
  8588. }
  8589. /*==========================================
  8590. * modify homunculus intimacy [orn]
  8591. *------------------------------------------
  8592. */
  8593. int atcommand_homfriendly(
  8594. const int fd, struct map_session_data* sd,
  8595. const char* command, const char* message)
  8596. {
  8597. int friendly = 0;
  8598. nullpo_retr(-1, sd);
  8599. if (!message || !*message)
  8600. return -1;
  8601. friendly = atoi(message);
  8602. if (merc_is_hom_active(sd->hd)) {
  8603. if (friendly > 0 && friendly <= 1000) {
  8604. sd->homunculus.intimacy = friendly * 100 ;
  8605. clif_send_homdata(sd,SP_INTIMATE,friendly);
  8606. } else {
  8607. return -1;
  8608. }
  8609. }
  8610. return 0;
  8611. }
  8612. /*==========================================
  8613. * modify homunculus hunger [orn]
  8614. *------------------------------------------
  8615. */
  8616. int atcommand_homhungry(
  8617. const int fd, struct map_session_data* sd,
  8618. const char* command, const char* message)
  8619. {
  8620. int hungry = 0;
  8621. nullpo_retr(-1, sd);
  8622. if (!message || !*message)
  8623. return -1;
  8624. hungry = atoi(message);
  8625. if (sd->status.hom_id > 0 && sd->hd) {
  8626. if (hungry >= 0 && hungry <= 100) {
  8627. sd->homunculus.hunger = hungry;
  8628. clif_send_homdata(sd,SP_HUNGRY,sd->homunculus.hunger);
  8629. } else {
  8630. return -1;
  8631. }
  8632. }
  8633. return 0;
  8634. }
  8635. /*==========================================
  8636. * modify homunculus hunger [orn]
  8637. *------------------------------------------
  8638. */
  8639. int atcommand_homtalk(
  8640. const int fd, struct map_session_data* sd,
  8641. const char* command, const char* message)
  8642. {
  8643. char mes[100],temp[100];
  8644. nullpo_retr(-1, sd);
  8645. if(!sd->status.hom_id || !sd->hd || !sd->homunculus.hp)
  8646. return -1;
  8647. if (sscanf(message, "%99[^\n]", mes) < 1)
  8648. return -1;
  8649. snprintf(temp, sizeof temp ,"%s : %s",sd->homunculus.name,mes);
  8650. clif_message(&sd->hd->bl, temp);
  8651. return 0;
  8652. }
  8653. /*==========================================
  8654. * Show homunculus stats
  8655. *------------------------------------------
  8656. */
  8657. int atcommand_hominfo(
  8658. const int fd, struct map_session_data* sd,
  8659. const char* command, const char* message)
  8660. {
  8661. nullpo_retr(-1, sd);
  8662. if(!merc_is_hom_active(sd->hd))
  8663. return -1;
  8664. clif_displaymessage(fd, "Homunculus stats :");
  8665. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d", sd->hd->battle_status.hp, sd->hd->battle_status.max_hp, sd->hd->battle_status.sp, sd->hd->battle_status.max_sp);
  8666. clif_displaymessage(fd, atcmd_output);
  8667. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d", sd->hd->battle_status.rhw.atk2+sd->hd->battle_status.batk, sd->hd->battle_status.matk_min, sd->hd->battle_status.matk_max);
  8668. clif_displaymessage(fd, atcmd_output);
  8669. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u", sd->homunculus.hunger, sd->homunculus.intimacy);
  8670. clif_displaymessage(fd, atcmd_output);
  8671. return 0;
  8672. }
  8673. /*==========================================
  8674. * Show Items DB Info v 1.0
  8675. * originally by [Lupus] eAthena
  8676. *------------------------------------------
  8677. */
  8678. int atcommand_iteminfo(
  8679. const int fd, struct map_session_data* sd,
  8680. const char* command, const char* message)
  8681. {
  8682. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8683. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8684. struct item_data *item_data, *item_array[MAX_SEARCH];
  8685. int i, count = 1;
  8686. if (!message || !*message) {
  8687. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8688. return -1;
  8689. }
  8690. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8691. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8692. if (!count) {
  8693. clif_displaymessage(fd, "Item not found.");
  8694. return -1;
  8695. }
  8696. if (count > MAX_SEARCH) {
  8697. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8698. clif_displaymessage(fd, atcmd_output);
  8699. count = MAX_SEARCH;
  8700. }
  8701. for (i = 0; i < count; i++) {
  8702. item_data = item_array[i];
  8703. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8704. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  8705. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8706. (item_data->script==NULL)? "None" : "With script"
  8707. );
  8708. clif_displaymessage(fd, atcmd_output);
  8709. 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. );
  8710. clif_displaymessage(fd, atcmd_output);
  8711. if (item_data->maxchance == 10000)
  8712. strcpy(atcmd_output, " - Available in the shops only");
  8713. else if (item_data->maxchance)
  8714. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8715. else
  8716. strcpy(atcmd_output, " - Monsters don't drop this item");
  8717. clif_displaymessage(fd, atcmd_output);
  8718. }
  8719. return 0;
  8720. }
  8721. /*==========================================
  8722. * Show who drops the item.
  8723. *------------------------------------------
  8724. */
  8725. int atcommand_whodrops(
  8726. const int fd, struct map_session_data* sd,
  8727. const char* command, const char* message)
  8728. {
  8729. struct item_data *item_data, *item_array[MAX_SEARCH];
  8730. int i,j, count = 1;
  8731. if (!message || !*message) {
  8732. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8733. return -1;
  8734. }
  8735. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8736. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8737. if (!count) {
  8738. clif_displaymessage(fd, "Item not found.");
  8739. return -1;
  8740. }
  8741. if (count > MAX_SEARCH) {
  8742. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8743. clif_displaymessage(fd, atcmd_output);
  8744. count = MAX_SEARCH;
  8745. }
  8746. for (i = 0; i < count; i++) {
  8747. item_data = item_array[i];
  8748. sprintf(atcmd_output, "Item: '%s'[%d]",
  8749. item_data->jname,item_data->slot);
  8750. clif_displaymessage(fd, atcmd_output);
  8751. if (item_data->mob[0].chance == 0) {
  8752. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8753. clif_displaymessage(fd, atcmd_output);
  8754. } else {
  8755. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8756. clif_displaymessage(fd, atcmd_output);
  8757. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8758. {
  8759. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8760. clif_displaymessage(fd, atcmd_output);
  8761. }
  8762. }
  8763. }
  8764. return 0;
  8765. }
  8766. /*==========================================
  8767. * @adopt by [Veider]
  8768. *
  8769. * adopt a novice
  8770. *------------------------------------------
  8771. */
  8772. int
  8773. atcommand_adopt(const int fd, struct map_session_data* sd,
  8774. const char* command, const char* message)
  8775. {
  8776. struct map_session_data *pl_sd1 = NULL;
  8777. struct map_session_data *pl_sd2 = NULL;
  8778. struct map_session_data *pl_sd3 = NULL;
  8779. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8780. nullpo_retr(-1, sd);
  8781. if (!message || !*message)
  8782. return -1;
  8783. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8784. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8785. return -1;
  8786. }
  8787. if (battle_config.etc_log)
  8788. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8789. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8790. sprintf(player2, "Cannot find player %s online", player1);
  8791. clif_displaymessage(fd, player2);
  8792. return -1;
  8793. }
  8794. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8795. sprintf(player1, "Cannot find player %s online", player2);
  8796. clif_displaymessage(fd, player1);
  8797. return -1;
  8798. }
  8799. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8800. sprintf(player1, "Cannot find player %s online", player3);
  8801. clif_displaymessage(fd, player1);
  8802. return -1;
  8803. }
  8804. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8805. clif_displaymessage(fd, "They are too young to be parents!");
  8806. return -1;
  8807. }
  8808. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8809. clif_displaymessage(fd, "They are family.. wish them luck");
  8810. return 0;
  8811. }
  8812. else
  8813. return -1;
  8814. }
  8815. int atcommand_version(
  8816. const int fd, struct map_session_data* sd,
  8817. const char* command, const char* message)
  8818. {
  8819. const char * revision;
  8820. if ((revision = get_svn_revision()) != 0) {
  8821. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8822. clif_displaymessage(fd,atcmd_output);
  8823. } else
  8824. clif_displaymessage(fd,"Cannot determine SVN revision");
  8825. return 0;
  8826. }
  8827. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8828. {
  8829. int time, id;
  8830. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8831. if (pl_sd == NULL)
  8832. return 0;
  8833. id = va_arg(ap, int);
  8834. time = va_arg(ap, int);
  8835. if (id != bl->id && !pc_isGM(pl_sd)) {
  8836. pl_sd->status.manner -= time;
  8837. if (pl_sd->status.manner < 0)
  8838. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8839. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8840. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8841. }
  8842. return 0;
  8843. }
  8844. /*==========================================
  8845. * @mutearea by MouseJstr
  8846. *------------------------------------------
  8847. */
  8848. int atcommand_mutearea(
  8849. const int fd, struct map_session_data* sd,
  8850. const char* command, const char* message)
  8851. {
  8852. int time;
  8853. nullpo_retr(0, sd);
  8854. time = atoi(message);
  8855. if (!time)
  8856. time = 15; // 15 minutes default
  8857. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8858. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8859. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8860. return 0;
  8861. }
  8862. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8863. {
  8864. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8865. if (bl == NULL)
  8866. return 0;
  8867. if (!pc_isGM(pl_sd))
  8868. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8869. return 0;
  8870. }
  8871. /*==========================================
  8872. * @shuffle by MouseJstr
  8873. *------------------------------------------
  8874. */
  8875. int atcommand_shuffle(
  8876. const int fd, struct map_session_data* sd,
  8877. const char* command, const char* message)
  8878. {
  8879. nullpo_retr(0, sd);
  8880. if (strcmp(message, "area")== 0) {
  8881. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8882. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8883. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8884. } else if (strcmp(message, "map")== 0) {
  8885. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8886. } else if (strcmp(message, "world") == 0) {
  8887. struct map_session_data **pl_allsd;
  8888. int i, users;
  8889. pl_allsd = map_getallusers(&users);
  8890. for (i = 0; i < users; i++)
  8891. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8892. } else
  8893. clif_displaymessage(fd, "options are area, map, or world");
  8894. return 0;
  8895. }
  8896. int atcommand_rates(
  8897. const int fd, struct map_session_data* sd,
  8898. const char* command, const char* message)
  8899. {
  8900. char buf[255];
  8901. nullpo_retr(0, sd);
  8902. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8903. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8904. clif_displaymessage(fd, buf);
  8905. return 0;
  8906. }
  8907. /*==========================================
  8908. * @me by lordalfa
  8909. * => Displays the OUTPUT string on top of
  8910. * the Visible players Heads.
  8911. *------------------------------------------
  8912. */
  8913. int atcommand_me(
  8914. const int fd, struct map_session_data* sd,
  8915. const char* command, const char* message)
  8916. {
  8917. char tempmes[200];
  8918. nullpo_retr(-1, sd);
  8919. memset(tempmes, '\0', sizeof(tempmes));
  8920. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8921. if (sd->sc.count && //no "chatting" while muted.
  8922. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  8923. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  8924. return -1;
  8925. if (!message || !*message) {
  8926. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8927. return -1;
  8928. }
  8929. sscanf(message, "%199[^\n]", tempmes);
  8930. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8931. clif_disp_overhead(sd, atcmd_output);
  8932. return 0;
  8933. }
  8934. /*==========================================
  8935. * @size
  8936. * => Resize your character sprite. [Valaris]
  8937. *------------------------------------------
  8938. */
  8939. int atcommand_size(
  8940. const int fd, struct map_session_data* sd,
  8941. const char* command, const char* message)
  8942. {
  8943. int size=0;
  8944. nullpo_retr(-1, sd);
  8945. if (!message || !*message)
  8946. return -1;
  8947. if (sscanf(message,"%d", &size) < 1)
  8948. return -1;
  8949. if(sd->state.size) {
  8950. sd->state.size=0;
  8951. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8952. }
  8953. if(size==1) {
  8954. sd->state.size=1;
  8955. clif_specialeffect(&sd->bl,420,AREA);
  8956. } else if(size==2) {
  8957. sd->state.size=2;
  8958. clif_specialeffect(&sd->bl,422,AREA);
  8959. }
  8960. return 0;
  8961. }
  8962. /*==========================================
  8963. * @monsterignore
  8964. * => Makes monsters ignore you. [Valaris]
  8965. *------------------------------------------
  8966. */
  8967. int atcommand_monsterignore(
  8968. const int fd, struct map_session_data* sd,
  8969. const char* command, const char* message)
  8970. {
  8971. nullpo_retr(-1, sd);
  8972. if (!sd->state.monster_ignore) {
  8973. sd->state.monster_ignore = 1;
  8974. clif_displaymessage(sd->fd, "You are now inmune to attacks.");
  8975. } else {
  8976. sd->state.monster_ignore = 0;
  8977. clif_displaymessage(sd->fd, "Returned to normal state.");
  8978. }
  8979. return 0;
  8980. }
  8981. /*==========================================
  8982. * @fakename
  8983. * => Gives your character a fake name. [Valaris]
  8984. *------------------------------------------
  8985. */
  8986. int atcommand_fakename(
  8987. const int fd, struct map_session_data* sd,
  8988. const char* command, const char* message)
  8989. {
  8990. char name[NAME_LENGTH];
  8991. nullpo_retr(-1, sd);
  8992. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8993. sd->fakename[0]='\0';
  8994. clif_charnameack(0, &sd->bl);
  8995. clif_displaymessage(sd->fd,"Returned to real name.");
  8996. return 0;
  8997. }
  8998. if (!message || !*message) {
  8999. clif_displaymessage(sd->fd,"You must enter a name.");
  9000. return 0;
  9001. }
  9002. if (sscanf(message, "%23[^\n]", name) < 1) {
  9003. return 0;
  9004. }
  9005. if(strlen(name) < 2) {
  9006. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  9007. return 0;
  9008. }
  9009. memcpy(sd->fakename,name,NAME_LENGTH-1);
  9010. clif_charnameack(0, &sd->bl);
  9011. clif_displaymessage(sd->fd,"Fake name enabled.");
  9012. return 0;
  9013. }
  9014. /*==========================================
  9015. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  9016. * => Shows information about the map flags [map name]
  9017. * Also set flags
  9018. *------------------------------------------
  9019. */
  9020. int atcommand_mapflag(
  9021. const int fd, struct map_session_data* sd,
  9022. const char* command, const char* message)
  9023. {
  9024. // WIP
  9025. return 0;
  9026. }
  9027. /*===================================
  9028. * Remove some messages
  9029. *-----------------------------------
  9030. */
  9031. int atcommand_showexp(
  9032. const int fd, struct map_session_data* sd,
  9033. const char* command, const char* message)
  9034. {
  9035. if (sd->state.showexp) {
  9036. sd->state.showexp = 0;
  9037. clif_displaymessage(fd, "Gained exp will not be shown.");
  9038. return 0;
  9039. }
  9040. sd->state.showexp = 1;
  9041. clif_displaymessage(fd, "Gained exp is now shown");
  9042. return 0;
  9043. }
  9044. int atcommand_showzeny(
  9045. const int fd, struct map_session_data* sd,
  9046. const char* command, const char* message)
  9047. {
  9048. if (sd->state.showzeny) {
  9049. sd->state.showzeny = 0;
  9050. clif_displaymessage(fd, "Gained zeny will not be shown.");
  9051. return 0;
  9052. }
  9053. sd->state.showzeny = 1;
  9054. clif_displaymessage(fd, "Gained zeny is now shown");
  9055. return 0;
  9056. }
  9057. int atcommand_showdelay(
  9058. const int fd, struct map_session_data* sd,
  9059. const char* command, const char* message)
  9060. {
  9061. if (sd->state.showdelay) {
  9062. sd->state.showdelay = 0;
  9063. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  9064. return 0;
  9065. }
  9066. sd->state.showdelay = 1;
  9067. clif_displaymessage(fd, "Skill delay failures are shown now.");
  9068. return 0;
  9069. }
  9070. /*==========================================
  9071. * Duel organizing functions [LuzZza]
  9072. *
  9073. * @duel [limit|nick] - create a duel
  9074. * @invite <nick> - invite player
  9075. * @accept - accept invitation
  9076. * @reject - reject invitation
  9077. * @leave - leave duel
  9078. *------------------------------------------
  9079. */
  9080. int atcommand_invite(
  9081. const int fd, struct map_session_data* sd,
  9082. const char* command, const char* message)
  9083. {
  9084. unsigned int did = sd->duel_group;
  9085. struct map_session_data *target_sd = map_nick2sd((char *)message);
  9086. if(did <= 0) {
  9087. // "Duel: @invite without @duel."
  9088. clif_displaymessage(fd, msg_txt(350));
  9089. return 0;
  9090. }
  9091. if(duel_list[did].max_players_limit > 0 &&
  9092. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  9093. // "Duel: Limit of players is reached."
  9094. clif_displaymessage(fd, msg_txt(351));
  9095. return 0;
  9096. }
  9097. if(target_sd == NULL) {
  9098. // "Duel: Player not found."
  9099. clif_displaymessage(fd, msg_txt(352));
  9100. return 0;
  9101. }
  9102. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9103. // "Duel: Player already in duel."
  9104. clif_displaymessage(fd, msg_txt(353));
  9105. return 0;
  9106. }
  9107. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  9108. {
  9109. sprintf(atcmd_output, msg_txt(364), message);
  9110. clif_displaymessage(fd, atcmd_output);
  9111. return 0;
  9112. }
  9113. duel_invite(did, sd, target_sd);
  9114. // "Duel: Invitation has been sent."
  9115. clif_displaymessage(fd, msg_txt(354));
  9116. return 0;
  9117. }
  9118. int atcommand_duel(
  9119. const int fd, struct map_session_data* sd,
  9120. const char* command, const char* message)
  9121. {
  9122. char output[256];
  9123. unsigned int maxpl=0, newduel;
  9124. struct map_session_data *target_sd;
  9125. /* // Commnted because it can be disabled in at-comms conf.
  9126. if(!battle_config.duel_enable) {
  9127. clif_displaymessage(fd, "Duel: duel is disable.");
  9128. return 0;
  9129. }
  9130. */
  9131. if(sd->duel_group > 0) {
  9132. duel_showinfo(sd->duel_group, sd);
  9133. return 0;
  9134. }
  9135. if(sd->duel_invite > 0) {
  9136. // "Duel: @duel without @reject."
  9137. clif_displaymessage(fd, msg_txt(355));
  9138. return 0;
  9139. }
  9140. if(!duel_checktime(sd)) {
  9141. // "Duel: You can take part in duel only one time per %d minutes."
  9142. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9143. clif_displaymessage(fd, output);
  9144. return 0;
  9145. }
  9146. if(strlen(message) > 0) {
  9147. if(sscanf(message, "%d", &maxpl) >= 1) {
  9148. if(maxpl < 2 || maxpl > 65535) {
  9149. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  9150. return 0;
  9151. }
  9152. duel_create(sd, maxpl);
  9153. } else {
  9154. target_sd = map_nick2sd((char *)message);
  9155. if(target_sd != NULL) {
  9156. if((newduel = duel_create(sd, 2)) != -1) {
  9157. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9158. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  9159. return 0;
  9160. }
  9161. duel_invite(newduel, sd, target_sd);
  9162. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  9163. }
  9164. } else {
  9165. // "Duel: Player not found."
  9166. clif_displaymessage(fd, msg_txt(352));
  9167. return 0;
  9168. }
  9169. }
  9170. } else
  9171. duel_create(sd, 0);
  9172. return 0;
  9173. }
  9174. int atcommand_leave(
  9175. const int fd, struct map_session_data* sd,
  9176. const char* command, const char* message)
  9177. {
  9178. if(sd->duel_group <= 0) {
  9179. // "Duel: @leave without @duel."
  9180. clif_displaymessage(fd, msg_txt(358));
  9181. return 0;
  9182. }
  9183. duel_leave(sd->duel_group, sd);
  9184. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  9185. return 0;
  9186. }
  9187. int atcommand_accept(
  9188. const int fd, struct map_session_data* sd,
  9189. const char* command, const char* message)
  9190. {
  9191. char output[256];
  9192. if(!duel_checktime(sd)) {
  9193. // "Duel: You can take part in duel only one time per %d minutes."
  9194. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9195. clif_displaymessage(fd, output);
  9196. return 0;
  9197. }
  9198. if(sd->duel_invite <= 0) {
  9199. // "Duel: @accept without invititation."
  9200. clif_displaymessage(fd, msg_txt(360));
  9201. return 0;
  9202. }
  9203. duel_accept(sd->duel_invite, sd);
  9204. // "Duel: Invitation has been accepted."
  9205. clif_displaymessage(fd, msg_txt(361));
  9206. return 0;
  9207. }
  9208. int atcommand_reject(
  9209. const int fd, struct map_session_data* sd,
  9210. const char* command, const char* message)
  9211. {
  9212. if(sd->duel_invite <= 0) {
  9213. // "Duel: @reject without invititation."
  9214. clif_displaymessage(fd, msg_txt(362));
  9215. return 0;
  9216. }
  9217. duel_reject(sd->duel_invite, sd);
  9218. // "Duel: Invitation has been rejected."
  9219. clif_displaymessage(fd, msg_txt(363));
  9220. return 0;
  9221. }
  9222. /*===================================
  9223. * Away message (@away, @aw) [LuzZza]
  9224. *-----------------------------------
  9225. */
  9226. int atcommand_away(
  9227. const int fd, struct map_session_data* sd,
  9228. const char* command, const char* message)
  9229. {
  9230. if(strlen(message) > 0) {
  9231. if(strlen(message) > 128)
  9232. return -1;
  9233. strcpy(sd->away_message, message);
  9234. //"Away automessage has been activated."
  9235. clif_displaymessage(fd, msg_txt(546));
  9236. } else {
  9237. if(strlen(sd->away_message) > 0) {
  9238. sd->away_message[0] = 0;
  9239. //"Away automessage has been disabled."
  9240. clif_displaymessage(fd, msg_txt(547));
  9241. return 0;
  9242. }
  9243. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  9244. clif_displaymessage(fd, msg_txt(548));
  9245. }
  9246. return 0;
  9247. }
  9248. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  9249. int atcommand_clone(
  9250. const int fd, struct map_session_data* sd,
  9251. const char* command, const char* message)
  9252. {
  9253. int x=0,y=0,flag=0,master=0,i=0;
  9254. struct map_session_data *pl_sd=NULL;
  9255. if (!message || !*message) {
  9256. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  9257. return 0;
  9258. }
  9259. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  9260. clif_displaymessage(fd, msg_txt(3));
  9261. return 0;
  9262. }
  9263. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  9264. clif_displaymessage(fd, msg_txt(126));
  9265. return 0;
  9266. }
  9267. if (strcmpi(command, "@clone") == 0)
  9268. flag = 1;
  9269. else if (strcmpi(command, "@slaveclone") == 0) {
  9270. flag = 2;
  9271. master = sd->bl.id;
  9272. if (battle_config.atc_slave_clone_limit
  9273. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  9274. clif_displaymessage(fd, msg_txt(127));
  9275. return 0;
  9276. }
  9277. }
  9278. do {
  9279. x = sd->bl.x + (rand() % 10 - 5);
  9280. y = sd->bl.y + (rand() % 10 - 5);
  9281. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  9282. if (i >= 10) {
  9283. x = sd->bl.x;
  9284. y = sd->bl.y;
  9285. }
  9286. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  9287. clif_displaymessage(fd, msg_txt(128+flag*2));
  9288. return 0;
  9289. }
  9290. clif_displaymessage(fd, msg_txt(129+flag*2));
  9291. return 0;
  9292. }
  9293. /*===================================
  9294. * Main chat [LuzZza]
  9295. * Usage: @main <on|off|message>
  9296. *-----------------------------------
  9297. */
  9298. int atcommand_main(
  9299. const int fd, struct map_session_data* sd,
  9300. const char* command, const char* message)
  9301. {
  9302. if(strlen(message) > 0) {
  9303. if(strcmpi(message, "on") == 0) {
  9304. if(!sd->state.mainchat) {
  9305. sd->state.mainchat = 1;
  9306. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  9307. } else {
  9308. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  9309. }
  9310. } else if(strcmpi(message, "off") == 0) {
  9311. if(sd->state.mainchat) {
  9312. sd->state.mainchat = 0;
  9313. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  9314. } else {
  9315. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  9316. }
  9317. } else {
  9318. if(!sd->state.mainchat) {
  9319. sd->state.mainchat = 1;
  9320. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  9321. }
  9322. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  9323. clif_displaymessage(fd, msg_txt(387));
  9324. return -1;
  9325. }
  9326. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  9327. // I use 0xFE000000 color for signalizing that this message is
  9328. // main chat message. 0xFE000000 is invalid color, same using
  9329. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  9330. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  9331. }
  9332. } else {
  9333. if(sd->state.mainchat)
  9334. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  9335. clif_displaymessage(fd, msg_txt(384));
  9336. else
  9337. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  9338. clif_displaymessage(fd, msg_txt(385));
  9339. }
  9340. return 0;
  9341. }
  9342. /*=====================================
  9343. * Autorejecting Invites/Deals [LuzZza]
  9344. * Usage: @noask
  9345. *-------------------------------------
  9346. */
  9347. int atcommand_noask(
  9348. const int fd, struct map_session_data* sd,
  9349. const char* command, const char* message)
  9350. {
  9351. if(sd->state.noask) {
  9352. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  9353. sd->state.noask = 0;
  9354. } else {
  9355. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  9356. sd->state.noask = 1;
  9357. }
  9358. return 0;
  9359. }
  9360. /*=====================================
  9361. * Send a @request message to all GMs of lowest_gm_level.
  9362. * Usage: @request <petition>
  9363. *-------------------------------------
  9364. */
  9365. int atcommand_request(
  9366. const int fd, struct map_session_data* sd,
  9367. const char* command, const char* message)
  9368. {
  9369. if (!message || !*message) {
  9370. clif_displaymessage(sd->fd,msg_txt(277));
  9371. return -1;
  9372. }
  9373. sprintf(atcmd_output, msg_txt(278), message);
  9374. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  9375. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  9376. clif_displaymessage(sd->fd,msg_txt(279));
  9377. return 0;
  9378. }
  9379. void do_init_atcommand() {
  9380. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  9381. duel_count = 0;
  9382. memset(&duel_list[0], 0, sizeof(duel_list));
  9383. return;
  9384. }
  9385. void do_final_atcommand() {
  9386. users_db->destroy(users_db,NULL);
  9387. }