atcommand.c 267 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "atcommand.h"
  14. #include "battle.h"
  15. #include "clif.h"
  16. #include "chrif.h"
  17. #include "intif.h"
  18. #include "itemdb.h"
  19. #include "log.h"
  20. #include "map.h"
  21. #include "pc.h"
  22. #include "status.h"
  23. #include "skill.h"
  24. #include "mob.h"
  25. #include "npc.h"
  26. #include "pet.h"
  27. #include "mercenary.h"
  28. #include "party.h"
  29. #include "guild.h"
  30. #include "script.h"
  31. #include "trade.h"
  32. #include "unit.h"
  33. #ifndef TXT_ONLY
  34. #include "mail.h"
  35. #endif
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include <string.h>
  39. #include <math.h>
  40. // extern variables
  41. char atcommand_symbol = '@'; // first char of the commands
  42. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  43. // local declarations
  44. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  45. typedef struct AtCommandInfo
  46. {
  47. const char* command;
  48. int level;
  49. AtCommandFunc func;
  50. } AtCommandInfo;
  51. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  52. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func);
  53. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message);
  54. /*=========================================
  55. * Generic variables
  56. *-----------------------------------------*/
  57. char atcmd_output[200];
  58. char atcmd_player_name[NAME_LENGTH];
  59. char atcmd_temp[100];
  60. // compare function for sorting high to lowest
  61. int hightolow_compare (const void * a, const void * b)
  62. {
  63. return ( *(int*)b - *(int*)a );
  64. }
  65. // compare function for sorting lowest to highest
  66. int lowtohigh_compare (const void * a, const void * b)
  67. {
  68. return ( *(int*)a - *(int*)b );
  69. }
  70. //-----------------------------------------------------------
  71. // Return the message string of the specified number by [Yor]
  72. //-----------------------------------------------------------
  73. char* msg_txt(int msg_number)
  74. {
  75. if (msg_number >= 0 && msg_number < MAX_MSG &&
  76. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  77. return msg_table[msg_number];
  78. return "??";
  79. }
  80. //-----------------------------------------------------------
  81. // Returns Players title (from msg_athena.conf) [Lupus]
  82. //-----------------------------------------------------------
  83. static char* player_title_txt(int level)
  84. {
  85. const char* format;
  86. format = (level >= battle_config.title_lvl8) ? msg_txt(332)
  87. : (level >= battle_config.title_lvl7) ? msg_txt(331)
  88. : (level >= battle_config.title_lvl6) ? msg_txt(330)
  89. : (level >= battle_config.title_lvl5) ? msg_txt(329)
  90. : (level >= battle_config.title_lvl4) ? msg_txt(328)
  91. : (level >= battle_config.title_lvl3) ? msg_txt(327)
  92. : (level >= battle_config.title_lvl2) ? msg_txt(326)
  93. : (level >= battle_config.title_lvl1) ? msg_txt(325)
  94. : "";
  95. sprintf(atcmd_temp, format, level);
  96. return atcmd_temp;
  97. }
  98. /*==========================================
  99. * Read Message Data
  100. *------------------------------------------*/
  101. int msg_config_read(const char* cfgName)
  102. {
  103. int msg_number;
  104. char line[1024], w1[1024], w2[1024];
  105. FILE *fp;
  106. static int called = 1;
  107. if ((fp = fopen(cfgName, "r")) == NULL) {
  108. ShowError("Messages file not found: %s\n", cfgName);
  109. return 1;
  110. }
  111. if ((--called) == 0)
  112. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  113. while(fgets(line, sizeof(line), fp))
  114. {
  115. if (line[0] == '/' && line[1] == '/')
  116. continue;
  117. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  118. continue;
  119. if (strcmpi(w1, "import") == 0)
  120. msg_config_read(w2);
  121. else
  122. {
  123. msg_number = atoi(w1);
  124. if (msg_number >= 0 && msg_number < MAX_MSG)
  125. {
  126. if (msg_table[msg_number] != NULL)
  127. aFree(msg_table[msg_number]);
  128. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  129. strcpy(msg_table[msg_number],w2);
  130. }
  131. }
  132. }
  133. fclose(fp);
  134. return 0;
  135. }
  136. /*==========================================
  137. * Cleanup Message Data
  138. *------------------------------------------*/
  139. void do_final_msg(void)
  140. {
  141. int i;
  142. for (i = 0; i < MAX_MSG; i++)
  143. aFree(msg_table[i]);
  144. }
  145. /*==========================================
  146. * @send (used for testing packet sends from the client)
  147. *------------------------------------------*/
  148. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  149. {
  150. int len=0,off,end,type;
  151. long num;
  152. (void)command; // not used
  153. // read message type as hex number (without the 0x)
  154. if(!message || !*message ||
  155. !((sscanf(message, "len %x", &type)==1 && (len=1))
  156. || sscanf(message, "%x", &type)==1) )
  157. {
  158. clif_displaymessage(fd, "Usage:");
  159. clif_displaymessage(fd, " @send len <packet hex number>");
  160. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  161. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  162. return -1;
  163. }
  164. #define PARSE_ERROR(error,p) \
  165. {\
  166. clif_displaymessage(fd, (error));\
  167. sprintf(atcmd_output, ">%s", (p));\
  168. clif_displaymessage(fd, atcmd_output);\
  169. }
  170. //define PARSE_ERROR
  171. #define CHECK_EOS(p) \
  172. if(*(p) == 0){\
  173. clif_displaymessage(fd, "Unexpected end of string");\
  174. return -1;\
  175. }
  176. //define CHECK_EOS
  177. #define SKIP_VALUE(p) \
  178. {\
  179. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  180. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  181. }
  182. //define SKIP_VALUE
  183. #define GET_VALUE(p,num) \
  184. {\
  185. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  186. PARSE_ERROR("Invalid number in:",(p));\
  187. return -1;\
  188. }\
  189. }
  190. //define GET_VALUE
  191. if (type > 0 && type < MAX_PACKET_DB) {
  192. if(len)
  193. {// show packet length
  194. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  195. clif_displaymessage(fd, atcmd_output);
  196. return 0;
  197. }
  198. len=packet_db[sd->packet_ver][type].len;
  199. off=2;
  200. if(len == 0)
  201. {// unknown packet - ERROR
  202. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  203. clif_displaymessage(fd, atcmd_output);
  204. return -1;
  205. } else if(len == -1)
  206. {// dynamic packet
  207. len=SHRT_MAX-4; // maximum length
  208. off=4;
  209. }
  210. WFIFOHEAD(fd, len);
  211. WFIFOW(fd,0)=TOW(type);
  212. // parse packet contents
  213. SKIP_VALUE(message);
  214. while(*message != 0 && off < len){
  215. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  216. {// default (byte)
  217. GET_VALUE(message,num);
  218. WFIFOB(fd,off)=TOB(num);
  219. ++off;
  220. } else if(TOUPPER(*message) == 'B')
  221. {// byte
  222. ++message;
  223. GET_VALUE(message,num);
  224. WFIFOB(fd,off)=TOB(num);
  225. ++off;
  226. } else if(TOUPPER(*message) == 'W')
  227. {// word (2 bytes)
  228. ++message;
  229. GET_VALUE(message,num);
  230. WFIFOW(fd,off)=TOW(num);
  231. off+=2;
  232. } else if(TOUPPER(*message) == 'L')
  233. {// long word (4 bytes)
  234. ++message;
  235. GET_VALUE(message,num);
  236. WFIFOL(fd,off)=TOL(num);
  237. off+=4;
  238. } else if(TOUPPER(*message) == 'S')
  239. {// string - escapes are valid
  240. // get string length - num <= 0 means not fixed length (default)
  241. ++message;
  242. if(*message == '"'){
  243. num=0;
  244. } else {
  245. GET_VALUE(message,num);
  246. while(*message != '"')
  247. {// find start of string
  248. if(*message == 0 || ISSPACE(*message)){
  249. PARSE_ERROR("Not a string:",message);
  250. return -1;
  251. }
  252. ++message;
  253. }
  254. }
  255. // parse string
  256. ++message;
  257. CHECK_EOS(message);
  258. end=(num<=0? 0: min(off+((int)num),len));
  259. for(; *message != '"' && (off < end || end == 0); ++off){
  260. if(*message == '\\'){
  261. ++message;
  262. CHECK_EOS(message);
  263. switch(*message){
  264. case 'a': num=0x07; break; // Bell
  265. case 'b': num=0x08; break; // Backspace
  266. case 't': num=0x09; break; // Horizontal tab
  267. case 'n': num=0x0A; break; // Line feed
  268. case 'v': num=0x0B; break; // Vertical tab
  269. case 'f': num=0x0C; break; // Form feed
  270. case 'r': num=0x0D; break; // Carriage return
  271. case 'e': num=0x1B; break; // Escape
  272. default: num=*message; break;
  273. case 'x': // Hexadecimal
  274. {
  275. ++message;
  276. CHECK_EOS(message);
  277. if(!ISXDIGIT(*message)){
  278. PARSE_ERROR("Not a hexadecimal digit:",message);
  279. return -1;
  280. }
  281. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  282. if(ISXDIGIT(*message)){
  283. ++message;
  284. CHECK_EOS(message);
  285. num<<=8;
  286. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  287. }
  288. WFIFOB(fd,off)=TOB(num);
  289. ++message;
  290. CHECK_EOS(message);
  291. continue;
  292. }
  293. case '0':
  294. case '1':
  295. case '2':
  296. case '3':
  297. case '4':
  298. case '5':
  299. case '6':
  300. case '7': // Octal
  301. {
  302. num=*message-'0'; // 1st octal digit
  303. ++message;
  304. CHECK_EOS(message);
  305. if(ISDIGIT(*message) && *message < '8'){
  306. num<<=3;
  307. num+=*message-'0'; // 2nd octal digit
  308. ++message;
  309. CHECK_EOS(message);
  310. if(ISDIGIT(*message) && *message < '8'){
  311. num<<=3;
  312. num+=*message-'0'; // 3rd octal digit
  313. ++message;
  314. CHECK_EOS(message);
  315. }
  316. }
  317. WFIFOB(fd,off)=TOB(num);
  318. continue;
  319. }
  320. }
  321. } else
  322. num=*message;
  323. WFIFOB(fd,off)=TOB(num);
  324. ++message;
  325. CHECK_EOS(message);
  326. }//for
  327. while(*message != '"')
  328. {// ignore extra characters
  329. ++message;
  330. CHECK_EOS(message);
  331. }
  332. // terminate the string
  333. if(off < end)
  334. {// fill the rest with 0's
  335. memset(WFIFOP(fd,off),0,end-off);
  336. off=end;
  337. }
  338. } else
  339. {// unknown
  340. PARSE_ERROR("Unknown type of value in:",message);
  341. return -1;
  342. }
  343. SKIP_VALUE(message);
  344. }
  345. if(packet_db[sd->packet_ver][type].len == -1)
  346. {// send dynamic packet
  347. WFIFOW(fd,2)=TOW(off);
  348. WFIFOSET(fd,off);
  349. } else
  350. {// send static packet
  351. if(off < len)
  352. memset(WFIFOP(fd,off),0,len-off);
  353. WFIFOSET(fd,len);
  354. }
  355. } else {
  356. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  357. return -1;
  358. }
  359. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  360. clif_displaymessage(fd, atcmd_output);
  361. return 0;
  362. #undef PARSE_ERROR
  363. #undef CHECK_EOS
  364. #undef SKIP_VALUE
  365. #undef GET_VALUE
  366. }
  367. /*==========================================
  368. * @rura, @warp, @mapmove
  369. *------------------------------------------*/
  370. int atcommand_mapmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  371. {
  372. char map_name[MAP_NAME_LENGTH_EXT];
  373. unsigned short mapindex;
  374. int x = 0, y = 0;
  375. int m = -1;
  376. nullpo_retr(-1, sd);
  377. memset(map_name, '\0', sizeof(map_name));
  378. if (!message || !*message ||
  379. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  380. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  381. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  382. return -1;
  383. }
  384. mapindex = mapindex_name2id(map_name);
  385. if (mapindex)
  386. m = map_mapindex2mapid(mapindex);
  387. if (!mapindex || m < 0) {
  388. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  389. return -1;
  390. }
  391. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  392. { //This is to prevent the pc_setpos call from printing an error.
  393. clif_displaymessage(fd, msg_txt(2));
  394. x = y = 0; //Invalid cell, use random spot.
  395. }
  396. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  397. clif_displaymessage(fd, msg_txt(247));
  398. return -1;
  399. }
  400. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  401. clif_displaymessage(fd, msg_txt(248));
  402. return -1;
  403. }
  404. if (pc_setpos(sd, mapindex, x, y, 3) != 0) {
  405. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  406. return -1;
  407. }
  408. clif_displaymessage(fd, msg_txt(0)); // Warped.
  409. return 0;
  410. }
  411. /*==========================================
  412. * Displays where a character is. Corrected version by Silent. [Skotlex]
  413. *------------------------------------------*/
  414. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  415. {
  416. struct map_session_data* pl_sd;
  417. nullpo_retr(-1, sd);
  418. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  419. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  420. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  421. return -1;
  422. }
  423. pl_sd = map_nick2sd(atcmd_player_name);
  424. if( pl_sd == NULL
  425. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  426. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  427. ) {
  428. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  429. return -1;
  430. }
  431. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  432. clif_displaymessage(fd, atcmd_output);
  433. return 0;
  434. }
  435. /*==========================================
  436. *
  437. *------------------------------------------*/
  438. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  439. {
  440. struct map_session_data *pl_sd = NULL;
  441. nullpo_retr(-1, sd);
  442. if (!message || !*message) {
  443. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  444. return -1;
  445. }
  446. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  447. {
  448. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  449. return -1;
  450. }
  451. if (pl_sd == sd)
  452. {
  453. clif_displaymessage(fd, "But you are already where you are...");
  454. return -1;
  455. }
  456. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  457. {
  458. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  459. return -1;
  460. }
  461. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  462. {
  463. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  464. return -1;
  465. }
  466. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  467. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  468. clif_displaymessage(fd, atcmd_output);
  469. return 0;
  470. }
  471. /*==========================================
  472. *
  473. *------------------------------------------*/
  474. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  475. {
  476. int x = 0, y = 0;
  477. nullpo_retr(-1, sd);
  478. memset(atcmd_output, '\0', sizeof(atcmd_output));
  479. sscanf(message, "%d %d", &x, &y);
  480. if (x <= 0) //If coordinates are 'wrong', random jump.
  481. x = -1;
  482. if (y <= 0)
  483. y = -1;
  484. if (sd->bl.m >= 0 && map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  485. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  486. return -1;
  487. }
  488. pc_setpos(sd, sd->mapindex, x, y, 3);
  489. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  490. clif_displaymessage(fd, atcmd_output);
  491. return 0;
  492. }
  493. /*==========================================
  494. * @who3 = Player name, his location
  495. *------------------------------------------*/
  496. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  497. {
  498. char temp0[100];
  499. struct map_session_data *pl_sd, **pl_allsd;
  500. int i, j, count, users;
  501. int pl_GM_level, GM_level;
  502. char match_text[100];
  503. char player_name[NAME_LENGTH];
  504. nullpo_retr(-1, sd);
  505. memset(atcmd_output, '\0', sizeof(atcmd_output));
  506. memset(match_text, '\0', sizeof(match_text));
  507. memset(player_name, '\0', sizeof(player_name));
  508. if (sscanf(message, "%99[^\n]", match_text) < 1)
  509. strcpy(match_text, "");
  510. for (j = 0; match_text[j]; j++)
  511. match_text[j] = TOLOWER(match_text[j]);
  512. count = 0;
  513. GM_level = pc_isGM(sd);
  514. pl_allsd = map_getallusers(&users);
  515. for (i = 0; i < users; i++) {
  516. if ((pl_sd = pl_allsd[i])) {
  517. pl_GM_level = pc_isGM(pl_sd);
  518. 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
  519. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  520. for (j = 0; player_name[j]; j++)
  521. player_name[j] = TOLOWER(player_name[j]);
  522. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  523. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  524. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  525. } else {
  526. atcmd_output[0]=0;
  527. }
  528. //Player name
  529. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  530. strcat(atcmd_output,temp0);
  531. //Player title, if exists
  532. if (pl_GM_level > 0) {
  533. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  534. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  535. strcat(atcmd_output,temp0);
  536. }
  537. //Players Location: map x y
  538. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  539. strcat(atcmd_output,temp0);
  540. clif_displaymessage(fd, atcmd_output);
  541. count++;
  542. }
  543. }
  544. }
  545. }
  546. if (count == 0)
  547. clif_displaymessage(fd, msg_txt(28)); // No player found.
  548. else if (count == 1)
  549. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  550. else {
  551. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  552. clif_displaymessage(fd, atcmd_output);
  553. }
  554. return 0;
  555. }
  556. /*==========================================
  557. * Player name, BLevel, Job,
  558. *------------------------------------------*/
  559. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  560. {
  561. char temp0[100];
  562. struct map_session_data *pl_sd, **pl_allsd;
  563. int i, j, count, users;
  564. int pl_GM_level, GM_level;
  565. char match_text[100];
  566. char player_name[NAME_LENGTH];
  567. nullpo_retr(-1, sd);
  568. memset(atcmd_output, '\0', sizeof(atcmd_output));
  569. memset(match_text, '\0', sizeof(match_text));
  570. memset(player_name, '\0', sizeof(player_name));
  571. if (sscanf(message, "%99[^\n]", match_text) < 1)
  572. strcpy(match_text, "");
  573. for (j = 0; match_text[j]; j++)
  574. match_text[j] = TOLOWER(match_text[j]);
  575. count = 0;
  576. GM_level = pc_isGM(sd);
  577. pl_allsd = map_getallusers(&users);
  578. for (i = 0; i < users; i++) {
  579. if ((pl_sd = pl_allsd[i])) {
  580. pl_GM_level = pc_isGM(pl_sd);
  581. 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
  582. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  583. for (j = 0; player_name[j]; j++)
  584. player_name[j] = TOLOWER(player_name[j]);
  585. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  586. //Players Name
  587. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  588. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  589. //Player title, if exists
  590. if (pl_GM_level > 0) {
  591. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  592. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  593. strcat(atcmd_output,temp0);
  594. }
  595. //Players Base Level / Job name
  596. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  597. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  598. strcat(atcmd_output,temp0);
  599. clif_displaymessage(fd, atcmd_output);
  600. count++;
  601. }
  602. }
  603. }
  604. }
  605. if (count == 0)
  606. clif_displaymessage(fd, msg_txt(28)); // No player found.
  607. else if (count == 1)
  608. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  609. else {
  610. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  611. clif_displaymessage(fd, atcmd_output);
  612. }
  613. return 0;
  614. }
  615. /*==========================================
  616. * Player name, Playrs Party / Guild name
  617. *------------------------------------------*/
  618. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  619. {
  620. char temp0[100];
  621. struct map_session_data *pl_sd, **pl_allsd;
  622. int i, j, count, users;
  623. int pl_GM_level, GM_level;
  624. char match_text[100];
  625. char player_name[NAME_LENGTH];
  626. struct guild *g;
  627. struct party_data *p;
  628. nullpo_retr(-1, sd);
  629. memset(temp0, '\0', sizeof(temp0));
  630. memset(atcmd_output, '\0', sizeof(atcmd_output));
  631. memset(match_text, '\0', sizeof(match_text));
  632. memset(player_name, '\0', sizeof(player_name));
  633. if (sscanf(message, "%99[^\n]", match_text) < 1)
  634. strcpy(match_text, "");
  635. for (j = 0; match_text[j]; j++)
  636. match_text[j] = TOLOWER(match_text[j]);
  637. count = 0;
  638. GM_level = pc_isGM(sd);
  639. pl_allsd = map_getallusers(&users);
  640. for (i = 0; i < users; i++) {
  641. if ((pl_sd = pl_allsd[i])) {
  642. pl_GM_level = pc_isGM(pl_sd);
  643. 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
  644. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  645. for (j = 0; player_name[j]; j++)
  646. player_name[j] = TOLOWER(player_name[j]);
  647. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  648. g = guild_search(pl_sd->status.guild_id);
  649. p = party_search(pl_sd->status.party_id);
  650. //Players Name
  651. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  652. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  653. //Player title, if exists
  654. if (pl_GM_level > 0) {
  655. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  656. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  657. strcat(atcmd_output,temp0);
  658. }
  659. //Players Party if exists
  660. if (p != NULL) {
  661. //sprintf(temp0," | Party: '%s'", p->name);
  662. sprintf(temp0, msg_txt(335), p->party.name);
  663. strcat(atcmd_output,temp0);
  664. }
  665. //Players Guild if exists
  666. if (g != NULL) {
  667. //sprintf(temp0," | Guild: '%s'", g->name);
  668. sprintf(temp0, msg_txt(336), g->name);
  669. strcat(atcmd_output,temp0);
  670. }
  671. clif_displaymessage(fd, atcmd_output);
  672. count++;
  673. }
  674. }
  675. }
  676. }
  677. if (count == 0)
  678. clif_displaymessage(fd, msg_txt(28)); // No player found.
  679. else if (count == 1)
  680. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  681. else {
  682. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  683. clif_displaymessage(fd, atcmd_output);
  684. }
  685. return 0;
  686. }
  687. /*==========================================
  688. *
  689. *------------------------------------------*/
  690. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  691. {
  692. struct map_session_data *pl_sd, **pl_allsd;
  693. int i, count, users;
  694. int pl_GM_level, GM_level;
  695. int map_id;
  696. char map_name[MAP_NAME_LENGTH_EXT];
  697. memset(atcmd_output, '\0', sizeof(atcmd_output));
  698. memset(map_name, '\0', sizeof(map_name));
  699. if (!message || !*message)
  700. map_id = sd->bl.m;
  701. else {
  702. sscanf(message, "%15s", map_name);
  703. if ((map_id = map_mapname2mapid(map_name)) < 0)
  704. map_id = sd->bl.m;
  705. }
  706. count = 0;
  707. GM_level = pc_isGM(sd);
  708. pl_allsd = map_getallusers(&users);
  709. for (i = 0; i < users; i++) {
  710. if ((pl_sd = pl_allsd[i])) {
  711. pl_GM_level = pc_isGM(pl_sd);
  712. 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
  713. if (pl_sd->bl.m == map_id) {
  714. if (pl_GM_level > 0)
  715. 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);
  716. else
  717. 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);
  718. clif_displaymessage(fd, atcmd_output);
  719. count++;
  720. }
  721. }
  722. }
  723. }
  724. if (count == 0)
  725. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  726. else if (count == 1)
  727. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  728. else {
  729. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  730. }
  731. clif_displaymessage(fd, atcmd_output);
  732. return 0;
  733. }
  734. /*==========================================
  735. *
  736. *------------------------------------------*/
  737. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  738. {
  739. struct map_session_data *pl_sd, **pl_allsd;
  740. int i, count, users;
  741. int pl_GM_level, GM_level;
  742. int map_id = 0;
  743. char map_name[MAP_NAME_LENGTH_EXT];
  744. nullpo_retr(-1, sd);
  745. memset(atcmd_output, '\0', sizeof(atcmd_output));
  746. memset(map_name, '\0', sizeof(map_name));
  747. if (!message || !*message)
  748. map_id = sd->bl.m;
  749. else {
  750. sscanf(message, "%15s", map_name);
  751. if ((map_id = map_mapname2mapid(map_name)) < 0)
  752. map_id = sd->bl.m;
  753. }
  754. count = 0;
  755. GM_level = pc_isGM(sd);
  756. pl_allsd = map_getallusers(&users);
  757. for (i = 0; i < users; i++) {
  758. if ((pl_sd = pl_allsd[i])) {
  759. pl_GM_level = pc_isGM(pl_sd);
  760. 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
  761. if (pl_sd->bl.m == map_id) {
  762. if (pl_GM_level > 0)
  763. 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);
  764. else
  765. 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);
  766. clif_displaymessage(fd, atcmd_output);
  767. count++;
  768. }
  769. }
  770. }
  771. }
  772. if (count == 0)
  773. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  774. else if (count == 1)
  775. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  776. else {
  777. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  778. }
  779. clif_displaymessage(fd, atcmd_output);
  780. return 0;
  781. }
  782. /*==========================================
  783. *
  784. *------------------------------------------*/
  785. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  786. {
  787. char temp0[100];
  788. char temp1[100];
  789. struct map_session_data *pl_sd, **pl_allsd;
  790. int i, count, users;
  791. int pl_GM_level, GM_level;
  792. int map_id = 0;
  793. char map_name[MAP_NAME_LENGTH_EXT];
  794. struct guild *g;
  795. struct party_data *p;
  796. nullpo_retr(-1, sd);
  797. memset(temp0, '\0', sizeof(temp0));
  798. memset(temp1, '\0', sizeof(temp1));
  799. memset(atcmd_output, '\0', sizeof(atcmd_output));
  800. memset(map_name, '\0', sizeof(map_name));
  801. if (!message || !*message)
  802. map_id = sd->bl.m;
  803. else {
  804. sscanf(message, "%15s", map_name);
  805. if ((map_id = map_mapname2mapid(map_name)) < 0)
  806. map_id = sd->bl.m;
  807. }
  808. count = 0;
  809. GM_level = pc_isGM(sd);
  810. pl_allsd = map_getallusers(&users);
  811. for (i = 0; i < users; i++) {
  812. if ((pl_sd = pl_allsd[i])) {
  813. pl_GM_level = pc_isGM(pl_sd);
  814. 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
  815. if (pl_sd->bl.m == map_id) {
  816. g = guild_search(pl_sd->status.guild_id);
  817. if (g == NULL)
  818. sprintf(temp1, "None");
  819. else
  820. sprintf(temp1, "%s", g->name);
  821. p = party_search(pl_sd->status.party_id);
  822. if (p == NULL)
  823. sprintf(temp0, "None");
  824. else
  825. sprintf(temp0, "%s", p->party.name);
  826. if (pl_GM_level > 0)
  827. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  828. else
  829. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  830. clif_displaymessage(fd, atcmd_output);
  831. count++;
  832. }
  833. }
  834. }
  835. }
  836. if (count == 0)
  837. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  838. else if (count == 1)
  839. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  840. else {
  841. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  842. }
  843. clif_displaymessage(fd, atcmd_output);
  844. return 0;
  845. }
  846. /*==========================================
  847. *
  848. *------------------------------------------*/
  849. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  850. {
  851. struct map_session_data *pl_sd, **pl_allsd;
  852. int i, j, count, users;
  853. int pl_GM_level, GM_level;
  854. char match_text[200];
  855. char player_name[NAME_LENGTH];
  856. struct guild *g;
  857. struct party_data *p;
  858. nullpo_retr(-1, sd);
  859. memset(atcmd_output, '\0', sizeof(atcmd_output));
  860. memset(match_text, '\0', sizeof(match_text));
  861. memset(player_name, '\0', sizeof(player_name));
  862. if (sscanf(message, "%199[^\n]", match_text) < 1)
  863. strcpy(match_text, "");
  864. for (j = 0; match_text[j]; j++)
  865. match_text[j] = TOLOWER(match_text[j]);
  866. count = 0;
  867. GM_level = pc_isGM(sd);
  868. pl_allsd = map_getallusers(&users);
  869. for (i = 0; i < users; i++) {
  870. pl_sd = pl_allsd[i];
  871. pl_GM_level = pc_isGM(pl_sd);
  872. if (!pl_GM_level)
  873. continue;
  874. if (match_text[0])
  875. {
  876. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  877. for (j = 0; player_name[j]; j++)
  878. player_name[j] = TOLOWER(player_name[j]);
  879. // search with no case sensitive
  880. if (strstr(player_name, match_text) == NULL)
  881. continue;
  882. }
  883. if (pl_GM_level > GM_level) {
  884. if (pl_sd->sc.option & OPTION_INVISIBLE)
  885. continue;
  886. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  887. clif_displaymessage(fd, atcmd_output);
  888. count++;
  889. continue;
  890. }
  891. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  892. pl_sd->status.name, pl_GM_level,
  893. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  894. clif_displaymessage(fd, atcmd_output);
  895. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  896. pl_sd->status.base_level,
  897. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  898. clif_displaymessage(fd, atcmd_output);
  899. p = party_search(pl_sd->status.party_id);
  900. g = guild_search(pl_sd->status.guild_id);
  901. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  902. p?p->party.name:"None", g?g->name:"None");
  903. clif_displaymessage(fd, atcmd_output);
  904. count++;
  905. }
  906. if (count == 0)
  907. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  908. else if (count == 1)
  909. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  910. else {
  911. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  912. clif_displaymessage(fd, atcmd_output);
  913. }
  914. return 0;
  915. }
  916. int atcommand_whozeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  917. {
  918. struct map_session_data *pl_sd, **pl_allsd;
  919. int i, j, count,c, users;
  920. char match_text[100];
  921. char player_name[NAME_LENGTH];
  922. int *zeny;
  923. int *counted;
  924. nullpo_retr(-1, sd);
  925. memset(atcmd_output, '\0', sizeof(atcmd_output));
  926. memset(match_text, '\0', sizeof(match_text));
  927. memset(player_name, '\0', sizeof(player_name));
  928. if (sscanf(message, "%99[^\n]", match_text) < 1)
  929. strcpy(match_text, "");
  930. for (j = 0; match_text[j]; j++)
  931. match_text[j] = TOLOWER(match_text[j]);
  932. count = 0;
  933. pl_allsd = map_getallusers(&users);
  934. if (users < 1)
  935. {
  936. clif_displaymessage(fd, msg_txt(28)); // No player found.
  937. return 0;
  938. }
  939. zeny = (int *)aMallocA(users*sizeof(int));
  940. counted = (int *)aMallocA(users*sizeof(int));
  941. for (i = 0; i < users; i++) {
  942. if ((pl_sd = pl_allsd[i])) {
  943. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  944. for (j = 0; player_name[j]; j++)
  945. player_name[j] = TOLOWER(player_name[j]);
  946. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  947. zeny[count]=pl_sd->status.zeny;
  948. counted[i]=0;
  949. count++;
  950. }
  951. }
  952. }
  953. qsort(zeny, count, sizeof(int), hightolow_compare);
  954. for (c = 0; c < count && c < 50; c++) {
  955. if(!zeny[c])
  956. continue;
  957. for (i = 0; i < users; i++) {
  958. if(!zeny[c])
  959. continue;
  960. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  961. if(pl_sd->status.zeny==zeny[c]) {
  962. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  963. clif_displaymessage(fd, atcmd_output);
  964. zeny[c]=0;
  965. counted[i]=1;
  966. }
  967. }
  968. }
  969. }
  970. if (count == 0)
  971. clif_displaymessage(fd, msg_txt(28)); // No player found.
  972. else if (count == 1)
  973. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  974. else {
  975. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  976. clif_displaymessage(fd, atcmd_output);
  977. }
  978. aFree(zeny);
  979. aFree(counted);
  980. return 0;
  981. }
  982. /*==========================================
  983. *
  984. *------------------------------------------*/
  985. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  986. {
  987. nullpo_retr(-1, sd);
  988. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  989. if (sd->status.pet_id > 0 && sd->pd)
  990. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  991. chrif_save(sd,0);
  992. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  993. return 0;
  994. }
  995. /*==========================================
  996. *
  997. *------------------------------------------*/
  998. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  999. {
  1000. int m;
  1001. nullpo_retr(-1, sd);
  1002. m = map_mapindex2mapid(sd->status.save_point.map);
  1003. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1004. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  1005. return -1;
  1006. }
  1007. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1008. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  1009. return -1;
  1010. }
  1011. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1012. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1013. return 0;
  1014. }
  1015. /*==========================================
  1016. *
  1017. *------------------------------------------*/
  1018. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1019. {
  1020. int speed;
  1021. nullpo_retr(-1, sd);
  1022. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1023. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  1024. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1025. clif_displaymessage(fd, atcmd_output);
  1026. return -1;
  1027. }
  1028. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  1029. status_calc_bl(&sd->bl, SCB_SPEED);
  1030. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1031. return 0;
  1032. }
  1033. /*==========================================
  1034. *
  1035. *------------------------------------------*/
  1036. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1037. {
  1038. nullpo_retr(-1, sd);
  1039. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1040. return -1;
  1041. if (storage_storageopen(sd) == 1)
  1042. { //Already open.
  1043. clif_displaymessage(fd, msg_txt(250));
  1044. return -1;
  1045. }
  1046. clif_displaymessage(fd, "Storage opened.");
  1047. return 0;
  1048. }
  1049. /*==========================================
  1050. *
  1051. *------------------------------------------*/
  1052. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1053. {
  1054. struct storage *stor; //changes from Freya/Yor
  1055. nullpo_retr(-1, sd);
  1056. if (!sd->status.guild_id) {
  1057. clif_displaymessage(fd, msg_txt(252));
  1058. return -1;
  1059. }
  1060. if (sd->npc_id || sd->vender_id || sd->state.trading || sd->state.storage_flag)
  1061. return -1;
  1062. if (sd->state.storage_flag) {
  1063. clif_displaymessage(fd, msg_txt(251));
  1064. return -1;
  1065. }
  1066. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1067. clif_displaymessage(fd, msg_txt(251));
  1068. return -1;
  1069. }
  1070. storage_guild_storageopen(sd);
  1071. clif_displaymessage(fd, "Guild storage opened.");
  1072. return 0;
  1073. }
  1074. /*==========================================
  1075. *
  1076. *------------------------------------------*/
  1077. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1078. {
  1079. int param1 = 0, param2 = 0, param3 = 0;
  1080. nullpo_retr(-1, sd);
  1081. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1082. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1083. return -1;
  1084. }
  1085. sd->sc.opt1 = param1;
  1086. sd->sc.opt2 = param2;
  1087. pc_setoption(sd, param3);
  1088. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1089. return 0;
  1090. }
  1091. /*==========================================
  1092. *
  1093. *------------------------------------------*/
  1094. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1095. {
  1096. nullpo_retr(-1, sd);
  1097. if (sd->sc.option & OPTION_INVISIBLE) {
  1098. sd->sc.option &= ~OPTION_INVISIBLE;
  1099. if (sd->disguise)
  1100. status_set_viewdata(&sd->bl, sd->disguise);
  1101. else
  1102. status_set_viewdata(&sd->bl, sd->status.class_);
  1103. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1104. } else {
  1105. sd->sc.option |= OPTION_INVISIBLE;
  1106. sd->vd.class_ = INVISIBLE_CLASS;
  1107. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1108. }
  1109. clif_changeoption(&sd->bl);
  1110. return 0;
  1111. }
  1112. /*==========================================
  1113. * Changes a character's class
  1114. *------------------------------------------*/
  1115. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1116. {
  1117. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1118. int job = 0, upper = 0;
  1119. nullpo_retr(-1, sd);
  1120. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1121. {
  1122. int i, found = 0;
  1123. const struct { char name[16]; int id; } jobs[] = {
  1124. { "novice", 0 },
  1125. { "swordsman", 1 },
  1126. { "mage", 2 },
  1127. { "archer", 3 },
  1128. { "acolyte", 4 },
  1129. { "merchant", 5 },
  1130. { "thief", 6 },
  1131. { "knight", 7 },
  1132. { "priest", 8 },
  1133. { "priestess", 8 },
  1134. { "wizard", 9 },
  1135. { "blacksmith", 10 },
  1136. { "hunter", 11 },
  1137. { "assassin", 12 },
  1138. { "crusader", 14 },
  1139. { "monk", 15 },
  1140. { "sage", 16 },
  1141. { "rogue", 17 },
  1142. { "alchemist", 18 },
  1143. { "bard", 19 },
  1144. { "dancer", 20 },
  1145. { "super novice", 23 },
  1146. { "supernovice", 23 },
  1147. { "gunslinger", 24 },
  1148. { "gunner", 24 },
  1149. { "ninja", 25 },
  1150. { "high novice", 4001 },
  1151. { "swordsman high", 4002 },
  1152. { "mage high", 4003 },
  1153. { "archer high", 4004 },
  1154. { "acolyte high", 4005 },
  1155. { "merchant high", 4006 },
  1156. { "thief high", 4007 },
  1157. { "lord knight", 4008 },
  1158. { "high priest", 4009 },
  1159. { "high priestess", 4009 },
  1160. { "high wizard", 4010 },
  1161. { "whitesmith", 4011 },
  1162. { "sniper", 4012 },
  1163. { "assassin cross", 4013 },
  1164. { "paladin", 4015 },
  1165. { "champion", 4016 },
  1166. { "professor", 4017 },
  1167. { "stalker", 4018 },
  1168. { "creator", 4019 },
  1169. { "clown", 4020 },
  1170. { "gypsy", 4021 },
  1171. { "baby novice", 4023 },
  1172. { "baby swordsman", 4024 },
  1173. { "baby mage", 4025 },
  1174. { "baby archer", 4026 },
  1175. { "baby acolyte", 4027 },
  1176. { "baby merchant", 4028 },
  1177. { "baby thief", 4029 },
  1178. { "baby knight", 4030 },
  1179. { "baby priest", 4031 },
  1180. { "baby priestess", 4031 },
  1181. { "baby wizard", 4032 },
  1182. { "baby blacksmith",4033 },
  1183. { "baby hunter", 4034 },
  1184. { "baby assassin", 4035 },
  1185. { "baby crusader", 4037 },
  1186. { "baby monk", 4038 },
  1187. { "baby sage", 4039 },
  1188. { "baby rogue", 4040 },
  1189. { "baby alchemist", 4041 },
  1190. { "baby bard", 4042 },
  1191. { "baby dancer", 4043 },
  1192. { "super baby", 4045 },
  1193. { "taekwon", 4046 },
  1194. { "taekwon boy", 4046 },
  1195. { "taekwon girl", 4046 },
  1196. { "star gladiator", 4047 },
  1197. { "soul linker", 4049 },
  1198. };
  1199. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1200. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1201. job = jobs[i].id;
  1202. upper = 0;
  1203. found = 1;
  1204. break;
  1205. }
  1206. }
  1207. if (!found) {
  1208. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1209. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1210. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1211. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1212. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1213. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1214. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1215. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1216. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1217. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1218. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1219. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1220. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1221. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1222. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1223. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1224. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1225. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1226. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1227. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1228. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1229. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1230. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1231. return -1;
  1232. }
  1233. }
  1234. if (job == 37 ||job == 45)
  1235. return 0;
  1236. if (pcdb_checkid(job))
  1237. {
  1238. if (pc_jobchange(sd, job, upper) == 0)
  1239. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1240. else {
  1241. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  1242. return -1;
  1243. }
  1244. } else {
  1245. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job name/ID>).");
  1246. clif_displaymessage(fd, " 0 Novice 7 Knight 14 Crusader 21 Peco Crusader");
  1247. clif_displaymessage(fd, " 1 Swordman 8 Priest 15 Monk 22 N/A");
  1248. clif_displaymessage(fd, " 2 Mage 9 Wizard 16 Sage 23 Super Novice");
  1249. clif_displaymessage(fd, " 3 Archer 10 Blacksmith 17 Rogue 24 Gunslinger");
  1250. clif_displaymessage(fd, " 4 Acolyte 11 Hunter 18 Alchemist 25 Ninja");
  1251. clif_displaymessage(fd, " 5 Merchant 12 Assassin 19 Bard 26 N/A");
  1252. clif_displaymessage(fd, " 6 Thief 13 Peco Knight 20 Dancer");
  1253. clif_displaymessage(fd, "4001 Novice High 4008 Lord Knight 4015 Paladin 4022 Peco Paladin");
  1254. clif_displaymessage(fd, "4002 Swordman High 4009 High Priest 4016 Champion");
  1255. clif_displaymessage(fd, "4003 Mage High 4010 High Wizard 4017 Professor");
  1256. clif_displaymessage(fd, "4004 Archer High 4011 Whitesmith 4018 Stalker");
  1257. clif_displaymessage(fd, "4005 Acolyte High 4012 Sniper 4019 Creator");
  1258. clif_displaymessage(fd, "4006 Merchant High 4013 Assassin Cross 4020 Clown");
  1259. clif_displaymessage(fd, "4007 Thief High 4014 Peco Lord Knight 4021 Gypsy");
  1260. clif_displaymessage(fd, "4023 Baby Novice 4030 Baby Knight 4037 Baby Crusader 4044 Baby Peco Crusader");
  1261. clif_displaymessage(fd, "4024 Baby Swordsman 4031 Baby Priest 4038 Baby Monk 4045 Super Baby");
  1262. clif_displaymessage(fd, "4025 Baby Mage 4032 Baby Wizard 4039 Baby Sage 4046 Taekwon Kid");
  1263. clif_displaymessage(fd, "4026 Baby Archer 4033 Baby Blacksmith 4040 Baby Rogue 4047 Taekwon Master");
  1264. clif_displaymessage(fd, "4027 Baby Acolyte 4034 Baby Hunter 4041 Baby Alchemist 4048 N/A");
  1265. clif_displaymessage(fd, "4028 Baby Merchant 4035 Baby Assassin 4042 Baby Bard 4049 Soul Linker");
  1266. clif_displaymessage(fd, "4029 Baby Thief 4036 Baby Peco-Knight 4043 Baby Dancer");
  1267. clif_displaymessage(fd, "[upper]: -1 (default) to automatically determine the 'level', 0 to force normal job, 1 to force high job.");
  1268. return -1;
  1269. }
  1270. return 0;
  1271. }
  1272. /*==========================================
  1273. *
  1274. *------------------------------------------*/
  1275. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1276. {
  1277. nullpo_retr(-1, sd);
  1278. clif_specialeffect(&sd->bl,450,SELF);
  1279. status_kill(&sd->bl);
  1280. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1281. return 0;
  1282. }
  1283. /*==========================================
  1284. *
  1285. *------------------------------------------*/
  1286. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1287. {
  1288. struct map_session_data *pl_sd;
  1289. nullpo_retr(-1, sd);
  1290. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1291. if (!message || !*message) {
  1292. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1293. return -1;
  1294. }
  1295. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1296. {
  1297. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1298. return -1;
  1299. }
  1300. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1301. { // you can kill only lower or same level
  1302. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1303. return -1;
  1304. }
  1305. status_kill(&pl_sd->bl);
  1306. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1307. if (fd != pl_sd->fd)
  1308. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1309. return 0;
  1310. }
  1311. /*==========================================
  1312. *
  1313. *------------------------------------------*/
  1314. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1315. {
  1316. nullpo_retr(-1, sd);
  1317. if (!status_revive(&sd->bl, 100, 100))
  1318. {
  1319. clif_displaymessage(fd, "You're not dead.");
  1320. return -1;
  1321. }
  1322. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1323. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1324. return 0;
  1325. }
  1326. /*==========================================
  1327. * +kamic [LuzZza]
  1328. *------------------------------------------*/
  1329. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1330. {
  1331. unsigned long color=0;
  1332. nullpo_retr(-1, sd);
  1333. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1334. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1335. if (!message || !*message) {
  1336. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1337. return -1;
  1338. }
  1339. sscanf(message, "%199[^\n]", atcmd_output);
  1340. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1341. } else {
  1342. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1343. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1344. return -1;
  1345. }
  1346. if(color > 0xFFFFFF) {
  1347. clif_displaymessage(fd, "Invalid color.");
  1348. return -1;
  1349. }
  1350. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  1351. }
  1352. return 0;
  1353. }
  1354. /*==========================================
  1355. *
  1356. *------------------------------------------*/
  1357. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1358. {
  1359. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1360. nullpo_retr(-1, sd);
  1361. sscanf(message, "%d %d", &hp, &sp);
  1362. if (hp == 0 && sp == 0) {
  1363. if (!status_percent_heal(&sd->bl, 100, 100))
  1364. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1365. else
  1366. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1367. return 0;
  1368. }
  1369. if(hp > 0 && sp >= 0) {
  1370. if(!status_heal(&sd->bl, hp, sp, 0))
  1371. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1372. else
  1373. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1374. return 0;
  1375. }
  1376. if(hp < 0 && sp <= 0) {
  1377. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1378. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1379. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1380. return 0;
  1381. }
  1382. //Opposing signs.
  1383. if (hp) {
  1384. if (hp > 0)
  1385. status_heal(&sd->bl, hp, 0, 0);
  1386. else {
  1387. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1388. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1389. }
  1390. }
  1391. if (sp) {
  1392. if (sp > 0)
  1393. status_heal(&sd->bl, 0, sp, 0);
  1394. else
  1395. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1396. }
  1397. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1398. return 0;
  1399. }
  1400. /*==========================================
  1401. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1402. *------------------------------------------*/
  1403. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1404. {
  1405. char item_name[100];
  1406. int number = 0, item_id, flag;
  1407. struct item item_tmp;
  1408. struct item_data *item_data;
  1409. int get_count, i;
  1410. nullpo_retr(-1, sd);
  1411. memset(item_name, '\0', sizeof(item_name));
  1412. if (!message || !*message || (
  1413. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1414. sscanf(message, "%99s %d", item_name, &number) < 1
  1415. )) {
  1416. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1417. return -1;
  1418. }
  1419. if (number <= 0)
  1420. number = 1;
  1421. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1422. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1423. {
  1424. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1425. return -1;
  1426. }
  1427. item_id = item_data->nameid;
  1428. get_count = number;
  1429. //Check if it's stackable.
  1430. if (!itemdb_isstackable2(item_data))
  1431. get_count = 1;
  1432. for (i = 0; i < number; i += get_count) {
  1433. // if not pet egg
  1434. if (!pet_create_egg(sd, item_id)) {
  1435. memset(&item_tmp, 0, sizeof(item_tmp));
  1436. item_tmp.nameid = item_id;
  1437. item_tmp.identify = 1;
  1438. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1439. clif_additem(sd, 0, 0, flag);
  1440. }
  1441. }
  1442. //Logs (A)dmins items [Lupus]
  1443. if(log_config.enable_logs&0x400)
  1444. log_pick_pc(sd, "A", item_id, number, NULL);
  1445. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1446. return 0;
  1447. }
  1448. /*==========================================
  1449. *
  1450. *------------------------------------------*/
  1451. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1452. {
  1453. struct item item_tmp;
  1454. struct item_data *item_data;
  1455. char item_name[100];
  1456. int item_id, number = 0;
  1457. int identify = 0, refine = 0, attr = 0;
  1458. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1459. int flag;
  1460. int loop, get_count, i;
  1461. nullpo_retr(-1, sd);
  1462. memset(item_name, '\0', sizeof(item_name));
  1463. if (!message || !*message || (
  1464. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1465. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1466. )) {
  1467. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1468. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1469. return -1;
  1470. }
  1471. if (number <= 0)
  1472. number = 1;
  1473. item_id = 0;
  1474. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1475. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1476. item_id = item_data->nameid;
  1477. if (item_id > 500) {
  1478. loop = 1;
  1479. get_count = number;
  1480. if (item_data->type == 4 || item_data->type == 5 ||
  1481. item_data->type == 7 || item_data->type == 8) {
  1482. loop = number;
  1483. get_count = 1;
  1484. if (item_data->type == 7) {
  1485. identify = 1;
  1486. refine = 0;
  1487. }
  1488. if (item_data->type == 8)
  1489. refine = 0;
  1490. if (refine > 10)
  1491. refine = 10;
  1492. } else {
  1493. identify = 1;
  1494. refine = attr = 0;
  1495. }
  1496. for (i = 0; i < loop; i++) {
  1497. memset(&item_tmp, 0, sizeof(item_tmp));
  1498. item_tmp.nameid = item_id;
  1499. item_tmp.identify = identify;
  1500. item_tmp.refine = refine;
  1501. item_tmp.attribute = attr;
  1502. item_tmp.card[0] = c1;
  1503. item_tmp.card[1] = c2;
  1504. item_tmp.card[2] = c3;
  1505. item_tmp.card[3] = c4;
  1506. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  1507. clif_additem(sd, 0, 0, flag);
  1508. }
  1509. //Logs (A)dmins items [Lupus]
  1510. if(log_config.enable_logs&0x400)
  1511. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  1512. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1513. } else {
  1514. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1515. return -1;
  1516. }
  1517. return 0;
  1518. }
  1519. /*==========================================
  1520. *
  1521. *------------------------------------------*/
  1522. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1523. {
  1524. int i;
  1525. nullpo_retr(-1, sd);
  1526. for (i = 0; i < MAX_INVENTORY; i++) {
  1527. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1528. //Logs (A)dmins items [Lupus]
  1529. if(log_config.enable_logs&0x400)
  1530. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  1531. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  1532. }
  1533. }
  1534. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1535. return 0;
  1536. }
  1537. /*==========================================
  1538. * Atcommand @lvlup
  1539. *------------------------------------------*/
  1540. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1541. {
  1542. int level=0, i=0, status_point=0;
  1543. nullpo_retr(-1, sd);
  1544. level = atoi(message);
  1545. if (!message || !*message || !level) {
  1546. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1547. return -1;
  1548. }
  1549. if (level > 0) {
  1550. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1551. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1552. return -1;
  1553. } // End Addition
  1554. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1555. level = pc_maxbaselv(sd) - sd->status.base_level;
  1556. for (i = 1; i <= level; i++)
  1557. status_point += (sd->status.base_level + i + 14) / 5;
  1558. if (sd->status.status_point > USHRT_MAX - status_point)
  1559. sd->status.status_point = USHRT_MAX;
  1560. else
  1561. sd->status.status_point += status_point;
  1562. sd->status.base_level += (unsigned int)level;
  1563. status_percent_heal(&sd->bl, 100, 100);
  1564. clif_misceffect(&sd->bl, 0);
  1565. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1566. } else {
  1567. if (sd->status.base_level == 1) {
  1568. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1569. return -1;
  1570. }
  1571. level*=-1;
  1572. if ((unsigned int)level >= sd->status.base_level)
  1573. level = sd->status.base_level-1;
  1574. for (i = 0; i > -level; i--)
  1575. status_point += (sd->status.base_level + i + 14) / 5;
  1576. if (sd->status.status_point < status_point)
  1577. pc_resetstate(sd);
  1578. if (sd->status.status_point < status_point)
  1579. sd->status.status_point = 0;
  1580. else
  1581. sd->status.status_point -= status_point;
  1582. sd->status.base_level -= (unsigned int)level;
  1583. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1584. }
  1585. clif_updatestatus(sd, SP_STATUSPOINT);
  1586. clif_updatestatus(sd, SP_BASELEVEL);
  1587. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1588. status_calc_pc(sd, 0);
  1589. if(sd->status.party_id)
  1590. party_send_levelup(sd);
  1591. return 0;
  1592. }
  1593. /*==========================================
  1594. *
  1595. *------------------------------------------*/
  1596. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1597. {
  1598. int level=0;
  1599. nullpo_retr(-1, sd);
  1600. level = atoi(message);
  1601. if (!message || !*message || !level) {
  1602. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1603. return -1;
  1604. }
  1605. if (level > 0) {
  1606. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1607. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1608. return -1;
  1609. }
  1610. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1611. level = pc_maxjoblv(sd) - sd->status.job_level;
  1612. sd->status.job_level += (unsigned int)level;
  1613. clif_updatestatus(sd, SP_JOBLEVEL);
  1614. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1615. if (sd->status.skill_point > USHRT_MAX - level)
  1616. sd->status.skill_point = USHRT_MAX;
  1617. else
  1618. sd->status.skill_point += level;
  1619. clif_updatestatus(sd, SP_SKILLPOINT);
  1620. status_calc_pc(sd, 0);
  1621. clif_misceffect(&sd->bl, 1);
  1622. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1623. } else {
  1624. if (sd->status.job_level == 1) {
  1625. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1626. return -1;
  1627. }
  1628. level *=-1;
  1629. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1630. level = sd->status.job_level-1;
  1631. sd->status.job_level -= (unsigned int)level;
  1632. clif_updatestatus(sd, SP_JOBLEVEL);
  1633. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1634. if (sd->status.skill_point < level)
  1635. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1636. if (sd->status.skill_point < level)
  1637. sd->status.skill_point = 0;
  1638. else
  1639. sd->status.skill_point -= level;
  1640. clif_updatestatus(sd, SP_SKILLPOINT);
  1641. status_calc_pc(sd, 0);
  1642. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1643. }
  1644. return 0;
  1645. }
  1646. /*==========================================
  1647. * @help
  1648. *------------------------------------------*/
  1649. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1650. {
  1651. char buf[2048], w1[2048], w2[2048];
  1652. int i, gm_level;
  1653. FILE* fp;
  1654. nullpo_retr(-1, sd);
  1655. memset(buf, '\0', sizeof(buf));
  1656. if ((fp = fopen(help_txt, "r")) != NULL) {
  1657. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1658. gm_level = pc_isGM(sd);
  1659. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1660. if (buf[0] == '/' && buf[1] == '/')
  1661. continue;
  1662. for (i = 0; buf[i] != '\0'; i++) {
  1663. if (buf[i] == '\r' || buf[i] == '\n') {
  1664. buf[i] = '\0';
  1665. break;
  1666. }
  1667. }
  1668. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1669. clif_displaymessage(fd, buf);
  1670. else if (gm_level >= atoi(w1))
  1671. clif_displaymessage(fd, w2);
  1672. }
  1673. fclose(fp);
  1674. } else {
  1675. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1676. return -1;
  1677. }
  1678. return 0;
  1679. }
  1680. /*==========================================
  1681. * @help2 - Char commands [Kayla]
  1682. *------------------------------------------*/
  1683. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1684. {
  1685. char buf[2048], w1[2048], w2[2048];
  1686. int i, gm_level;
  1687. FILE* fp;
  1688. nullpo_retr(-1, sd);
  1689. memset(buf, '\0', sizeof(buf));
  1690. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1691. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1692. gm_level = pc_isGM(sd);
  1693. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1694. if (buf[0] == '/' && buf[1] == '/')
  1695. continue;
  1696. for (i = 0; buf[i] != '\0'; i++) {
  1697. if (buf[i] == '\r' || buf[i] == '\n') {
  1698. buf[i] = '\0';
  1699. break;
  1700. }
  1701. }
  1702. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1703. clif_displaymessage(fd, buf);
  1704. else if (gm_level >= atoi(w1))
  1705. clif_displaymessage(fd, w2);
  1706. }
  1707. fclose(fp);
  1708. } else {
  1709. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1710. return -1;
  1711. }
  1712. return 0;
  1713. }
  1714. /*==========================================
  1715. * @gm
  1716. *------------------------------------------*/
  1717. int atcommand_gm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1718. {
  1719. char password[100];
  1720. nullpo_retr(-1, sd);
  1721. memset(password, '\0', sizeof(password));
  1722. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  1723. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  1724. return -1;
  1725. }
  1726. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  1727. clif_displaymessage(fd, msg_txt(50)); // You already have some GM powers.
  1728. return -1;
  1729. } else
  1730. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  1731. return 0;
  1732. }
  1733. // helper function, used in foreach calls to stop auto-attack timers
  1734. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1735. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1736. {
  1737. struct unit_data *ud = unit_bl2ud(bl);
  1738. int id = va_arg(ap, int);
  1739. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1740. {
  1741. unit_stop_attack(bl);
  1742. return 1;
  1743. }
  1744. return 0;
  1745. }
  1746. /*==========================================
  1747. *
  1748. *------------------------------------------*/
  1749. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1750. {
  1751. TBL_PC* sd = (TBL_PC*)bl;
  1752. clif_pvpset(sd, 0, 0, 2);
  1753. if (sd->pvp_timer != -1) {
  1754. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1755. sd->pvp_timer = -1;
  1756. }
  1757. return 0;
  1758. }
  1759. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1760. {
  1761. nullpo_retr(-1, sd);
  1762. //if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  1763. // clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  1764. // return -1;
  1765. //}
  1766. if (!map[sd->bl.m].flag.pvp) {
  1767. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1768. return -1;
  1769. }
  1770. map[sd->bl.m].flag.pvp = 0;
  1771. if (!battle_config.pk_mode)
  1772. clif_send0199(sd->bl.m, 0);
  1773. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1774. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1775. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1776. return 0;
  1777. }
  1778. /*==========================================
  1779. *
  1780. *------------------------------------------*/
  1781. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1782. {
  1783. struct map_session_data *pl_sd, **pl_allsd;
  1784. int i, users;
  1785. nullpo_retr(-1, sd);
  1786. //if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  1787. // clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  1788. // return -1;
  1789. //}
  1790. if (!map[sd->bl.m].flag.pvp) {
  1791. map[sd->bl.m].flag.pvp = 1;
  1792. if (!battle_config.pk_mode)
  1793. {
  1794. clif_send0199(sd->bl.m, 1);
  1795. pl_allsd = map_getallusers(&users);
  1796. for (i = 0; i < users; i++) {
  1797. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  1798. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  1799. pl_sd->pvp_rank = 0;
  1800. pl_sd->pvp_lastusers = 0;
  1801. pl_sd->pvp_point = 5;
  1802. pl_sd->pvp_won = 0;
  1803. pl_sd->pvp_lost = 0;
  1804. }
  1805. }
  1806. }
  1807. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1808. } else {
  1809. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1810. return -1;
  1811. }
  1812. return 0;
  1813. }
  1814. /*==========================================
  1815. *
  1816. *------------------------------------------*/
  1817. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1818. {
  1819. nullpo_retr(-1, sd);
  1820. if (map[sd->bl.m].flag.gvg) {
  1821. map[sd->bl.m].flag.gvg = 0;
  1822. clif_send0199(sd->bl.m, 0);
  1823. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1824. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1825. } else {
  1826. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1827. return -1;
  1828. }
  1829. return 0;
  1830. }
  1831. /*==========================================
  1832. *
  1833. *------------------------------------------*/
  1834. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1835. {
  1836. nullpo_retr(-1, sd);
  1837. if (!map[sd->bl.m].flag.gvg) {
  1838. map[sd->bl.m].flag.gvg = 1;
  1839. clif_send0199(sd->bl.m, 3);
  1840. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1841. } else {
  1842. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1843. return -1;
  1844. }
  1845. return 0;
  1846. }
  1847. /*==========================================
  1848. *
  1849. *------------------------------------------*/
  1850. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1851. {
  1852. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1853. nullpo_retr(-1, sd);
  1854. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1855. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1856. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1857. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1858. clif_displaymessage(fd, atcmd_output);
  1859. return -1;
  1860. }
  1861. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1862. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1863. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1864. pc_changelook(sd, LOOK_HAIR, hair_style);
  1865. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1866. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1867. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1868. } else {
  1869. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1870. return -1;
  1871. }
  1872. return 0;
  1873. }
  1874. /*==========================================
  1875. * @dye && @ccolor
  1876. *------------------------------------------*/
  1877. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1878. {
  1879. int cloth_color = 0;
  1880. nullpo_retr(-1, sd);
  1881. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1882. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1883. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1884. clif_displaymessage(fd, atcmd_output);
  1885. return -1;
  1886. }
  1887. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1888. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1889. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1890. } else {
  1891. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1892. return -1;
  1893. }
  1894. return 0;
  1895. }
  1896. /*==========================================
  1897. * @hairstyle && @hstyle
  1898. *------------------------------------------*/
  1899. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1900. {
  1901. int hair_style = 0;
  1902. nullpo_retr(-1, sd);
  1903. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1904. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1905. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1906. clif_displaymessage(fd, atcmd_output);
  1907. return -1;
  1908. }
  1909. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1910. pc_changelook(sd, LOOK_HAIR, hair_style);
  1911. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1912. } else {
  1913. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1914. return -1;
  1915. }
  1916. return 0;
  1917. }
  1918. /*==========================================
  1919. * @haircolor && @hcolor
  1920. *------------------------------------------*/
  1921. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1922. {
  1923. int hair_color = 0;
  1924. nullpo_retr(-1, sd);
  1925. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1926. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1927. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1928. clif_displaymessage(fd, atcmd_output);
  1929. return -1;
  1930. }
  1931. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1932. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1933. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1934. } else {
  1935. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1936. return -1;
  1937. }
  1938. return 0;
  1939. }
  1940. /*==========================================
  1941. * @go [city_number or city_name] - Updated by Harbin
  1942. *------------------------------------------*/
  1943. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1944. {
  1945. int i;
  1946. int town;
  1947. char map_name[MAP_NAME_LENGTH];
  1948. int m;
  1949. const struct {
  1950. char map[MAP_NAME_LENGTH];
  1951. int x, y;
  1952. } data[] = {
  1953. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1954. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1955. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1956. { MAP_PAYON, 162, 233 }, // 3=Payon
  1957. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1958. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1959. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1960. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1961. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1962. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1963. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1964. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1965. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1966. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1967. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1968. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1969. { MAP_JAIL, 23, 61 }, // 16=Prison
  1970. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1971. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1972. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1973. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1974. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1975. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1976. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1977. { MAP_VEINS, 216, 123 }, // 24=Veins
  1978. };
  1979. nullpo_retr(-1, sd);
  1980. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  1981. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  1982. return 0;
  1983. }
  1984. memset(map_name, '\0', sizeof(map_name));
  1985. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1986. // get the number
  1987. town = atoi(message);
  1988. // if no value, display all value
  1989. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  1990. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1991. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  1992. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  1993. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  1994. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  1995. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  1996. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  1997. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  1998. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  1999. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2000. clif_displaymessage(fd, " 24=Veins");
  2001. return -1;
  2002. }
  2003. // get possible name of the city
  2004. map_name[MAP_NAME_LENGTH-1] = '\0';
  2005. for (i = 0; map_name[i]; i++)
  2006. map_name[i] = TOLOWER(map_name[i]);
  2007. // try to identify the map name
  2008. if (strncmp(map_name, "prontera", 3) == 0) {
  2009. town = 0;
  2010. } else if (strncmp(map_name, "morocc", 3) == 0) {
  2011. town = 1;
  2012. } else if (strncmp(map_name, "geffen", 3) == 0) {
  2013. town = 2;
  2014. } else if (strncmp(map_name, "payon", 3) == 0 ||
  2015. strncmp(map_name, "paion", 3) == 0) {
  2016. town = 3;
  2017. } else if (strncmp(map_name, "alberta", 3) == 0) {
  2018. town = 4;
  2019. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  2020. strncmp(map_name, "islude", 3) == 0) {
  2021. town = 5;
  2022. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2023. strcmp(map_name, "al") == 0) {
  2024. town = 6;
  2025. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  2026. strcmp(map_name, "christmas") == 0 ||
  2027. strncmp(map_name, "xmas", 3) == 0 ||
  2028. strncmp(map_name, "x-mas", 3) == 0) {
  2029. town = 7;
  2030. } else if (strncmp(map_name, "comodo", 3) == 0) {
  2031. town = 8;
  2032. } else if (strncmp(map_name, "yuno", 3) == 0) {
  2033. town = 9;
  2034. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  2035. town = 10;
  2036. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  2037. town = 11;
  2038. } else if (strncmp(map_name, "umbala", 3) == 0) {
  2039. town = 12;
  2040. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  2041. town = 13;
  2042. } else if (strncmp(map_name, "louyang", 3) == 0) {
  2043. town = 14;
  2044. } else if (strncmp(map_name, "new_zone01", 3) == 0 ||
  2045. strncmp(map_name, "startpoint", 3) == 0 ||
  2046. strncmp(map_name, "begining", 3) == 0) {
  2047. town = 15;
  2048. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2049. strncmp(map_name, "prison", 3) == 0 ||
  2050. strncmp(map_name, "jails", 3) == 0) {
  2051. town = 16;
  2052. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2053. strncmp(map_name, "jawai", 3) == 0) {
  2054. town = 17;
  2055. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2056. strncmp(map_name, "ayotaya", 3) == 0) {
  2057. town = 18;
  2058. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2059. strncmp(map_name, "ainbroch", 5) == 0) {
  2060. town = 19;
  2061. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2062. town = 20;
  2063. } else if (strncmp(map_name, "einbech", 3) == 0) {
  2064. town = 21;
  2065. } else if (strncmp(map_name, "hugel", 3) == 0) {
  2066. town = 22;
  2067. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2068. town = 23;
  2069. } else if (strncmp(map_name, "veins", 3) == 0) {
  2070. town = 24;
  2071. }
  2072. if (town >= 0 && town < ARRAYLENGTH(data))
  2073. {
  2074. m = map_mapname2mapid(data[town].map);
  2075. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2076. clif_displaymessage(fd, msg_txt(247));
  2077. return -1;
  2078. }
  2079. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2080. clif_displaymessage(fd, msg_txt(248));
  2081. return -1;
  2082. }
  2083. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, 3) == 0) {
  2084. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2085. } else {
  2086. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2087. return -1;
  2088. }
  2089. } else { // if you arrive here, you have an error in town variable when reading of names
  2090. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2091. return -1;
  2092. }
  2093. return 0;
  2094. }
  2095. /*==========================================
  2096. *
  2097. *------------------------------------------*/
  2098. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2099. {
  2100. char name[NAME_LENGTH];
  2101. char monster[NAME_LENGTH];
  2102. int mob_id;
  2103. int number = 0;
  2104. int count;
  2105. int i, k, range;
  2106. short mx, my;
  2107. nullpo_retr(-1, sd);
  2108. memset(name, '\0', sizeof(name));
  2109. memset(monster, '\0', sizeof(monster));
  2110. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2111. if (!message || !*message) {
  2112. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2113. return -1;
  2114. }
  2115. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2116. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2117. //All data can be left as it is.
  2118. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2119. //Here, it is possible name was not given and we are using monster for it.
  2120. if (count < 3) //Blank mob's name.
  2121. name[0] = '\0';
  2122. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2123. //All data can be left as it is.
  2124. } else if (sscanf(message, "%23s", monster) > 0) {
  2125. //As before, name may be already filled.
  2126. name[0] = '\0';
  2127. } else {
  2128. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2129. return -1;
  2130. }
  2131. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2132. mob_id = mobdb_checkid(atoi(monster));
  2133. if (mob_id == 0) {
  2134. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2135. return -1;
  2136. }
  2137. if (mob_id == MOBID_EMPERIUM) {
  2138. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  2139. return -1;
  2140. }
  2141. if (number <= 0)
  2142. number = 1;
  2143. if (strlen(name) < 1)
  2144. strcpy(name, "--ja--");
  2145. // 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
  2146. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2147. number = battle_config.atc_spawn_quantity_limit;
  2148. if (battle_config.etc_log)
  2149. 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);
  2150. count = 0;
  2151. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  2152. for (i = 0; i < number; i++) {
  2153. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2154. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  2155. count += (k != 0) ? 1 : 0;
  2156. }
  2157. if (count != 0)
  2158. if (number == count)
  2159. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2160. else {
  2161. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2162. clif_displaymessage(fd, atcmd_output);
  2163. }
  2164. else {
  2165. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2166. return -1;
  2167. }
  2168. return 0;
  2169. }
  2170. // small monster spawning [Valaris]
  2171. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2172. {
  2173. char name[NAME_LENGTH] = "";
  2174. char monster[NAME_LENGTH] = "";
  2175. int mob_id = 0;
  2176. int number = 0;
  2177. int x = 0;
  2178. int y = 0;
  2179. int count;
  2180. int i;
  2181. nullpo_retr(-1, sd);
  2182. if (!message || !*message) {
  2183. clif_displaymessage(fd, "Give a monster name/id please.");
  2184. return -1;
  2185. }
  2186. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2187. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2188. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2189. clif_displaymessage(fd, "Give a monster name/id please.");
  2190. return -1;
  2191. }
  2192. // If monster identifier/name argument is a name
  2193. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2194. mob_id = atoi(monster);
  2195. if (mob_id == 0) {
  2196. clif_displaymessage(fd, msg_txt(40));
  2197. return -1;
  2198. }
  2199. if (mob_id == MOBID_EMPERIUM) {
  2200. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2201. return -1;
  2202. }
  2203. if (mobdb_checkid(mob_id) == 0) {
  2204. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2205. return -1;
  2206. }
  2207. if (number <= 0)
  2208. number = 1;
  2209. if (strlen(name) < 1)
  2210. strcpy(name, "--ja--");
  2211. // 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
  2212. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2213. number = battle_config.atc_spawn_quantity_limit;
  2214. count = 0;
  2215. for (i = 0; i < number; i++) {
  2216. int mx, my;
  2217. if (x <= 0)
  2218. mx = sd->bl.x + (rand() % 11 - 5);
  2219. else
  2220. mx = x;
  2221. if (y <= 0)
  2222. my = sd->bl.y + (rand() % 11 - 5);
  2223. else
  2224. my = y;
  2225. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2226. }
  2227. if (count != 0)
  2228. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2229. else
  2230. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2231. return 0;
  2232. }
  2233. // big monster spawning [Valaris]
  2234. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2235. {
  2236. char name[NAME_LENGTH] = "";
  2237. char monster[NAME_LENGTH] = "";
  2238. int mob_id = 0;
  2239. int number = 0;
  2240. int x = 0;
  2241. int y = 0;
  2242. int count;
  2243. int i;
  2244. nullpo_retr(-1, sd);
  2245. if (!message || !*message) {
  2246. clif_displaymessage(fd, "Give a monster name/id please.");
  2247. return -1;
  2248. }
  2249. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2250. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2251. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2252. clif_displaymessage(fd, "Give a monster name/id please.");
  2253. return -1;
  2254. }
  2255. // If monster identifier/name argument is a name
  2256. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2257. mob_id = atoi(monster);
  2258. if (mob_id == 0) {
  2259. clif_displaymessage(fd, msg_txt(40));
  2260. return -1;
  2261. }
  2262. if (mob_id == MOBID_EMPERIUM) {
  2263. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2264. return -1;
  2265. }
  2266. if (mobdb_checkid(mob_id) == 0) {
  2267. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2268. return -1;
  2269. }
  2270. if (number <= 0)
  2271. number = 1;
  2272. if (strlen(name) < 1)
  2273. strcpy(name, "--ja--");
  2274. // 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
  2275. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2276. number = battle_config.atc_spawn_quantity_limit;
  2277. count = 0;
  2278. for (i = 0; i < number; i++) {
  2279. int mx, my;
  2280. if (x <= 0)
  2281. mx = sd->bl.x + (rand() % 11 - 5);
  2282. else
  2283. mx = x;
  2284. if (y <= 0)
  2285. my = sd->bl.y + (rand() % 11 - 5);
  2286. else
  2287. my = y;
  2288. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2289. }
  2290. if (count != 0)
  2291. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2292. else
  2293. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2294. return 0;
  2295. }
  2296. /*==========================================
  2297. *
  2298. *------------------------------------------*/
  2299. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2300. {
  2301. struct mob_data *md;
  2302. int flag;
  2303. nullpo_retr(0, ap);
  2304. nullpo_retr(0, md=(struct mob_data *)bl);
  2305. flag = va_arg(ap, int);
  2306. if (md->guardian_data)
  2307. return 0; //Do not touch WoE mobs!
  2308. if (flag)
  2309. status_zap(bl,md->status.hp, 0);
  2310. else
  2311. status_kill(bl);
  2312. return 1;
  2313. }
  2314. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2315. {
  2316. int map_id;
  2317. char map_name[MAP_NAME_LENGTH_EXT];
  2318. if (!sd) return;
  2319. memset(map_name, '\0', sizeof(map_name));
  2320. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2321. map_id = sd->bl.m;
  2322. else {
  2323. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2324. map_id = sd->bl.m;
  2325. }
  2326. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2327. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2328. return;
  2329. }
  2330. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2331. {
  2332. atcommand_killmonster_sub(fd, sd, message, 1);
  2333. return 0;
  2334. }
  2335. /*==========================================
  2336. *
  2337. *------------------------------------------*/
  2338. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2339. {
  2340. atcommand_killmonster_sub(fd, sd, message, 0);
  2341. return 0;
  2342. }
  2343. /*==========================================
  2344. *
  2345. *------------------------------------------*/
  2346. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2347. {
  2348. int i,j, position = 0, refine = 0, current_position, final_refine;
  2349. int count;
  2350. nullpo_retr(-1, sd);
  2351. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2352. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2353. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  2354. sprintf(atcmd_output, "%d: Left Accessory", EQI_ACC_L);
  2355. clif_displaymessage(fd, atcmd_output);
  2356. sprintf(atcmd_output, "%d: Right Accessory", EQI_ACC_R);
  2357. clif_displaymessage(fd, atcmd_output);
  2358. sprintf(atcmd_output, "%d: Shoes", EQI_SHOES);
  2359. clif_displaymessage(fd, atcmd_output);
  2360. sprintf(atcmd_output, "%d: Garment", EQI_GARMENT);
  2361. clif_displaymessage(fd, atcmd_output);
  2362. sprintf(atcmd_output, "%d: Lower Headgear", EQI_HEAD_LOW);
  2363. clif_displaymessage(fd, atcmd_output);
  2364. sprintf(atcmd_output, "%d: Mid Headgear", EQI_HEAD_MID);
  2365. clif_displaymessage(fd, atcmd_output);
  2366. sprintf(atcmd_output, "%d: Top Headgear", EQI_HEAD_TOP);
  2367. clif_displaymessage(fd, atcmd_output);
  2368. sprintf(atcmd_output, "%d: Body Armor", EQI_ARMOR);
  2369. clif_displaymessage(fd, atcmd_output);
  2370. sprintf(atcmd_output, "%d: Left Hand", EQI_HAND_L);
  2371. clif_displaymessage(fd, atcmd_output);
  2372. sprintf(atcmd_output, "%d: Right Hand", EQI_HAND_R);
  2373. clif_displaymessage(fd, atcmd_output);
  2374. return -1;
  2375. }
  2376. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2377. count = 0;
  2378. for (j = 0; j < EQI_MAX-1; j++) {
  2379. if ((i = sd->equip_index[j]) < 0)
  2380. continue;
  2381. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2382. continue;
  2383. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2384. continue;
  2385. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2386. continue;
  2387. if(position && !(sd->status.inventory[i].equip & position))
  2388. continue;
  2389. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2390. if (sd->status.inventory[i].refine != final_refine) {
  2391. sd->status.inventory[i].refine = final_refine;
  2392. current_position = sd->status.inventory[i].equip;
  2393. pc_unequipitem(sd, i, 3);
  2394. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2395. clif_delitem(sd, i, 1);
  2396. clif_additem(sd, i, 1, 0);
  2397. pc_equipitem(sd, i, current_position);
  2398. clif_misceffect(&sd->bl, 3);
  2399. count++;
  2400. }
  2401. }
  2402. if (count == 0)
  2403. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  2404. else if (count == 1)
  2405. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  2406. else {
  2407. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  2408. clif_displaymessage(fd, atcmd_output);
  2409. }
  2410. return 0;
  2411. }
  2412. /*==========================================
  2413. *
  2414. *------------------------------------------*/
  2415. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2416. {
  2417. char item_name[100];
  2418. int item_id, attribute = 0, star = 0;
  2419. int flag = 0;
  2420. struct item_data *item_data;
  2421. struct item tmp_item;
  2422. nullpo_retr(-1, sd);
  2423. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2424. memset(item_name, '\0', sizeof(item_name));
  2425. if (!message || !*message || (
  2426. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2427. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2428. )) {
  2429. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2430. return -1;
  2431. }
  2432. item_id = 0;
  2433. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2434. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2435. {
  2436. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  2437. clif_displaymessage(fd, atcmd_output);
  2438. return -1;
  2439. }
  2440. item_id = item_data->nameid;
  2441. if (itemdb_isequip2(item_data)) {
  2442. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2443. attribute = ATTRIBUTE_NORMAL;
  2444. if (star < MIN_STAR || star > MAX_STAR)
  2445. star = 0;
  2446. memset(&tmp_item, 0, sizeof tmp_item);
  2447. tmp_item.nameid = item_id;
  2448. tmp_item.amount = 1;
  2449. tmp_item.identify = 1;
  2450. tmp_item.card[0] = CARD0_FORGE;
  2451. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2452. ((star*5) << 8) + attribute:0;
  2453. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2454. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2455. clif_produceeffect(sd, 0, item_id);
  2456. clif_misceffect(&sd->bl, 3);
  2457. //Logs (A)dmins items [Lupus]
  2458. if(log_config.enable_logs&0x400)
  2459. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  2460. if ((flag = pc_additem(sd, &tmp_item, 1)))
  2461. clif_additem(sd, 0, 0, flag);
  2462. } else {
  2463. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  2464. clif_displaymessage(fd, atcmd_output);
  2465. return -1;
  2466. }
  2467. return 0;
  2468. }
  2469. /*==========================================
  2470. *
  2471. *------------------------------------------*/
  2472. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2473. {
  2474. int position = 0;
  2475. nullpo_retr(-1, sd);
  2476. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2477. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2478. {
  2479. int i;
  2480. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2481. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2482. {
  2483. if( sd->status.memo_point[i].map )
  2484. 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);
  2485. else
  2486. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2487. clif_displaymessage(sd->fd, atcmd_output);
  2488. }
  2489. return 0;
  2490. }
  2491. if( position < 0 && position >= MAX_MEMOPOINTS )
  2492. {
  2493. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2494. clif_displaymessage(fd, atcmd_output);
  2495. return -1;
  2496. }
  2497. pc_memo(sd, position);
  2498. return 0;
  2499. }
  2500. /*==========================================
  2501. *
  2502. *------------------------------------------*/
  2503. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2504. {
  2505. int y;
  2506. nullpo_retr(-1, sd);
  2507. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2508. for (y = 2; y >= -2; y--) {
  2509. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2510. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2511. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2512. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2513. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2514. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2515. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2516. clif_displaymessage(fd, atcmd_output);
  2517. }
  2518. return 0;
  2519. }
  2520. /*==========================================
  2521. *
  2522. *------------------------------------------*/
  2523. int atcommand_displaystatus(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2524. {
  2525. int i, type, flag;
  2526. nullpo_retr(-1, sd);
  2527. if (!message || !*message || (i = sscanf(message, "%d %d", &type, &flag)) < 1) {
  2528. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag>).");
  2529. return -1;
  2530. }
  2531. if (i == 1) flag = 1;
  2532. clif_status_change(&sd->bl, type, flag);
  2533. return 0;
  2534. }
  2535. /*==========================================
  2536. * @stpoint (Rewritten by [Yor])
  2537. *------------------------------------------*/
  2538. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2539. {
  2540. int point, new_status_point;
  2541. if (!message || !*message || (point = atoi(message)) == 0) {
  2542. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2543. return -1;
  2544. }
  2545. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  2546. new_status_point = USHRT_MAX;
  2547. else
  2548. if (point < 0 && sd->status.status_point < -point)
  2549. new_status_point = 0;
  2550. else
  2551. new_status_point = sd->status.status_point + point;
  2552. if (new_status_point != (int)sd->status.status_point) {
  2553. sd->status.status_point = (unsigned short)new_status_point;
  2554. clif_updatestatus(sd, SP_STATUSPOINT);
  2555. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  2556. } else {
  2557. if (point < 0)
  2558. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2559. else
  2560. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2561. return -1;
  2562. }
  2563. return 0;
  2564. }
  2565. /*==========================================
  2566. * @skpoint (Rewritten by [Yor])
  2567. *------------------------------------------*/
  2568. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2569. {
  2570. int point, new_skill_point;
  2571. nullpo_retr(-1, sd);
  2572. if (!message || !*message || (point = atoi(message)) == 0) {
  2573. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2574. return -1;
  2575. }
  2576. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  2577. new_skill_point = USHRT_MAX;
  2578. else if (point < 0 && sd->status.skill_point < -point)
  2579. new_skill_point = 0;
  2580. else
  2581. new_skill_point = sd->status.skill_point + point;
  2582. if (new_skill_point != (int)sd->status.skill_point) {
  2583. sd->status.skill_point = (unsigned short)new_skill_point;
  2584. clif_updatestatus(sd, SP_SKILLPOINT);
  2585. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  2586. } else {
  2587. if (point < 0)
  2588. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2589. else
  2590. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2591. return -1;
  2592. }
  2593. return 0;
  2594. }
  2595. /*==========================================
  2596. * @zeny (Rewritten by [Yor])
  2597. *------------------------------------------*/
  2598. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2599. {
  2600. int zeny, new_zeny;
  2601. nullpo_retr(-1, sd);
  2602. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2603. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2604. return -1;
  2605. }
  2606. new_zeny = sd->status.zeny + zeny;
  2607. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2608. new_zeny = MAX_ZENY;
  2609. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2610. new_zeny = 0;
  2611. if (new_zeny != sd->status.zeny) {
  2612. sd->status.zeny = new_zeny;
  2613. clif_updatestatus(sd, SP_ZENY);
  2614. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  2615. } else {
  2616. if (zeny < 0)
  2617. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2618. else
  2619. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2620. return -1;
  2621. }
  2622. return 0;
  2623. }
  2624. /*==========================================
  2625. *
  2626. *------------------------------------------*/
  2627. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2628. {
  2629. int i, value = 0, new_value, max;
  2630. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  2631. short* status[6];
  2632. //we don't use direct initialization because it isn't part of the c standard.
  2633. nullpo_retr(-1, sd);
  2634. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2635. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2636. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2637. clif_displaymessage(fd, atcmd_output);
  2638. return -1;
  2639. }
  2640. for (i = 0; param[i] != NULL; i++)
  2641. if (strcmpi(command, param[i]) == 0)
  2642. break;
  2643. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  2644. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2645. clif_displaymessage(fd, atcmd_output);
  2646. return -1;
  2647. }
  2648. status[0] = &sd->status.str;
  2649. status[1] = &sd->status.agi;
  2650. status[2] = &sd->status.vit;
  2651. status[3] = &sd->status.int_;
  2652. status[4] = &sd->status.dex;
  2653. status[5] = &sd->status.luk;
  2654. max = SHRT_MAX;
  2655. new_value = cap_value(*status[i] + value, 1, max);
  2656. if (new_value != (int)*status[i]) {
  2657. *status[i] = new_value;
  2658. clif_updatestatus(sd, SP_STR + i);
  2659. clif_updatestatus(sd, SP_USTR + i);
  2660. status_calc_pc(sd, 0);
  2661. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2662. } else {
  2663. if (value < 0)
  2664. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  2665. else
  2666. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  2667. return -1;
  2668. }
  2669. return 0;
  2670. }
  2671. /*==========================================
  2672. * Stat all by fritz (rewritten by [Yor])
  2673. *------------------------------------------*/
  2674. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2675. {
  2676. int index, count, value, max, new_value;
  2677. short* status[6];
  2678. //we don't use direct initialization because it isn't part of the c standard.
  2679. nullpo_retr(-1, sd);
  2680. status[0] = &sd->status.str;
  2681. status[1] = &sd->status.agi;
  2682. status[2] = &sd->status.vit;
  2683. status[3] = &sd->status.int_;
  2684. status[4] = &sd->status.dex;
  2685. status[5] = &sd->status.luk;
  2686. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2687. value = pc_maxparameter(sd);
  2688. max = pc_maxparameter(sd);
  2689. } else {
  2690. max = SHRT_MAX;
  2691. }
  2692. count = 0;
  2693. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2694. if (value > 0 && *status[index] > max - value)
  2695. new_value = max;
  2696. else if (value < 0 && *status[index] <= -value)
  2697. new_value = 1;
  2698. else
  2699. new_value = *status[index] +value;
  2700. if (new_value != (int)*status[index]) {
  2701. *status[index] = new_value;
  2702. clif_updatestatus(sd, SP_STR + index);
  2703. clif_updatestatus(sd, SP_USTR + index);
  2704. count++;
  2705. }
  2706. }
  2707. if (count > 0) { // if at least 1 stat modified
  2708. status_calc_pc(sd, 0);
  2709. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2710. } else {
  2711. if (value < 0)
  2712. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  2713. else
  2714. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  2715. return -1;
  2716. }
  2717. return 0;
  2718. }
  2719. /*==========================================
  2720. *
  2721. *------------------------------------------*/
  2722. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2723. {
  2724. int level = 0;
  2725. short added_level;
  2726. struct guild *guild_info;
  2727. nullpo_retr(-1, sd);
  2728. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2729. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2730. return -1;
  2731. }
  2732. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2733. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2734. return -1;
  2735. }
  2736. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2737. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2738. // return -1;
  2739. //}
  2740. added_level = (short)level;
  2741. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2742. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2743. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2744. added_level = 1 - guild_info->guild_lv;
  2745. if (added_level != 0) {
  2746. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  2747. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2748. } else {
  2749. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2750. return -1;
  2751. }
  2752. return 0;
  2753. }
  2754. /*==========================================
  2755. *
  2756. *------------------------------------------*/
  2757. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2758. {
  2759. struct item_data *item_data;
  2760. int id, pet_id;
  2761. nullpo_retr(-1, sd);
  2762. if (!message || !*message) {
  2763. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2764. return -1;
  2765. }
  2766. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2767. id = item_data->nameid;
  2768. else
  2769. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2770. ;
  2771. else
  2772. id = atoi(message);
  2773. pet_id = search_petDB_index(id, PET_CLASS);
  2774. if (pet_id < 0)
  2775. pet_id = search_petDB_index(id, PET_EGG);
  2776. if (pet_id >= 0) {
  2777. sd->catch_target_class = pet_db[pet_id].class_;
  2778. intif_create_pet(
  2779. sd->status.account_id, sd->status.char_id,
  2780. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2781. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2782. 100, 0, 1, pet_db[pet_id].jname);
  2783. } else {
  2784. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2785. return -1;
  2786. }
  2787. return 0;
  2788. }
  2789. /*==========================================
  2790. *
  2791. *------------------------------------------*/
  2792. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2793. {
  2794. nullpo_retr(-1, sd);
  2795. if (sd->status.pet_id <= 0)
  2796. clif_sendegg(sd);
  2797. else {
  2798. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2799. return -1;
  2800. }
  2801. return 0;
  2802. }
  2803. /*==========================================
  2804. *
  2805. *------------------------------------------*/
  2806. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2807. {
  2808. int friendly;
  2809. struct pet_data *pd;
  2810. nullpo_retr(-1, sd);
  2811. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2812. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2813. return -1;
  2814. }
  2815. pd = sd->pd;
  2816. if (!pd) {
  2817. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2818. return -1;
  2819. }
  2820. if (friendly < 0 || friendly > 1000)
  2821. {
  2822. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2823. return -1;
  2824. }
  2825. if (friendly == pd->pet.intimate) {
  2826. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  2827. return -1;
  2828. }
  2829. pd->pet.intimate = friendly;
  2830. clif_send_petstatus(sd);
  2831. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  2832. return 0;
  2833. }
  2834. /*==========================================
  2835. *
  2836. *------------------------------------------*/
  2837. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2838. {
  2839. int hungry;
  2840. struct pet_data *pd;
  2841. nullpo_retr(-1, sd);
  2842. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2843. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2844. return -1;
  2845. }
  2846. pd = sd->pd;
  2847. if (!sd->status.pet_id || !pd) {
  2848. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2849. return -1;
  2850. }
  2851. if (hungry < 0 || hungry > 100) {
  2852. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2853. return -1;
  2854. }
  2855. if (hungry == pd->pet.hungry) {
  2856. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  2857. return -1;
  2858. }
  2859. pd->pet.hungry = hungry;
  2860. clif_send_petstatus(sd);
  2861. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  2862. return 0;
  2863. }
  2864. /*==========================================
  2865. *
  2866. *------------------------------------------*/
  2867. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2868. {
  2869. struct pet_data *pd;
  2870. nullpo_retr(-1, sd);
  2871. if (!sd->status.pet_id || !sd->pd) {
  2872. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2873. return -1;
  2874. }
  2875. pd = sd->pd;
  2876. if (!pd->pet.rename_flag) {
  2877. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2878. return -1;
  2879. }
  2880. pd->pet.rename_flag = 0;
  2881. intif_save_petdata(sd->status.account_id, &pd->pet);
  2882. clif_send_petstatus(sd);
  2883. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2884. return 0;
  2885. }
  2886. /*==========================================
  2887. *
  2888. *------------------------------------------*/
  2889. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2890. {
  2891. struct map_session_data *pl_sd = NULL;
  2892. nullpo_retr(-1, sd);
  2893. if (!message || !*message) {
  2894. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2895. return -1;
  2896. }
  2897. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2898. {
  2899. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2900. return -1;
  2901. }
  2902. if (pl_sd == sd)
  2903. {
  2904. clif_displaymessage(fd, "You are already where you are...");
  2905. return -1;
  2906. }
  2907. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  2908. {
  2909. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2910. return -1;
  2911. }
  2912. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2913. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  2914. return -1;
  2915. }
  2916. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2917. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  2918. return -1;
  2919. }
  2920. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  2921. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2922. clif_displaymessage(fd, atcmd_output);
  2923. return 0;
  2924. }
  2925. /*==========================================
  2926. * charblock command (usage: charblock <player_name>)
  2927. * This command do a definitiv ban on a player
  2928. *------------------------------------------*/
  2929. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2930. {
  2931. nullpo_retr(-1, sd);
  2932. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2933. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2934. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  2935. return -1;
  2936. }
  2937. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2938. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2939. return 0;
  2940. }
  2941. /*==========================================
  2942. * charban command (usage: charban <time> <player_name>)
  2943. * This command do a limited ban on a player
  2944. * Time is done as follows:
  2945. * Adjustment value (-1, 1, +1, etc...)
  2946. * Modified element:
  2947. * a or y: year
  2948. * m: month
  2949. * j or d: day
  2950. * h: hour
  2951. * mn: minute
  2952. * s: second
  2953. * <example> @ban +1m-2mn1s-6y test_player
  2954. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2955. *------------------------------------------*/
  2956. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2957. {
  2958. char * modif_p;
  2959. int year, month, day, hour, minute, second, value;
  2960. nullpo_retr(-1, sd);
  2961. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2962. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2963. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2964. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  2965. return -1;
  2966. }
  2967. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2968. modif_p = atcmd_output;
  2969. year = month = day = hour = minute = second = 0;
  2970. while (modif_p[0] != '\0') {
  2971. value = atoi(modif_p);
  2972. if (value == 0)
  2973. modif_p++;
  2974. else {
  2975. if (modif_p[0] == '-' || modif_p[0] == '+')
  2976. modif_p++;
  2977. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2978. modif_p++;
  2979. if (modif_p[0] == 's') {
  2980. second = value;
  2981. modif_p++;
  2982. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  2983. minute = value;
  2984. modif_p = modif_p + 2;
  2985. } else if (modif_p[0] == 'h') {
  2986. hour = value;
  2987. modif_p++;
  2988. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2989. day = value;
  2990. modif_p++;
  2991. } else if (modif_p[0] == 'm') {
  2992. month = value;
  2993. modif_p++;
  2994. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2995. year = value;
  2996. modif_p++;
  2997. } else if (modif_p[0] != '\0') {
  2998. modif_p++;
  2999. }
  3000. }
  3001. }
  3002. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3003. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3004. return -1;
  3005. }
  3006. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3007. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3008. return 0;
  3009. }
  3010. /*==========================================
  3011. * charunblock command (usage: charunblock <player_name>)
  3012. *------------------------------------------*/
  3013. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3014. {
  3015. nullpo_retr(-1, sd);
  3016. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3017. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3018. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3019. return -1;
  3020. }
  3021. // send answer to login server via char-server
  3022. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3023. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3024. return 0;
  3025. }
  3026. /*==========================================
  3027. * charunban command (usage: charunban <player_name>)
  3028. *------------------------------------------*/
  3029. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3030. {
  3031. nullpo_retr(-1, sd);
  3032. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3033. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3034. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3035. return -1;
  3036. }
  3037. // send answer to login server via char-server
  3038. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3039. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3040. return 0;
  3041. }
  3042. /*==========================================
  3043. *
  3044. *------------------------------------------*/
  3045. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3046. {
  3047. nullpo_retr(-1, sd);
  3048. if (night_flag != 1) {
  3049. map_night_timer(night_timer_tid, 0, 0, 1);
  3050. } else {
  3051. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  3052. return -1;
  3053. }
  3054. return 0;
  3055. }
  3056. /*==========================================
  3057. *
  3058. *------------------------------------------*/
  3059. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3060. {
  3061. nullpo_retr(-1, sd);
  3062. if (night_flag != 0) {
  3063. map_day_timer(day_timer_tid, 0, 0, 1);
  3064. } else {
  3065. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  3066. return -1;
  3067. }
  3068. return 0;
  3069. }
  3070. /*==========================================
  3071. *
  3072. *------------------------------------------*/
  3073. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3074. {
  3075. struct map_session_data *pl_sd, **pl_allsd;
  3076. int i, users;
  3077. nullpo_retr(-1, sd);
  3078. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  3079. pl_allsd = map_getallusers(&users);
  3080. for(i = 0; i < users; i++) {
  3081. 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
  3082. status_kill(&pl_sd->bl);
  3083. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3084. }
  3085. }
  3086. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3087. return 0;
  3088. }
  3089. /*==========================================
  3090. *
  3091. *------------------------------------------*/
  3092. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3093. {
  3094. struct map_session_data *pl_sd, **pl_allsd;
  3095. int i, users;
  3096. nullpo_retr(-1, sd);
  3097. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  3098. pl_allsd = map_getallusers(&users);
  3099. for (i = 0; i < users; i++) {
  3100. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  3101. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  3102. {
  3103. status_kill(&pl_sd->bl);
  3104. // clif_specialeffect(&pl_sd->bl,450,1);
  3105. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3106. }
  3107. }
  3108. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3109. return 0;
  3110. }
  3111. /*==========================================
  3112. *
  3113. *------------------------------------------*/
  3114. static void atcommand_raise_sub(struct map_session_data* sd)
  3115. {
  3116. if (!sd->state.auth || !status_isdead(&sd->bl))
  3117. return;
  3118. if(!status_revive(&sd->bl, 100, 100))
  3119. return;
  3120. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3121. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3122. }
  3123. /*==========================================
  3124. *
  3125. *------------------------------------------*/
  3126. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3127. {
  3128. int i, users;
  3129. struct map_session_data **all_sd;
  3130. nullpo_retr(-1, sd);
  3131. all_sd = map_getallusers(&users);
  3132. for (i = 0; i < users; i++) {
  3133. atcommand_raise_sub(all_sd[i]);
  3134. }
  3135. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3136. return 0;
  3137. }
  3138. /*==========================================
  3139. *
  3140. *------------------------------------------*/
  3141. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3142. {
  3143. struct map_session_data **pl_allsd;
  3144. int i, users;
  3145. nullpo_retr(-1, sd);
  3146. pl_allsd = map_getallusers(&users);
  3147. for (i = 0; i < users; i++) {
  3148. if (sd->bl.m == pl_allsd[i]->bl.m)
  3149. atcommand_raise_sub(pl_allsd[i]);
  3150. }
  3151. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3152. return 0;
  3153. }
  3154. /*==========================================
  3155. *
  3156. *------------------------------------------*/
  3157. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3158. {
  3159. struct map_session_data *pl_sd;
  3160. nullpo_retr(-1, sd);
  3161. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3162. if (!message || !*message) {
  3163. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3164. return -1;
  3165. }
  3166. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3167. {
  3168. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3169. return -1;
  3170. }
  3171. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3172. {
  3173. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3174. return -1;
  3175. }
  3176. clif_GM_kick(sd, pl_sd, 1);
  3177. return 0;
  3178. }
  3179. /*==========================================
  3180. *
  3181. *------------------------------------------*/
  3182. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3183. {
  3184. struct map_session_data *pl_sd, **pl_allsd;
  3185. int i, users;
  3186. nullpo_retr(-1, sd);
  3187. pl_allsd = map_getallusers(&users);
  3188. for (i = 0; i < users; i++) {
  3189. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3190. if (sd->status.account_id != pl_sd->status.account_id)
  3191. clif_GM_kick(sd, pl_sd, 0);
  3192. }
  3193. }
  3194. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3195. return 0;
  3196. }
  3197. /*==========================================
  3198. *
  3199. *------------------------------------------*/
  3200. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3201. {
  3202. nullpo_retr(-1, sd);
  3203. pc_allskillup(sd); // all skills
  3204. sd->status.skill_point = 0; // 0 skill points
  3205. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3206. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  3207. return 0;
  3208. }
  3209. /*==========================================
  3210. *
  3211. *------------------------------------------*/
  3212. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3213. {
  3214. int skill_id;
  3215. nullpo_retr(-1, sd);
  3216. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3217. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3218. return -1;
  3219. }
  3220. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3221. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3222. return -1;
  3223. }
  3224. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3225. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3226. return -1;
  3227. }
  3228. if (pc_checkskill(sd, skill_id) > 0) {
  3229. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3230. return -1;
  3231. }
  3232. pc_skill(sd, skill_id, 1, 0);
  3233. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3234. return 0;
  3235. }
  3236. /*==========================================
  3237. *
  3238. *------------------------------------------*/
  3239. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3240. {
  3241. int skill_id;
  3242. nullpo_retr(-1, sd);
  3243. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3244. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3245. return -1;
  3246. }
  3247. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3248. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3249. return -1;
  3250. }
  3251. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3252. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3253. return -1;
  3254. }
  3255. if (pc_checkskill(sd, skill_id) == 0) {
  3256. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3257. return -1;
  3258. }
  3259. sd->status.skill[skill_id].lv = 0;
  3260. sd->status.skill[skill_id].flag = 0;
  3261. clif_skillinfoblock(sd);
  3262. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3263. return 0;
  3264. }
  3265. /*==========================================
  3266. *
  3267. *------------------------------------------*/
  3268. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3269. {
  3270. int number;
  3271. nullpo_retr(-1, sd);
  3272. if (!message || !*message || (number = atoi(message)) < 0) {
  3273. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  3274. return -1;
  3275. }
  3276. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  3277. if (number > 500)
  3278. number = 500;
  3279. if (number >= 0 && number <= 0x7FFF) {
  3280. if (sd->spiritball != number || number > 499) {
  3281. if (sd->spiritball > 0)
  3282. pc_delspiritball(sd, sd->spiritball, 1);
  3283. sd->spiritball = number;
  3284. clif_spiritball(sd);
  3285. // no message, player can look the difference
  3286. if (number > 1000)
  3287. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  3288. } else {
  3289. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  3290. return -1;
  3291. }
  3292. } else {
  3293. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3294. return -1;
  3295. }
  3296. return 0;
  3297. }
  3298. /*==========================================
  3299. *
  3300. *------------------------------------------*/
  3301. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3302. {
  3303. char party[NAME_LENGTH];
  3304. nullpo_retr(-1, sd);
  3305. memset(party, '\0', sizeof(party));
  3306. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3307. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3308. return -1;
  3309. }
  3310. party_create(sd, party, 0, 0);
  3311. return 0;
  3312. }
  3313. /*==========================================
  3314. *
  3315. *------------------------------------------*/
  3316. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3317. {
  3318. char guild[NAME_LENGTH];
  3319. int prev;
  3320. nullpo_retr(-1, sd);
  3321. memset(guild, '\0', sizeof(guild));
  3322. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3323. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3324. return -1;
  3325. }
  3326. prev = battle_config.guild_emperium_check;
  3327. battle_config.guild_emperium_check = 0;
  3328. guild_create(sd, guild);
  3329. battle_config.guild_emperium_check = prev;
  3330. return 0;
  3331. }
  3332. /*==========================================
  3333. *
  3334. *------------------------------------------*/
  3335. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3336. {
  3337. nullpo_retr(-1, sd);
  3338. if (agit_flag == 1) {
  3339. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  3340. return -1;
  3341. }
  3342. agit_flag = 1;
  3343. guild_agit_start();
  3344. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  3345. return 0;
  3346. }
  3347. /*==========================================
  3348. *
  3349. *------------------------------------------*/
  3350. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3351. {
  3352. nullpo_retr(-1, sd);
  3353. if (agit_flag == 0) {
  3354. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  3355. return -1;
  3356. }
  3357. agit_flag = 0;
  3358. guild_agit_end();
  3359. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  3360. return 0;
  3361. }
  3362. /*==========================================
  3363. * @mapexit - shuts down the map server
  3364. *------------------------------------------*/
  3365. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3366. {
  3367. struct map_session_data *pl_sd, **pl_allsd;
  3368. int i, users;
  3369. nullpo_retr(-1, sd);
  3370. pl_allsd = map_getallusers(&users);
  3371. for (i = 0; i < users; i++) {
  3372. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  3373. clif_GM_kick(sd, pl_sd, 0);
  3374. }
  3375. clif_GM_kick(sd, sd, 0);
  3376. flush_fifos();
  3377. runflag = 0;
  3378. return 0;
  3379. }
  3380. /*==========================================
  3381. * idsearch <part_of_name>: revrited by [Yor]
  3382. *------------------------------------------*/
  3383. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3384. {
  3385. char item_name[100];
  3386. unsigned int i, match;
  3387. struct item_data *item_array[MAX_SEARCH];
  3388. nullpo_retr(-1, sd);
  3389. memset(item_name, '\0', sizeof(item_name));
  3390. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3391. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3392. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3393. return -1;
  3394. }
  3395. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3396. clif_displaymessage(fd, atcmd_output);
  3397. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3398. if (match > MAX_SEARCH) {
  3399. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3400. clif_displaymessage(fd, atcmd_output);
  3401. match = MAX_SEARCH;
  3402. }
  3403. for(i = 0; i < match; i++) {
  3404. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3405. clif_displaymessage(fd, atcmd_output);
  3406. }
  3407. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3408. clif_displaymessage(fd, atcmd_output);
  3409. return 0;
  3410. }
  3411. /*==========================================
  3412. * Recall All Characters Online To Your Location
  3413. *------------------------------------------*/
  3414. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3415. {
  3416. struct map_session_data *pl_sd, **pl_allsd;
  3417. int i;
  3418. int count, users;
  3419. nullpo_retr(-1, sd);
  3420. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3421. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3422. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3423. return -1;
  3424. }
  3425. count = 0;
  3426. pl_allsd = map_getallusers(&users);
  3427. for (i = 0; i < users; i++) {
  3428. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  3429. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3430. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3431. count++;
  3432. else {
  3433. if (pc_isdead(pl_sd)) { //Wake them up
  3434. pc_setstand(pl_sd);
  3435. pc_setrestartvalue(pl_sd,1);
  3436. }
  3437. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3438. }
  3439. }
  3440. }
  3441. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3442. if (count) {
  3443. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3444. clif_displaymessage(fd, atcmd_output);
  3445. }
  3446. return 0;
  3447. }
  3448. /*==========================================
  3449. * Recall online characters of a guild to your location
  3450. *------------------------------------------*/
  3451. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3452. {
  3453. struct map_session_data *pl_sd, **pl_allsd;
  3454. int i, users, count;
  3455. char guild_name[NAME_LENGTH];
  3456. struct guild *g;
  3457. nullpo_retr(-1, sd);
  3458. memset(guild_name, '\0', sizeof(guild_name));
  3459. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3460. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3461. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3462. return -1;
  3463. }
  3464. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3465. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3466. return -1;
  3467. }
  3468. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3469. (g = guild_search(atoi(message))) != NULL) {
  3470. count = 0;
  3471. pl_allsd = map_getallusers(&users);
  3472. for (i = 0; i < users; i++) {
  3473. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  3474. pl_sd->status.guild_id == g->guild_id) {
  3475. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3476. continue; //Skip GMs greater than you.
  3477. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3478. count++;
  3479. else
  3480. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3481. }
  3482. }
  3483. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  3484. clif_displaymessage(fd, atcmd_output);
  3485. if (count) {
  3486. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3487. clif_displaymessage(fd, atcmd_output);
  3488. }
  3489. } else {
  3490. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3491. return -1;
  3492. }
  3493. return 0;
  3494. }
  3495. /*==========================================
  3496. * Recall online characters of a party to your location
  3497. *------------------------------------------*/
  3498. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3499. {
  3500. int i;
  3501. struct map_session_data *pl_sd, **pl_allsd;
  3502. char party_name[NAME_LENGTH];
  3503. struct party_data *p;
  3504. int count, users;
  3505. nullpo_retr(-1, sd);
  3506. memset(party_name, '\0', sizeof(party_name));
  3507. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3508. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3509. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3510. return -1;
  3511. }
  3512. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3513. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3514. return -1;
  3515. }
  3516. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3517. (p = party_search(atoi(message))) != NULL) {
  3518. count = 0;
  3519. pl_allsd = map_getallusers(&users);
  3520. for (i = 0; i < users; i++) {
  3521. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  3522. pl_sd->status.party_id == p->party.party_id) {
  3523. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3524. continue; //Skip GMs greater than you.
  3525. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3526. count++;
  3527. else
  3528. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3529. }
  3530. }
  3531. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  3532. clif_displaymessage(fd, atcmd_output);
  3533. if (count) {
  3534. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3535. clif_displaymessage(fd, atcmd_output);
  3536. }
  3537. } else {
  3538. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3539. return -1;
  3540. }
  3541. return 0;
  3542. }
  3543. /*==========================================
  3544. *
  3545. *------------------------------------------*/
  3546. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3547. {
  3548. nullpo_retr(-1, sd);
  3549. itemdb_reload();
  3550. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  3551. return 0;
  3552. }
  3553. /*==========================================
  3554. *
  3555. *------------------------------------------*/
  3556. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3557. {
  3558. nullpo_retr(-1, sd);
  3559. mob_reload();
  3560. read_petdb();
  3561. merc_reload();
  3562. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  3563. return 0;
  3564. }
  3565. /*==========================================
  3566. *
  3567. *------------------------------------------*/
  3568. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3569. {
  3570. nullpo_retr(-1, sd);
  3571. skill_reload();
  3572. merc_skill_reload();
  3573. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  3574. return 0;
  3575. }
  3576. /*==========================================
  3577. * @reloadatcommand - reloads atcommand_athena.conf
  3578. *------------------------------------------*/
  3579. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3580. {
  3581. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  3582. clif_displaymessage(fd, msg_txt(254));
  3583. return 0;
  3584. }
  3585. /*==========================================
  3586. * @reloadbattleconf - reloads battle_athena.conf
  3587. *------------------------------------------*/
  3588. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3589. {
  3590. struct Battle_Config prev_config;
  3591. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3592. battle_config_read(BATTLE_CONF_FILENAME);
  3593. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3594. || prev_config.item_rate_common != battle_config.item_rate_common
  3595. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3596. || prev_config.item_rate_card != battle_config.item_rate_card
  3597. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3598. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3599. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3600. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3601. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3602. || prev_config.item_rate_use != battle_config.item_rate_use
  3603. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3604. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3605. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3606. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3607. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3608. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3609. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3610. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3611. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3612. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3613. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3614. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3615. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3616. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3617. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3618. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3619. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3620. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3621. )
  3622. { //Drop rates changed.
  3623. mob_reload(); //Needed as well so rate changes take effect.
  3624. #ifndef TXT_ONLY
  3625. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3626. #endif
  3627. }
  3628. clif_displaymessage(fd, msg_txt(255));
  3629. return 0;
  3630. }
  3631. /*==========================================
  3632. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3633. *------------------------------------------*/
  3634. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3635. {
  3636. status_readdb();
  3637. clif_displaymessage(fd, msg_txt(256));
  3638. return 0;
  3639. }
  3640. /*==========================================
  3641. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3642. *------------------------------------------*/
  3643. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3644. {
  3645. pc_readdb();
  3646. clif_displaymessage(fd, msg_txt(257));
  3647. return 0;
  3648. }
  3649. /*==========================================
  3650. * @reloadmotd - reloads motd.txt
  3651. *------------------------------------------*/
  3652. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3653. {
  3654. pc_read_motd();
  3655. clif_displaymessage(fd, msg_txt(268));
  3656. return 0;
  3657. }
  3658. /*==========================================
  3659. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3660. *------------------------------------------*/
  3661. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3662. {
  3663. nullpo_retr(-1, sd);
  3664. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3665. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3666. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3667. flush_fifos();
  3668. script_reload();
  3669. npc_reload();
  3670. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  3671. return 0;
  3672. }
  3673. /*==========================================
  3674. * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database)
  3675. *------------------------------------------*/
  3676. int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3677. {
  3678. nullpo_retr(-1, sd);
  3679. chrif_reloadGMdb();
  3680. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  3681. return 0;
  3682. }
  3683. /*==========================================
  3684. * @mapinfo <map name> [0-3] by MC_Cameri
  3685. * => Shows information about the map [map name]
  3686. * 0 = no additional information
  3687. * 1 = Show users in that map and their location
  3688. * 2 = Shows NPCs in that map
  3689. * 3 = Shows the shops/chats in that map (not implemented)
  3690. *------------------------------------------*/
  3691. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3692. {
  3693. struct map_session_data *pl_sd, **pl_allsd;
  3694. struct npc_data *nd = NULL;
  3695. struct chat_data *cd = NULL;
  3696. char direction[12];
  3697. int m_id, i, chat_num, users, list = 0;
  3698. unsigned short m_index;
  3699. nullpo_retr(-1, sd);
  3700. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3701. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3702. memset(direction, '\0', sizeof(direction));
  3703. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  3704. if (list < 0 || list > 3) {
  3705. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3706. return -1;
  3707. }
  3708. if (atcmd_player_name[0] == '\0') {
  3709. safestrncpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3710. m_id = map_mapindex2mapid(sd->mapindex);
  3711. } else {
  3712. m_id = map_mapname2mapid(atcmd_player_name);
  3713. }
  3714. if (m_id < 0) {
  3715. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3716. return -1;
  3717. }
  3718. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  3719. clif_displaymessage(fd, "------ Map Info ------");
  3720. chat_num = 0;
  3721. pl_allsd = map_getallusers(&users);
  3722. for (i = 0; i < users; i++) {
  3723. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  3724. chat_num++;
  3725. }
  3726. }
  3727. 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);
  3728. clif_displaymessage(fd, atcmd_output);
  3729. clif_displaymessage(fd, "------ Map Flags ------");
  3730. strcpy(atcmd_output,"PvP Flags: ");
  3731. if (map[m_id].flag.pvp)
  3732. strcat(atcmd_output, "Pvp ON | ");
  3733. if (map[m_id].flag.pvp_noguild)
  3734. strcat(atcmd_output, "NoGuild | ");
  3735. if (map[m_id].flag.pvp_noparty)
  3736. strcat(atcmd_output, "NoParty | ");
  3737. if (map[m_id].flag.pvp_nightmaredrop)
  3738. strcat(atcmd_output, "NightmareDrop | ");
  3739. if (map[m_id].flag.pvp_nocalcrank)
  3740. strcat(atcmd_output, "NoCalcRank | ");
  3741. clif_displaymessage(fd, atcmd_output);
  3742. strcpy(atcmd_output,"GvG Flags: ");
  3743. if (map[m_id].flag.gvg)
  3744. strcat(atcmd_output, "GvG ON | ");
  3745. if (map[m_id].flag.gvg_dungeon)
  3746. strcat(atcmd_output, "GvG Dungeon | ");
  3747. if (map[m_id].flag.gvg_castle)
  3748. strcat(atcmd_output, "GvG Castle | ");
  3749. if (map[m_id].flag.gvg_noparty)
  3750. strcat(atcmd_output, "NoParty | ");
  3751. clif_displaymessage(fd, atcmd_output);
  3752. strcpy(atcmd_output,"Teleport Flags: ");
  3753. if (map[m_id].flag.noteleport)
  3754. strcat(atcmd_output, "NoTeleport | ");
  3755. if (map[m_id].flag.monster_noteleport)
  3756. strcat(atcmd_output, "Monster NoTeleport | ");
  3757. if (map[m_id].flag.nowarp)
  3758. strcat(atcmd_output, "NoWarp | ");
  3759. if (map[m_id].flag.nowarpto)
  3760. strcat(atcmd_output, "NoWarpTo | ");
  3761. if (map[m_id].flag.noreturn)
  3762. strcat(atcmd_output, "NoReturn | ");
  3763. if (map[m_id].flag.nogo)
  3764. strcat(atcmd_output, "NoGo | ");
  3765. if (map[m_id].flag.nomemo)
  3766. strcat(atcmd_output, "NoMemo | ");
  3767. clif_displaymessage(fd, atcmd_output);
  3768. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  3769. clif_displaymessage(fd, atcmd_output);
  3770. if (map[m_id].flag.nosave) {
  3771. if (!map[m_id].save.map)
  3772. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3773. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3774. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3775. else
  3776. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3777. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3778. clif_displaymessage(fd, atcmd_output);
  3779. }
  3780. strcpy(atcmd_output,"Weather Flags: ");
  3781. if (map[m_id].flag.snow)
  3782. strcat(atcmd_output, "Snow | ");
  3783. if (map[m_id].flag.fog)
  3784. strcat(atcmd_output, "Fog | ");
  3785. if (map[m_id].flag.sakura)
  3786. strcat(atcmd_output, "Sakura | ");
  3787. if (map[m_id].flag.clouds)
  3788. strcat(atcmd_output, "Clouds | ");
  3789. if (map[m_id].flag.clouds2)
  3790. strcat(atcmd_output, "Clouds2 | ");
  3791. if (map[m_id].flag.fireworks)
  3792. strcat(atcmd_output, "Fireworks | ");
  3793. if (map[m_id].flag.leaves)
  3794. strcat(atcmd_output, "Leaves | ");
  3795. if (map[m_id].flag.rain)
  3796. strcat(atcmd_output, "Rain | ");
  3797. if (map[m_id].flag.indoors)
  3798. strcat(atcmd_output, "Indoors | ");
  3799. if (map[m_id].flag.nightenabled)
  3800. strcat(atcmd_output, "Displays Night | ");
  3801. clif_displaymessage(fd, atcmd_output);
  3802. strcpy(atcmd_output,"Other Flags: ");
  3803. if (map[m_id].flag.nobranch)
  3804. strcat(atcmd_output, "NoBranch | ");
  3805. if (map[m_id].flag.notrade)
  3806. strcat(atcmd_output, "NoTrade | ");
  3807. if (map[m_id].flag.novending)
  3808. strcat(atcmd_output, "NoVending | ");
  3809. if (map[m_id].flag.nodrop)
  3810. strcat(atcmd_output, "NoDrop | ");
  3811. if (map[m_id].flag.noskill)
  3812. strcat(atcmd_output, "NoSkill | ");
  3813. if (map[m_id].flag.noicewall)
  3814. strcat(atcmd_output, "NoIcewall | ");
  3815. clif_displaymessage(fd, atcmd_output);
  3816. strcpy(atcmd_output,"Other Flags: ");
  3817. if (map[m_id].nocommand)
  3818. strcat(atcmd_output, "NoCommand | ");
  3819. if (map[m_id].flag.nobaseexp)
  3820. strcat(atcmd_output, "NoBaseEXP | ");
  3821. if (map[m_id].flag.nojobexp)
  3822. strcat(atcmd_output, "NoJobEXP | ");
  3823. if (map[m_id].flag.nomobloot)
  3824. strcat(atcmd_output, "NoMobLoot | ");
  3825. if (map[m_id].flag.nomvploot)
  3826. strcat(atcmd_output, "NoMVPLoot | ");
  3827. if (map[m_id].flag.partylock)
  3828. strcat(atcmd_output, "PartyLock | ");
  3829. if (map[m_id].flag.guildlock)
  3830. strcat(atcmd_output, "GuildLock | ");
  3831. clif_displaymessage(fd, atcmd_output);
  3832. switch (list) {
  3833. case 0:
  3834. // Do nothing. It's list 0, no additional display.
  3835. break;
  3836. case 1:
  3837. clif_displaymessage(fd, "----- Players in Map -----");
  3838. for (i = 0; i < users; i++) {
  3839. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  3840. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3841. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3842. clif_displaymessage(fd, atcmd_output);
  3843. }
  3844. }
  3845. break;
  3846. case 2:
  3847. clif_displaymessage(fd, "----- NPCs in Map -----");
  3848. for (i = 0; i < map[m_id].npc_num;) {
  3849. nd = map[m_id].npc[i];
  3850. switch(nd->ud.dir) {
  3851. case 0: strcpy(direction, "North"); break;
  3852. case 1: strcpy(direction, "North West"); break;
  3853. case 2: strcpy(direction, "West"); break;
  3854. case 3: strcpy(direction, "South West"); break;
  3855. case 4: strcpy(direction, "South"); break;
  3856. case 5: strcpy(direction, "South East"); break;
  3857. case 6: strcpy(direction, "East"); break;
  3858. case 7: strcpy(direction, "North East"); break;
  3859. case 9: strcpy(direction, "North"); break;
  3860. default: strcpy(direction, "Unknown"); break;
  3861. }
  3862. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3863. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3864. clif_displaymessage(fd, atcmd_output);
  3865. }
  3866. break;
  3867. case 3:
  3868. clif_displaymessage(fd, "----- Chats in Map -----");
  3869. for (i = 0; i < users; i++) {
  3870. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  3871. pl_sd->mapindex == m_index &&
  3872. cd->usersd[0] == pl_sd) {
  3873. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  3874. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3875. clif_displaymessage(fd, atcmd_output);
  3876. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  3877. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  3878. clif_displaymessage(fd, atcmd_output);
  3879. }
  3880. }
  3881. break;
  3882. default: // normally impossible to arrive here
  3883. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3884. return -1;
  3885. break;
  3886. }
  3887. return 0;
  3888. }
  3889. /*==========================================
  3890. *
  3891. *------------------------------------------*/
  3892. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3893. {
  3894. nullpo_retr(-1, sd);
  3895. if (!pc_isriding(sd)) { // if actually no peco
  3896. if (!pc_checkskill(sd, KN_RIDING))
  3897. {
  3898. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  3899. return -1;
  3900. }
  3901. if (sd->disguise)
  3902. {
  3903. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco while in disguise.
  3904. return -1;
  3905. }
  3906. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3907. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  3908. } else { //Dismount
  3909. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3910. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  3911. }
  3912. return 0;
  3913. }
  3914. /*==========================================
  3915. *Spy Commands by Syrus22
  3916. *------------------------------------------*/
  3917. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3918. {
  3919. char guild_name[NAME_LENGTH];
  3920. struct guild *g;
  3921. nullpo_retr(-1, sd);
  3922. memset(guild_name, '\0', sizeof(guild_name));
  3923. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3924. if (!enable_spy)
  3925. {
  3926. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3927. return -1;
  3928. }
  3929. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3930. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  3931. return -1;
  3932. }
  3933. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3934. (g = guild_search(atoi(message))) != NULL) {
  3935. if (sd->guildspy == g->guild_id) {
  3936. sd->guildspy = 0;
  3937. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3938. clif_displaymessage(fd, atcmd_output);
  3939. } else {
  3940. sd->guildspy = g->guild_id;
  3941. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3942. clif_displaymessage(fd, atcmd_output);
  3943. }
  3944. } else {
  3945. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3946. return -1;
  3947. }
  3948. return 0;
  3949. }
  3950. /*==========================================
  3951. *
  3952. *------------------------------------------*/
  3953. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3954. {
  3955. char party_name[NAME_LENGTH];
  3956. struct party_data *p;
  3957. nullpo_retr(-1, sd);
  3958. memset(party_name, '\0', sizeof(party_name));
  3959. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3960. if (!enable_spy)
  3961. {
  3962. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  3963. return -1;
  3964. }
  3965. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3966. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  3967. return -1;
  3968. }
  3969. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3970. (p = party_search(atoi(message))) != NULL) {
  3971. if (sd->partyspy == p->party.party_id) {
  3972. sd->partyspy = 0;
  3973. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3974. clif_displaymessage(fd, atcmd_output);
  3975. } else {
  3976. sd->partyspy = p->party.party_id;
  3977. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3978. clif_displaymessage(fd, atcmd_output);
  3979. }
  3980. } else {
  3981. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3982. return -1;
  3983. }
  3984. return 0;
  3985. }
  3986. /*==========================================
  3987. * @repairall [Valaris]
  3988. *------------------------------------------*/
  3989. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3990. {
  3991. int count, i;
  3992. nullpo_retr(-1, sd);
  3993. count = 0;
  3994. for (i = 0; i < MAX_INVENTORY; i++) {
  3995. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3996. sd->status.inventory[i].attribute = 0;
  3997. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3998. count++;
  3999. }
  4000. }
  4001. if (count > 0) {
  4002. clif_misceffect(&sd->bl, 3);
  4003. clif_equiplist(sd);
  4004. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4005. } else {
  4006. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4007. return -1;
  4008. }
  4009. return 0;
  4010. }
  4011. /*==========================================
  4012. * @nuke [Valaris]
  4013. *------------------------------------------*/
  4014. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4015. {
  4016. struct map_session_data *pl_sd;
  4017. nullpo_retr(-1, sd);
  4018. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4019. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4020. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4021. return -1;
  4022. }
  4023. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4024. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4025. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4026. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4027. } else {
  4028. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4029. return -1;
  4030. }
  4031. } else {
  4032. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4033. return -1;
  4034. }
  4035. return 0;
  4036. }
  4037. /*==========================================
  4038. * @tonpc
  4039. *------------------------------------------*/
  4040. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4041. {
  4042. char npcname[NAME_LENGTH];
  4043. struct npc_data *nd;
  4044. nullpo_retr(-1, sd);
  4045. memset(npcname, 0, sizeof(npcname));
  4046. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4047. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4048. return -1;
  4049. }
  4050. if ((nd = npc_name2id(npcname)) != NULL) {
  4051. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, 3) == 0)
  4052. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4053. else
  4054. return -1;
  4055. } else {
  4056. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4057. return -1;
  4058. }
  4059. return 0;
  4060. }
  4061. /*==========================================
  4062. *
  4063. *------------------------------------------*/
  4064. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4065. {
  4066. char NPCname[NAME_LENGTH];
  4067. nullpo_retr(-1, sd);
  4068. memset(NPCname, '\0', sizeof(NPCname));
  4069. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4070. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4071. return -1;
  4072. }
  4073. if (npc_name2id(NPCname) != NULL) {
  4074. npc_enable(NPCname, 1);
  4075. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4076. } else {
  4077. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4078. return -1;
  4079. }
  4080. return 0;
  4081. }
  4082. /*==========================================
  4083. *
  4084. *------------------------------------------*/
  4085. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4086. {
  4087. char NPCname[NAME_LENGTH];
  4088. nullpo_retr(-1, sd);
  4089. memset(NPCname, '\0', sizeof(NPCname));
  4090. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4091. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4092. return -1;
  4093. }
  4094. if (npc_name2id(NPCname) == NULL) {
  4095. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4096. return -1;
  4097. }
  4098. npc_enable(NPCname, 0);
  4099. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4100. return 0;
  4101. }
  4102. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4103. {
  4104. FILE *fp;
  4105. if (!message || !*message) {
  4106. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4107. return -1;
  4108. }
  4109. // check if script file exists
  4110. if ((fp = fopen(message, "r")) == NULL) {
  4111. clif_displaymessage(fd, msg_txt(261));
  4112. return -1;
  4113. }
  4114. fclose(fp);
  4115. // add to list of script sources and run it
  4116. npc_addsrcfile(message);
  4117. npc_parsesrcfile(message);
  4118. npc_read_event_script();
  4119. clif_displaymessage(fd, msg_txt(262));
  4120. return 0;
  4121. }
  4122. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4123. {
  4124. struct npc_data *nd;
  4125. char NPCname[NAME_LENGTH];
  4126. nullpo_retr(-1, sd);
  4127. memset(NPCname, '\0', sizeof(NPCname));
  4128. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4129. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4130. return -1;
  4131. }
  4132. if ((nd = npc_name2id(NPCname)) == NULL) {
  4133. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4134. return -1;
  4135. }
  4136. npc_unload_duplicates(nd);
  4137. npc_unload(nd);
  4138. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4139. return 0;
  4140. }
  4141. /*==========================================
  4142. * time in txt for time command (by [Yor])
  4143. *------------------------------------------*/
  4144. char* txt_time(unsigned int duration)
  4145. {
  4146. int days, hours, minutes, seconds;
  4147. char temp[256];
  4148. static char temp1[256];
  4149. memset(temp, '\0', sizeof(temp));
  4150. memset(temp1, '\0', sizeof(temp1));
  4151. days = duration / (60 * 60 * 24);
  4152. duration = duration - (60 * 60 * 24 * days);
  4153. hours = duration / (60 * 60);
  4154. duration = duration - (60 * 60 * hours);
  4155. minutes = duration / 60;
  4156. seconds = duration - (60 * minutes);
  4157. if (days < 2)
  4158. sprintf(temp, msg_txt(219), days); // %d day
  4159. else
  4160. sprintf(temp, msg_txt(220), days); // %d days
  4161. if (hours < 2)
  4162. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4163. else
  4164. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4165. if (minutes < 2)
  4166. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4167. else
  4168. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4169. if (seconds < 2)
  4170. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4171. else
  4172. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4173. return temp1;
  4174. }
  4175. /*==========================================
  4176. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4177. * Calculation management of GM modification (@day/@night GM commands) is done
  4178. *------------------------------------------*/
  4179. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4180. {
  4181. struct TimerData * timer_data;
  4182. struct TimerData * timer_data2;
  4183. time_t time_server; // variable for number of seconds (used with time() function)
  4184. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4185. char temp[256];
  4186. nullpo_retr(-1, sd);
  4187. memset(temp, '\0', sizeof(temp));
  4188. time(&time_server); // get time in seconds since 1/1/1970
  4189. datetime = localtime(&time_server); // convert seconds in structure
  4190. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4191. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4192. clif_displaymessage(fd, temp);
  4193. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4194. if (night_flag == 0)
  4195. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4196. else
  4197. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4198. } else if (battle_config.night_duration == 0)
  4199. if (night_flag == 1) { // we start with night
  4200. timer_data = get_timer(day_timer_tid);
  4201. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4202. clif_displaymessage(fd, temp);
  4203. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4204. } else
  4205. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4206. else if (battle_config.day_duration == 0)
  4207. if (night_flag == 0) { // we start with day
  4208. timer_data = get_timer(night_timer_tid);
  4209. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4210. clif_displaymessage(fd, temp);
  4211. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4212. } else
  4213. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4214. else {
  4215. if (night_flag == 0) {
  4216. timer_data = get_timer(night_timer_tid);
  4217. timer_data2 = get_timer(day_timer_tid);
  4218. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4219. clif_displaymessage(fd, temp);
  4220. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4221. 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.
  4222. else
  4223. 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.
  4224. clif_displaymessage(fd, temp);
  4225. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4226. clif_displaymessage(fd, temp);
  4227. } else {
  4228. timer_data = get_timer(day_timer_tid);
  4229. timer_data2 = get_timer(night_timer_tid);
  4230. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4231. clif_displaymessage(fd, temp);
  4232. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4233. 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.
  4234. else
  4235. 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.
  4236. clif_displaymessage(fd, temp);
  4237. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4238. clif_displaymessage(fd, temp);
  4239. }
  4240. }
  4241. return 0;
  4242. }
  4243. //Added by Coltaro
  4244. //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...).
  4245. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4246. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4247. {
  4248. const int factor_year = 518400; //12*30*24*60 = 518400
  4249. const int factor_month = 43200; //30*24*60 = 43200
  4250. const int factor_day = 1440; //24*60 = 1440
  4251. const int factor_hour = 60;
  4252. *year = jailtime/factor_year;
  4253. jailtime -= *year*factor_year;
  4254. *month = jailtime/factor_month;
  4255. jailtime -= *month*factor_month;
  4256. *day = jailtime/factor_day;
  4257. jailtime -= *day*factor_day;
  4258. *hour = jailtime/factor_hour;
  4259. jailtime -= *hour*factor_hour;
  4260. *minute = jailtime;
  4261. *year = *year > 0? *year : 0;
  4262. *month = *month > 0? *month : 0;
  4263. *day = *day > 0? *day : 0;
  4264. *hour = *hour > 0? *hour : 0;
  4265. *minute = *minute > 0? *minute : 0;
  4266. return;
  4267. }
  4268. /*==========================================
  4269. * @jail <char_name> by [Yor]
  4270. * Special warp! No check with nowarp and nowarpto flag
  4271. *------------------------------------------*/
  4272. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4273. {
  4274. struct map_session_data *pl_sd;
  4275. int x, y;
  4276. unsigned short m_index;
  4277. nullpo_retr(-1, sd);
  4278. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4279. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4280. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4281. return -1;
  4282. }
  4283. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4284. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4285. return -1;
  4286. }
  4287. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4288. { // you can jail only lower or same GM
  4289. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4290. return -1;
  4291. }
  4292. if (pl_sd->sc.data[SC_JAILED])
  4293. {
  4294. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4295. return -1;
  4296. }
  4297. switch(rand() % 2) { //Jail Locations
  4298. case 0:
  4299. m_index = mapindex_name2id(MAP_JAIL);
  4300. x = 24;
  4301. y = 75;
  4302. break;
  4303. default:
  4304. m_index = mapindex_name2id(MAP_JAIL);
  4305. x = 49;
  4306. y = 75;
  4307. break;
  4308. }
  4309. //Duration of INT_MAX to specify infinity.
  4310. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4311. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4312. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4313. return 0;
  4314. }
  4315. /*==========================================
  4316. * @unjail/@discharge <char_name> by [Yor]
  4317. * Special warp! No check with nowarp and nowarpto flag
  4318. *------------------------------------------*/
  4319. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4320. {
  4321. struct map_session_data *pl_sd;
  4322. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4323. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4324. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4325. return -1;
  4326. }
  4327. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4328. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4329. return -1;
  4330. }
  4331. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4332. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4333. return -1;
  4334. }
  4335. if (!pl_sd->sc.data[SC_JAILED])
  4336. {
  4337. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4338. return -1;
  4339. }
  4340. //Reset jail time to 1 sec.
  4341. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4342. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4343. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4344. return 0;
  4345. }
  4346. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4347. {
  4348. struct map_session_data *pl_sd = NULL;
  4349. int year, month, day, hour, minute, value;
  4350. char * modif_p;
  4351. int jailtime = 0,x,y;
  4352. short m_index = 0;
  4353. nullpo_retr(-1, sd);
  4354. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4355. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4356. return -1;
  4357. }
  4358. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4359. modif_p = atcmd_output;
  4360. year = month = day = hour = minute = 0;
  4361. while (modif_p[0] != '\0') {
  4362. value = atoi(modif_p);
  4363. if (value == 0)
  4364. modif_p++;
  4365. else {
  4366. if (modif_p[0] == '-' || modif_p[0] == '+')
  4367. modif_p++;
  4368. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4369. modif_p++;
  4370. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4371. minute = value;
  4372. modif_p = modif_p + 2;
  4373. } else if (modif_p[0] == 'h') {
  4374. hour = value;
  4375. modif_p++;
  4376. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4377. day = value;
  4378. modif_p++;
  4379. } else if (modif_p[0] == 'm') {
  4380. month = value;
  4381. modif_p++;
  4382. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4383. year = value;
  4384. modif_p++;
  4385. } else if (modif_p[0] != '\0') {
  4386. modif_p++;
  4387. }
  4388. }
  4389. }
  4390. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4391. clif_displaymessage(fd, "Invalid time for jail command.");
  4392. return -1;
  4393. }
  4394. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4395. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4396. return -1;
  4397. }
  4398. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4399. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4400. return -1;
  4401. }
  4402. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4403. if(jailtime==0) {
  4404. clif_displaymessage(fd, "Invalid time for jail command.");
  4405. return -1;
  4406. }
  4407. //Added by Coltaro
  4408. if(pl_sd->sc.data[SC_JAILED] &&
  4409. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4410. { //Update the player's jail time
  4411. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4412. if (jailtime <= 0) {
  4413. jailtime = 0;
  4414. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4415. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4416. } else {
  4417. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4418. 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
  4419. clif_displaymessage(pl_sd->fd, atcmd_output);
  4420. 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
  4421. clif_displaymessage(fd, atcmd_output);
  4422. }
  4423. } else if (jailtime < 0) {
  4424. clif_displaymessage(fd, "Invalid time for jail command.");
  4425. return -1;
  4426. }
  4427. //Jail locations, add more as you wish.
  4428. switch(rand()%2)
  4429. {
  4430. case 1: //Jail #1
  4431. m_index = mapindex_name2id(MAP_JAIL);
  4432. x = 49; y = 75;
  4433. break;
  4434. default: //Default Jail
  4435. m_index = mapindex_name2id(MAP_JAIL);
  4436. x = 24; y = 75;
  4437. break;
  4438. }
  4439. 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).
  4440. return 0;
  4441. }
  4442. //By Coltaro
  4443. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4444. {
  4445. int year, month, day, hour, minute;
  4446. nullpo_retr(-1, sd);
  4447. if (!sd->sc.data[SC_JAILED]) {
  4448. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4449. return -1;
  4450. }
  4451. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4452. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4453. return 0;
  4454. }
  4455. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4456. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4457. return -1;
  4458. }
  4459. //Get remaining jail time
  4460. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4461. 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
  4462. clif_displaymessage(fd, atcmd_output);
  4463. return 0;
  4464. }
  4465. /*==========================================
  4466. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4467. *------------------------------------------*/
  4468. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4469. {
  4470. int id = 0;
  4471. nullpo_retr(-1, sd);
  4472. if (!message || !*message) {
  4473. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4474. return -1;
  4475. }
  4476. if ((id = atoi(message)) > 0)
  4477. { //Acquired an ID
  4478. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4479. id = 0; //Invalid id for either mobs or npcs.
  4480. } else { //Acquired a Name
  4481. if ((id = mobdb_searchname(message)) == 0)
  4482. {
  4483. struct npc_data* nd = npc_name2id(message);
  4484. if (nd != NULL)
  4485. id = nd->n;
  4486. }
  4487. }
  4488. if (id == 0)
  4489. {
  4490. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4491. return -1;
  4492. }
  4493. if(pc_isriding(sd))
  4494. {
  4495. //FIXME: wrong message [ultramage]
  4496. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4497. return -1;
  4498. }
  4499. pc_disguise(sd, id);
  4500. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4501. return 0;
  4502. }
  4503. /*==========================================
  4504. * DisguiseAll
  4505. *------------------------------------------*/
  4506. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4507. {
  4508. int mob_id=0, i=0, users;
  4509. struct map_session_data *pl_sd, **pl_allsd;
  4510. nullpo_retr(-1, sd);
  4511. if (!message || !*message) {
  4512. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4513. return -1;
  4514. }
  4515. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4516. mob_id = atoi(message);
  4517. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4518. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4519. return -1;
  4520. }
  4521. pl_allsd = map_getallusers(&users);
  4522. for(i=0; i < users; i++)
  4523. {
  4524. if((pl_sd = pl_allsd[i]))
  4525. pc_disguise(pl_sd, mob_id);
  4526. }
  4527. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4528. return 0;
  4529. }
  4530. /*==========================================
  4531. * @undisguise by [Yor]
  4532. *------------------------------------------*/
  4533. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4534. {
  4535. nullpo_retr(-1, sd);
  4536. if (sd->disguise) {
  4537. pc_disguise(sd, 0);
  4538. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4539. } else {
  4540. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4541. return -1;
  4542. }
  4543. return 0;
  4544. }
  4545. /*==========================================
  4546. * UndisguiseAll
  4547. *------------------------------------------*/
  4548. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4549. {
  4550. struct map_session_data *pl_sd, **pl_allsd;
  4551. int i, users;
  4552. nullpo_retr(-1, sd);
  4553. pl_allsd = map_getallusers(&users);
  4554. for(i=0; i < users; i++) {
  4555. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  4556. pc_disguise(pl_sd, 0);
  4557. }
  4558. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4559. return 0;
  4560. }
  4561. /*==========================================
  4562. * @exp by [Skotlex]
  4563. *------------------------------------------*/
  4564. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4565. {
  4566. char output[200];
  4567. double nextb, nextj;
  4568. nullpo_retr(-1, sd);
  4569. memset(output, '\0', sizeof(output));
  4570. nextb = pc_nextbaseexp(sd);
  4571. if (nextb)
  4572. nextb = sd->status.base_exp*100.0/nextb;
  4573. nextj = pc_nextjobexp(sd);
  4574. if (nextj)
  4575. nextj = sd->status.job_exp*100.0/nextj;
  4576. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4577. clif_displaymessage(fd, output);
  4578. return 0;
  4579. }
  4580. /*==========================================
  4581. * @broadcast by [Valaris]
  4582. *------------------------------------------*/
  4583. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4584. {
  4585. nullpo_retr(-1, sd);
  4586. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4587. if (!message || !*message) {
  4588. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4589. return -1;
  4590. }
  4591. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4592. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  4593. return 0;
  4594. }
  4595. /*==========================================
  4596. * @localbroadcast by [Valaris]
  4597. *------------------------------------------*/
  4598. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4599. {
  4600. nullpo_retr(-1, sd);
  4601. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4602. if (!message || !*message) {
  4603. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4604. return -1;
  4605. }
  4606. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4607. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  4608. return 0;
  4609. }
  4610. /*==========================================
  4611. * @email <actual@email> <new@email> by [Yor]
  4612. *------------------------------------------*/
  4613. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4614. {
  4615. char actual_email[100];
  4616. char new_email[100];
  4617. nullpo_retr(-1, sd);
  4618. memset(actual_email, '\0', sizeof(actual_email));
  4619. memset(new_email, '\0', sizeof(new_email));
  4620. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4621. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4622. return -1;
  4623. }
  4624. if (e_mail_check(actual_email) == 0) {
  4625. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4626. return -1;
  4627. } else if (e_mail_check(new_email) == 0) {
  4628. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4629. return -1;
  4630. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4631. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4632. return -1;
  4633. } else if (strcmpi(actual_email, new_email) == 0) {
  4634. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4635. return -1;
  4636. }
  4637. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4638. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4639. return 0;
  4640. }
  4641. /*==========================================
  4642. *@effect
  4643. *------------------------------------------*/
  4644. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4645. {
  4646. int type = 0, flag = 0;
  4647. nullpo_retr(-1, sd);
  4648. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4649. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4650. return -1;
  4651. }
  4652. clif_specialeffect(&sd->bl, type, flag);
  4653. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4654. return 0;
  4655. }
  4656. /*==========================================
  4657. * @killer by MouseJstr
  4658. * enable killing players even when not in pvp
  4659. *------------------------------------------*/
  4660. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4661. {
  4662. nullpo_retr(-1, sd);
  4663. sd->state.killer = !sd->state.killer;
  4664. if(sd->state.killer)
  4665. clif_displaymessage(fd, msg_txt(241));
  4666. else {
  4667. clif_displaymessage(fd, msg_txt(287));
  4668. pc_stop_attack(sd);
  4669. }
  4670. return 0;
  4671. }
  4672. /*==========================================
  4673. * @killable by MouseJstr
  4674. * enable other people killing you
  4675. *------------------------------------------*/
  4676. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4677. {
  4678. nullpo_retr(-1, sd);
  4679. sd->state.killable = !sd->state.killable;
  4680. if(sd->state.killable)
  4681. clif_displaymessage(fd, msg_txt(242));
  4682. else {
  4683. clif_displaymessage(fd, msg_txt(288));
  4684. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4685. }
  4686. return 0;
  4687. }
  4688. /*==========================================
  4689. * @skillon by MouseJstr
  4690. * turn skills on for the map
  4691. *------------------------------------------*/
  4692. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4693. {
  4694. nullpo_retr(-1, sd);
  4695. map[sd->bl.m].flag.noskill = 0;
  4696. clif_displaymessage(fd, msg_txt(244));
  4697. return 0;
  4698. }
  4699. /*==========================================
  4700. * @skilloff by MouseJstr
  4701. * Turn skills off on the map
  4702. *------------------------------------------*/
  4703. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4704. {
  4705. nullpo_retr(-1, sd);
  4706. map[sd->bl.m].flag.noskill = 1;
  4707. clif_displaymessage(fd, msg_txt(243));
  4708. return 0;
  4709. }
  4710. /*==========================================
  4711. * @npcmove by MouseJstr
  4712. * move a npc
  4713. *------------------------------------------*/
  4714. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4715. {
  4716. int x = 0, y = 0, m;
  4717. struct npc_data *nd = 0;
  4718. nullpo_retr(-1, sd);
  4719. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4720. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4721. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4722. return -1;
  4723. }
  4724. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4725. {
  4726. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4727. return -1;
  4728. }
  4729. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4730. {
  4731. clif_displaymessage(fd, "NPC is not on this map.");
  4732. return -1; //Not on a map.
  4733. }
  4734. x = cap_value(x, 0, map[m].xs-1);
  4735. y = cap_value(y, 0, map[m].ys-1);
  4736. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4737. map_moveblock(&nd->bl, x, y, gettick());
  4738. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4739. clif_displaymessage(fd, "NPC moved.");
  4740. return 0;
  4741. }
  4742. /*==========================================
  4743. * @addwarp by MouseJstr
  4744. * Create a new static warp point.
  4745. *------------------------------------------*/
  4746. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4747. {
  4748. char mapname[32];
  4749. int x,y;
  4750. unsigned short m;
  4751. struct npc_data* nd;
  4752. nullpo_retr(-1, sd);
  4753. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4754. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4755. return -1;
  4756. }
  4757. m = mapindex_name2id(mapname);
  4758. if( m == 0 )
  4759. {
  4760. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4761. clif_displaymessage(fd, atcmd_output);
  4762. return -1;
  4763. }
  4764. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4765. if( nd == NULL )
  4766. return -1;
  4767. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4768. clif_displaymessage(fd, atcmd_output);
  4769. return 0;
  4770. }
  4771. /*==========================================
  4772. * @follow by [MouseJstr]
  4773. * Follow a player .. staying no more then 5 spaces away
  4774. *------------------------------------------*/
  4775. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4776. {
  4777. struct map_session_data *pl_sd = NULL;
  4778. nullpo_retr(-1, sd);
  4779. if (!message || !*message) {
  4780. if (sd->followtarget == -1)
  4781. return -1;
  4782. pc_stop_following (sd);
  4783. clif_displaymessage(fd, "Follow mode OFF.");
  4784. return 0;
  4785. }
  4786. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4787. {
  4788. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4789. return -1;
  4790. }
  4791. if (sd->followtarget == pl_sd->bl.id) {
  4792. pc_stop_following (sd);
  4793. clif_displaymessage(fd, "Follow mode OFF.");
  4794. } else {
  4795. pc_follow(sd, pl_sd->bl.id);
  4796. clif_displaymessage(fd, "Follow mode ON.");
  4797. }
  4798. return 0;
  4799. }
  4800. /*==========================================
  4801. * @dropall by [MouseJstr]
  4802. * Drop all your possession on the ground
  4803. *------------------------------------------*/
  4804. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4805. {
  4806. int i;
  4807. nullpo_retr(-1, sd);
  4808. for (i = 0; i < MAX_INVENTORY; i++) {
  4809. if (sd->status.inventory[i].amount) {
  4810. if(sd->status.inventory[i].equip != 0)
  4811. pc_unequipitem(sd, i, 3);
  4812. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4813. }
  4814. }
  4815. return 0;
  4816. }
  4817. /*==========================================
  4818. * @storeall by [MouseJstr]
  4819. * Put everything into storage
  4820. *------------------------------------------*/
  4821. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4822. {
  4823. int i;
  4824. nullpo_retr(-1, sd);
  4825. if (sd->state.storage_flag != 1)
  4826. { //Open storage.
  4827. switch (storage_storageopen(sd)) {
  4828. case 2: //Try again
  4829. clif_displaymessage(fd, "run this command again..");
  4830. return 0;
  4831. case 1: //Failure
  4832. clif_displaymessage(fd, "You can't open the storage currently.");
  4833. return -1;
  4834. }
  4835. }
  4836. for (i = 0; i < MAX_INVENTORY; i++) {
  4837. if (sd->status.inventory[i].amount) {
  4838. if(sd->status.inventory[i].equip != 0)
  4839. pc_unequipitem(sd, i, 3);
  4840. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4841. }
  4842. }
  4843. storage_storageclose(sd);
  4844. clif_displaymessage(fd, "It is done");
  4845. return 0;
  4846. }
  4847. /*==========================================
  4848. * @skillid by [MouseJstr]
  4849. * lookup a skill by name
  4850. *------------------------------------------*/
  4851. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4852. {
  4853. int skillen, idx;
  4854. nullpo_retr(-1, sd);
  4855. if (!message || !*message)
  4856. {
  4857. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  4858. return -1;
  4859. }
  4860. skillen = strlen(message);
  4861. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4862. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4863. {
  4864. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  4865. clif_displaymessage(fd, atcmd_output);
  4866. }
  4867. }
  4868. return 0;
  4869. }
  4870. /*==========================================
  4871. * @useskill by [MouseJstr]
  4872. * A way of using skills without having to find them in the skills menu
  4873. *------------------------------------------*/
  4874. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4875. {
  4876. struct map_session_data *pl_sd = NULL;
  4877. struct block_list *bl;
  4878. int skillnum;
  4879. int skilllv;
  4880. char target[100];
  4881. nullpo_retr(-1, sd);
  4882. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4883. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  4884. return -1;
  4885. }
  4886. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4887. {
  4888. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4889. return -1;
  4890. }
  4891. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  4892. {
  4893. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4894. return -1;
  4895. }
  4896. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4897. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4898. bl = &sd->hd->bl;
  4899. else
  4900. bl = &sd->bl;
  4901. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4902. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4903. else
  4904. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4905. return 0;
  4906. }
  4907. /*==========================================
  4908. * @displayskill by [Skotlex]
  4909. * Debug command to locate new skill IDs. It sends the
  4910. * three possible skill-effect packets to the area.
  4911. *------------------------------------------*/
  4912. int atcommand_displayskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4913. {
  4914. struct status_data * status;
  4915. unsigned int tick;
  4916. int skillnum;
  4917. int skilllv = 1;
  4918. nullpo_retr(-1, sd);
  4919. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4920. {
  4921. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  4922. return -1;
  4923. }
  4924. status = status_get_status_data(&sd->bl);
  4925. tick = gettick();
  4926. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4927. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4928. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4929. return 0;
  4930. }
  4931. /*==========================================
  4932. * @skilltree by [MouseJstr]
  4933. * prints the skill tree for a player required to get to a skill
  4934. *------------------------------------------*/
  4935. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4936. {
  4937. struct map_session_data *pl_sd = NULL;
  4938. int skillnum, skillidx = -1;
  4939. int meets = 1, j, c=0;
  4940. char target[NAME_LENGTH], *tbl;
  4941. struct skill_tree_entry *ent;
  4942. nullpo_retr(-1, sd);
  4943. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4944. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  4945. return -1;
  4946. }
  4947. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4948. {
  4949. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4950. return -1;
  4951. }
  4952. c = pc_calc_skilltree_normalize_job(pl_sd);
  4953. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4954. tbl = job_name(c);
  4955. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  4956. tbl, pc_checkskill(pl_sd, 1));
  4957. clif_displaymessage(fd, atcmd_output);
  4958. for (j = 0; skill_tree[c][j].id != 0; j++) {
  4959. if (skill_tree[c][j].id == skillnum) {
  4960. skillidx = j;
  4961. break;
  4962. }
  4963. }
  4964. if (skillidx == -1) {
  4965. sprintf(atcmd_output, "I do not believe the player can use that skill");
  4966. clif_displaymessage(fd, atcmd_output);
  4967. return 0;
  4968. }
  4969. ent = &skill_tree[c][skillidx];
  4970. for(j=0;j<5;j++)
  4971. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4972. {
  4973. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  4974. clif_displaymessage(fd, atcmd_output);
  4975. meets = 0;
  4976. }
  4977. if (meets == 1) {
  4978. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  4979. clif_displaymessage(fd, atcmd_output);
  4980. }
  4981. return 0;
  4982. }
  4983. // Hand a ring with partners name on it to this char
  4984. void getring (struct map_session_data* sd)
  4985. {
  4986. int flag, item_id;
  4987. struct item item_tmp;
  4988. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4989. memset(&item_tmp, 0, sizeof(item_tmp));
  4990. item_tmp.nameid = item_id;
  4991. item_tmp.identify = 1;
  4992. item_tmp.card[0] = 255;
  4993. item_tmp.card[2] = sd->status.partner_id;
  4994. item_tmp.card[3] = sd->status.partner_id >> 16;
  4995. //Logs (A)dmins items [Lupus]
  4996. if(log_config.enable_logs&0x400)
  4997. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  4998. if((flag = pc_additem(sd,&item_tmp,1))) {
  4999. clif_additem(sd,0,0,flag);
  5000. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5001. }
  5002. }
  5003. /*==========================================
  5004. * @marry by [MouseJstr], fixed by Lupus
  5005. * Marry two players
  5006. *------------------------------------------*/
  5007. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5008. {
  5009. struct map_session_data *pl_sd1 = NULL;
  5010. struct map_session_data *pl_sd2 = NULL;
  5011. char player1[128], player2[128]; //Length used for return error msgs
  5012. nullpo_retr(-1, sd);
  5013. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5014. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5015. return -1;
  5016. }
  5017. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5018. sprintf(player2, "Cannot find player '%s' online", player1);
  5019. clif_displaymessage(fd, player2);
  5020. return -1;
  5021. }
  5022. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5023. sprintf(player1, "Cannot find player '%s' online", player2);
  5024. clif_displaymessage(fd, player1);
  5025. return -1;
  5026. }
  5027. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5028. clif_displaymessage(fd, "They are married.. wish them well");
  5029. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5030. // Auto-give named rings (Aru)
  5031. getring (pl_sd1);
  5032. getring (pl_sd2);
  5033. return 0;
  5034. }
  5035. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5036. return -1;
  5037. }
  5038. /*==========================================
  5039. * @divorce by [MouseJstr], fixed by [Lupus]
  5040. * divorce two players
  5041. *------------------------------------------*/
  5042. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5043. {
  5044. struct map_session_data *pl_sd = NULL;
  5045. nullpo_retr(-1, sd);
  5046. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5047. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5048. return -1;
  5049. }
  5050. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5051. {
  5052. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5053. return -1;
  5054. }
  5055. if (pc_divorce(pl_sd) != 0) {
  5056. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5057. clif_displaymessage(fd, atcmd_output);
  5058. return -1;
  5059. }
  5060. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5061. clif_displaymessage(fd, atcmd_output);
  5062. return 0;
  5063. }
  5064. /*==========================================
  5065. * @changelook by [Celest]
  5066. *------------------------------------------*/
  5067. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5068. {
  5069. int i, j = 0, k = 0;
  5070. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5071. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5072. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5073. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5074. return -1;
  5075. } else if (i == 2) {
  5076. if (j < 1) j = 1;
  5077. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5078. j = pos[j - 1];
  5079. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5080. k = j; // swap
  5081. j = LOOK_HEAD_TOP;
  5082. }
  5083. clif_changelook(&sd->bl,j,k);
  5084. return 0;
  5085. }
  5086. /*==========================================
  5087. * @autotrade by durf (changed by Lupus)
  5088. * Turns on/off Autotrade for a specific player
  5089. *------------------------------------------*/
  5090. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5091. {
  5092. nullpo_retr(-1, sd);
  5093. if (sd->vender_id) //check if player's vending
  5094. {
  5095. sd->state.autotrade = 1;
  5096. clif_authfail_fd(fd, 15);
  5097. }
  5098. else
  5099. {
  5100. //"You should be vending to use @Autotrade."
  5101. clif_displaymessage(fd, msg_txt(549));
  5102. }
  5103. return 0;
  5104. }
  5105. /*==========================================
  5106. * @changegm by durf (changed by Lupus)
  5107. * Changes Master of your Guild to a specified guild member
  5108. *------------------------------------------*/
  5109. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5110. {
  5111. struct guild *g;
  5112. struct map_session_data *pl_sd;
  5113. nullpo_retr(-1, sd);
  5114. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5115. {
  5116. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5117. return -1;
  5118. }
  5119. if (strlen(message)==0)
  5120. {
  5121. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5122. return -1;
  5123. }
  5124. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5125. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5126. return -1;
  5127. }
  5128. guild_gm_change(sd->status.guild_id, pl_sd);
  5129. return 0;
  5130. }
  5131. /*==========================================
  5132. * @changeleader by Skotlex
  5133. * Changes the leader of a party.
  5134. *------------------------------------------*/
  5135. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5136. {
  5137. struct party_data *p;
  5138. struct map_session_data *pl_sd;
  5139. int mi, pl_mi;
  5140. nullpo_retr(-1, sd);
  5141. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5142. { //Need to be a party leader.
  5143. clif_displaymessage(fd, msg_txt(282));
  5144. return -1;
  5145. }
  5146. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  5147. if (mi == MAX_PARTY)
  5148. return -1; //Shouldn't happen
  5149. if (!p->party.member[mi].leader)
  5150. { //Need to be a party leader.
  5151. clif_displaymessage(fd, msg_txt(282));
  5152. return -1;
  5153. }
  5154. if (strlen(message)==0)
  5155. {
  5156. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5157. return -1;
  5158. }
  5159. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  5160. clif_displaymessage(fd, msg_txt(283));
  5161. return -1;
  5162. }
  5163. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  5164. if (pl_mi == MAX_PARTY)
  5165. return -1; //Shouldn't happen
  5166. //Change leadership.
  5167. p->party.member[mi].leader = 0;
  5168. if (p->data[mi].sd->fd)
  5169. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  5170. p->party.member[pl_mi].leader = 1;
  5171. if (p->data[pl_mi].sd->fd)
  5172. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  5173. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  5174. //Update info.
  5175. clif_party_info(p,NULL);
  5176. return 0;
  5177. }
  5178. /*==========================================
  5179. * @partyoption by Skotlex
  5180. * Used to change the item share setting of a party.
  5181. *------------------------------------------*/
  5182. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5183. {
  5184. struct party_data *p;
  5185. int mi, option;
  5186. char w1[15], w2[15];
  5187. nullpo_retr(-1, sd);
  5188. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5189. {
  5190. clif_displaymessage(fd, msg_txt(282));
  5191. return -1;
  5192. }
  5193. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  5194. if (mi == MAX_PARTY)
  5195. return -1; //Shouldn't happen
  5196. if (!p->party.member[mi].leader)
  5197. {
  5198. clif_displaymessage(fd, msg_txt(282));
  5199. return -1;
  5200. }
  5201. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5202. {
  5203. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  5204. return -1;
  5205. }
  5206. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  5207. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5208. //Change item share type.
  5209. if (option != p->party.item)
  5210. party_changeoption(sd, p->party.exp, option);
  5211. else
  5212. clif_displaymessage(fd, msg_txt(286));
  5213. return 0;
  5214. }
  5215. /*==========================================
  5216. * @autoloot by Upa-Kun
  5217. * Turns on/off AutoLoot for a specific player
  5218. *------------------------------------------*/
  5219. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5220. {
  5221. int rate;
  5222. double drate;
  5223. nullpo_retr(-1, sd);
  5224. // autoloot command without value
  5225. if(!message || !*message)
  5226. {
  5227. if (sd->state.autoloot)
  5228. rate = 0;
  5229. else
  5230. rate = 10000;
  5231. } else {
  5232. drate = atof(message);
  5233. rate = (int)(drate*100);
  5234. }
  5235. if (rate < 0) rate = 0;
  5236. if (rate > 10000) rate = 10000;
  5237. sd->state.autoloot = rate;
  5238. if (sd->state.autoloot) {
  5239. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5240. clif_displaymessage(fd, atcmd_output);
  5241. }else
  5242. clif_displaymessage(fd, "Autoloot is now off.");
  5243. return 0;
  5244. }
  5245. /*==========================================
  5246. * It is made to rain.
  5247. *------------------------------------------*/
  5248. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5249. {
  5250. nullpo_retr(-1, sd);
  5251. if (map[sd->bl.m].flag.rain) {
  5252. map[sd->bl.m].flag.rain=0;
  5253. clif_weather(sd->bl.m);
  5254. clif_displaymessage(fd, "The rain has stopped.");
  5255. } else {
  5256. map[sd->bl.m].flag.rain=1;
  5257. clif_weather(sd->bl.m);
  5258. clif_displaymessage(fd, "It is made to rain.");
  5259. }
  5260. return 0;
  5261. }
  5262. /*==========================================
  5263. * It is made to snow.
  5264. *------------------------------------------*/
  5265. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5266. {
  5267. nullpo_retr(-1, sd);
  5268. if (map[sd->bl.m].flag.snow) {
  5269. map[sd->bl.m].flag.snow=0;
  5270. clif_weather(sd->bl.m);
  5271. clif_displaymessage(fd, "Snow has stopped falling.");
  5272. } else {
  5273. map[sd->bl.m].flag.snow=1;
  5274. clif_weather(sd->bl.m);
  5275. clif_displaymessage(fd, "It is made to snow.");
  5276. }
  5277. return 0;
  5278. }
  5279. /*==========================================
  5280. * Cherry tree snowstorm is made to fall. (Sakura)
  5281. *------------------------------------------*/
  5282. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5283. {
  5284. nullpo_retr(-1, sd);
  5285. if (map[sd->bl.m].flag.sakura) {
  5286. map[sd->bl.m].flag.sakura=0;
  5287. clif_weather(sd->bl.m);
  5288. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5289. } else {
  5290. map[sd->bl.m].flag.sakura=1;
  5291. clif_weather(sd->bl.m);
  5292. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5293. }
  5294. return 0;
  5295. }
  5296. /*==========================================
  5297. * Clouds appear.
  5298. *------------------------------------------*/
  5299. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5300. {
  5301. nullpo_retr(-1, sd);
  5302. if (map[sd->bl.m].flag.clouds) {
  5303. map[sd->bl.m].flag.clouds=0;
  5304. clif_weather(sd->bl.m);
  5305. clif_displaymessage(fd, "The clouds has disappear.");
  5306. } else {
  5307. map[sd->bl.m].flag.clouds=1;
  5308. clif_weather(sd->bl.m);
  5309. clif_displaymessage(fd, "Clouds appear.");
  5310. }
  5311. return 0;
  5312. }
  5313. /*==========================================
  5314. * Different type of clouds using effect 516
  5315. *------------------------------------------*/
  5316. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5317. {
  5318. nullpo_retr(-1, sd);
  5319. if (map[sd->bl.m].flag.clouds2) {
  5320. map[sd->bl.m].flag.clouds2=0;
  5321. clif_weather(sd->bl.m);
  5322. clif_displaymessage(fd, "The alternative clouds disappear.");
  5323. } else {
  5324. map[sd->bl.m].flag.clouds2=1;
  5325. clif_weather(sd->bl.m);
  5326. clif_displaymessage(fd, "Alternative clouds appear.");
  5327. }
  5328. return 0;
  5329. }
  5330. /*==========================================
  5331. * Fog hangs over.
  5332. *------------------------------------------*/
  5333. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5334. {
  5335. nullpo_retr(-1, sd);
  5336. if (map[sd->bl.m].flag.fog) {
  5337. map[sd->bl.m].flag.fog=0;
  5338. clif_weather(sd->bl.m);
  5339. clif_displaymessage(fd, "The fog has gone.");
  5340. } else {
  5341. map[sd->bl.m].flag.fog=1;
  5342. clif_weather(sd->bl.m);
  5343. clif_displaymessage(fd, "Fog hangs over.");
  5344. }
  5345. return 0;
  5346. }
  5347. /*==========================================
  5348. * Fallen leaves fall.
  5349. *------------------------------------------*/
  5350. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5351. {
  5352. nullpo_retr(-1, sd);
  5353. if (map[sd->bl.m].flag.leaves) {
  5354. map[sd->bl.m].flag.leaves=0;
  5355. clif_weather(sd->bl.m);
  5356. clif_displaymessage(fd, "Leaves no longer fall.");
  5357. } else {
  5358. map[sd->bl.m].flag.leaves=1;
  5359. clif_weather(sd->bl.m);
  5360. clif_displaymessage(fd, "Fallen leaves fall.");
  5361. }
  5362. return 0;
  5363. }
  5364. /*==========================================
  5365. * Fireworks appear.
  5366. *------------------------------------------*/
  5367. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5368. {
  5369. nullpo_retr(-1, sd);
  5370. if (map[sd->bl.m].flag.fireworks) {
  5371. map[sd->bl.m].flag.fireworks=0;
  5372. clif_weather(sd->bl.m);
  5373. clif_displaymessage(fd, "Fireworks are ended.");
  5374. } else {
  5375. map[sd->bl.m].flag.fireworks=1;
  5376. clif_weather(sd->bl.m);
  5377. clif_displaymessage(fd, "Fireworks are launched.");
  5378. }
  5379. return 0;
  5380. }
  5381. /*==========================================
  5382. * Clearing Weather Effects by Dexity
  5383. *------------------------------------------*/
  5384. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5385. {
  5386. nullpo_retr(-1, sd);
  5387. map[sd->bl.m].flag.rain=0;
  5388. map[sd->bl.m].flag.snow=0;
  5389. map[sd->bl.m].flag.sakura=0;
  5390. map[sd->bl.m].flag.clouds=0;
  5391. map[sd->bl.m].flag.clouds2=0;
  5392. map[sd->bl.m].flag.fog=0;
  5393. map[sd->bl.m].flag.fireworks=0;
  5394. map[sd->bl.m].flag.leaves=0;
  5395. clif_weather(sd->bl.m);
  5396. clif_displaymessage(fd, msg_txt(291));
  5397. return 0;
  5398. }
  5399. /*===============================================================
  5400. * Sound Command - plays a sound for everyone around! [Codemaster]
  5401. *---------------------------------------------------------------*/
  5402. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  5403. {
  5404. char sound_file[100];
  5405. memset(sound_file, '\0', sizeof(sound_file));
  5406. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5407. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5408. return -1;
  5409. }
  5410. if(strstr(sound_file, ".wav") == NULL)
  5411. strcat(sound_file, ".wav");
  5412. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5413. return 0;
  5414. }
  5415. /*==========================================
  5416. * MOB Search
  5417. *------------------------------------------*/
  5418. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  5419. {
  5420. int mob_id,fd;
  5421. static int number=0;
  5422. struct mob_data *md;
  5423. nullpo_retr(0, bl);
  5424. if(!ap){
  5425. number=0;
  5426. return 0;
  5427. }
  5428. mob_id = va_arg(ap,int);
  5429. fd = va_arg(ap,int);
  5430. md = (struct mob_data *)bl;
  5431. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  5432. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  5433. ++number,bl->x, bl->y,md->name);
  5434. clif_displaymessage(fd, atcmd_output);
  5435. }
  5436. return 0;
  5437. }
  5438. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5439. {
  5440. char mob_name[100];
  5441. int mob_id,map_id = 0;
  5442. nullpo_retr(-1, sd);
  5443. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5444. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5445. return -1;
  5446. }
  5447. if ((mob_id = atoi(mob_name)) == 0)
  5448. mob_id = mobdb_searchname(mob_name);
  5449. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5450. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5451. clif_displaymessage(fd, atcmd_output);
  5452. return -1;
  5453. }
  5454. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5455. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5456. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5457. map_id = sd->bl.m;
  5458. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5459. clif_displaymessage(fd, atcmd_output);
  5460. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  5461. atmobsearch_sub(&sd->bl,0); // reset the counter
  5462. return 0;
  5463. }
  5464. /*==========================================
  5465. * @cleanmap - cleans items on the ground
  5466. *------------------------------------------*/
  5467. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5468. {
  5469. nullpo_retr(0, bl);
  5470. map_clearflooritem(bl->id);
  5471. return 0;
  5472. }
  5473. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5474. {
  5475. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5476. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5477. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5478. BL_ITEM);
  5479. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5480. return 0;
  5481. }
  5482. /*==========================================
  5483. * make a NPC/PET talk
  5484. *------------------------------------------*/
  5485. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5486. {
  5487. char name[NAME_LENGTH],mes[100],temp[100];
  5488. struct npc_data *nd;
  5489. if (sd->sc.count && //no "chatting" while muted.
  5490. (sd->sc.data[SC_BERSERK] ||
  5491. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5492. return -1;
  5493. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5494. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5495. return -1;
  5496. }
  5497. if (!(nd = npc_name2id(name))) {
  5498. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5499. return -1;
  5500. }
  5501. strtok(name, "#"); // discard extra name identifier if present
  5502. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5503. clif_message(&nd->bl, temp);
  5504. return 0;
  5505. }
  5506. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5507. {
  5508. char mes[100],temp[100];
  5509. struct pet_data *pd;
  5510. const char* emo[] = { "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5511. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5512. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5513. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5514. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5515. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", NULL };
  5516. nullpo_retr(-1, sd);
  5517. if(!sd->status.pet_id || !(pd=sd->pd))
  5518. {
  5519. clif_displaymessage(fd, msg_txt(184));
  5520. return -1;
  5521. }
  5522. if (sd->sc.count && //no "chatting" while muted.
  5523. (sd->sc.data[SC_BERSERK] ||
  5524. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5525. return -1;
  5526. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5527. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5528. return -1;
  5529. }
  5530. if (message[0] == '/') {
  5531. int i;
  5532. for (i = 0; emo[i] != NULL; i++) {
  5533. if (!stricmp(message, emo[i])) {
  5534. clif_emotion(&pd->bl, i);
  5535. return 0;
  5536. }
  5537. }
  5538. }
  5539. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5540. clif_message(&pd->bl, temp);
  5541. return 0;
  5542. }
  5543. /*==========================================
  5544. * @users - displays the number of players present on each map (percentage)
  5545. *------------------------------------------*/
  5546. static DBMap* users_db = NULL; // unsigned int mapindex -> int users
  5547. static int users_all;
  5548. static int atcommand_users_sub1(struct map_session_data* sd,va_list va)
  5549. {
  5550. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  5551. users_all++;
  5552. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  5553. return 0;
  5554. }
  5555. static int atcommand_users_sub2(DBKey key,void* val,va_list va)
  5556. {
  5557. char buf[256];
  5558. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  5559. sprintf(buf,"%s: %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  5560. clif_displaymessage(sd->fd,buf);
  5561. return 0;
  5562. }
  5563. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5564. {
  5565. char buf[256];
  5566. users_all = 0;
  5567. users_db->clear(users_db, NULL);
  5568. clif_foreachclient(atcommand_users_sub1);
  5569. users_db->foreach(users_db,atcommand_users_sub2,sd);
  5570. sprintf(buf,"all: %d",users_all);
  5571. clif_displaymessage(fd,buf);
  5572. return 0;
  5573. }
  5574. /*==========================================
  5575. *
  5576. *------------------------------------------*/
  5577. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5578. {
  5579. pc_resetstate(sd);
  5580. pc_resetskill(sd,1);
  5581. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5582. clif_displaymessage(fd, atcmd_output);
  5583. return 0;
  5584. }
  5585. /*==========================================
  5586. *
  5587. *------------------------------------------*/
  5588. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5589. {
  5590. char name[NAME_LENGTH];
  5591. int mob_id = 0;
  5592. int duration = 0;
  5593. struct mob_data *md;
  5594. unsigned int tick=gettick();
  5595. nullpo_retr(-1, sd);
  5596. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5597. {
  5598. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5599. return -1;
  5600. }
  5601. if (duration < 1)
  5602. duration =1;
  5603. else if (duration > 60)
  5604. duration =60;
  5605. if ((mob_id = atoi(name)) == 0)
  5606. mob_id = mobdb_searchname(name);
  5607. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5608. {
  5609. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5610. return -1;
  5611. }
  5612. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5613. if(!md)
  5614. return -1;
  5615. md->master_id=sd->bl.id;
  5616. md->special_state.ai=1;
  5617. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5618. clif_misceffect2(&md->bl,344);
  5619. mob_spawn(md);
  5620. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5621. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5622. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5623. return 0;
  5624. }
  5625. /*==========================================
  5626. * @adjcmdlvl by [MouseJstr]
  5627. *
  5628. * Temp adjust the GM level required to use a GM command
  5629. * Useful during beta testing to allow players to use GM commands for short periods of time
  5630. *------------------------------------------*/
  5631. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5632. {
  5633. int newlev;
  5634. char name[100];
  5635. AtCommandInfo* cmd;
  5636. nullpo_retr(-1, sd);
  5637. if (!message || !*message || sscanf(message, "%d %99s", &newlev, name) != 2)
  5638. {
  5639. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  5640. return -1;
  5641. }
  5642. cmd = get_atcommandinfo_byname(name);
  5643. if (cmd == NULL)
  5644. {
  5645. clif_displaymessage(fd, "@command not found.");
  5646. return -1;
  5647. }
  5648. else if (newlev > pc_isGM(sd))
  5649. {
  5650. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5651. return -1;
  5652. }
  5653. else if (cmd->level > pc_isGM(sd))
  5654. {
  5655. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5656. return -1;
  5657. }
  5658. else
  5659. {
  5660. cmd->level = newlev;
  5661. clif_displaymessage(fd, "@command level changed.");
  5662. return 0;
  5663. }
  5664. }
  5665. /*==========================================
  5666. * @adjgmlvl by [MouseJstr]
  5667. * Create a temp GM
  5668. * Useful during beta testing to allow players to use GM commands for short periods of time
  5669. *------------------------------------------*/
  5670. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5671. {
  5672. int newlev;
  5673. char user[NAME_LENGTH];
  5674. struct map_session_data *pl_sd;
  5675. nullpo_retr(-1, sd);
  5676. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5677. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5678. return -1;
  5679. }
  5680. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5681. {
  5682. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5683. return -1;
  5684. }
  5685. pc_set_gm_level(pl_sd->status.account_id, newlev);
  5686. return 0;
  5687. }
  5688. /*==========================================
  5689. * @trade by [MouseJstr]
  5690. * Open a trade window with a remote player
  5691. *------------------------------------------*/
  5692. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5693. {
  5694. struct map_session_data *pl_sd = NULL;
  5695. nullpo_retr(-1, sd);
  5696. if (!message || !*message) {
  5697. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5698. return -1;
  5699. }
  5700. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5701. {
  5702. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5703. return -1;
  5704. }
  5705. trade_traderequest(sd, pl_sd);
  5706. return 0;
  5707. }
  5708. /*==========================================
  5709. * @setbattleflag by [MouseJstr]
  5710. * set a battle_config flag without having to reboot
  5711. *------------------------------------------*/
  5712. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5713. {
  5714. char flag[128], value[128];
  5715. nullpo_retr(-1, sd);
  5716. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5717. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5718. return -1;
  5719. }
  5720. if (battle_set_value(flag, value) == 0)
  5721. {
  5722. clif_displaymessage(fd, "unknown battle_config flag");
  5723. return -1;
  5724. }
  5725. clif_displaymessage(fd, "battle_config set as requested");
  5726. return 0;
  5727. }
  5728. /*==========================================
  5729. * @unmute [Valaris]
  5730. *------------------------------------------*/
  5731. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5732. {
  5733. struct map_session_data *pl_sd = NULL;
  5734. nullpo_retr(-1, sd);
  5735. if (!message || !*message) {
  5736. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5737. return -1;
  5738. }
  5739. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5740. {
  5741. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5742. return -1;
  5743. }
  5744. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5745. clif_displaymessage(sd->fd,"Player is not muted");
  5746. return -1;
  5747. }
  5748. pl_sd->status.manner = 0;
  5749. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  5750. clif_displaymessage(sd->fd,"Player unmuted");
  5751. return 0;
  5752. }
  5753. /*==========================================
  5754. * @uptime by MC Cameri
  5755. *------------------------------------------*/
  5756. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5757. {
  5758. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5759. minute = 60, days = 0, hours = 0, minutes = 0;
  5760. nullpo_retr(-1, sd);
  5761. seconds = get_uptime();
  5762. days = seconds/day;
  5763. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5764. hours = seconds/hour;
  5765. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5766. minutes = seconds/minute;
  5767. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5768. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5769. clif_displaymessage(fd, atcmd_output);
  5770. return 0;
  5771. }
  5772. /*==========================================
  5773. * @changesex <sex>
  5774. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5775. *------------------------------------------*/
  5776. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5777. {
  5778. nullpo_retr(-1, sd);
  5779. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  5780. return 0;
  5781. }
  5782. /*================================================
  5783. * @mute - Mutes a player for a set amount of time
  5784. *------------------------------------------------*/
  5785. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5786. {
  5787. struct map_session_data *pl_sd = NULL;
  5788. int manner;
  5789. nullpo_retr(-1, sd);
  5790. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5791. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5792. return -1;
  5793. }
  5794. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5795. {
  5796. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5797. return -1;
  5798. }
  5799. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5800. {
  5801. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5802. return -1;
  5803. }
  5804. clif_GM_silence(sd, pl_sd, 0);
  5805. pl_sd->status.manner -= manner;
  5806. if(pl_sd->status.manner < 0)
  5807. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5808. return 0;
  5809. }
  5810. /*==========================================
  5811. * @refresh (like @jumpto <<yourself>>)
  5812. *------------------------------------------*/
  5813. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5814. {
  5815. nullpo_retr(-1, sd);
  5816. clif_refresh(sd);
  5817. return 0;
  5818. }
  5819. /*==========================================
  5820. * @identify
  5821. * => GM's magnifier.
  5822. *------------------------------------------*/
  5823. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5824. {
  5825. int i,num;
  5826. nullpo_retr(-1, sd);
  5827. for(i=num=0;i<MAX_INVENTORY;i++){
  5828. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5829. num++;
  5830. }
  5831. }
  5832. if (num > 0) {
  5833. clif_item_identify_list(sd);
  5834. } else {
  5835. clif_displaymessage(fd,"There are no items to appraise.");
  5836. }
  5837. return 0;
  5838. }
  5839. /*==========================================
  5840. * @gmotd (Global MOTD)
  5841. * by davidsiaw :P
  5842. *------------------------------------------*/
  5843. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5844. {
  5845. char buf[256];
  5846. FILE *fp;
  5847. nullpo_retr(-1, sd);
  5848. if((fp = fopen(motd_txt, "r"))!=NULL){
  5849. while(fgets(buf, sizeof(buf), fp) != NULL)
  5850. {
  5851. int i;
  5852. if (buf[0] == '/' && buf[1] == '/')
  5853. continue;
  5854. for(i=0; buf[i]; i++){
  5855. if(buf[i]=='\r' || buf[i]=='\n'){
  5856. buf[i]=0;
  5857. break;
  5858. }
  5859. }
  5860. intif_GMmessage(buf,strlen(buf)+1,8);
  5861. }
  5862. fclose(fp);
  5863. }
  5864. return 0;
  5865. }
  5866. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5867. {
  5868. int effect = 0;
  5869. nullpo_retr(-1, sd);
  5870. if (!message || !*message)
  5871. return -1;
  5872. if (sscanf(message, "%d", &effect) < 1)
  5873. return -1;
  5874. clif_misceffect(&sd->bl,effect);
  5875. return 0;
  5876. }
  5877. /*==========================================
  5878. * MAIL SYSTEM
  5879. *------------------------------------------*/
  5880. int atcommand_mail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5881. {
  5882. nullpo_retr(0,sd);
  5883. #ifndef TXT_ONLY
  5884. mail_openmail(sd);
  5885. #endif
  5886. return 0;
  5887. }
  5888. /*==========================================
  5889. * Show Monster DB Info v 1.0
  5890. * originally by [Lupus] eAthena
  5891. *------------------------------------------*/
  5892. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5893. {
  5894. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5895. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5896. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5897. char atcmd_output2[200];
  5898. struct item_data *item_data;
  5899. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5900. int count;
  5901. int i, j, k;
  5902. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5903. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5904. if (!message || !*message) {
  5905. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  5906. return -1;
  5907. }
  5908. // If monster identifier/name argument is a name
  5909. if ((i = mobdb_checkid(atoi(message))))
  5910. {
  5911. mob_array[0] = mob_db(i);
  5912. count = 1;
  5913. } else
  5914. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5915. if (!count) {
  5916. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5917. return -1;
  5918. }
  5919. if (count > MAX_SEARCH) {
  5920. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5921. clif_displaymessage(fd, atcmd_output);
  5922. count = MAX_SEARCH;
  5923. }
  5924. for (k = 0; k < count; k++) {
  5925. mob = mob_array[k];
  5926. // stats
  5927. if (mob->mexp)
  5928. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5929. else
  5930. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  5931. clif_displaymessage(fd, atcmd_output);
  5932. 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);
  5933. clif_displaymessage(fd, atcmd_output);
  5934. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  5935. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  5936. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5937. clif_displaymessage(fd, atcmd_output);
  5938. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  5939. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5940. mob->range2 , mob->range3, msize[mob->status.size],
  5941. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5942. clif_displaymessage(fd, atcmd_output);
  5943. // drops
  5944. clif_displaymessage(fd, " Drops:");
  5945. strcpy(atcmd_output, " ");
  5946. j = 0;
  5947. for (i = 0; i < MAX_MOB_DROP; i++) {
  5948. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  5949. continue;
  5950. if (item_data->slot)
  5951. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  5952. else
  5953. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  5954. strcat(atcmd_output, atcmd_output2);
  5955. if (++j % 3 == 0) {
  5956. clif_displaymessage(fd, atcmd_output);
  5957. strcpy(atcmd_output, " ");
  5958. }
  5959. }
  5960. if (j == 0)
  5961. clif_displaymessage(fd, "This monster has no drops.");
  5962. else if (j % 3 != 0)
  5963. clif_displaymessage(fd, atcmd_output);
  5964. // mvp
  5965. if (mob->mexp) {
  5966. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  5967. clif_displaymessage(fd, atcmd_output);
  5968. strcpy(atcmd_output, " MVP Items:");
  5969. j = 0;
  5970. for (i = 0; i < 3; i++) {
  5971. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  5972. continue;
  5973. if (mob->mvpitem[i].p > 0) {
  5974. j++;
  5975. if (j == 1)
  5976. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5977. else
  5978. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  5979. strcat(atcmd_output, atcmd_output2);
  5980. }
  5981. }
  5982. if (j == 0)
  5983. clif_displaymessage(fd, "This monster has no MVP prizes.");
  5984. else
  5985. clif_displaymessage(fd, atcmd_output);
  5986. }
  5987. }
  5988. return 0;
  5989. }
  5990. /*=========================================
  5991. * @showmobs by KarLaeda
  5992. * => For 5 sec displays the mobs on minimap
  5993. *------------------------------------------*/
  5994. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  5995. {
  5996. struct map_session_data *sd;
  5997. if (!session[id] || (sd = session[id]->session_data) == NULL)
  5998. return 0;
  5999. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  6000. return 1;
  6001. }
  6002. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  6003. {
  6004. int mob_id,fd;
  6005. struct map_session_data* sd;
  6006. static int number=0;
  6007. struct mob_data *md;
  6008. if(!ap){
  6009. number=0;
  6010. return 0;
  6011. }
  6012. mob_id = va_arg(ap,int);
  6013. fd = va_arg(ap,int);
  6014. sd = va_arg(ap,struct map_session_data*);
  6015. md = (struct mob_data *)bl;
  6016. if(md->special_state.ai || md->master_id)
  6017. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  6018. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  6019. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  6020. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  6021. }
  6022. return 0;
  6023. }
  6024. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6025. {
  6026. char mob_name[100];
  6027. int mob_id,map_id = 0;
  6028. nullpo_retr(-1, sd);
  6029. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6030. return -1;
  6031. if ((mob_id = atoi(mob_name)) == 0)
  6032. mob_id = mobdb_searchname(mob_name);
  6033. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6034. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6035. clif_displaymessage(fd, atcmd_output);
  6036. return 0;
  6037. }
  6038. // Uncomment the following line to show mini-bosses & MVP.
  6039. //#define SHOW_MVP
  6040. #ifndef SHOW_MVP
  6041. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6042. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6043. clif_displaymessage(fd, atcmd_output);
  6044. return 0;
  6045. }
  6046. #endif
  6047. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6048. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6049. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6050. map_id = sd->bl.m;
  6051. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6052. mob_name, mapindex_id2name(sd->mapindex));
  6053. clif_displaymessage(fd, atcmd_output);
  6054. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  6055. atshowmobs_sub(&sd->bl,0);
  6056. return 0;
  6057. }
  6058. /*==========================================
  6059. * homunculus level up [orn]
  6060. *------------------------------------------*/
  6061. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6062. {
  6063. TBL_HOM * hd;
  6064. int level = 0, i = 0;
  6065. nullpo_retr(-1, sd);
  6066. if (!message || !*message) {
  6067. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <+/- # of levels>.");
  6068. return -1;
  6069. }
  6070. if ( !merc_is_hom_active(sd->hd) ) {
  6071. clif_displaymessage(fd, "You do not have a homunculus.");
  6072. return -1;
  6073. }
  6074. level = atoi(message);
  6075. hd = sd->hd;
  6076. for (i = 1; i <= level && hd->exp_next; i++){
  6077. hd->homunculus.exp += hd->exp_next;
  6078. merc_hom_levelup(hd);
  6079. }
  6080. status_calc_homunculus(hd,0);
  6081. status_percent_heal(&hd->bl, 100, 100);
  6082. clif_misceffect2(&hd->bl,568);
  6083. return 0;
  6084. }
  6085. /*==========================================
  6086. * homunculus evolution H [orn]
  6087. *------------------------------------------*/
  6088. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6089. {
  6090. nullpo_retr(-1, sd);
  6091. if ( !merc_is_hom_active(sd->hd) ) {
  6092. clif_displaymessage(fd, "You do not have a homunculus.");
  6093. return -1;
  6094. }
  6095. if ( !merc_hom_evolution(sd->hd) ) {
  6096. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6097. return -1;
  6098. }
  6099. return 0;
  6100. }
  6101. /*==========================================
  6102. * call choosen homunculus [orn]
  6103. *------------------------------------------*/
  6104. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6105. {
  6106. int homunid;
  6107. nullpo_retr(-1, sd);
  6108. if ( merc_is_hom_active(sd->hd) ) {
  6109. clif_displaymessage(fd, msg_txt(450));
  6110. return -1;
  6111. }
  6112. if (!message || !*message) {
  6113. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6114. return -1;
  6115. }
  6116. homunid = atoi(message);
  6117. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6118. {
  6119. clif_displaymessage(fd, "Invalid Homunculus id.");
  6120. return -1;
  6121. }
  6122. merc_create_homunculus_request(sd,homunid);
  6123. return 0;
  6124. }
  6125. /*==========================================
  6126. * modify homunculus intimacy [orn]
  6127. *------------------------------------------*/
  6128. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6129. {
  6130. int friendly = 0;
  6131. nullpo_retr(-1, sd);
  6132. if ( !merc_is_hom_active(sd->hd) ) {
  6133. clif_displaymessage(fd, "You do not have a homunculus.");
  6134. return -1;
  6135. }
  6136. if (!message || !*message) {
  6137. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6138. return -1;
  6139. }
  6140. friendly = atoi(message);
  6141. friendly = cap_value(friendly, 0, 1000);
  6142. sd->hd->homunculus.intimacy = friendly * 100 ;
  6143. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6144. return 0;
  6145. }
  6146. /*==========================================
  6147. * modify homunculus hunger [orn]
  6148. *------------------------------------------*/
  6149. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6150. {
  6151. int hungry = 0;
  6152. nullpo_retr(-1, sd);
  6153. if ( !merc_is_hom_active(sd->hd) ) {
  6154. clif_displaymessage(fd, "You do not have a homunculus.");
  6155. return -1;
  6156. }
  6157. if (!message || !*message) {
  6158. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6159. return -1;
  6160. }
  6161. hungry = atoi(message);
  6162. hungry = cap_value(hungry, 0, 100);
  6163. sd->hd->homunculus.hunger = hungry;
  6164. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6165. return 0;
  6166. }
  6167. /*==========================================
  6168. * make the homunculus speak [orn]
  6169. *------------------------------------------*/
  6170. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6171. {
  6172. char mes[100],temp[100];
  6173. nullpo_retr(-1, sd);
  6174. if (sd->sc.count && //no "chatting" while muted.
  6175. (sd->sc.data[SC_BERSERK] ||
  6176. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6177. return -1;
  6178. if ( !merc_is_hom_active(sd->hd) ) {
  6179. clif_displaymessage(fd, "You do not have a homunculus.");
  6180. return -1;
  6181. }
  6182. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6183. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6184. return -1;
  6185. }
  6186. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6187. clif_message(&sd->hd->bl, temp);
  6188. return 0;
  6189. }
  6190. /*==========================================
  6191. * Show homunculus stats
  6192. *------------------------------------------*/
  6193. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6194. {
  6195. struct homun_data *hd;
  6196. struct status_data *status;
  6197. nullpo_retr(-1, sd);
  6198. if ( !merc_is_hom_active(sd->hd) ) {
  6199. clif_displaymessage(fd, "You do not have a homunculus.");
  6200. return -1;
  6201. }
  6202. hd = sd->hd;
  6203. status = status_get_status_data(&hd->bl);
  6204. clif_displaymessage(fd, "Homunculus stats :");
  6205. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6206. status->hp, status->max_hp, status->sp, status->max_sp);
  6207. clif_displaymessage(fd, atcmd_output);
  6208. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6209. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6210. clif_displaymessage(fd, atcmd_output);
  6211. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6212. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6213. clif_displaymessage(fd, atcmd_output);
  6214. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6215. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6216. status->str, status->agi, status->vit,
  6217. status->int_, status->dex, status->luk);
  6218. clif_displaymessage(fd, atcmd_output);
  6219. return 0;
  6220. }
  6221. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6222. {
  6223. struct homun_data *hd;
  6224. struct s_homunculus_db *db;
  6225. struct s_homunculus *hom;
  6226. int lv, min, max, evo;
  6227. nullpo_retr(-1, sd);
  6228. if ( !merc_is_hom_active(sd->hd) ) {
  6229. clif_displaymessage(fd, "You do not have a homunculus.");
  6230. return -1;
  6231. }
  6232. hd = sd->hd;
  6233. hom = &hd->homunculus;
  6234. db = hd->homunculusDB;
  6235. lv = hom->level;
  6236. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6237. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6238. clif_displaymessage(fd, atcmd_output);
  6239. lv--; //Since the first increase is at level 2.
  6240. evo = (hom->class_ == db->evo_class);
  6241. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6242. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6243. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6244. clif_displaymessage(fd, atcmd_output);
  6245. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6246. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6247. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6248. clif_displaymessage(fd, atcmd_output);
  6249. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6250. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6251. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6252. clif_displaymessage(fd, atcmd_output);
  6253. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6254. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6255. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6256. clif_displaymessage(fd, atcmd_output);
  6257. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6258. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6259. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6260. clif_displaymessage(fd, atcmd_output);
  6261. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6262. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6263. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6264. clif_displaymessage(fd, atcmd_output);
  6265. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6266. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6267. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6268. clif_displaymessage(fd, atcmd_output);
  6269. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6270. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6271. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6272. clif_displaymessage(fd, atcmd_output);
  6273. return 0;
  6274. }
  6275. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6276. {
  6277. TBL_PC* tsd = sd;
  6278. nullpo_retr(-1, sd);
  6279. if ((!message || !*message) && !sd->hd)
  6280. {
  6281. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  6282. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  6283. return -1;
  6284. }
  6285. if (message && *message) {
  6286. tsd = map_nick2sd((char*)message);
  6287. if (!tsd) {
  6288. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6289. return -1;
  6290. }
  6291. if (pc_isGM(tsd) > pc_isGM(sd)) {
  6292. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6293. return -1;
  6294. }
  6295. }
  6296. if(!merc_hom_shuffle(tsd->hd))
  6297. return -1;
  6298. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6299. //Print out the new stats
  6300. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  6301. atcommand_homstats(fd, tsd, command, message);
  6302. return 0;
  6303. }
  6304. /*==========================================
  6305. * Show Items DB Info v 1.0
  6306. * originally by [Lupus] eAthena
  6307. *------------------------------------------*/
  6308. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6309. {
  6310. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  6311. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  6312. struct item_data *item_data, *item_array[MAX_SEARCH];
  6313. int i, count = 1;
  6314. if (!message || !*message) {
  6315. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6316. return -1;
  6317. }
  6318. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6319. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6320. if (!count) {
  6321. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6322. return -1;
  6323. }
  6324. if (count > MAX_SEARCH) {
  6325. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6326. clif_displaymessage(fd, atcmd_output);
  6327. count = MAX_SEARCH;
  6328. }
  6329. for (i = 0; i < count; i++) {
  6330. item_data = item_array[i];
  6331. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6332. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6333. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  6334. (item_data->script==NULL)? "None" : "With script"
  6335. );
  6336. clif_displaymessage(fd, atcmd_output);
  6337. 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. );
  6338. clif_displaymessage(fd, atcmd_output);
  6339. if (item_data->maxchance == 10000)
  6340. strcpy(atcmd_output, " - Available in the shops only");
  6341. else if (item_data->maxchance)
  6342. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6343. else
  6344. strcpy(atcmd_output, " - Monsters don't drop this item");
  6345. clif_displaymessage(fd, atcmd_output);
  6346. }
  6347. return 0;
  6348. }
  6349. /*==========================================
  6350. * Show who drops the item.
  6351. *------------------------------------------*/
  6352. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6353. {
  6354. struct item_data *item_data, *item_array[MAX_SEARCH];
  6355. int i,j, count = 1;
  6356. if (!message || !*message) {
  6357. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6358. return -1;
  6359. }
  6360. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6361. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6362. if (!count) {
  6363. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6364. return -1;
  6365. }
  6366. if (count > MAX_SEARCH) {
  6367. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6368. clif_displaymessage(fd, atcmd_output);
  6369. count = MAX_SEARCH;
  6370. }
  6371. for (i = 0; i < count; i++) {
  6372. item_data = item_array[i];
  6373. sprintf(atcmd_output, "Item: '%s'[%d]",
  6374. item_data->jname,item_data->slot);
  6375. clif_displaymessage(fd, atcmd_output);
  6376. if (item_data->mob[0].chance == 0) {
  6377. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6378. clif_displaymessage(fd, atcmd_output);
  6379. } else {
  6380. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6381. clif_displaymessage(fd, atcmd_output);
  6382. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6383. {
  6384. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6385. clif_displaymessage(fd, atcmd_output);
  6386. }
  6387. }
  6388. }
  6389. return 0;
  6390. }
  6391. int atcommand_whereis(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6392. {
  6393. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6394. int count;
  6395. int i, j, k;
  6396. if (!message || !*message) {
  6397. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6398. return -1;
  6399. }
  6400. // If monster identifier/name argument is a name
  6401. if ((i = mobdb_checkid(atoi(message))))
  6402. {
  6403. mob_array[0] = mob_db(i);
  6404. count = 1;
  6405. } else
  6406. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6407. if (!count) {
  6408. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6409. return -1;
  6410. }
  6411. if (count > MAX_SEARCH) {
  6412. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6413. clif_displaymessage(fd, atcmd_output);
  6414. count = MAX_SEARCH;
  6415. }
  6416. for (k = 0; k < count; k++) {
  6417. mob = mob_array[k];
  6418. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6419. clif_displaymessage(fd, atcmd_output);
  6420. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6421. {
  6422. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6423. if (j < 0) continue;
  6424. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6425. clif_displaymessage(fd, atcmd_output);
  6426. }
  6427. if (i == 0)
  6428. clif_displaymessage(fd, "This monster does not spawn normally.");
  6429. }
  6430. return 0;
  6431. }
  6432. /*==========================================
  6433. * @adopt by [Veider]
  6434. * adopt a novice
  6435. *------------------------------------------*/
  6436. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6437. {
  6438. struct map_session_data *pl_sd1 = NULL;
  6439. struct map_session_data *pl_sd2 = NULL;
  6440. struct map_session_data *pl_sd3 = NULL;
  6441. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6442. nullpo_retr(-1, sd);
  6443. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6444. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  6445. return -1;
  6446. }
  6447. if (battle_config.etc_log)
  6448. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6449. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6450. sprintf(player2, "Cannot find player %s online", player1);
  6451. clif_displaymessage(fd, player2);
  6452. return -1;
  6453. }
  6454. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6455. sprintf(player1, "Cannot find player %s online", player2);
  6456. clif_displaymessage(fd, player1);
  6457. return -1;
  6458. }
  6459. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6460. sprintf(player1, "Cannot find player %s online", player3);
  6461. clif_displaymessage(fd, player1);
  6462. return -1;
  6463. }
  6464. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  6465. clif_displaymessage(fd, "They are family.. wish them luck");
  6466. return 0;
  6467. }
  6468. else
  6469. return -1;
  6470. }
  6471. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6472. {
  6473. const char * revision;
  6474. if ((revision = get_svn_revision()) != 0) {
  6475. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6476. clif_displaymessage(fd,atcmd_output);
  6477. } else
  6478. clif_displaymessage(fd,"Cannot determine SVN revision");
  6479. return 0;
  6480. }
  6481. /*==========================================
  6482. * @mutearea by MouseJstr
  6483. *------------------------------------------*/
  6484. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6485. {
  6486. int time, id;
  6487. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6488. if (pl_sd == NULL)
  6489. return 0;
  6490. id = va_arg(ap, int);
  6491. time = va_arg(ap, int);
  6492. if (id != bl->id && !pc_isGM(pl_sd)) {
  6493. pl_sd->status.manner -= time;
  6494. if (pl_sd->status.manner < 0)
  6495. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6496. else if (pl_sd->sc.data[SC_NOCHAT])
  6497. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  6498. }
  6499. return 0;
  6500. }
  6501. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6502. {
  6503. int time;
  6504. nullpo_retr(0, sd);
  6505. if (!message || !*message) {
  6506. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6507. return -1;
  6508. }
  6509. time = atoi(message);
  6510. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6511. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6512. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6513. return 0;
  6514. }
  6515. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6516. {
  6517. char buf[255];
  6518. nullpo_retr(0, sd);
  6519. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  6520. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6521. clif_displaymessage(fd, buf);
  6522. return 0;
  6523. }
  6524. /*==========================================
  6525. * @me by lordalfa
  6526. * => Displays the OUTPUT string on top of the Visible players Heads.
  6527. *------------------------------------------*/
  6528. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6529. {
  6530. char tempmes[200];
  6531. nullpo_retr(-1, sd);
  6532. memset(tempmes, '\0', sizeof(tempmes));
  6533. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6534. if (sd->sc.count && //no "chatting" while muted.
  6535. (sd->sc.data[SC_BERSERK] ||
  6536. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6537. return -1;
  6538. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6539. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6540. return -1;
  6541. }
  6542. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6543. clif_disp_overhead(sd, atcmd_output);
  6544. return 0;
  6545. }
  6546. /*==========================================
  6547. * @size
  6548. * => Resize your character sprite. [Valaris]
  6549. *------------------------------------------*/
  6550. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6551. {
  6552. int size=0;
  6553. nullpo_retr(-1, sd);
  6554. size = atoi(message);
  6555. if(sd->state.size) {
  6556. sd->state.size=0;
  6557. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  6558. }
  6559. if(size==1) {
  6560. sd->state.size=1;
  6561. clif_specialeffect(&sd->bl,420,AREA);
  6562. } else if(size==2) {
  6563. sd->state.size=2;
  6564. clif_specialeffect(&sd->bl,422,AREA);
  6565. }
  6566. return 0;
  6567. }
  6568. /*==========================================
  6569. * @monsterignore
  6570. * => Makes monsters ignore you. [Valaris]
  6571. *------------------------------------------*/
  6572. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6573. {
  6574. nullpo_retr(-1, sd);
  6575. if (!sd->state.monster_ignore) {
  6576. sd->state.monster_ignore = 1;
  6577. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6578. } else {
  6579. sd->state.monster_ignore = 0;
  6580. clif_displaymessage(sd->fd, "Returned to normal state.");
  6581. }
  6582. return 0;
  6583. }
  6584. /*==========================================
  6585. * @fakename
  6586. * => Gives your character a fake name. [Valaris]
  6587. *------------------------------------------*/
  6588. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6589. {
  6590. char name[NAME_LENGTH];
  6591. nullpo_retr(-1, sd);
  6592. if((!message || !*message) && strlen(sd->fakename) > 1) {
  6593. sd->fakename[0]='\0';
  6594. clif_charnameack(0, &sd->bl);
  6595. clif_displaymessage(sd->fd,"Returned to real name.");
  6596. return 0;
  6597. }
  6598. if (!message || !*message || sscanf(message, "%23[^\n]", name) < 1) {
  6599. clif_displaymessage(sd->fd,"You must enter a name.");
  6600. return -1;
  6601. }
  6602. if(strlen(name) < 2) {
  6603. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  6604. return -1;
  6605. }
  6606. memcpy(sd->fakename,name,NAME_LENGTH);
  6607. sd->fakename[NAME_LENGTH-1] = '\0';
  6608. clif_charnameack(0, &sd->bl);
  6609. clif_displaymessage(sd->fd,"Fake name enabled.");
  6610. return 0;
  6611. }
  6612. /*==========================================
  6613. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  6614. * => Shows information about the map flags [map name]
  6615. * Also set flags
  6616. *------------------------------------------*/
  6617. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6618. {
  6619. // WIP
  6620. return 0;
  6621. }
  6622. /*===================================
  6623. * Remove some messages
  6624. *-----------------------------------*/
  6625. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6626. {
  6627. if (sd->state.showexp) {
  6628. sd->state.showexp = 0;
  6629. clif_displaymessage(fd, "Gained exp will not be shown.");
  6630. return 0;
  6631. }
  6632. sd->state.showexp = 1;
  6633. clif_displaymessage(fd, "Gained exp is now shown");
  6634. return 0;
  6635. }
  6636. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6637. {
  6638. if (sd->state.showzeny) {
  6639. sd->state.showzeny = 0;
  6640. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6641. return 0;
  6642. }
  6643. sd->state.showzeny = 1;
  6644. clif_displaymessage(fd, "Gained zeny is now shown");
  6645. return 0;
  6646. }
  6647. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6648. {
  6649. if (sd->state.showdelay) {
  6650. sd->state.showdelay = 0;
  6651. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6652. return 0;
  6653. }
  6654. sd->state.showdelay = 1;
  6655. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6656. return 0;
  6657. }
  6658. /*==========================================
  6659. * Duel organizing functions [LuzZza]
  6660. *
  6661. * @duel [limit|nick] - create a duel
  6662. * @invite <nick> - invite player
  6663. * @accept - accept invitation
  6664. * @reject - reject invitation
  6665. * @leave - leave duel
  6666. *------------------------------------------*/
  6667. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6668. {
  6669. unsigned int did = sd->duel_group;
  6670. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6671. if(did <= 0) {
  6672. // "Duel: @invite without @duel."
  6673. clif_displaymessage(fd, msg_txt(350));
  6674. return 0;
  6675. }
  6676. if(duel_list[did].max_players_limit > 0 &&
  6677. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6678. // "Duel: Limit of players is reached."
  6679. clif_displaymessage(fd, msg_txt(351));
  6680. return 0;
  6681. }
  6682. if(target_sd == NULL) {
  6683. // "Duel: Player not found."
  6684. clif_displaymessage(fd, msg_txt(352));
  6685. return 0;
  6686. }
  6687. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6688. // "Duel: Player already in duel."
  6689. clif_displaymessage(fd, msg_txt(353));
  6690. return 0;
  6691. }
  6692. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6693. {
  6694. sprintf(atcmd_output, msg_txt(364), message);
  6695. clif_displaymessage(fd, atcmd_output);
  6696. return 0;
  6697. }
  6698. duel_invite(did, sd, target_sd);
  6699. // "Duel: Invitation has been sent."
  6700. clif_displaymessage(fd, msg_txt(354));
  6701. return 0;
  6702. }
  6703. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6704. {
  6705. char output[256];
  6706. unsigned int maxpl=0, newduel;
  6707. struct map_session_data *target_sd;
  6708. if(sd->duel_group > 0) {
  6709. duel_showinfo(sd->duel_group, sd);
  6710. return 0;
  6711. }
  6712. if(sd->duel_invite > 0) {
  6713. // "Duel: @duel without @reject."
  6714. clif_displaymessage(fd, msg_txt(355));
  6715. return 0;
  6716. }
  6717. if(!duel_checktime(sd)) {
  6718. // "Duel: You can take part in duel only one time per %d minutes."
  6719. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6720. clif_displaymessage(fd, output);
  6721. return 0;
  6722. }
  6723. if(strlen(message) > 0) {
  6724. if(sscanf(message, "%d", &maxpl) >= 1) {
  6725. if(maxpl < 2 || maxpl > 65535) {
  6726. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6727. return 0;
  6728. }
  6729. duel_create(sd, maxpl);
  6730. } else {
  6731. target_sd = map_nick2sd((char *)message);
  6732. if(target_sd != NULL) {
  6733. if((newduel = duel_create(sd, 2)) != -1) {
  6734. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6735. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6736. return 0;
  6737. }
  6738. duel_invite(newduel, sd, target_sd);
  6739. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6740. }
  6741. } else {
  6742. // "Duel: Player not found."
  6743. clif_displaymessage(fd, msg_txt(352));
  6744. return 0;
  6745. }
  6746. }
  6747. } else
  6748. duel_create(sd, 0);
  6749. return 0;
  6750. }
  6751. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6752. {
  6753. if(sd->duel_group <= 0) {
  6754. // "Duel: @leave without @duel."
  6755. clif_displaymessage(fd, msg_txt(358));
  6756. return 0;
  6757. }
  6758. duel_leave(sd->duel_group, sd);
  6759. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6760. return 0;
  6761. }
  6762. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6763. {
  6764. char output[256];
  6765. if(!duel_checktime(sd)) {
  6766. // "Duel: You can take part in duel only one time per %d minutes."
  6767. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6768. clif_displaymessage(fd, output);
  6769. return 0;
  6770. }
  6771. if(sd->duel_invite <= 0) {
  6772. // "Duel: @accept without invititation."
  6773. clif_displaymessage(fd, msg_txt(360));
  6774. return 0;
  6775. }
  6776. duel_accept(sd->duel_invite, sd);
  6777. // "Duel: Invitation has been accepted."
  6778. clif_displaymessage(fd, msg_txt(361));
  6779. return 0;
  6780. }
  6781. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6782. {
  6783. if(sd->duel_invite <= 0) {
  6784. // "Duel: @reject without invititation."
  6785. clif_displaymessage(fd, msg_txt(362));
  6786. return 0;
  6787. }
  6788. duel_reject(sd->duel_invite, sd);
  6789. // "Duel: Invitation has been rejected."
  6790. clif_displaymessage(fd, msg_txt(363));
  6791. return 0;
  6792. }
  6793. /*===================================
  6794. * Away message (@away, @aw) [LuzZza]
  6795. *-----------------------------------*/
  6796. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6797. {
  6798. if(strlen(message) > 0) {
  6799. if(strlen(message) > 128)
  6800. return -1;
  6801. strcpy(sd->away_message, message);
  6802. //"Away automessage has been activated."
  6803. clif_displaymessage(fd, msg_txt(546));
  6804. } else {
  6805. if(strlen(sd->away_message) > 0) {
  6806. sd->away_message[0] = 0;
  6807. //"Away automessage has been disabled."
  6808. clif_displaymessage(fd, msg_txt(547));
  6809. return 0;
  6810. }
  6811. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  6812. clif_displaymessage(fd, msg_txt(548));
  6813. }
  6814. return 0;
  6815. }
  6816. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6817. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6818. {
  6819. int x=0,y=0,flag=0,master=0,i=0;
  6820. struct map_session_data *pl_sd=NULL;
  6821. if (!message || !*message) {
  6822. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  6823. return 0;
  6824. }
  6825. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6826. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6827. return 0;
  6828. }
  6829. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  6830. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6831. return 0;
  6832. }
  6833. if (strcmpi(command, "@clone") == 0)
  6834. flag = 1;
  6835. else if (strcmpi(command, "@slaveclone") == 0) {
  6836. flag = 2;
  6837. master = sd->bl.id;
  6838. if (battle_config.atc_slave_clone_limit
  6839. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6840. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6841. return 0;
  6842. }
  6843. }
  6844. do {
  6845. x = sd->bl.x + (rand() % 10 - 5);
  6846. y = sd->bl.y + (rand() % 10 - 5);
  6847. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6848. if (i >= 10) {
  6849. x = sd->bl.x;
  6850. y = sd->bl.y;
  6851. }
  6852. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6853. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6854. return 0;
  6855. }
  6856. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6857. return 0;
  6858. }
  6859. /*===================================
  6860. * Main chat [LuzZza]
  6861. * Usage: @main <on|off|message>
  6862. *-----------------------------------*/
  6863. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6864. {
  6865. if(strlen(message) > 0) {
  6866. if(strcmpi(message, "on") == 0) {
  6867. if(!sd->state.mainchat) {
  6868. sd->state.mainchat = 1;
  6869. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6870. } else {
  6871. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6872. }
  6873. } else if(strcmpi(message, "off") == 0) {
  6874. if(sd->state.mainchat) {
  6875. sd->state.mainchat = 0;
  6876. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6877. } else {
  6878. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6879. }
  6880. } else {
  6881. if(!sd->state.mainchat) {
  6882. sd->state.mainchat = 1;
  6883. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6884. }
  6885. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6886. clif_displaymessage(fd, msg_txt(387));
  6887. return -1;
  6888. }
  6889. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  6890. // I use 0xFE000000 color for signalizing that this message is
  6891. // main chat message. 0xFE000000 is invalid color, same using
  6892. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  6893. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  6894. // Chat logging type 'M' / Main Chat
  6895. if( log_config.chat&1 || (log_config.chat&32 && !(agit_flag && log_config.chat&64)) )
  6896. log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  6897. }
  6898. } else {
  6899. if(sd->state.mainchat)
  6900. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6901. else
  6902. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6903. }
  6904. return 0;
  6905. }
  6906. /*=====================================
  6907. * Autorejecting Invites/Deals [LuzZza]
  6908. * Usage: @noask
  6909. *-------------------------------------*/
  6910. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6911. {
  6912. if(sd->state.noask) {
  6913. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6914. sd->state.noask = 0;
  6915. } else {
  6916. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6917. sd->state.noask = 1;
  6918. }
  6919. return 0;
  6920. }
  6921. /*=====================================
  6922. * Send a @request message to all GMs of lowest_gm_level.
  6923. * Usage: @request <petition>
  6924. *-------------------------------------*/
  6925. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6926. {
  6927. if (!message || !*message) {
  6928. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6929. return -1;
  6930. }
  6931. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6932. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  6933. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6934. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6935. return 0;
  6936. }
  6937. /*==========================================
  6938. * Feel (SG save map) Reset [HiddenDragon]
  6939. *------------------------------------------*/
  6940. int atcommand_feelreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6941. {
  6942. pc_resetfeel(sd);
  6943. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  6944. return 0;
  6945. }
  6946. /*==========================================
  6947. * atcommand_info[] structure definition
  6948. *------------------------------------------*/
  6949. AtCommandInfo atcommand_info[] = {
  6950. { "rura", 40, atcommand_mapmove },
  6951. { "warp", 40, atcommand_mapmove },
  6952. { "mapmove", 40, atcommand_mapmove }, // + /mm
  6953. { "where", 1, atcommand_where },
  6954. { "jumpto", 20, atcommand_jumpto }, // + /shift
  6955. { "warpto", 20, atcommand_jumpto },
  6956. { "goto", 20, atcommand_jumpto },
  6957. { "jump", 40, atcommand_jump },
  6958. { "who", 20, atcommand_who },
  6959. { "whois", 20, atcommand_who },
  6960. { "who2", 20, atcommand_who2 },
  6961. { "who3", 20, atcommand_who3 },
  6962. { "whomap", 20, atcommand_whomap },
  6963. { "whomap2", 20, atcommand_whomap2 },
  6964. { "whomap3", 20, atcommand_whomap3 },
  6965. { "whogm", 20, atcommand_whogm },
  6966. { "save", 40, atcommand_save },
  6967. { "return", 40, atcommand_load },
  6968. { "load", 40, atcommand_load },
  6969. { "speed", 40, atcommand_speed },
  6970. { "storage", 1, atcommand_storage },
  6971. { "gstorage", 50, atcommand_guildstorage },
  6972. { "option", 40, atcommand_option },
  6973. { "hide", 40, atcommand_hide }, // + /hide
  6974. { "jobchange", 40, atcommand_jobchange },
  6975. { "job", 40, atcommand_jobchange },
  6976. { "die", 1, atcommand_die },
  6977. { "kill", 60, atcommand_kill },
  6978. { "alive", 60, atcommand_alive },
  6979. { "kami", 40, atcommand_kami },
  6980. { "kamib", 40, atcommand_kami },
  6981. { "kamic", 40, atcommand_kami },
  6982. { "heal", 40, atcommand_heal },
  6983. { "item", 60, atcommand_item },
  6984. { "item2", 60, atcommand_item2 },
  6985. { "itemreset", 40, atcommand_itemreset },
  6986. { "blvl", 60, atcommand_baselevelup },
  6987. { "lvup", 60, atcommand_baselevelup },
  6988. { "blevel", 60, atcommand_baselevelup },
  6989. { "baselvl", 60, atcommand_baselevelup },
  6990. { "baselvup", 60, atcommand_baselevelup },
  6991. { "baselevel", 60, atcommand_baselevelup },
  6992. { "baselvlup", 60, atcommand_baselevelup },
  6993. { "jlvl", 60, atcommand_joblevelup },
  6994. { "jlevel", 60, atcommand_joblevelup },
  6995. { "joblvl", 60, atcommand_joblevelup },
  6996. { "joblevel", 60, atcommand_joblevelup },
  6997. { "joblvup", 60, atcommand_joblevelup },
  6998. { "joblvlup", 60, atcommand_joblevelup },
  6999. { "h", 20, atcommand_help },
  7000. { "help", 20, atcommand_help },
  7001. { "h2", 20, atcommand_help2 },
  7002. { "help2", 20, atcommand_help2 },
  7003. { "gm", 100, atcommand_gm },
  7004. { "pvpoff", 40, atcommand_pvpoff },
  7005. { "pvpon", 40, atcommand_pvpon },
  7006. { "gvgoff", 40, atcommand_gvgoff },
  7007. { "gpvpoff", 40, atcommand_gvgoff },
  7008. { "gvgon", 40, atcommand_gvgon },
  7009. { "gpvpon", 40, atcommand_gvgon },
  7010. { "model", 20, atcommand_model },
  7011. { "go", 10, atcommand_go },
  7012. { "monster", 50, atcommand_monster },
  7013. { "spawn", 50, atcommand_monster },
  7014. { "monstersmall", 50, atcommand_monstersmall },
  7015. { "monsterbig", 50, atcommand_monsterbig },
  7016. { "killmonster", 60, atcommand_killmonster },
  7017. { "killmonster2", 40, atcommand_killmonster2 },
  7018. { "refine", 60, atcommand_refine },
  7019. { "produce", 60, atcommand_produce },
  7020. { "memo", 40, atcommand_memo },
  7021. { "gat", 99, atcommand_gat },
  7022. { "displaystatus", 99, atcommand_displaystatus },
  7023. { "stpoint", 60, atcommand_statuspoint },
  7024. { "skpoint", 60, atcommand_skillpoint },
  7025. { "zeny", 60, atcommand_zeny },
  7026. { "str", 60, atcommand_param },
  7027. { "agi", 60, atcommand_param },
  7028. { "vit", 60, atcommand_param },
  7029. { "int", 60, atcommand_param },
  7030. { "dex", 60, atcommand_param },
  7031. { "luk", 60, atcommand_param },
  7032. { "glvl", 60, atcommand_guildlevelup },
  7033. { "glevel", 60, atcommand_guildlevelup },
  7034. { "guildlvl", 60, atcommand_guildlevelup },
  7035. { "guildlvup", 60, atcommand_guildlevelup },
  7036. { "guildlevel", 60, atcommand_guildlevelup },
  7037. { "guildlvlup", 60, atcommand_guildlevelup },
  7038. { "makeegg", 60, atcommand_makeegg },
  7039. { "hatch", 60, atcommand_hatch },
  7040. { "petfriendly", 40, atcommand_petfriendly },
  7041. { "pethungry", 40, atcommand_pethungry },
  7042. { "petrename", 1, atcommand_petrename },
  7043. { "recall", 60, atcommand_recall }, // + /recall
  7044. { "night", 80, atcommand_night },
  7045. { "day", 80, atcommand_day },
  7046. { "doom", 80, atcommand_doom },
  7047. { "doommap", 80, atcommand_doommap },
  7048. { "raise", 80, atcommand_raise },
  7049. { "raisemap", 80, atcommand_raisemap },
  7050. { "kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7051. { "kickall", 99, atcommand_kickall },
  7052. { "allskill", 60, atcommand_allskill },
  7053. { "allskills", 60, atcommand_allskill },
  7054. { "skillall", 60, atcommand_allskill },
  7055. { "skillsall", 60, atcommand_allskill },
  7056. { "questskill", 40, atcommand_questskill },
  7057. { "lostskill", 40, atcommand_lostskill },
  7058. { "spiritball", 40, atcommand_spiritball },
  7059. { "party", 1, atcommand_party },
  7060. { "guild", 50, atcommand_guild },
  7061. { "agitstart", 60, atcommand_agitstart },
  7062. { "agitend", 60, atcommand_agitend },
  7063. { "mapexit", 99, atcommand_mapexit },
  7064. { "idsearch", 60, atcommand_idsearch },
  7065. { "broadcast", 40, atcommand_broadcast }, // + /b and /nb
  7066. { "localbroadcast", 40, atcommand_localbroadcast }, // + /lb and /nlb
  7067. { "recallall", 80, atcommand_recallall },
  7068. { "reloaditemdb", 99, atcommand_reloaditemdb },
  7069. { "reloadmobdb", 99, atcommand_reloadmobdb },
  7070. { "reloadskilldb", 99, atcommand_reloadskilldb },
  7071. { "reloadscript", 99, atcommand_reloadscript },
  7072. { "reloadgmdb", 99, atcommand_reloadgmdb },
  7073. { "reloadatcommand", 99, atcommand_reloadatcommand },
  7074. { "reloadbattleconf", 99, atcommand_reloadbattleconf },
  7075. { "reloadstatusdb", 99, atcommand_reloadstatusdb },
  7076. { "reloadpcdb", 99, atcommand_reloadpcdb },
  7077. { "reloadmotd", 99, atcommand_reloadmotd },
  7078. { "mapinfo", 99, atcommand_mapinfo },
  7079. { "dye", 40, atcommand_dye },
  7080. { "ccolor", 40, atcommand_dye },
  7081. { "hairstyle", 40, atcommand_hair_style },
  7082. { "hstyle", 40, atcommand_hair_style },
  7083. { "haircolor", 40, atcommand_hair_color },
  7084. { "hcolor", 40, atcommand_hair_color },
  7085. { "statall", 60, atcommand_stat_all },
  7086. { "statsall", 60, atcommand_stat_all },
  7087. { "allstats", 60, atcommand_stat_all },
  7088. { "allstat", 60, atcommand_stat_all },
  7089. { "block", 60, atcommand_char_block },
  7090. { "charblock", 60, atcommand_char_block },
  7091. { "ban", 60, atcommand_char_ban },
  7092. { "banish", 60, atcommand_char_ban },
  7093. { "charban", 60, atcommand_char_ban },
  7094. { "charbanish", 60, atcommand_char_ban },
  7095. { "unblock", 60, atcommand_char_unblock },
  7096. { "charunblock", 60, atcommand_char_unblock },
  7097. { "unban", 60, atcommand_char_unban },
  7098. { "unbanish", 60, atcommand_char_unban },
  7099. { "charunban", 60, atcommand_char_unban },
  7100. { "charunbanish", 60, atcommand_char_unban },
  7101. { "mount", 20, atcommand_mount_peco },
  7102. { "mountpeco", 20, atcommand_mount_peco },
  7103. { "guildspy", 60, atcommand_guildspy },
  7104. { "partyspy", 60, atcommand_partyspy },
  7105. { "repairall", 60, atcommand_repairall },
  7106. { "guildrecall", 60, atcommand_guildrecall },
  7107. { "partyrecall", 60, atcommand_partyrecall },
  7108. { "nuke", 60, atcommand_nuke },
  7109. { "shownpc", 80, atcommand_shownpc },
  7110. { "hidenpc", 80, atcommand_hidenpc },
  7111. { "loadnpc", 80, atcommand_loadnpc },
  7112. { "unloadnpc", 80, atcommand_unloadnpc },
  7113. { "time", 1, atcommand_servertime },
  7114. { "date", 1, atcommand_servertime },
  7115. { "serverdate", 1, atcommand_servertime },
  7116. { "servertime", 1, atcommand_servertime },
  7117. { "jail", 60, atcommand_jail },
  7118. { "unjail", 60, atcommand_unjail },
  7119. { "discharge", 60, atcommand_unjail },
  7120. { "jailfor", 60, atcommand_jailfor },
  7121. { "jailtime", 1, atcommand_jailtime },
  7122. { "disguise", 20, atcommand_disguise },
  7123. { "undisguise", 20, atcommand_undisguise },
  7124. { "email", 1, atcommand_email },
  7125. { "effect", 40, atcommand_effect },
  7126. { "follow", 20, atcommand_follow },
  7127. { "addwarp", 60, atcommand_addwarp },
  7128. { "skillon", 80, atcommand_skillon },
  7129. { "skilloff", 80, atcommand_skilloff },
  7130. { "killer", 60, atcommand_killer },
  7131. { "npcmove", 80, atcommand_npcmove },
  7132. { "killable", 40, atcommand_killable },
  7133. { "dropall", 40, atcommand_dropall },
  7134. { "storeall", 40, atcommand_storeall },
  7135. { "skillid", 40, atcommand_skillid },
  7136. { "useskill", 40, atcommand_useskill },
  7137. { "displayskill", 99, atcommand_displayskill },
  7138. { "snow", 99, atcommand_snow },
  7139. { "sakura", 99, atcommand_sakura },
  7140. { "clouds", 99, atcommand_clouds },
  7141. { "clouds2", 99, atcommand_clouds2 },
  7142. { "fog", 99, atcommand_fog },
  7143. { "fireworks", 99, atcommand_fireworks },
  7144. { "leaves", 99, atcommand_leaves },
  7145. { "summon", 60, atcommand_summon },
  7146. { "adjgmlvl", 99, atcommand_adjgmlvl },
  7147. { "adjcmdlvl", 99, atcommand_adjcmdlvl },
  7148. { "trade", 60, atcommand_trade },
  7149. { "send", 99, atcommand_send },
  7150. { "setbattleflag", 99, atcommand_setbattleflag },
  7151. { "unmute", 80, atcommand_unmute },
  7152. { "clearweather", 99, atcommand_clearweather },
  7153. { "uptime", 1, atcommand_uptime },
  7154. { "changesex", 60, atcommand_changesex },
  7155. { "mute", 80, atcommand_mute },
  7156. { "whozeny", 20, atcommand_whozeny },
  7157. { "refresh", 1, atcommand_refresh },
  7158. { "identify", 40, atcommand_identify },
  7159. { "gmotd", 20, atcommand_gmotd },
  7160. { "misceffect", 50, atcommand_misceffect },
  7161. { "mobsearch", 10, atcommand_mobsearch },
  7162. { "cleanmap", 40, atcommand_cleanmap },
  7163. { "npctalk", 20, atcommand_npctalk },
  7164. { "pettalk", 10, atcommand_pettalk },
  7165. { "users", 40, atcommand_users },
  7166. { "reset", 40, atcommand_reset },
  7167. { "skilltree", 40, atcommand_skilltree },
  7168. { "marry", 40, atcommand_marry },
  7169. { "divorce", 40, atcommand_divorce },
  7170. { "sound", 40, atcommand_sound },
  7171. { "undisguiseall", 99, atcommand_undisguiseall },
  7172. { "disguiseall", 99, atcommand_disguiseall },
  7173. { "changelook", 60, atcommand_changelook },
  7174. { "autoloot", 10, atcommand_autoloot },
  7175. { "mobinfo", 1, atcommand_mobinfo },
  7176. { "monsterinfo", 1, atcommand_mobinfo },
  7177. { "mi", 1, atcommand_mobinfo },
  7178. { "exp", 1, atcommand_exp },
  7179. { "adopt", 40, atcommand_adopt },
  7180. { "version", 1, atcommand_version },
  7181. { "mutearea", 99, atcommand_mutearea },
  7182. { "stfu", 99, atcommand_mutearea },
  7183. { "rates", 1, atcommand_rates },
  7184. { "iteminfo", 1, atcommand_iteminfo },
  7185. { "ii", 1, atcommand_iteminfo },
  7186. { "whodrops", 1, atcommand_whodrops },
  7187. { "whereis", 10, atcommand_whereis },
  7188. { "mapflag", 99, atcommand_mapflag },
  7189. { "me", 20, atcommand_me },
  7190. { "monsterignore", 99, atcommand_monsterignore },
  7191. { "battleignore", 99, atcommand_monsterignore },
  7192. { "fakename", 20, atcommand_fakename },
  7193. { "size", 20, atcommand_size },
  7194. { "showexp", 10, atcommand_showexp},
  7195. { "showzeny", 10, atcommand_showzeny},
  7196. { "showdelay", 1, atcommand_showdelay},
  7197. { "autotrade", 10, atcommand_autotrade },
  7198. { "at", 10, atcommand_autotrade },
  7199. { "changegm", 10, atcommand_changegm },
  7200. { "changeleader", 10, atcommand_changeleader },
  7201. { "partyoption", 10, atcommand_partyoption},
  7202. { "invite", 1, atcommand_invite },
  7203. { "duel", 1, atcommand_duel },
  7204. { "leave", 1, atcommand_leave },
  7205. { "accept", 1, atcommand_accept },
  7206. { "reject", 1, atcommand_reject },
  7207. { "away", 1, atcommand_away },
  7208. { "aw", 1, atcommand_away },
  7209. { "main", 1, atcommand_main },
  7210. { "clone", 50, atcommand_clone },
  7211. { "slaveclone", 50, atcommand_clone },
  7212. { "evilclone", 50, atcommand_clone },
  7213. { "tonpc", 40, atcommand_tonpc },
  7214. { "commands", 1, atcommand_commands },
  7215. { "noask", 1, atcommand_noask },
  7216. { "request", 20, atcommand_request },
  7217. { "hlvl", 60, atcommand_homlevel },
  7218. { "hlevel", 60, atcommand_homlevel },
  7219. { "homlvl", 60, atcommand_homlevel },
  7220. { "homlvup", 60, atcommand_homlevel },
  7221. { "homlevel", 60, atcommand_homlevel },
  7222. { "homevolve", 60, atcommand_homevolution },
  7223. { "homevolution", 60, atcommand_homevolution },
  7224. { "makehomun", 60, atcommand_makehomun },
  7225. { "homfriendly", 60, atcommand_homfriendly },
  7226. { "homhungry", 60, atcommand_homhungry },
  7227. { "homtalk", 10, atcommand_homtalk },
  7228. { "hominfo", 1, atcommand_hominfo },
  7229. { "homstats", 1, atcommand_homstats },
  7230. { "homshuffle", 60, atcommand_homshuffle },
  7231. { "showmobs", 10, atcommand_showmobs },
  7232. { "feelreset", 10, atcommand_feelreset },
  7233. { "mail", 1, atcommand_mail },
  7234. };
  7235. /*==========================================
  7236. * Command lookup functions
  7237. *------------------------------------------*/
  7238. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  7239. {
  7240. int i;
  7241. if( *name == atcommand_symbol ) name++; // for backwards compatibility
  7242. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, strcmpi(atcommand_info[i].command, name) == 0 );
  7243. return ( i != ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7244. }
  7245. static AtCommandInfo* get_atcommandinfo_byfunc(const AtCommandFunc func)
  7246. {
  7247. int i;
  7248. ARR_FIND( 0, ARRAYLENGTH(atcommand_info), i, atcommand_info[i].func == func );
  7249. return ( i != ARRAYLENGTH(atcommand_info) ) ? &atcommand_info[i] : NULL;
  7250. }
  7251. /*==========================================
  7252. * Retrieve the command's required gm level
  7253. *------------------------------------------*/
  7254. int get_atcommand_level(const AtCommandFunc func)
  7255. {
  7256. AtCommandInfo* info = get_atcommandinfo_byfunc(func);
  7257. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7258. }
  7259. /// Executes an at-command.
  7260. /// To be called by internal server code (bypasses various restrictions).
  7261. bool is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  7262. {
  7263. AtCommandInfo* info;
  7264. char command[100];
  7265. char args[100];
  7266. char output[200];
  7267. if( !str || !*str )
  7268. return false;
  7269. if( *str != atcommand_symbol ) // check first char
  7270. return false;
  7271. if( sscanf(str, "%99s %99[^\n]", command, args) < 2 )
  7272. args[0] = '\0';
  7273. info = get_atcommandinfo_byname(command);
  7274. if( info == NULL || info->func == NULL || gmlvl < info->level )
  7275. {
  7276. if( gmlvl == 0 )
  7277. return false; // will just display as normal text
  7278. else
  7279. {
  7280. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7281. clif_displaymessage(fd, output);
  7282. return true;
  7283. }
  7284. }
  7285. if( log_config.gm && info->level >= log_config.gm )
  7286. log_atcommand(sd, str);
  7287. if( info->func(fd, sd, command, args) != 0 )
  7288. {
  7289. sprintf(output, msg_txt(154), command); // "%s failed."
  7290. clif_displaymessage(fd, output);
  7291. }
  7292. return true;
  7293. }
  7294. /// Executes an at-command.
  7295. /// To be used by player-invoked code (restrictions will be applied).
  7296. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  7297. {
  7298. int gmlvl = pc_isGM(sd);
  7299. nullpo_retr(false, sd);
  7300. if( !message || !*message )
  7301. return false; // shouldn't happen
  7302. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7303. return true; // so that it won't display as normal message
  7304. if( battle_config.atc_gmonly != 0 && gmlvl == 0 )
  7305. return false;
  7306. if( map[sd->bl.m].nocommand && gmlvl < map[sd->bl.m].nocommand )
  7307. {
  7308. clif_displaymessage(fd, msg_txt(143)); // "Commands are disabled on this map."
  7309. return false;
  7310. }
  7311. // skip 10/11-langtype's codepage indicator, if detected
  7312. if( message[0] == '|' && strlen(message) >= 4 && message[3] == atcommand_symbol )
  7313. message += 3;
  7314. return is_atcommand_sub(fd,sd,message,gmlvl);
  7315. }
  7316. /*==========================================
  7317. *
  7318. *------------------------------------------*/
  7319. int atcommand_config_read(const char* cfgName)
  7320. {
  7321. char line[1024], w1[1024], w2[1024];
  7322. AtCommandInfo* p;
  7323. FILE* fp;
  7324. if( (fp = fopen(cfgName, "r")) == NULL )
  7325. {
  7326. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  7327. return 1;
  7328. }
  7329. while( fgets(line, sizeof(line), fp) )
  7330. {
  7331. if( line[0] == '/' && line[1] == '/' )
  7332. continue;
  7333. if( sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2 )
  7334. continue;
  7335. p = get_atcommandinfo_byname(w1);
  7336. if( p != NULL )
  7337. {
  7338. p->level = atoi(w2);
  7339. p->level = cap_value(p->level, 0, 100);
  7340. }
  7341. else
  7342. if( strcmpi(w1, "import") == 0 )
  7343. atcommand_config_read(w2);
  7344. else
  7345. if( strcmpi(w1, "command_symbol") == 0 &&
  7346. w2[0] > 31 && // control characters
  7347. w2[0] != '/' && // symbol of standard ragnarok GM commands
  7348. w2[0] != '%' && // symbol of party chat speaking
  7349. w2[0] != '$' && // symbol of guild chat speaking
  7350. w2[0] != '#' ) // symbol of charcommand
  7351. atcommand_symbol = w2[0];
  7352. else
  7353. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  7354. }
  7355. fclose(fp);
  7356. return 0;
  7357. }
  7358. void do_init_atcommand()
  7359. {
  7360. users_db = uidb_alloc(DB_OPT_BASE);
  7361. duel_count = 0;
  7362. memset(&duel_list[0], 0, sizeof(duel_list));
  7363. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  7364. return;
  7365. }
  7366. void do_final_atcommand()
  7367. {
  7368. users_db->destroy(users_db,NULL);
  7369. }
  7370. // commands that need to go _after_ the commands table
  7371. /*==========================================
  7372. * @commands Lists available @ commands to you
  7373. *------------------------------------------*/
  7374. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7375. {
  7376. char line_buff[CHATBOX_SIZE];
  7377. int i, gm_lvl = pc_isGM(sd), count = 0;
  7378. char* cur = line_buff;
  7379. memset(line_buff,' ',CHATBOX_SIZE);
  7380. line_buff[CHATBOX_SIZE-1] = 0;
  7381. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7382. for( i = 0; i < ARRAYLENGTH(atcommand_info); i++ )
  7383. {
  7384. unsigned int slen;
  7385. if( gm_lvl < atcommand_info[i].level )
  7386. continue;
  7387. slen = (unsigned int)strlen(atcommand_info[i].command);
  7388. // flush the text buffer if this command won't fit into it
  7389. if( ((CHATBOX_SIZE-1+(int)line_buff)-(int)cur) < (int)slen )
  7390. {
  7391. clif_displaymessage(fd,line_buff);
  7392. cur = line_buff;
  7393. memset(line_buff,' ',CHATBOX_SIZE);
  7394. line_buff[CHATBOX_SIZE-1] = 0;
  7395. }
  7396. memcpy(cur,atcommand_info[i].command,slen);
  7397. cur += slen+(10-slen%10);
  7398. count++;
  7399. }
  7400. clif_displaymessage(fd,line_buff);
  7401. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7402. clif_displaymessage(fd, atcmd_output);
  7403. return 0;
  7404. }