atcommand.c 247 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005
  1. // $Id: atcommand.c 148 2004-09-30 14:05:37Z MouseJstr $
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <math.h>
  7. #include "../common/socket.h"
  8. #include "../common/timer.h"
  9. #include "../common/nullpo.h"
  10. #include "log.h"
  11. #include "clif.h"
  12. #include "chrif.h"
  13. #include "intif.h"
  14. #include "itemdb.h"
  15. #include "map.h"
  16. #include "pc.h"
  17. #include "skill.h"
  18. #include "mob.h"
  19. #include "pet.h"
  20. #include "battle.h"
  21. #include "party.h"
  22. #include "guild.h"
  23. #include "atcommand.h"
  24. #include "script.h"
  25. #include "npc.h"
  26. #include "trade.h"
  27. #include "core.h"
  28. #ifndef TXT_ONLY
  29. #include "mail.h"
  30. #endif
  31. #define STATE_BLIND 0x10
  32. static char command_symbol = '@'; // first char of the commands (by [Yor])
  33. static char msg_table[1000][1024]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  34. #define ATCOMMAND_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  35. ATCOMMAND_FUNC(broadcast);
  36. ATCOMMAND_FUNC(localbroadcast);
  37. ATCOMMAND_FUNC(rurap);
  38. ATCOMMAND_FUNC(rura);
  39. ATCOMMAND_FUNC(where);
  40. ATCOMMAND_FUNC(jumpto);
  41. ATCOMMAND_FUNC(jump);
  42. ATCOMMAND_FUNC(who);
  43. ATCOMMAND_FUNC(who2);
  44. ATCOMMAND_FUNC(who3);
  45. ATCOMMAND_FUNC(whomap);
  46. ATCOMMAND_FUNC(whomap2);
  47. ATCOMMAND_FUNC(whomap3);
  48. ATCOMMAND_FUNC(whogm); // by Yor
  49. ATCOMMAND_FUNC(whozeny); // [Valaris]
  50. ATCOMMAND_FUNC(happyhappyjoyjoy); // [Valaris]
  51. ATCOMMAND_FUNC(save);
  52. ATCOMMAND_FUNC(load);
  53. ATCOMMAND_FUNC(speed);
  54. ATCOMMAND_FUNC(storage);
  55. ATCOMMAND_FUNC(guildstorage);
  56. ATCOMMAND_FUNC(option);
  57. ATCOMMAND_FUNC(hide);
  58. ATCOMMAND_FUNC(jobchange);
  59. ATCOMMAND_FUNC(die);
  60. ATCOMMAND_FUNC(kill);
  61. ATCOMMAND_FUNC(alive);
  62. ATCOMMAND_FUNC(kami);
  63. ATCOMMAND_FUNC(heal);
  64. ATCOMMAND_FUNC(item);
  65. ATCOMMAND_FUNC(item2);
  66. ATCOMMAND_FUNC(itemreset);
  67. ATCOMMAND_FUNC(itemcheck);
  68. ATCOMMAND_FUNC(baselevelup);
  69. ATCOMMAND_FUNC(joblevelup);
  70. ATCOMMAND_FUNC(help);
  71. ATCOMMAND_FUNC(gm);
  72. ATCOMMAND_FUNC(pvpoff);
  73. ATCOMMAND_FUNC(pvpon);
  74. ATCOMMAND_FUNC(gvgoff);
  75. ATCOMMAND_FUNC(gvgon);
  76. ATCOMMAND_FUNC(model);
  77. ATCOMMAND_FUNC(go);
  78. ATCOMMAND_FUNC(monster);
  79. ATCOMMAND_FUNC(monstersmall);
  80. ATCOMMAND_FUNC(monsterbig);
  81. ATCOMMAND_FUNC(spawn);
  82. ATCOMMAND_FUNC(killmonster);
  83. ATCOMMAND_FUNC(killmonster2);
  84. ATCOMMAND_FUNC(refine);
  85. ATCOMMAND_FUNC(produce);
  86. ATCOMMAND_FUNC(memo);
  87. ATCOMMAND_FUNC(gat);
  88. ATCOMMAND_FUNC(packet);
  89. ATCOMMAND_FUNC(statuspoint);
  90. ATCOMMAND_FUNC(skillpoint);
  91. ATCOMMAND_FUNC(zeny);
  92. ATCOMMAND_FUNC(param);
  93. ATCOMMAND_FUNC(guildlevelup);
  94. ATCOMMAND_FUNC(makeegg);
  95. ATCOMMAND_FUNC(hatch);
  96. ATCOMMAND_FUNC(petfriendly);
  97. ATCOMMAND_FUNC(pethungry);
  98. ATCOMMAND_FUNC(petrename);
  99. ATCOMMAND_FUNC(charpetrename); // by Yor
  100. ATCOMMAND_FUNC(recall);
  101. ATCOMMAND_FUNC(recallall);
  102. ATCOMMAND_FUNC(revive);
  103. ATCOMMAND_FUNC(character_stats);
  104. ATCOMMAND_FUNC(character_stats_all);
  105. ATCOMMAND_FUNC(character_option);
  106. ATCOMMAND_FUNC(character_save);
  107. ATCOMMAND_FUNC(night);
  108. ATCOMMAND_FUNC(day);
  109. ATCOMMAND_FUNC(doom);
  110. ATCOMMAND_FUNC(doommap);
  111. ATCOMMAND_FUNC(raise);
  112. ATCOMMAND_FUNC(raisemap);
  113. ATCOMMAND_FUNC(character_baselevel);
  114. ATCOMMAND_FUNC(character_joblevel);
  115. ATCOMMAND_FUNC(kick);
  116. ATCOMMAND_FUNC(kickall);
  117. ATCOMMAND_FUNC(allskill);
  118. ATCOMMAND_FUNC(questskill);
  119. ATCOMMAND_FUNC(charquestskill);
  120. ATCOMMAND_FUNC(lostskill);
  121. ATCOMMAND_FUNC(charlostskill);
  122. ATCOMMAND_FUNC(spiritball);
  123. ATCOMMAND_FUNC(party);
  124. ATCOMMAND_FUNC(guild);
  125. ATCOMMAND_FUNC(charskreset);
  126. ATCOMMAND_FUNC(charstreset);
  127. ATCOMMAND_FUNC(charreset);
  128. ATCOMMAND_FUNC(charstpoint);
  129. ATCOMMAND_FUNC(charmodel);
  130. ATCOMMAND_FUNC(charskpoint);
  131. ATCOMMAND_FUNC(charzeny);
  132. ATCOMMAND_FUNC(agitstart);
  133. ATCOMMAND_FUNC(agitend);
  134. ATCOMMAND_FUNC(reloaditemdb);
  135. ATCOMMAND_FUNC(reloadmobdb);
  136. ATCOMMAND_FUNC(reloadskilldb);
  137. #ifndef TXT_ONLY
  138. ATCOMMAND_FUNC(rehash);// by Fr3DBr
  139. #else /* TXT_ONLY */
  140. ATCOMMAND_FUNC(reloadscript);
  141. #endif /* TXT_ONLY */
  142. ATCOMMAND_FUNC(reloadgmdb); // by Yor
  143. ATCOMMAND_FUNC(mapexit);
  144. ATCOMMAND_FUNC(idsearch);
  145. ATCOMMAND_FUNC(mapinfo);
  146. ATCOMMAND_FUNC(dye); //** by fritz
  147. ATCOMMAND_FUNC(hair_style); //** by fritz
  148. ATCOMMAND_FUNC(hair_color); //** by fritz
  149. ATCOMMAND_FUNC(stat_all); //** by fritz
  150. ATCOMMAND_FUNC(char_change_sex); // by Yor
  151. ATCOMMAND_FUNC(char_block); // by Yor
  152. ATCOMMAND_FUNC(char_ban); // by Yor
  153. ATCOMMAND_FUNC(char_unblock); // by Yor
  154. ATCOMMAND_FUNC(char_unban); // by Yor
  155. ATCOMMAND_FUNC(mount_peco); // by Valaris
  156. ATCOMMAND_FUNC(char_mount_peco); // by Yor
  157. ATCOMMAND_FUNC(guildspy); // [Syrus22]
  158. ATCOMMAND_FUNC(partyspy); // [Syrus22]
  159. ATCOMMAND_FUNC(repairall); // [Valaris]
  160. ATCOMMAND_FUNC(guildrecall); // by Yor
  161. ATCOMMAND_FUNC(partyrecall); // by Yor
  162. //ATCOMMAND_FUNC(nuke); // [Valaris]
  163. ATCOMMAND_FUNC(enablenpc);
  164. ATCOMMAND_FUNC(disablenpc);
  165. ATCOMMAND_FUNC(servertime); // by Yor
  166. ATCOMMAND_FUNC(chardelitem); // by Yor
  167. ATCOMMAND_FUNC(jail); // by Yor
  168. ATCOMMAND_FUNC(unjail); // by Yor
  169. ATCOMMAND_FUNC(disguise); // [Valaris]
  170. ATCOMMAND_FUNC(undisguise); // by Yor
  171. ATCOMMAND_FUNC(chardisguise); // Kalaspuff
  172. ATCOMMAND_FUNC(charundisguise); // Kalaspuff
  173. ATCOMMAND_FUNC(email); // by Yor
  174. ATCOMMAND_FUNC(effect);//by Apple
  175. ATCOMMAND_FUNC(character_item_list); // by Yor
  176. ATCOMMAND_FUNC(character_storage_list); // by Yor
  177. ATCOMMAND_FUNC(character_cart_list); // by Yor
  178. ATCOMMAND_FUNC(addwarp); // by MouseJstr
  179. ATCOMMAND_FUNC(follow); // by MouseJstr
  180. ATCOMMAND_FUNC(skillon); // by MouseJstr
  181. ATCOMMAND_FUNC(skilloff); // by MouseJstr
  182. ATCOMMAND_FUNC(killer); // by MouseJstr
  183. ATCOMMAND_FUNC(npcmove); // by MouseJstr
  184. ATCOMMAND_FUNC(killable); // by MouseJstr
  185. ATCOMMAND_FUNC(charkillable); // by MouseJstr
  186. ATCOMMAND_FUNC(chareffect); // by MouseJstr
  187. ATCOMMAND_FUNC(chardye); // by MouseJstr
  188. ATCOMMAND_FUNC(charhairstyle); // by MouseJstr
  189. ATCOMMAND_FUNC(charhaircolor); // by MouseJstr
  190. ATCOMMAND_FUNC(dropall); // by MouseJstr
  191. ATCOMMAND_FUNC(chardropall); // by MouseJstr
  192. ATCOMMAND_FUNC(storeall); // by MouseJstr
  193. ATCOMMAND_FUNC(charstoreall); // by MouseJstr
  194. ATCOMMAND_FUNC(skillid); // by MouseJstr
  195. ATCOMMAND_FUNC(useskill); // by MouseJstr
  196. ATCOMMAND_FUNC(summon);
  197. ATCOMMAND_FUNC(rain);
  198. ATCOMMAND_FUNC(snow);
  199. ATCOMMAND_FUNC(sakura);
  200. ATCOMMAND_FUNC(fog);
  201. ATCOMMAND_FUNC(leaves);
  202. ATCOMMAND_FUNC(adjgmlvl); // by MouseJstr
  203. ATCOMMAND_FUNC(adjcmdlvl); // by MouseJstr
  204. ATCOMMAND_FUNC(trade); // by MouseJstr
  205. ATCOMMAND_FUNC(send); // by davidsiaw
  206. ATCOMMAND_FUNC(setbattleflag); // by MouseJstr
  207. ATCOMMAND_FUNC(unmute); // [Valaris]
  208. ATCOMMAND_FUNC(uptime); // by MC Cameri
  209. ATCOMMAND_FUNC(changesex); // by MC Cameri
  210. ATCOMMAND_FUNC(mute); // celest
  211. ATCOMMAND_FUNC(refresh); // by MC Cameri
  212. ATCOMMAND_FUNC(petid); // by MC Cameri
  213. ATCOMMAND_FUNC(identify); // by MC Cameri
  214. ATCOMMAND_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  215. #ifndef TXT_ONLY
  216. ATCOMMAND_FUNC(checkmail); // [Valaris]
  217. ATCOMMAND_FUNC(listmail); // [Valaris]
  218. ATCOMMAND_FUNC(listnewmail); // [Valaris]
  219. ATCOMMAND_FUNC(readmail); // [Valaris]
  220. ATCOMMAND_FUNC(sendmail); // [Valaris]
  221. ATCOMMAND_FUNC(sendprioritymail); // [Valaris]
  222. ATCOMMAND_FUNC(deletemail); // [Valaris]
  223. ATCOMMAND_FUNC(sound); // [Valaris]
  224. ATCOMMAND_FUNC(refreshonline); // [Valaris]
  225. #endif /* TXT_ONLY */
  226. /*==========================================
  227. *AtCommandInfo atcommand_info[]構造体の定義
  228. *------------------------------------------
  229. */
  230. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  231. // to set default level, read atcommand_athena.conf first please.
  232. static AtCommandInfo atcommand_info[] = {
  233. { AtCommand_RuraP, "@rura+", 60, atcommand_rurap },
  234. { AtCommand_RuraP, "@charwarp", 60, atcommand_rurap },
  235. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  236. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  237. { AtCommand_Where, "@where", 1, atcommand_where },
  238. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  239. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  240. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  241. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  242. { AtCommand_Who, "@who", 20, atcommand_who },
  243. { AtCommand_Who, "@whois", 20, atcommand_who },
  244. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  245. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  246. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  247. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  248. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  249. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  250. { AtCommand_Save, "@save", 40, atcommand_save },
  251. { AtCommand_Load, "@return", 40, atcommand_load },
  252. { AtCommand_Load, "@load", 40, atcommand_load },
  253. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  254. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  255. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  256. { AtCommand_Option, "@option", 40, atcommand_option },
  257. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  258. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  259. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  260. { AtCommand_Die, "@die", 1, atcommand_die },
  261. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  262. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  263. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  264. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  265. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  266. { AtCommand_Item, "@item", 60, atcommand_item },
  267. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  268. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  269. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  270. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  271. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  272. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  273. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  274. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  275. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  276. { AtCommand_H, "@h", 20, atcommand_help },
  277. { AtCommand_Help, "@help", 20, atcommand_help },
  278. { AtCommand_GM, "@gm", 100, atcommand_gm },
  279. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  280. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  281. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  282. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  283. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  284. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  285. { AtCommand_Model, "@model", 20, atcommand_model },
  286. { AtCommand_Go, "@go", 10, atcommand_go },
  287. { AtCommand_Spawn, "@monster", 50, atcommand_spawn },
  288. { AtCommand_Spawn, "@spawn", 50, atcommand_spawn },
  289. // { AtCommand_Spawn, "@summon", 50, atcommand_spawn },
  290. { AtCommand_Monster, "@monster2", 50, atcommand_monster },
  291. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  292. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  293. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  294. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  295. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  296. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  297. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  298. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  299. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  300. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  301. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  302. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  303. { AtCommand_Strength, "@str", 60, atcommand_param },
  304. { AtCommand_Agility, "@agi", 60, atcommand_param },
  305. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  306. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  307. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  308. { AtCommand_Luck, "@luk", 60, atcommand_param },
  309. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  310. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  311. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  312. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  313. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  314. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  315. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  316. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  317. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  318. { AtCommand_CharacterStats, "@charstats", 40, atcommand_character_stats },
  319. { AtCommand_CharacterStatsAll, "@charstatsall", 40, atcommand_character_stats_all },
  320. { AtCommand_CharacterOption, "@charoption", 60, atcommand_character_option },
  321. { AtCommand_CharacterSave, "@charsave", 60, atcommand_character_save },
  322. { AtCommand_Night, "@night", 80, atcommand_night },
  323. { AtCommand_Day, "@day", 80, atcommand_day },
  324. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  325. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  326. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  327. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  328. { AtCommand_CharacterBaseLevel, "@charbaselvl", 60, atcommand_character_baselevel },
  329. { AtCommand_CharacterJobLevel, "@charjlvl", 60, atcommand_character_joblevel },
  330. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  331. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  332. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  333. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  334. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  335. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  336. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  337. { AtCommand_CharQuestSkill, "@charquestskill", 60, atcommand_charquestskill },
  338. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  339. { AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill },
  340. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  341. { AtCommand_Party, "@party", 1, atcommand_party },
  342. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  343. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  344. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  345. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  346. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  347. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  348. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  349. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  350. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  351. { AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset },
  352. { AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset },
  353. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  354. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  355. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  356. #ifndef TXT_ONLY
  357. { AtCommand_Rehash, "@rehash", 99, atcommand_rehash }, // admin command
  358. #else /* TXT_ONLY */
  359. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  360. #endif /* TXT_ONLY */
  361. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  362. { AtCommand_CharReset, "@charreset", 60, atcommand_charreset },
  363. { AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel },
  364. { AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint },
  365. { AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint },
  366. { AtCommand_CharZeny, "@charzeny", 60, atcommand_charzeny },
  367. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  368. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  369. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  370. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  371. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  372. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  373. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  374. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  375. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  376. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  377. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  378. { AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex }, // by Yor
  379. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  380. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  381. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  382. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  383. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  384. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  385. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  386. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  387. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  388. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  389. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  390. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  391. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  392. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  393. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  394. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  395. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  396. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  397. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  398. // { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  399. { AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc }, // []
  400. { AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // []
  401. { AtCommand_ServerTime, "@time", 0, atcommand_servertime }, // by Yor
  402. { AtCommand_ServerTime, "@date", 0, atcommand_servertime }, // by Yor
  403. { AtCommand_ServerTime, "@server_date", 0, atcommand_servertime }, // by Yor
  404. { AtCommand_ServerTime, "@serverdate", 0, atcommand_servertime }, // by Yor
  405. { AtCommand_ServerTime, "@server_time", 0, atcommand_servertime }, // by Yor
  406. { AtCommand_ServerTime, "@servertime", 0, atcommand_servertime }, // by Yor
  407. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  408. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  409. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  410. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  411. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  412. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  413. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  414. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  415. { AtCommand_EMail, "@email", 0, atcommand_email }, // by Yor
  416. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  417. { AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list }, // by Yor
  418. { AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list }, // by Yor
  419. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  420. { AtCommand_Follow, "@follow", 10, atcommand_follow }, // by MouseJstr
  421. { AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp }, // by MouseJstr
  422. { AtCommand_SkillOn, "@skillon", 20, atcommand_skillon }, // by MouseJstr
  423. { AtCommand_SkillOff, "@skilloff", 20, atcommand_skilloff }, // by MouseJstr
  424. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  425. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  426. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  427. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  428. { AtCommand_Chareffect, "@chareffect", 40, atcommand_chareffect }, // MouseJstr
  429. /*
  430. { AtCommand_Chardye, "@chardye", 40, atcommand_chardye }, // MouseJstr
  431. { AtCommand_Charhairstyle, "@charhairstyle", 40, atcommand_charhairstyle }, // MouseJstr
  432. { AtCommand_Charhaircolor, "@charhaircolor", 40, atcommand_charhaircolor }, // MouseJstr
  433. */
  434. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  435. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  436. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  437. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  438. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  439. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  440. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  441. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  442. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  443. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  444. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  445. /*
  446. { AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle },
  447. { AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance },
  448. { AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect },
  449. */
  450. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  451. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  452. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  453. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  454. { AtCommand_Send, "@send", 60, atcommand_send },
  455. { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag },
  456. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  457. { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri
  458. { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri
  459. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  460. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  461. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  462. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy",40, atcommand_happyhappyjoyjoy }, // [Valaris]
  463. { AtCommand_Refresh, "@refresh", 0, atcommand_refresh }, // by MC Cameri
  464. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  465. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  466. { AtCommand_Gmotd, "@gmotd", 0, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  467. #ifndef TXT_ONLY // sql-only commands
  468. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  469. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  470. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  471. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  472. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  473. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  474. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  475. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  476. #endif /* TXT_ONLY */
  477. // add new commands before this line
  478. { AtCommand_Unknown, NULL, 1, NULL }
  479. };
  480. /*====================================================
  481. * This function return the name of the job (by [Yor])
  482. *----------------------------------------------------
  483. */
  484. char * job_name(int class) {
  485. switch (class) {
  486. case 0: return "Novice";
  487. case 1: return "Swordsman";
  488. case 2: return "Mage";
  489. case 3: return "Archer";
  490. case 4: return "Acolyte";
  491. case 5: return "Merchant";
  492. case 6: return "Thief";
  493. case 7: return "Knight";
  494. case 8: return "Priest";
  495. case 9: return "Wizard";
  496. case 10: return "Blacksmith";
  497. case 11: return "Hunter";
  498. case 12: return "Assassin";
  499. case 13: return "Knight 2";
  500. case 14: return "Crusader";
  501. case 15: return "Monk";
  502. case 16: return "Sage";
  503. case 17: return "Rogue";
  504. case 18: return "Alchemist";
  505. case 19: return "Bard";
  506. case 20: return "Dancer";
  507. case 21: return "Crusader 2";
  508. case 22: return "Wedding";
  509. case 23: return "Super Novice";
  510. case 4001: return "Novice High";
  511. case 4002: return "Swordsman High";
  512. case 4003: return "Mage High";
  513. case 4004: return "Archer High";
  514. case 4005: return "Acolyte High";
  515. case 4006: return "Merchant High";
  516. case 4007: return "Thief High";
  517. case 4008: return "Lord Knight";
  518. case 4009: return "High Priest";
  519. case 4010: return "High Wizard";
  520. case 4011: return "Whitesmith";
  521. case 4012: return "Sniper";
  522. case 4013: return "Assassin Cross";
  523. case 4014: return "Peko Knight";
  524. case 4015: return "Paladin";
  525. case 4016: return "Champion";
  526. case 4017: return "Professor";
  527. case 4018: return "Stalker";
  528. case 4019: return "Creator";
  529. case 4020: return "Clown";
  530. case 4021: return "Gypsy";
  531. case 4022: return "Peko Paladin";
  532. case 4023: return "Baby Novice";
  533. case 4024: return "Baby Swordsman";
  534. case 4025: return "Baby Mage";
  535. case 4026: return "Baby Archer";
  536. case 4027: return "Baby Acolyte";
  537. case 4028: return "Baby Merchant";
  538. case 4029: return "Baby Thief";
  539. case 4030: return "Baby Knight";
  540. case 4031: return "Baby Priest";
  541. case 4032: return "Baby Wizard";
  542. case 4033: return "Baby Blacksmith";
  543. case 4034: return "Baby Hunter";
  544. case 4035: return "Baby Assassin";
  545. case 4036: return "Baby Peco Knight";
  546. case 4037: return "Baby Crusader";
  547. case 4038: return "Baby Monk";
  548. case 4039: return "Baby Sage";
  549. case 4040: return "Baby Rogue";
  550. case 4041: return "Baby Alchemist";
  551. case 4042: return "Baby Bard";
  552. case 4043: return "Baby Dancer";
  553. case 4044: return "Baby Peco Crusader";
  554. case 4045: return "Super Baby";
  555. }
  556. return "Unknown Job";
  557. }
  558. /*==========================================
  559. * str_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  560. *------------------------------------------
  561. */
  562. char *str_lower(char *str)
  563. {
  564. int i;
  565. for (i=0; str[i]; i++)
  566. if ((str[i] >= 65) && (str[i] <= 90))
  567. str[i] += 32;
  568. return str;
  569. }
  570. // compare function for sorting high to lowest
  571. int hightolow_compare (const void * a, const void * b)
  572. {
  573. return ( *(int*)b - *(int*)a );
  574. }
  575. // compare function for sorting lowest to highest
  576. int lowtohigh_compare (const void * a, const void * b)
  577. {
  578. return ( *(int*)a - *(int*)b );
  579. }
  580. //-----------------------------------------------------------
  581. // Return the message string of the specified number by [Yor]
  582. //-----------------------------------------------------------
  583. char * msg_txt(int msg_number) {
  584. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])) &&
  585. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  586. return msg_table[msg_number];
  587. return "??";
  588. }
  589. //------------------------------------------------------------
  590. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  591. //------------------------------------------------------------
  592. int e_mail_check(unsigned char *email) {
  593. char ch;
  594. unsigned char* last_arobas;
  595. // athena limits
  596. if (strlen(email) < 3 || strlen(email) > 39)
  597. return 0;
  598. // part of RFC limits (official reference of e-mail description)
  599. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  600. return 0;
  601. if (email[strlen(email)-1] == '.')
  602. return 0;
  603. last_arobas = strrchr(email, '@');
  604. if (strstr(last_arobas, "@.") != NULL ||
  605. strstr(last_arobas, "..") != NULL)
  606. return 0;
  607. for(ch = 1; ch < 32; ch++) {
  608. if (strchr(last_arobas, ch) != NULL) {
  609. return 0;
  610. break;
  611. }
  612. }
  613. if (strchr(last_arobas, ' ') != NULL ||
  614. strchr(last_arobas, ';') != NULL)
  615. return 0;
  616. // all correct
  617. return 1;
  618. }
  619. /*==========================================
  620. * get_atcommand_level @コマンドの必要レベルを取得
  621. *------------------------------------------
  622. */
  623. int get_atcommand_level(const AtCommandType type) {
  624. int i;
  625. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  626. if (atcommand_info[i].type == type)
  627. return atcommand_info[i].level;
  628. return 100; // 100: command can not be used
  629. }
  630. /*==========================================
  631. *is_atcommand @コマンドに存在するかどうか確認する
  632. *------------------------------------------
  633. */
  634. AtCommandType
  635. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  636. const char* str = message;
  637. int s_flag = 0;
  638. AtCommandInfo info;
  639. AtCommandType type;
  640. nullpo_retr(AtCommand_None, sd);
  641. if (!message || !*message)
  642. return AtCommand_None;
  643. memset(&info, 0, sizeof(info));
  644. str += strlen(sd->status.name);
  645. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  646. if (*str == ':')
  647. s_flag = 1;
  648. str++;
  649. }
  650. if (!*str)
  651. return AtCommand_None;
  652. type = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  653. if (type != AtCommand_None) {
  654. char command[100];
  655. char output[200];
  656. const char* p = str;
  657. memset(command, '\0', sizeof(command));
  658. memset(output, '\0', sizeof(output));
  659. while (*p && !isspace(*p))
  660. p++;
  661. if (p - str >= sizeof(command)) // too long
  662. return AtCommand_Unknown;
  663. strncpy(command, str, p - str);
  664. while (isspace(*p))
  665. p++;
  666. if (type == AtCommand_Unknown || info.proc == NULL) {
  667. sprintf(output, msg_table[153], command); // %s is Unknown Command.
  668. clif_displaymessage(fd, output);
  669. } else {
  670. if (info.proc(fd, sd, command, p) != 0) {
  671. // Command can not be executed
  672. sprintf(output, msg_table[154], command); // %s failed.
  673. clif_displaymessage(fd, output);
  674. }
  675. }
  676. // ToDo: Fix Logs :)
  677. //if((log_config.gm) && (info.level >= log_config.gm))
  678. // log_atcommand(sd, message);
  679. return info.type;
  680. }
  681. return AtCommand_None;
  682. }
  683. /*==========================================
  684. *
  685. *------------------------------------------
  686. */
  687. AtCommandType atcommand(const int level, const char* message, struct AtCommandInfo* info) {
  688. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  689. if (!info)
  690. return AtCommand_None;
  691. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  692. return AtCommand_None;
  693. if (!p || !*p) {
  694. fprintf(stderr, "at command message is empty\n");
  695. return AtCommand_None;
  696. }
  697. if (*p == command_symbol) { // check first char.
  698. char command[101];
  699. int i = 0;
  700. memset(info, 0, sizeof(AtCommandInfo));
  701. sscanf(p, "%100s", command);
  702. command[sizeof(command)-1] = '\0';
  703. while (atcommand_info[i].type != AtCommand_Unknown) {
  704. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  705. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  706. break;
  707. }
  708. i++;
  709. }
  710. if (atcommand_info[i].type == AtCommand_Unknown) {
  711. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  712. if (level == 0)
  713. return AtCommand_None;
  714. else
  715. return AtCommand_Unknown;
  716. }
  717. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  718. } else {
  719. return AtCommand_None;
  720. }
  721. return info->type;
  722. }
  723. /*==========================================
  724. *
  725. *------------------------------------------
  726. */
  727. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  728. int flag = va_arg(ap, int);
  729. nullpo_retr(0, bl);
  730. if (flag)
  731. mob_damage(NULL, (struct mob_data *)bl, ((struct mob_data *)bl)->hp, 2);
  732. else
  733. mob_delete((struct mob_data *)bl);
  734. return 0;
  735. }
  736. #ifndef TXT_ONLY
  737. static int atkillnpc_sub(struct block_list *bl, va_list ap)
  738. {
  739. int flag = va_arg(ap,int);
  740. nullpo_retr(0, bl);
  741. npc_delete((struct npc_data *)bl);
  742. flag = 0;
  743. return 0;
  744. }
  745. void rehash( const int fd, struct map_session_data* sd )
  746. {
  747. int map_id = 0;
  748. int LOADED_MAPS = map_num;
  749. for (map_id = 0; map_id < LOADED_MAPS;map_id++) {
  750. if (map_id > LOADED_MAPS)
  751. break;
  752. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, 0);
  753. map_foreachinarea(atkillnpc_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_NPC, 0);
  754. }
  755. }
  756. #endif /* not TXT_ONLY */
  757. /*==========================================
  758. * Read Message Data
  759. *------------------------------------------
  760. */
  761. int msg_config_read(const char *cfgName) {
  762. int msg_number;
  763. char line[1024], w1[1024], w2[1024];
  764. FILE *fp;
  765. if ((fp = fopen(cfgName, "r")) == NULL) {
  766. printf("Messages file not found: %s\n", cfgName);
  767. return 1;
  768. }
  769. while(fgets(line, sizeof(line)-1, fp)) {
  770. if (line[0] == '/' && line[1] == '/')
  771. continue;
  772. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  773. if (strcmpi(w1, "import") == 0) {
  774. msg_config_read(w2);
  775. } else {
  776. msg_number = atoi(w1);
  777. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])))
  778. strcpy(msg_table[msg_number], w2);
  779. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  780. }
  781. }
  782. }
  783. fclose(fp);
  784. return 0;
  785. }
  786. /*==========================================
  787. *
  788. *------------------------------------------
  789. */
  790. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  791. int i;
  792. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  793. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  794. return &atcommand_info[i];
  795. return NULL;
  796. }
  797. /*==========================================
  798. *
  799. *------------------------------------------
  800. */
  801. int atcommand_config_read(const char *cfgName) {
  802. char line[1024], w1[1024], w2[1024];
  803. AtCommandInfo* p;
  804. FILE* fp;
  805. if ((fp = fopen(cfgName, "r")) == NULL) {
  806. printf("At commands configuration file not found: %s\n", cfgName);
  807. return 1;
  808. }
  809. while (fgets(line, sizeof(line)-1, fp)) {
  810. if (line[0] == '/' && line[1] == '/')
  811. continue;
  812. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  813. continue;
  814. p = get_atcommandinfo_byname(w1);
  815. if (p != NULL) {
  816. p->level = atoi(w2);
  817. if (p->level > 100)
  818. p->level = 100;
  819. else if (p->level < 0)
  820. p->level = 0;
  821. }
  822. if (strcmpi(w1, "import") == 0)
  823. atcommand_config_read(w2);
  824. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  825. w2[0] != '/' && // symbol of standard ragnarok GM commands
  826. w2[0] != '%' && // symbol of party chat speaking
  827. w2[0] != '#') // symbol of charcommand
  828. command_symbol = w2[0];
  829. }
  830. fclose(fp);
  831. return 0;
  832. }
  833. /*==========================================
  834. // @ command processing functions
  835. *------------------------------------------
  836. */
  837. /*==========================================
  838. * @send (used for testing packet sends from the client)
  839. *------------------------------------------
  840. */
  841. int atcommand_send(
  842. const int fd, struct map_session_data* sd,
  843. const char* command, const char* message)
  844. {
  845. int a = atoi(message);
  846. if (a)
  847. {
  848. unsigned char buf[1024];
  849. switch(a)
  850. {
  851. case 1:
  852. WBUFW(buf,0)=0x18d;
  853. case 2:
  854. WBUFW(buf,0)=0x18e;
  855. case 3:
  856. WBUFW(buf,0)=0x18f;
  857. case 4:
  858. WBUFW(buf,0)=0x190;
  859. }
  860. }
  861. return 0;
  862. }
  863. /*==========================================
  864. * @rura+
  865. *------------------------------------------
  866. */
  867. int atcommand_rurap(
  868. const int fd, struct map_session_data* sd,
  869. const char* command, const char* message)
  870. {
  871. char map_name[100];
  872. char character[100];
  873. int x = 0, y = 0;
  874. struct map_session_data *pl_sd;
  875. int m;
  876. memset(map_name, '\0', sizeof(map_name));
  877. memset(character, '\0', sizeof(character));
  878. if (!message || !*message || sscanf(message, "%99s %d %d %99[^\n]", map_name, &x, &y, character) < 4) {
  879. clif_displaymessage(fd, "Usage: @charwarp/@rura+ <mapname> <x> <y> <char name>");
  880. return -1;
  881. }
  882. if (x <= 0)
  883. x = rand() % 399 + 1;
  884. if (y <= 0)
  885. y = rand() % 399 + 1;
  886. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  887. strcat(map_name, ".gat");
  888. if ((pl_sd = map_nick2sd(character)) != NULL) {
  889. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can rura+ only lower or same GM level
  890. if (x > 0 && x < 400 && y > 0 && y < 400) {
  891. m = map_mapname2mapid(map_name);
  892. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  893. clif_displaymessage(fd, "You are not authorised to warp someone to this map.");
  894. return -1;
  895. }
  896. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  897. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  898. return -1;
  899. }
  900. if (pc_setpos(pl_sd, map_name, x, y, 3) == 0) {
  901. clif_displaymessage(pl_sd->fd, msg_table[0]); // Warped.
  902. clif_displaymessage(fd, msg_table[15]); // Player warped (message sends to player too).
  903. } else {
  904. clif_displaymessage(fd, msg_table[1]); // Map not found.
  905. return -1;
  906. }
  907. } else {
  908. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  909. return -1;
  910. }
  911. } else {
  912. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  913. return -1;
  914. }
  915. } else {
  916. clif_displaymessage(fd, msg_table[3]); // Character not found.
  917. return -1;
  918. }
  919. return 0;
  920. }
  921. // @rura
  922. /*==========================================
  923. *
  924. *------------------------------------------
  925. */
  926. int atcommand_rura(
  927. const int fd, struct map_session_data* sd,
  928. const char* command, const char* message)
  929. {
  930. char map_name[100];
  931. int x = 0, y = 0;
  932. int m;
  933. memset(map_name, '\0', sizeof(map_name));
  934. if (!message || !*message || sscanf(message, "%99s %d %d", map_name, &x, &y) < 1) {
  935. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  936. return -1;
  937. }
  938. if (x <= 0)
  939. x = rand() % 399 + 1;
  940. if (y <= 0)
  941. y = rand() % 399 + 1;
  942. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  943. strcat(map_name, ".gat");
  944. if (x > 0 && x < 400 && y > 0 && y < 400) {
  945. m = map_mapname2mapid(map_name);
  946. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  947. clif_displaymessage(fd, "You are not authorised to warp you to this map.");
  948. return -1;
  949. }
  950. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  951. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  952. return -1;
  953. }
  954. if (pc_setpos(sd, map_name, x, y, 3) == 0)
  955. clif_displaymessage(fd, msg_table[0]); // Warped.
  956. else {
  957. clif_displaymessage(fd, msg_table[1]); // Map not found.
  958. return -1;
  959. }
  960. } else {
  961. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  962. return -1;
  963. }
  964. return 0;
  965. }
  966. /*==========================================
  967. *
  968. *------------------------------------------
  969. */
  970. int atcommand_where(
  971. const int fd, struct map_session_data* sd,
  972. const char* command, const char* message)
  973. {
  974. char character[100];
  975. char output[200];
  976. struct map_session_data *pl_sd = NULL;
  977. nullpo_retr(-1, sd);
  978. if (!message || !*message)
  979. return -1;
  980. memset(character, '\0', sizeof character);
  981. if (sscanf(message, "%99[^\n]", character) < 1)
  982. return -1;
  983. if(strncmp(sd->status.name,character,24)==0)
  984. return -1;
  985. if ((pl_sd = map_nick2sd(character)) == NULL) {
  986. snprintf(output, sizeof output, "%s %d %d",
  987. sd->mapname, sd->bl.x, sd->bl.y);
  988. clif_displaymessage(fd, output);
  989. return -1;
  990. }
  991. snprintf(output, sizeof output, "%s %s %d %d",
  992. character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  993. clif_displaymessage(fd, output);
  994. return 0;
  995. }
  996. /*==========================================
  997. *
  998. *------------------------------------------
  999. */
  1000. int atcommand_jumpto(
  1001. const int fd, struct map_session_data* sd,
  1002. const char* command, const char* message)
  1003. {
  1004. char character[100];
  1005. char output[200];
  1006. struct map_session_data *pl_sd = NULL;
  1007. nullpo_retr(-1, sd);
  1008. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1009. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1010. return -1;
  1011. }
  1012. memset(character, '\0', sizeof character);
  1013. if (sscanf(message, "%99[^\n]", character) < 1)
  1014. return -1;
  1015. if(strncmp(sd->status.name,character,24)==0) //Yourself mate? Tsk tsk tsk.
  1016. return -1;
  1017. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1018. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1019. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  1020. return -1;
  1021. }
  1022. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1023. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1024. return -1;
  1025. }
  1026. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  1027. sprintf(output, msg_table[4], character); // Jump to %s
  1028. clif_displaymessage(fd, output);
  1029. } else {
  1030. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1031. return -1;
  1032. }
  1033. return 0;
  1034. }
  1035. /*==========================================
  1036. *
  1037. *------------------------------------------
  1038. */
  1039. int atcommand_jump(
  1040. const int fd, struct map_session_data* sd,
  1041. const char* command, const char* message)
  1042. {
  1043. char output[200];
  1044. int x = 0, y = 0;
  1045. memset(output, '\0', sizeof(output));
  1046. sscanf(message, "%d %d", &x, &y);
  1047. if (x <= 0)
  1048. x = rand() % 399 + 1;
  1049. if (y <= 0)
  1050. y = rand() % 399 + 1;
  1051. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1052. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1053. clif_displaymessage(fd, "You are not authorised to warp you to your actual map.");
  1054. return -1;
  1055. }
  1056. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1057. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1058. return -1;
  1059. }
  1060. pc_setpos(sd, sd->mapname, x, y, 3);
  1061. sprintf(output, msg_table[5], x, y); // Jump to %d %d
  1062. clif_displaymessage(fd, output);
  1063. } else {
  1064. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1065. return -1;
  1066. }
  1067. return 0;
  1068. }
  1069. /*==========================================
  1070. *
  1071. *------------------------------------------
  1072. */
  1073. int atcommand_who(
  1074. const int fd, struct map_session_data* sd,
  1075. const char* command, const char* message)
  1076. {
  1077. char output[200];
  1078. struct map_session_data *pl_sd;
  1079. int i, j, count;
  1080. int pl_GM_level, GM_level;
  1081. char match_text[100];
  1082. char player_name[24];
  1083. memset(output, '\0', sizeof(output));
  1084. memset(match_text, '\0', sizeof(match_text));
  1085. memset(player_name, '\0', sizeof(player_name));
  1086. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1087. strcpy(match_text, "");
  1088. for (j = 0; match_text[j]; j++)
  1089. match_text[j] = tolower(match_text[j]);
  1090. count = 0;
  1091. GM_level = pc_isGM(sd);
  1092. for (i = 0; i < fd_max; i++) {
  1093. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1094. pl_GM_level = pc_isGM(pl_sd);
  1095. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1096. memcpy(player_name, pl_sd->status.name, 24);
  1097. for (j = 0; player_name[j]; j++)
  1098. player_name[j] = tolower(player_name[j]);
  1099. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1100. if (pl_GM_level > 0)
  1101. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1102. else
  1103. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1104. clif_displaymessage(fd, output);
  1105. count++;
  1106. }
  1107. }
  1108. }
  1109. }
  1110. if (count == 0)
  1111. clif_displaymessage(fd, msg_table[28]); // No player found.
  1112. else if (count == 1)
  1113. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1114. else {
  1115. sprintf(output, msg_table[30], count); // %d players found.
  1116. clif_displaymessage(fd, output);
  1117. }
  1118. return 0;
  1119. }
  1120. /*==========================================
  1121. *
  1122. *------------------------------------------
  1123. */
  1124. int atcommand_who2(
  1125. const int fd, struct map_session_data* sd,
  1126. const char* command, const char* message)
  1127. {
  1128. char output[200];
  1129. struct map_session_data *pl_sd;
  1130. int i, j, count;
  1131. int pl_GM_level, GM_level;
  1132. char match_text[100];
  1133. char player_name[24];
  1134. memset(output, '\0', sizeof(output));
  1135. memset(match_text, '\0', sizeof(match_text));
  1136. memset(player_name, '\0', sizeof(player_name));
  1137. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1138. strcpy(match_text, "");
  1139. for (j = 0; match_text[j]; j++)
  1140. match_text[j] = tolower(match_text[j]);
  1141. count = 0;
  1142. GM_level = pc_isGM(sd);
  1143. for (i = 0; i < fd_max; i++) {
  1144. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1145. pl_GM_level = pc_isGM(pl_sd);
  1146. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1147. memcpy(player_name, pl_sd->status.name, 24);
  1148. for (j = 0; player_name[j]; j++)
  1149. player_name[j] = tolower(player_name[j]);
  1150. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1151. if (pl_GM_level > 0)
  1152. sprintf(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);
  1153. else
  1154. sprintf(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);
  1155. clif_displaymessage(fd, output);
  1156. count++;
  1157. }
  1158. }
  1159. }
  1160. }
  1161. if (count == 0)
  1162. clif_displaymessage(fd, msg_table[28]); // No player found.
  1163. else if (count == 1)
  1164. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1165. else {
  1166. sprintf(output, msg_table[30], count); // %d players found.
  1167. clif_displaymessage(fd, output);
  1168. }
  1169. return 0;
  1170. }
  1171. /*==========================================
  1172. *
  1173. *------------------------------------------
  1174. */
  1175. int atcommand_who3(
  1176. const int fd, struct map_session_data* sd,
  1177. const char* command, const char* message)
  1178. {
  1179. char temp0[100];
  1180. char temp1[100];
  1181. char output[200];
  1182. struct map_session_data *pl_sd;
  1183. int i, j, count;
  1184. int pl_GM_level, GM_level;
  1185. char match_text[100];
  1186. char player_name[24];
  1187. struct guild *g;
  1188. struct party *p;
  1189. memset(temp0, '\0', sizeof(temp0));
  1190. memset(temp1, '\0', sizeof(temp1));
  1191. memset(output, '\0', sizeof(output));
  1192. memset(match_text, '\0', sizeof(match_text));
  1193. memset(player_name, '\0', sizeof(player_name));
  1194. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1195. strcpy(match_text, "");
  1196. for (j = 0; match_text[j]; j++)
  1197. match_text[j] = tolower(match_text[j]);
  1198. count = 0;
  1199. GM_level = pc_isGM(sd);
  1200. for (i = 0; i < fd_max; i++) {
  1201. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1202. pl_GM_level = pc_isGM(pl_sd);
  1203. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1204. memcpy(player_name, pl_sd->status.name, 24);
  1205. for (j = 0; player_name[j]; j++)
  1206. player_name[j] = tolower(player_name[j]);
  1207. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1208. g = guild_search(pl_sd->status.guild_id);
  1209. if (g == NULL)
  1210. sprintf(temp1, "None");
  1211. else
  1212. sprintf(temp1, "%s", g->name);
  1213. p = party_search(pl_sd->status.party_id);
  1214. if (p == NULL)
  1215. sprintf(temp0, "None");
  1216. else
  1217. sprintf(temp0, "%s", p->name);
  1218. if (pl_GM_level > 0)
  1219. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1220. else
  1221. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1222. clif_displaymessage(fd, output);
  1223. count++;
  1224. }
  1225. }
  1226. }
  1227. }
  1228. if (count == 0)
  1229. clif_displaymessage(fd, msg_table[28]); // No player found.
  1230. else if (count == 1)
  1231. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1232. else {
  1233. sprintf(output, msg_table[30], count); // %d players found.
  1234. clif_displaymessage(fd, output);
  1235. }
  1236. return 0;
  1237. }
  1238. /*==========================================
  1239. *
  1240. *------------------------------------------
  1241. */
  1242. int atcommand_whomap(
  1243. const int fd, struct map_session_data* sd,
  1244. const char* command, const char* message)
  1245. {
  1246. char output[200];
  1247. struct map_session_data *pl_sd;
  1248. int i, count;
  1249. int pl_GM_level, GM_level;
  1250. int map_id;
  1251. char map_name[100];
  1252. memset(output, '\0', sizeof(output));
  1253. memset(map_name, '\0', sizeof(map_name));
  1254. if (!message || !*message)
  1255. map_id = sd->bl.m;
  1256. else {
  1257. sscanf(message, "%99s", map_name);
  1258. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1259. strcat(map_name, ".gat");
  1260. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1261. map_id = sd->bl.m;
  1262. }
  1263. count = 0;
  1264. GM_level = pc_isGM(sd);
  1265. for (i = 0; i < fd_max; i++) {
  1266. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1267. pl_GM_level = pc_isGM(pl_sd);
  1268. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1269. if (pl_sd->bl.m == map_id) {
  1270. if (pl_GM_level > 0)
  1271. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1272. else
  1273. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1274. clif_displaymessage(fd, output);
  1275. count++;
  1276. }
  1277. }
  1278. }
  1279. }
  1280. if (count == 0)
  1281. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1282. else if (count == 1)
  1283. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1284. else {
  1285. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1286. }
  1287. clif_displaymessage(fd, output);
  1288. return 0;
  1289. }
  1290. /*==========================================
  1291. *
  1292. *------------------------------------------
  1293. */
  1294. int atcommand_whomap2(
  1295. const int fd, struct map_session_data* sd,
  1296. const char* command, const char* message)
  1297. {
  1298. char output[200];
  1299. struct map_session_data *pl_sd;
  1300. int i, count;
  1301. int pl_GM_level, GM_level;
  1302. int map_id = 0;
  1303. char map_name[100];
  1304. memset(output, '\0', sizeof(output));
  1305. memset(map_name, '\0', sizeof(map_name));
  1306. if (!message || !*message)
  1307. map_id = sd->bl.m;
  1308. else {
  1309. sscanf(message, "%99s", map_name);
  1310. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1311. strcat(map_name, ".gat");
  1312. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1313. map_id = sd->bl.m;
  1314. }
  1315. count = 0;
  1316. GM_level = pc_isGM(sd);
  1317. for (i = 0; i < fd_max; i++) {
  1318. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1319. pl_GM_level = pc_isGM(pl_sd);
  1320. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1321. if (pl_sd->bl.m == map_id) {
  1322. if (pl_GM_level > 0)
  1323. sprintf(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);
  1324. else
  1325. sprintf(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);
  1326. clif_displaymessage(fd, output);
  1327. count++;
  1328. }
  1329. }
  1330. }
  1331. }
  1332. if (count == 0)
  1333. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1334. else if (count == 1)
  1335. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1336. else {
  1337. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1338. }
  1339. clif_displaymessage(fd, output);
  1340. return 0;
  1341. }
  1342. /*==========================================
  1343. *
  1344. *------------------------------------------
  1345. */
  1346. int atcommand_whomap3(
  1347. const int fd, struct map_session_data* sd,
  1348. const char* command, const char* message)
  1349. {
  1350. char temp0[100];
  1351. char temp1[100];
  1352. char output[200];
  1353. struct map_session_data *pl_sd;
  1354. int i, count;
  1355. int pl_GM_level, GM_level;
  1356. int map_id = 0;
  1357. char map_name[100];
  1358. struct guild *g;
  1359. struct party *p;
  1360. memset(temp0, '\0', sizeof(temp0));
  1361. memset(temp1, '\0', sizeof(temp1));
  1362. memset(output, '\0', sizeof(output));
  1363. memset(map_name, '\0', sizeof(map_name));
  1364. if (!message || !*message)
  1365. map_id = sd->bl.m;
  1366. else {
  1367. sscanf(message, "%99s", map_name);
  1368. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1369. strcat(map_name, ".gat");
  1370. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1371. map_id = sd->bl.m;
  1372. }
  1373. count = 0;
  1374. GM_level = pc_isGM(sd);
  1375. for (i = 0; i < fd_max; i++) {
  1376. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1377. pl_GM_level = pc_isGM(pl_sd);
  1378. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1379. if (pl_sd->bl.m == map_id) {
  1380. g = guild_search(pl_sd->status.guild_id);
  1381. if (g == NULL)
  1382. sprintf(temp1, "None");
  1383. else
  1384. sprintf(temp1, "%s", g->name);
  1385. p = party_search(pl_sd->status.party_id);
  1386. if (p == NULL)
  1387. sprintf(temp0, "None");
  1388. else
  1389. sprintf(temp0, "%s", p->name);
  1390. if (pl_GM_level > 0)
  1391. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1392. else
  1393. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1394. clif_displaymessage(fd, output);
  1395. count++;
  1396. }
  1397. }
  1398. }
  1399. }
  1400. if (count == 0)
  1401. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1402. else if (count == 1)
  1403. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1404. else {
  1405. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1406. }
  1407. clif_displaymessage(fd, output);
  1408. return 0;
  1409. }
  1410. /*==========================================
  1411. *
  1412. *------------------------------------------
  1413. */
  1414. int atcommand_whogm(
  1415. const int fd, struct map_session_data* sd,
  1416. const char* command, const char* message)
  1417. {
  1418. char temp0[100];
  1419. char temp1[100];
  1420. char output[200];
  1421. struct map_session_data *pl_sd;
  1422. int i, j, count;
  1423. int pl_GM_level, GM_level;
  1424. char match_text[100];
  1425. char player_name[24];
  1426. struct guild *g;
  1427. struct party *p;
  1428. memset(temp0, '\0', sizeof(temp0));
  1429. memset(temp1, '\0', sizeof(temp1));
  1430. memset(output, '\0', sizeof(output));
  1431. memset(match_text, '\0', sizeof(match_text));
  1432. memset(player_name, '\0', sizeof(player_name));
  1433. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1434. strcpy(match_text, "");
  1435. for (j = 0; match_text[j]; j++)
  1436. match_text[j] = tolower(match_text[j]);
  1437. count = 0;
  1438. GM_level = pc_isGM(sd);
  1439. for (i = 0; i < fd_max; i++) {
  1440. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1441. pl_GM_level = pc_isGM(pl_sd);
  1442. if (pl_GM_level > 0) {
  1443. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1444. memcpy(player_name, pl_sd->status.name, 24);
  1445. for (j = 0; player_name[j]; j++)
  1446. player_name[j] = tolower(player_name[j]);
  1447. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1448. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1449. clif_displaymessage(fd, output);
  1450. sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level);
  1451. clif_displaymessage(fd, output);
  1452. g = guild_search(pl_sd->status.guild_id);
  1453. if (g == NULL)
  1454. sprintf(temp1, "None");
  1455. else
  1456. sprintf(temp1, "%s", g->name);
  1457. p = party_search(pl_sd->status.party_id);
  1458. if (p == NULL)
  1459. sprintf(temp0, "None");
  1460. else
  1461. sprintf(temp0, "%s", p->name);
  1462. sprintf(output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1463. clif_displaymessage(fd, output);
  1464. count++;
  1465. }
  1466. }
  1467. }
  1468. }
  1469. }
  1470. if (count == 0)
  1471. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1472. else if (count == 1)
  1473. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1474. else {
  1475. sprintf(output, msg_table[152], count); // %d GMs found.
  1476. clif_displaymessage(fd, output);
  1477. }
  1478. return 0;
  1479. }
  1480. int atcommand_whozeny(
  1481. const int fd, struct map_session_data* sd,
  1482. const char* command, const char* message)
  1483. {
  1484. char output[200];
  1485. struct map_session_data *pl_sd;
  1486. int i, j, count,c;
  1487. char match_text[100];
  1488. char player_name[24];
  1489. int zeny[clif_countusers()];
  1490. char counted[clif_countusers()];
  1491. memset(output, '\0', sizeof(output));
  1492. memset(match_text, '\0', sizeof(match_text));
  1493. memset(player_name, '\0', sizeof(player_name));
  1494. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1495. strcpy(match_text, "");
  1496. for (j = 0; match_text[j]; j++)
  1497. match_text[j] = tolower(match_text[j]);
  1498. count = 0;
  1499. for (i = 0; i < fd_max; i++) {
  1500. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1501. memcpy(player_name, pl_sd->status.name, 24);
  1502. for (j = 0; player_name[j]; j++)
  1503. player_name[j] = tolower(player_name[j]);
  1504. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1505. zeny[count]=pl_sd->status.zeny;
  1506. count++;
  1507. }
  1508. }
  1509. }
  1510. qsort(zeny, count, sizeof(int), hightolow_compare);
  1511. for (c = 0; c < count && c < 50; c++) {
  1512. if(!zeny[c])
  1513. continue;
  1514. for (i = 0; i < fd_max; i++) {
  1515. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !counted[i] && zeny[c]) {
  1516. if(pl_sd->status.zeny==zeny[c]) {
  1517. sprintf(output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1518. clif_displaymessage(fd, output);
  1519. zeny[c]=0;
  1520. counted[i]=1;
  1521. }
  1522. }
  1523. }
  1524. }
  1525. if (count == 0)
  1526. clif_displaymessage(fd, msg_table[28]); // No player found.
  1527. else if (count == 1)
  1528. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1529. else {
  1530. sprintf(output, msg_table[30], count); // %d players found.
  1531. clif_displaymessage(fd, output);
  1532. }
  1533. return 0;
  1534. }
  1535. // cause random emote on all online players [Valaris]
  1536. int atcommand_happyhappyjoyjoy(
  1537. const int fd, struct map_session_data* sd,
  1538. const char* command, const char* message)
  1539. {
  1540. struct map_session_data *pl_sd;
  1541. int i,e;
  1542. for (i = 0; i < fd_max; i++) {
  1543. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1544. e=rand()%40;
  1545. if(e==34)
  1546. e = 0;
  1547. clif_emotion(&pl_sd->bl,e);
  1548. }
  1549. }
  1550. return 0;
  1551. }
  1552. /*==========================================
  1553. *
  1554. *------------------------------------------
  1555. */
  1556. int atcommand_save(
  1557. const int fd, struct map_session_data* sd,
  1558. const char* command, const char* message)
  1559. {
  1560. pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y);
  1561. if (sd->status.pet_id > 0 && sd->pd)
  1562. intif_save_petdata(sd->status.account_id, &sd->pet);
  1563. pc_makesavestatus(sd);
  1564. chrif_save(sd);
  1565. storage_storage_save(sd);
  1566. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1567. return 0;
  1568. }
  1569. /*==========================================
  1570. *
  1571. *------------------------------------------
  1572. */
  1573. int atcommand_load(
  1574. const int fd, struct map_session_data* sd,
  1575. const char* command, const char* message)
  1576. {
  1577. int m;
  1578. m = map_mapname2mapid(sd->status.save_point.map);
  1579. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1580. clif_displaymessage(fd, "You are not authorised to warp you to your save map.");
  1581. return -1;
  1582. }
  1583. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1584. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1585. return -1;
  1586. }
  1587. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1588. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1589. return 0;
  1590. }
  1591. /*==========================================
  1592. *
  1593. *------------------------------------------
  1594. */
  1595. int atcommand_speed(
  1596. const int fd, struct map_session_data* sd,
  1597. const char* command, const char* message)
  1598. {
  1599. char output[200];
  1600. int speed;
  1601. memset(output, '\0', sizeof(output));
  1602. if (!message || !*message) {
  1603. sprintf(output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1604. clif_displaymessage(fd, output);
  1605. return -1;
  1606. }
  1607. speed = atoi(message);
  1608. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1609. sd->speed = speed;
  1610. //sd->walktimer = x;
  1611. //この文を追加 by れ�
  1612. clif_updatestatus(sd, SP_SPEED);
  1613. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1614. } else {
  1615. sprintf(output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1616. clif_displaymessage(fd, output);
  1617. return -1;
  1618. }
  1619. return 0;
  1620. }
  1621. /*==========================================
  1622. *
  1623. *------------------------------------------
  1624. */
  1625. int atcommand_storage(
  1626. const int fd, struct map_session_data* sd,
  1627. const char* command, const char* message)
  1628. {
  1629. storage_storageopen(sd);
  1630. return 0;
  1631. }
  1632. /*==========================================
  1633. *
  1634. *------------------------------------------
  1635. */
  1636. int atcommand_guildstorage(
  1637. const int fd, struct map_session_data* sd,
  1638. const char* command, const char* message)
  1639. {
  1640. if (sd->status.guild_id > 0)
  1641. storage_guild_storageopen(sd);
  1642. return 0;
  1643. }
  1644. /*==========================================
  1645. *
  1646. *------------------------------------------
  1647. */
  1648. int atcommand_option(
  1649. const int fd, struct map_session_data* sd,
  1650. const char* command, const char* message)
  1651. {
  1652. int param1 = 0, param2 = 0, param3 = 0;
  1653. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1654. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1655. return -1;
  1656. }
  1657. sd->opt1 = param1;
  1658. sd->opt2 = param2;
  1659. if (!(sd->status.option & CART_MASK) && param3 & CART_MASK) {
  1660. clif_cart_itemlist(sd);
  1661. clif_cart_equiplist(sd);
  1662. clif_updatestatus(sd, SP_CARTINFO);
  1663. }
  1664. sd->status.option = param3;
  1665. // fix pecopeco display
  1666. if (sd->status.class == 13 || sd->status.class == 21 || sd->status.class == 4014 || sd->status.class == 4022) {
  1667. if (!pc_isriding(sd)) { // sd have the new value...
  1668. if (sd->status.class == 13)
  1669. sd->status.class = sd->view_class = 7;
  1670. else if (sd->status.class == 21)
  1671. sd->status.class = sd->view_class = 14;
  1672. else if (sd->status.class == 4014)
  1673. sd->status.class = sd->view_class = 4008;
  1674. else if (sd->status.class == 4022)
  1675. sd->status.class = sd->view_class = 4015;
  1676. }
  1677. } else {
  1678. if (pc_isriding(sd)) { // sd have the new value...
  1679. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  1680. sd->status.option &= ~0x0020;
  1681. } else {
  1682. if (sd->status.class == 7)
  1683. sd->status.class = sd->view_class = 13;
  1684. else if (sd->status.class == 14)
  1685. sd->status.class = sd->view_class = 21;
  1686. else if (sd->status.class == 4008)
  1687. sd->status.class = sd->view_class = 4014;
  1688. else if (sd->status.class == 4015)
  1689. sd->status.class = sd->view_class = 4022;
  1690. else
  1691. sd->status.option &= ~0x0020;
  1692. }
  1693. }
  1694. }
  1695. clif_changeoption(&sd->bl);
  1696. pc_calcstatus(sd, 0);
  1697. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1698. return 0;
  1699. }
  1700. /*==========================================
  1701. *
  1702. *------------------------------------------
  1703. */
  1704. int atcommand_hide(
  1705. const int fd, struct map_session_data* sd,
  1706. const char* command, const char* message)
  1707. {
  1708. if (sd->status.option & OPTION_HIDE) {
  1709. sd->status.option &= ~OPTION_HIDE;
  1710. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1711. } else {
  1712. sd->status.option |= OPTION_HIDE;
  1713. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1714. }
  1715. clif_changeoption(&sd->bl);
  1716. return 0;
  1717. }
  1718. /*==========================================
  1719. * 転職する upperを指定すると転生や養子にもなれる
  1720. *------------------------------------------
  1721. */
  1722. int atcommand_jobchange(
  1723. const int fd, struct map_session_data* sd,
  1724. const char* command, const char* message)
  1725. {
  1726. int job = 0, upper = -1;
  1727. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1728. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  1729. return -1;
  1730. }
  1731. if (job == 37 ||job == 45)
  1732. return 0;
  1733. if ((job >= 0 && job < MAX_PC_CLASS)) {
  1734. // fix pecopeco display
  1735. if ((job != 13 && job != 21 && job != 4014 && job != 4022)) {
  1736. if (pc_isriding(sd)) {
  1737. if (sd->status.class == 13)
  1738. sd->status.class = sd->view_class = 7;
  1739. if (sd->status.class == 21)
  1740. sd->status.class = sd->view_class = 14;
  1741. if (sd->status.class == 4014)
  1742. sd->status.class = sd->view_class = 4008;
  1743. if (sd->status.class == 4022)
  1744. sd->status.class = sd->view_class = 4015;
  1745. sd->status.option &= ~0x0020;
  1746. clif_changeoption(&sd->bl);
  1747. pc_calcstatus(sd, 0);
  1748. }
  1749. } else {
  1750. if (!pc_isriding(sd)) {
  1751. if (job == 13)
  1752. job = 7;
  1753. if (job == 21)
  1754. job = 14;
  1755. if (job == 4014)
  1756. job = 4008;
  1757. if (job == 4022)
  1758. job = 4015;
  1759. }
  1760. }
  1761. if (pc_jobchange(sd, job, upper) == 0)
  1762. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  1763. else {
  1764. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  1765. return -1;
  1766. }
  1767. } else {
  1768. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  1769. return -1;
  1770. }
  1771. return 0;
  1772. }
  1773. /*==========================================
  1774. *
  1775. *------------------------------------------
  1776. */
  1777. int atcommand_die(
  1778. const int fd, struct map_session_data* sd,
  1779. const char* command, const char* message)
  1780. {
  1781. pc_damage(NULL, sd, sd->status.hp + 1);
  1782. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  1783. return 0;
  1784. }
  1785. /*==========================================
  1786. *
  1787. *------------------------------------------
  1788. */
  1789. int atcommand_kill(
  1790. const int fd, struct map_session_data* sd,
  1791. const char* command, const char* message)
  1792. {
  1793. char character[100];
  1794. struct map_session_data *pl_sd;
  1795. memset(character, '\0', sizeof(character));
  1796. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1797. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  1798. return -1;
  1799. }
  1800. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1801. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  1802. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  1803. clif_displaymessage(fd, msg_table[14]); // Character killed.
  1804. } else {
  1805. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1806. return -1;
  1807. }
  1808. } else {
  1809. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1810. return -1;
  1811. }
  1812. return 0;
  1813. }
  1814. /*==========================================
  1815. *
  1816. *------------------------------------------
  1817. */
  1818. int atcommand_alive(
  1819. const int fd, struct map_session_data* sd,
  1820. const char* command, const char* message)
  1821. {
  1822. if (pc_isdead(sd)) {
  1823. sd->status.hp = sd->status.max_hp;
  1824. sd->status.sp = sd->status.max_sp;
  1825. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1826. pc_setstand(sd);
  1827. if (battle_config.pc_invincible_time > 0)
  1828. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  1829. clif_updatestatus(sd, SP_HP);
  1830. clif_updatestatus(sd, SP_SP);
  1831. clif_resurrection(&sd->bl, 1);
  1832. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  1833. return 0;
  1834. }
  1835. return -1;
  1836. }
  1837. /*==========================================
  1838. *
  1839. *------------------------------------------
  1840. */
  1841. int atcommand_kami(
  1842. const int fd, struct map_session_data* sd,
  1843. const char* command, const char* message)
  1844. {
  1845. char output[200];
  1846. memset(output, '\0', sizeof(output));
  1847. if (!message || !*message) {
  1848. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1849. return -1;
  1850. }
  1851. sscanf(message, "%199[^\n]", output);
  1852. intif_GMmessage(output, strlen(output) + 1, (*(command + 5) == 'b') ? 0x10 : 0);
  1853. return 0;
  1854. }
  1855. /*==========================================
  1856. *
  1857. *------------------------------------------
  1858. */
  1859. int atcommand_heal(
  1860. const int fd, struct map_session_data* sd,
  1861. const char* command, const char* message)
  1862. {
  1863. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1864. sscanf(message, "%d %d", &hp, &sp);
  1865. if (hp == 0 && sp == 0) {
  1866. hp = sd->status.max_hp - sd->status.hp;
  1867. sp = sd->status.max_sp - sd->status.sp;
  1868. } else {
  1869. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  1870. hp = sd->status.max_hp - sd->status.hp;
  1871. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  1872. hp = 1 - sd->status.hp;
  1873. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  1874. sp = sd->status.max_sp - sd->status.sp;
  1875. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  1876. sp = 1 - sd->status.sp;
  1877. }
  1878. if (hp > 0) // display like heal
  1879. clif_heal(fd, SP_HP, hp);
  1880. else if (hp < 0) // display like damage
  1881. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  1882. if (sp > 0) // no display when we lost SP
  1883. clif_heal(fd, SP_SP, sp);
  1884. if (hp != 0 || sp != 0) {
  1885. pc_heal(sd, hp, sp);
  1886. if (hp >= 0 && sp >= 0)
  1887. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  1888. else
  1889. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  1890. } else {
  1891. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  1892. return -1;
  1893. }
  1894. return 0;
  1895. }
  1896. /*==========================================
  1897. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1898. *------------------------------------------
  1899. */
  1900. int atcommand_item(
  1901. const int fd, struct map_session_data* sd,
  1902. const char* command, const char* message)
  1903. {
  1904. char item_name[100];
  1905. int number = 0, item_id, flag;
  1906. struct item item_tmp;
  1907. struct item_data *item_data;
  1908. int get_count, i, pet_id;
  1909. memset(item_name, '\0', sizeof(item_name));
  1910. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  1911. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1912. return -1;
  1913. }
  1914. if (number <= 0)
  1915. number = 1;
  1916. item_id = 0;
  1917. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1918. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1919. item_id = item_data->nameid;
  1920. if (item_id >= 500) {
  1921. get_count = number;
  1922. // check pet egg
  1923. pet_id = search_petDB_index(item_id, PET_EGG);
  1924. if (item_data->type == 4 || item_data->type == 5 ||
  1925. item_data->type == 7 || item_data->type == 8) {
  1926. get_count = 1;
  1927. }
  1928. for (i = 0; i < number; i += get_count) {
  1929. // if pet egg
  1930. if (pet_id >= 0) {
  1931. sd->catch_target_class = pet_db[pet_id].class;
  1932. intif_create_pet(sd->status.account_id, sd->status.char_id,
  1933. pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
  1934. pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
  1935. 100, 0, 1, pet_db[pet_id].jname);
  1936. // if not pet egg
  1937. } else {
  1938. memset(&item_tmp, 0, sizeof(item_tmp));
  1939. item_tmp.nameid = item_id;
  1940. item_tmp.identify = 1;
  1941. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  1942. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  1943. }
  1944. }
  1945. clif_displaymessage(fd, msg_table[18]); // Item created.
  1946. } else {
  1947. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  1948. return -1;
  1949. }
  1950. return 0;
  1951. }
  1952. /*==========================================
  1953. *
  1954. *------------------------------------------
  1955. */
  1956. int atcommand_item2(
  1957. const int fd, struct map_session_data* sd,
  1958. const char* command, const char* message)
  1959. {
  1960. struct item item_tmp;
  1961. struct item_data *item_data;
  1962. char item_name[100];
  1963. int item_id, number = 0;
  1964. int identify = 0, refine = 0, attr = 0;
  1965. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1966. int flag;
  1967. int loop, get_count, i;
  1968. memset(item_name, '\0', sizeof(item_name));
  1969. if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
  1970. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1971. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1972. return -1;
  1973. }
  1974. if (number <= 0)
  1975. number = 1;
  1976. item_id = 0;
  1977. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1978. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1979. item_id = item_data->nameid;
  1980. if (item_id > 500) {
  1981. loop = 1;
  1982. get_count = number;
  1983. if (item_data->type == 4 || item_data->type == 5 ||
  1984. item_data->type == 7 || item_data->type == 8) {
  1985. loop = number;
  1986. get_count = 1;
  1987. if (item_data->type == 7) {
  1988. identify = 1;
  1989. refine = 0;
  1990. }
  1991. if (item_data->type == 8)
  1992. refine = 0;
  1993. if (refine > 10)
  1994. refine = 10;
  1995. } else {
  1996. identify = 1;
  1997. refine = attr = 0;
  1998. }
  1999. for (i = 0; i < loop; i++) {
  2000. memset(&item_tmp, 0, sizeof(item_tmp));
  2001. item_tmp.nameid = item_id;
  2002. item_tmp.identify = identify;
  2003. item_tmp.refine = refine;
  2004. item_tmp.attribute = attr;
  2005. item_tmp.card[0] = c1;
  2006. item_tmp.card[1] = c2;
  2007. item_tmp.card[2] = c3;
  2008. item_tmp.card[3] = c4;
  2009. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2010. clif_additem(sd, 0, 0, flag);
  2011. }
  2012. clif_displaymessage(fd, msg_table[18]); // Item created.
  2013. } else {
  2014. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2015. return -1;
  2016. }
  2017. return 0;
  2018. }
  2019. /*==========================================
  2020. *
  2021. *------------------------------------------
  2022. */
  2023. int atcommand_itemreset(
  2024. const int fd, struct map_session_data* sd,
  2025. const char* command, const char* message)
  2026. {
  2027. int i;
  2028. for (i = 0; i < MAX_INVENTORY; i++) {
  2029. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0)
  2030. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2031. }
  2032. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2033. return 0;
  2034. }
  2035. /*==========================================
  2036. *
  2037. *------------------------------------------
  2038. */
  2039. int atcommand_itemcheck(
  2040. const int fd, struct map_session_data* sd,
  2041. const char* command, const char* message)
  2042. {
  2043. pc_checkitem(sd);
  2044. return 0;
  2045. }
  2046. /*==========================================
  2047. *
  2048. *------------------------------------------
  2049. */
  2050. int atcommand_baselevelup(
  2051. const int fd, struct map_session_data* sd,
  2052. const char* command, const char* message)
  2053. {
  2054. int level, i;
  2055. if (!message || !*message || (level = atoi(message)) == 0) {
  2056. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2057. return -1;
  2058. }
  2059. if (level > 0) {
  2060. if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  2061. clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher.
  2062. return -1;
  2063. } // End Addition
  2064. if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
  2065. level = battle_config.maximum_level - sd->status.base_level;
  2066. for (i = 1; i <= level; i++)
  2067. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2068. sd->status.base_level += level;
  2069. clif_updatestatus(sd, SP_BASELEVEL);
  2070. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2071. clif_updatestatus(sd, SP_STATUSPOINT);
  2072. pc_calcstatus(sd, 0);
  2073. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2074. clif_misceffect(&sd->bl, 0);
  2075. clif_displaymessage(fd, msg_table[21]); // Base level raised.
  2076. } else {
  2077. if (sd->status.base_level == 1) {
  2078. clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower.
  2079. return -1;
  2080. }
  2081. if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow
  2082. level = 1 - sd->status.base_level;
  2083. if (sd->status.status_point > 0) {
  2084. for (i = 0; i > level; i--)
  2085. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2086. if (sd->status.status_point < 0)
  2087. sd->status.status_point = 0;
  2088. clif_updatestatus(sd, SP_STATUSPOINT);
  2089. } // to add: remove status points from stats
  2090. sd->status.base_level += level;
  2091. clif_updatestatus(sd, SP_BASELEVEL);
  2092. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2093. pc_calcstatus(sd, 0);
  2094. clif_displaymessage(fd, msg_table[22]); // Base level lowered.
  2095. }
  2096. return 0;
  2097. }
  2098. /*==========================================
  2099. *
  2100. *------------------------------------------
  2101. */
  2102. int atcommand_joblevelup(
  2103. const int fd, struct map_session_data* sd,
  2104. const char* command, const char* message)
  2105. {
  2106. int up_level = 50, level;
  2107. if (!message || !*message || (level = atoi(message)) == 0) {
  2108. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2109. return -1;
  2110. }
  2111. if (sd->status.class == 0 || sd->status.class == 4001)
  2112. up_level -= 40;
  2113. else if ((sd->status.class > 4007 && sd->status.class < 4024) || sd->status.class == 23)
  2114. up_level += 20;
  2115. if (level > 0) {
  2116. if (sd->status.job_level == up_level) {
  2117. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2118. return -1;
  2119. }
  2120. if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow
  2121. level = up_level - sd->status.job_level;
  2122. sd->status.job_level += level;
  2123. clif_updatestatus(sd, SP_JOBLEVEL);
  2124. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2125. sd->status.skill_point += level;
  2126. clif_updatestatus(sd, SP_SKILLPOINT);
  2127. pc_calcstatus(sd, 0);
  2128. clif_misceffect(&sd->bl, 1);
  2129. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2130. } else {
  2131. if (sd->status.job_level == 1) {
  2132. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2133. return -1;
  2134. }
  2135. if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow
  2136. level = 1 - sd->status.job_level;
  2137. sd->status.job_level += level;
  2138. clif_updatestatus(sd, SP_JOBLEVEL);
  2139. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2140. if (sd->status.skill_point > 0) {
  2141. sd->status.skill_point += level;
  2142. if (sd->status.skill_point < 0)
  2143. sd->status.skill_point = 0;
  2144. clif_updatestatus(sd, SP_SKILLPOINT);
  2145. } // to add: remove status points from skills
  2146. pc_calcstatus(sd, 0);
  2147. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2148. }
  2149. return 0;
  2150. }
  2151. /*==========================================
  2152. *
  2153. *------------------------------------------
  2154. */
  2155. int atcommand_help(
  2156. const int fd, struct map_session_data* sd,
  2157. const char* command, const char* message)
  2158. {
  2159. char buf[2048], w1[2048], w2[2048];
  2160. int i, gm_level;
  2161. FILE* fp;
  2162. memset(buf, '\0', sizeof(buf));
  2163. if ((fp = fopen(help_txt, "r")) != NULL) {
  2164. clif_displaymessage(fd, msg_table[26]); // Help commands:
  2165. gm_level = pc_isGM(sd);
  2166. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2167. if (buf[0] == '/' && buf[1] == '/')
  2168. continue;
  2169. for (i = 0; buf[i] != '\0'; i++) {
  2170. if (buf[i] == '\r' || buf[i] == '\n') {
  2171. buf[i] = '\0';
  2172. break;
  2173. }
  2174. }
  2175. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2176. clif_displaymessage(fd, buf);
  2177. else if (gm_level >= atoi(w1))
  2178. clif_displaymessage(fd, w2);
  2179. }
  2180. fclose(fp);
  2181. } else {
  2182. clif_displaymessage(fd, msg_table[27]); // File help.txt not found.
  2183. return -1;
  2184. }
  2185. return 0;
  2186. }
  2187. /*==========================================
  2188. *
  2189. *------------------------------------------
  2190. */
  2191. int atcommand_gm(
  2192. const int fd, struct map_session_data* sd,
  2193. const char* command, const char* message)
  2194. {
  2195. char password[100];
  2196. memset(password, '\0', sizeof(password));
  2197. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2198. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2199. return -1;
  2200. }
  2201. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  2202. clif_displaymessage(fd, msg_table[50]); // You already have some GM powers.
  2203. return -1;
  2204. } else
  2205. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2206. return 0;
  2207. }
  2208. /*==========================================
  2209. *
  2210. *------------------------------------------
  2211. */
  2212. int atcommand_pvpoff(
  2213. const int fd, struct map_session_data* sd,
  2214. const char* command, const char* message)
  2215. {
  2216. struct map_session_data *pl_sd;
  2217. int i;
  2218. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2219. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2220. return -1;
  2221. }
  2222. if (map[sd->bl.m].flag.pvp) {
  2223. map[sd->bl.m].flag.pvp = 0;
  2224. clif_send0199(sd->bl.m, 0);
  2225. for (i = 0; i < fd_max; i++) { //人数分ループ
  2226. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2227. if (sd->bl.m == pl_sd->bl.m) {
  2228. clif_pvpset(pl_sd, 0, 0, 2);
  2229. if (pl_sd->pvp_timer != -1) {
  2230. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2231. pl_sd->pvp_timer = -1;
  2232. }
  2233. }
  2234. }
  2235. }
  2236. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2237. } else {
  2238. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2239. return -1;
  2240. }
  2241. return 0;
  2242. }
  2243. /*==========================================
  2244. *
  2245. *------------------------------------------
  2246. */
  2247. int atcommand_pvpon(
  2248. const int fd, struct map_session_data* sd,
  2249. const char* command, const char* message)
  2250. {
  2251. struct map_session_data *pl_sd;
  2252. int i;
  2253. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2254. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2255. return -1;
  2256. }
  2257. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2258. map[sd->bl.m].flag.pvp = 1;
  2259. clif_send0199(sd->bl.m, 1);
  2260. for (i = 0; i < fd_max; i++) {
  2261. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2262. if (sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2263. pl_sd->pvp_timer = add_timer(gettick() + 200,
  2264. pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2265. pl_sd->pvp_rank = 0;
  2266. pl_sd->pvp_lastusers = 0;
  2267. pl_sd->pvp_point = 5;
  2268. }
  2269. }
  2270. }
  2271. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2272. } else {
  2273. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2274. return -1;
  2275. }
  2276. return 0;
  2277. }
  2278. /*==========================================
  2279. *
  2280. *------------------------------------------
  2281. */
  2282. int atcommand_gvgoff(
  2283. const int fd, struct map_session_data* sd,
  2284. const char* command, const char* message)
  2285. {
  2286. if (map[sd->bl.m].flag.gvg) {
  2287. map[sd->bl.m].flag.gvg = 0;
  2288. clif_send0199(sd->bl.m, 0);
  2289. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2290. } else {
  2291. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2292. return -1;
  2293. }
  2294. return 0;
  2295. }
  2296. /*==========================================
  2297. *
  2298. *------------------------------------------
  2299. */
  2300. int atcommand_gvgon(
  2301. const int fd, struct map_session_data* sd,
  2302. const char* command, const char* message)
  2303. {
  2304. if (!map[sd->bl.m].flag.gvg) {
  2305. map[sd->bl.m].flag.gvg = 1;
  2306. clif_send0199(sd->bl.m, 3);
  2307. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2308. } else {
  2309. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2310. return -1;
  2311. }
  2312. return 0;
  2313. }
  2314. /*==========================================
  2315. *
  2316. *------------------------------------------
  2317. */
  2318. int atcommand_model(
  2319. const int fd, struct map_session_data* sd,
  2320. const char* command, const char* message)
  2321. {
  2322. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2323. char output[200];
  2324. memset(output, '\0', sizeof(output));
  2325. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2326. sprintf(output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2327. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2328. clif_displaymessage(fd, output);
  2329. return -1;
  2330. }
  2331. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2332. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2333. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2334. //服の色変更
  2335. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2336. //服の色未実装職の判定
  2337. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2338. return -1;
  2339. } else {
  2340. pc_changelook(sd, LOOK_HAIR, hair_style);
  2341. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2342. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2343. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2344. }
  2345. } else {
  2346. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2347. return -1;
  2348. }
  2349. return 0;
  2350. }
  2351. /*==========================================
  2352. * @dye && @ccolor
  2353. *------------------------------------------
  2354. */
  2355. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2356. {
  2357. int cloth_color = 0;
  2358. char output[200];
  2359. memset(output, '\0', sizeof(output));
  2360. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2361. sprintf(output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2362. clif_displaymessage(fd, output);
  2363. return -1;
  2364. }
  2365. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2366. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2367. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2368. return -1;
  2369. } else {
  2370. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2371. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2372. }
  2373. } else {
  2374. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2375. return -1;
  2376. }
  2377. return 0;
  2378. }
  2379. /*==========================================
  2380. * @chardye by [MouseJstr]
  2381. *------------------------------------------
  2382. */
  2383. int
  2384. atcommand_chardye(const int fd, struct map_session_data* sd,
  2385. const char* command, const char* message)
  2386. {
  2387. return 0;
  2388. }
  2389. /*==========================================
  2390. * @hairstyle && @hstyle
  2391. *------------------------------------------
  2392. */
  2393. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2394. {
  2395. int hair_style = 0;
  2396. char output[200];
  2397. memset(output, '\0', sizeof(output));
  2398. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2399. sprintf(output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2400. clif_displaymessage(fd, output);
  2401. return -1;
  2402. }
  2403. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2404. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2405. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2406. return -1;
  2407. } else {
  2408. pc_changelook(sd, LOOK_HAIR, hair_style);
  2409. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2410. }
  2411. } else {
  2412. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2413. return -1;
  2414. }
  2415. return 0;
  2416. }
  2417. /*==========================================
  2418. * @charhairstyle by [MouseJstr]
  2419. *------------------------------------------
  2420. */
  2421. int
  2422. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2423. const char* command, const char* message)
  2424. {
  2425. return 0;
  2426. }
  2427. /*==========================================
  2428. * @haircolor && @hcolor
  2429. *------------------------------------------
  2430. */
  2431. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2432. {
  2433. int hair_color = 0;
  2434. char output[200];
  2435. memset(output, '\0', sizeof(output));
  2436. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2437. sprintf(output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2438. clif_displaymessage(fd, output);
  2439. return -1;
  2440. }
  2441. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2442. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2443. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2444. return -1;
  2445. } else {
  2446. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2447. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2448. }
  2449. } else {
  2450. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2451. return -1;
  2452. }
  2453. return 0;
  2454. }
  2455. /*==========================================
  2456. * @charhaircolor by [MouseJstr]
  2457. *------------------------------------------
  2458. */
  2459. int
  2460. atcommand_charhaircolor(const int fd, struct map_session_data* sd,
  2461. const char* command, const char* message)
  2462. {
  2463. return 0;
  2464. }
  2465. /*==========================================
  2466. * @go [city_number/city_name]: improved by [yor] to add city names and help
  2467. *------------------------------------------
  2468. */
  2469. int atcommand_go(
  2470. const int fd, struct map_session_data* sd,
  2471. const char* command, const char* message)
  2472. {
  2473. int i;
  2474. int town;
  2475. char map_name[100];
  2476. char output[200];
  2477. int m;
  2478. if(map[sd->bl.m].flag.nogo) {
  2479. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2480. return 0;
  2481. }
  2482. struct { char map[16]; int x, y; } data[] = {
  2483. { "prontera.gat", 156, 191 }, // 0=Prontera
  2484. { "morocc.gat", 156, 93 }, // 1=Morroc
  2485. { "geffen.gat", 119, 59 }, // 2=Geffen
  2486. { "payon.gat", 162, 233 }, // 3=Payon
  2487. { "alberta.gat", 192, 147 }, // 4=Alberta
  2488. { "izlude.gat", 128, 114 }, // 5=Izlude
  2489. { "aldebaran.gat",140, 131 }, // 6=Al de Baran
  2490. { "xmas.gat", 147, 134 }, // 7=Lutie
  2491. { "comodo.gat", 209, 143 }, // 8=Comodo
  2492. { "yuno.gat", 157, 51 }, // 9=Yuno
  2493. { "amatsu.gat", 198, 84 }, // 10=Amatsu
  2494. { "gonryun.gat", 160, 120 }, // 11=Gon Ryun
  2495. { "umbala.gat", 89, 157 }, // 12=Umbala
  2496. { "niflheim.gat", 21, 153 }, // 13=Niflheim
  2497. { "louyang.gat", 217, 40 }, // 14=Lou Yang
  2498. { "new_1-1.gat", 53, 111 }, // 15=Start point
  2499. { "sec_pri.gat", 23, 61 }, // 16=Prison
  2500. };
  2501. memset(map_name, '\0', sizeof(map_name));
  2502. memset(output, '\0', sizeof(output));
  2503. // get the number
  2504. town = atoi(message);
  2505. // if no value, display all value
  2506. if (!message || !*message || sscanf(message, "%99s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2507. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2508. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2509. clif_displaymessage(fd, "-3=(Memo point 2) 4=Alberta 11=Gon Ryun");
  2510. clif_displaymessage(fd, "-2=(Memo point 1) 5=Izlude 12=Umbala");
  2511. clif_displaymessage(fd, "-1=(Memo point 0) 6=Al de Baran 13=Niflheim");
  2512. clif_displaymessage(fd, " 0=Prontera 7=Lutie 14=Lou Yang");
  2513. clif_displaymessage(fd, " 1=Morroc 8=Comodo 15=Start point");
  2514. clif_displaymessage(fd, " 2=Geffen 9=Yuno 16=Prison");
  2515. clif_displaymessage(fd, " 3=Payon 10=Amatsu");
  2516. return -1;
  2517. } else {
  2518. // get possible name of the city and add .gat if not in the name
  2519. map_name[sizeof(map_name)-1] = '\0';
  2520. for (i = 0; map_name[i]; i++)
  2521. map_name[i] = tolower(map_name[i]);
  2522. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  2523. strcat(map_name, ".gat");
  2524. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2525. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2526. town = 0;
  2527. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2528. town = 1;
  2529. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2530. town = 2;
  2531. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2532. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2533. town = 3;
  2534. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2535. town = 4;
  2536. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2537. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2538. town = 5;
  2539. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2540. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2541. town = 6;
  2542. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2543. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2544. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2545. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2546. town = 7;
  2547. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2548. town = 8;
  2549. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2550. town = 9;
  2551. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2552. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2553. town = 10;
  2554. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2555. town = 11;
  2556. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2557. town = 12;
  2558. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2559. town = 13;
  2560. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2561. town = 14;
  2562. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2563. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2564. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2565. town = 15;
  2566. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2567. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2568. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2569. town = 16;
  2570. }
  2571. if (town >= -3 && town <= -1) {
  2572. if (sd->status.memo_point[-town-1].map[0]) {
  2573. m = map_mapname2mapid(sd->status.memo_point[-town-1].map);
  2574. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2575. clif_displaymessage(fd, "You are not authorised to warp you to this memo map.");
  2576. return -1;
  2577. }
  2578. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2579. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2580. return -1;
  2581. }
  2582. if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
  2583. clif_displaymessage(fd, msg_table[0]); // Warped.
  2584. } else {
  2585. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2586. return -1;
  2587. }
  2588. } else {
  2589. sprintf(output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2590. clif_displaymessage(fd, output);
  2591. return -1;
  2592. }
  2593. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2594. m = map_mapname2mapid(data[town].map);
  2595. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2596. clif_displaymessage(fd, "You are not authorised to warp you to this destination map.");
  2597. return -1;
  2598. }
  2599. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2600. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2601. return -1;
  2602. }
  2603. if (pc_setpos(sd, data[town].map, data[town].x, data[town].y, 3) == 0) {
  2604. clif_displaymessage(fd, msg_table[0]); // Warped.
  2605. } else {
  2606. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2607. return -1;
  2608. }
  2609. } else { // if you arrive here, you have an error in town variable when reading of names
  2610. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2611. return -1;
  2612. }
  2613. }
  2614. return 0;
  2615. }
  2616. /*==========================================
  2617. *
  2618. *------------------------------------------
  2619. */
  2620. int atcommand_monster(
  2621. const int fd, struct map_session_data* sd,
  2622. const char* command, const char* message)
  2623. {
  2624. char name[100];
  2625. char monster[100];
  2626. char output[200];
  2627. int mob_id;
  2628. int number = 0;
  2629. int x = 0, y = 0;
  2630. int count;
  2631. int i, j, k;
  2632. int mx, my, range;
  2633. memset(name, '\0', sizeof(name));
  2634. memset(monster, '\0', sizeof(monster));
  2635. memset(output, '\0', sizeof(output));
  2636. if (!message || !*message ||
  2637. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2638. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2639. sscanf(message, "%99s %99s %d %d %d", name, monster, &number, &x, &y) < 2)) {
  2640. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2641. return -1;
  2642. }
  2643. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2644. mob_id = mobdb_checkid(atoi(monster));
  2645. if (mob_id == 0) {
  2646. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2647. return -1;
  2648. }
  2649. if (mob_id == 1288) {
  2650. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2651. return -1;
  2652. }
  2653. if (number <= 0)
  2654. number = 1;
  2655. if (strlen(name) < 1)
  2656. strcpy(name, "--ja--");
  2657. // 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
  2658. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2659. number = battle_config.atc_spawn_quantity_limit;
  2660. if (battle_config.etc_log)
  2661. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2662. count = 0;
  2663. range = sqrt(number) / 2;
  2664. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2665. for (i = 0; i < number; i++) {
  2666. j = 0;
  2667. k = 0;
  2668. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2669. if (x <= 0)
  2670. mx = sd->bl.x + (rand() % range - (range / 2));
  2671. else
  2672. mx = x;
  2673. if (y <= 0)
  2674. my = sd->bl.y + (rand() % range - (range / 2));
  2675. else
  2676. my = y;
  2677. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2678. }
  2679. count += (k != 0) ? 1 : 0;
  2680. }
  2681. if (count != 0)
  2682. if (number == count)
  2683. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2684. else {
  2685. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2686. clif_displaymessage(fd, output);
  2687. }
  2688. else {
  2689. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2690. return -1;
  2691. }
  2692. return 0;
  2693. }
  2694. /*==========================================
  2695. *
  2696. *------------------------------------------
  2697. */
  2698. int atcommand_spawn(
  2699. const int fd, struct map_session_data* sd,
  2700. const char* command, const char* message) {
  2701. char name[100];
  2702. char monster[100];
  2703. char output[200];
  2704. int mob_id;
  2705. int number = 0;
  2706. int x = 0, y = 0;
  2707. int count;
  2708. int i, j, k;
  2709. int mx, my, range;
  2710. memset(name, '\0', sizeof(name));
  2711. memset(monster, '\0', sizeof(monster));
  2712. memset(output, '\0', sizeof(output));
  2713. if (!message || !*message ||
  2714. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2715. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2716. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1)) {
  2717. clif_displaymessage(fd, msg_table[143]); // Give a monster name/id please.
  2718. return -1;
  2719. }
  2720. // If monster identifier/name argument is a name
  2721. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2722. mob_id = mobdb_checkid(atoi(monster));
  2723. if (mob_id == 0) {
  2724. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2725. return -1;
  2726. }
  2727. if (mob_id == 1288) {
  2728. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2729. return -1;
  2730. }
  2731. if (number <= 0)
  2732. number = 1;
  2733. if (strlen(name) < 1)
  2734. strcpy(name, "--ja--");
  2735. // 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
  2736. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2737. number = battle_config.atc_spawn_quantity_limit;
  2738. if (battle_config.etc_log)
  2739. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2740. count = 0;
  2741. range = sqrt(number) / 2;
  2742. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2743. for (i = 0; i < number; i++) {
  2744. j = 0;
  2745. k = 0;
  2746. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2747. if (x <= 0)
  2748. mx = sd->bl.x + (rand() % range - (range / 2));
  2749. else
  2750. mx = x;
  2751. if (y <= 0)
  2752. my = sd->bl.y + (rand() % range - (range / 2));
  2753. else
  2754. my = y;
  2755. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2756. }
  2757. count += (k != 0) ? 1 : 0;
  2758. }
  2759. if (count != 0)
  2760. if (number == count)
  2761. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2762. else {
  2763. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2764. clif_displaymessage(fd, output);
  2765. }
  2766. else {
  2767. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2768. return -1;
  2769. }
  2770. return 0;
  2771. }
  2772. // small monster spawning [Valaris]
  2773. int atcommand_monstersmall(
  2774. const int fd, struct map_session_data* sd,
  2775. const char* command, const char* message) {
  2776. char name[100] = "";
  2777. char monster[100] = "";
  2778. int mob_id = 0;
  2779. int number = 0;
  2780. int x = 0;
  2781. int y = 0;
  2782. int count;
  2783. int i;
  2784. nullpo_retr(-1, sd);
  2785. if (!message || !*message) {
  2786. clif_displaymessage(fd, "Give a monster name/id please.");
  2787. return 0;
  2788. }
  2789. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2790. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2791. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2792. clif_displaymessage(fd, "Give a monster name/id please.");
  2793. return 0;
  2794. }
  2795. // If monster identifier/name argument is a name
  2796. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2797. mob_id = atoi(monster);
  2798. if (mob_id == 0) {
  2799. clif_displaymessage(fd, "Monster name hasn't been found.");
  2800. return 0;
  2801. }
  2802. if (mob_id == 1288) {
  2803. clif_displaymessage(fd, "Cannot spawn emperium.");
  2804. return 0;
  2805. }
  2806. if (mob_id > 2000) {
  2807. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2808. return 0;
  2809. }
  2810. if (number <= 0)
  2811. number = 1;
  2812. if (strlen(name) < 1)
  2813. strcpy(name, "--ja--");
  2814. // 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
  2815. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2816. number = battle_config.atc_spawn_quantity_limit;
  2817. count = 0;
  2818. for (i = 0; i < number; i++) {
  2819. int mx, my;
  2820. if (x <= 0)
  2821. mx = sd->bl.x + (rand() % 11 - 5);
  2822. else
  2823. mx = x;
  2824. if (y <= 0)
  2825. my = sd->bl.y + (rand() % 11 - 5);
  2826. else
  2827. my = y;
  2828. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2000, 1, "") != 0) ? 1 : 0;
  2829. }
  2830. if (count != 0)
  2831. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2832. else
  2833. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2834. return 0;
  2835. }
  2836. // big monster spawning [Valaris]
  2837. int atcommand_monsterbig(
  2838. const int fd, struct map_session_data* sd,
  2839. const char* command, const char* message) {
  2840. char name[100] = "";
  2841. char monster[100] = "";
  2842. int mob_id = 0;
  2843. int number = 0;
  2844. int x = 0;
  2845. int y = 0;
  2846. int count;
  2847. int i;
  2848. nullpo_retr(-1, sd);
  2849. if (!message || !*message) {
  2850. clif_displaymessage(fd, "Give a monster name/id please.");
  2851. return 0;
  2852. }
  2853. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2854. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2855. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2856. clif_displaymessage(fd, "Give a monster name/id please.");
  2857. return 0;
  2858. }
  2859. // If monster identifier/name argument is a name
  2860. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2861. mob_id = atoi(monster);
  2862. if (mob_id == 0) {
  2863. clif_displaymessage(fd, "Monster name hasn't been found.");
  2864. return 0;
  2865. }
  2866. if (mob_id == 1288) {
  2867. clif_displaymessage(fd, "Cannot spawn emperium.");
  2868. return 0;
  2869. }
  2870. if (mob_id > 2000) {
  2871. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2872. return 0;
  2873. }
  2874. if (number <= 0)
  2875. number = 1;
  2876. if (strlen(name) < 1)
  2877. strcpy(name, "--ja--");
  2878. // 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
  2879. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2880. number = battle_config.atc_spawn_quantity_limit;
  2881. count = 0;
  2882. for (i = 0; i < number; i++) {
  2883. int mx, my;
  2884. if (x <= 0)
  2885. mx = sd->bl.x + (rand() % 11 - 5);
  2886. else
  2887. mx = x;
  2888. if (y <= 0)
  2889. my = sd->bl.y + (rand() % 11 - 5);
  2890. else
  2891. my = y;
  2892. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+4000, 1, "") != 0) ? 1 : 0;
  2893. }
  2894. if (count != 0)
  2895. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2896. else
  2897. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2898. return 0;
  2899. }
  2900. /*==========================================
  2901. *
  2902. *------------------------------------------
  2903. */
  2904. void atcommand_killmonster_sub(
  2905. const int fd, struct map_session_data* sd, const char* message,
  2906. const int drop)
  2907. {
  2908. int map_id;
  2909. char map_name[100];
  2910. memset(map_name, '\0', sizeof(map_name));
  2911. if (!message || !*message || sscanf(message, "%99s", map_name) < 1)
  2912. map_id = sd->bl.m;
  2913. else {
  2914. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  2915. strcat(map_name, ".gat");
  2916. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2917. map_id = sd->bl.m;
  2918. }
  2919. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, drop);
  2920. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  2921. return;
  2922. }
  2923. /*==========================================
  2924. *
  2925. *------------------------------------------
  2926. */
  2927. int atcommand_killmonster(
  2928. const int fd, struct map_session_data* sd,
  2929. const char* command, const char* message)
  2930. {
  2931. atcommand_killmonster_sub(fd, sd, message, 1);
  2932. return 0;
  2933. }
  2934. /*==========================================
  2935. *
  2936. *------------------------------------------
  2937. */
  2938. int atcommand_killmonster2(
  2939. const int fd, struct map_session_data* sd,
  2940. const char* command, const char* message)
  2941. {
  2942. atcommand_killmonster_sub(fd, sd, message, 0);
  2943. return 0;
  2944. }
  2945. /*==========================================
  2946. *
  2947. *------------------------------------------
  2948. */
  2949. int atcommand_refine(
  2950. const int fd, struct map_session_data* sd,
  2951. const char* command, const char* message)
  2952. {
  2953. int i, position = 0, refine = 0, current_position, final_refine;
  2954. int count;
  2955. char output[200];
  2956. memset(output, '\0', sizeof(output));
  2957. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2958. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  2959. return -1;
  2960. }
  2961. if (refine < -10)
  2962. refine = -10;
  2963. else if (refine > 10)
  2964. refine = 10;
  2965. else if (refine == 0)
  2966. refine = 1;
  2967. count = 0;
  2968. for (i = 0; i < MAX_INVENTORY; i++) {
  2969. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  2970. (sd->status.inventory[i].equip & position ||
  2971. (sd->status.inventory[i].equip && !position))) {
  2972. final_refine = sd->status.inventory[i].refine + refine;
  2973. if (final_refine > 10)
  2974. final_refine = 10;
  2975. else if (final_refine < 0)
  2976. final_refine = 0;
  2977. if (sd->status.inventory[i].refine != final_refine) {
  2978. sd->status.inventory[i].refine = final_refine;
  2979. current_position = sd->status.inventory[i].equip;
  2980. pc_unequipitem(sd, i, 0, BF_NORMAL);
  2981. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  2982. clif_delitem(sd, i, 1);
  2983. clif_additem(sd, i, 1, 0);
  2984. pc_equipitem(sd, i, current_position);
  2985. clif_misceffect((struct block_list*)&sd->bl, 3);
  2986. count++;
  2987. }
  2988. }
  2989. }
  2990. if (count == 0)
  2991. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  2992. else if (count == 1)
  2993. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  2994. else {
  2995. sprintf(output, msg_table[168], count); // %d items have been refined!
  2996. clif_displaymessage(fd, output);
  2997. }
  2998. return 0;
  2999. }
  3000. /*==========================================
  3001. *
  3002. *------------------------------------------
  3003. */
  3004. int atcommand_produce(
  3005. const int fd, struct map_session_data* sd,
  3006. const char* command, const char* message)
  3007. {
  3008. char item_name[100];
  3009. int item_id, attribute = 0, star = 0;
  3010. int flag = 0;
  3011. struct item_data *item_data;
  3012. struct item tmp_item;
  3013. char output[200];
  3014. memset(output, '\0', sizeof(output));
  3015. memset(item_name, '\0', sizeof(item_name));
  3016. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3017. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3018. return -1;
  3019. }
  3020. item_id = 0;
  3021. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3022. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3023. item_id = item_data->nameid;
  3024. if (itemdb_exists(item_id) &&
  3025. (item_id <= 500 || item_id > 1099) &&
  3026. (item_id < 4001 || item_id > 4148) &&
  3027. (item_id < 7001 || item_id > 10019) &&
  3028. itemdb_isequip(item_id)) {
  3029. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3030. attribute = ATTRIBUTE_NORMAL;
  3031. if (star < MIN_STAR || star > MAX_STAR)
  3032. star = 0;
  3033. memset(&tmp_item, 0, sizeof tmp_item);
  3034. tmp_item.nameid = item_id;
  3035. tmp_item.amount = 1;
  3036. tmp_item.identify = 1;
  3037. tmp_item.card[0] = 0x00ff;
  3038. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3039. *((unsigned long *)(&tmp_item.card[2])) = sd->char_id;
  3040. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3041. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3042. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3043. clif_additem(sd, 0, 0, flag);
  3044. } else {
  3045. if (battle_config.error_log)
  3046. printf("@produce NOT WEAPON [%d]\n", item_id);
  3047. if (item_id != 0 && itemdb_exists(item_id))
  3048. sprintf(output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3049. else
  3050. sprintf(output, msg_table[170]); // This item is not an equipment.
  3051. clif_displaymessage(fd, output);
  3052. return -1;
  3053. }
  3054. return 0;
  3055. }
  3056. /*==========================================
  3057. * Sub-function to display actual memo points
  3058. *------------------------------------------
  3059. */
  3060. void atcommand_memo_sub(struct map_session_data* sd) {
  3061. int i;
  3062. char output[200];
  3063. memset(output, '\0', sizeof(output));
  3064. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3065. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3066. if (sd->status.memo_point[i].map[0])
  3067. sprintf(output, "%d - %s (%d,%d)", i, sd->status.memo_point[i].map, sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  3068. else
  3069. sprintf(output, msg_table[171], i); // %d - void
  3070. clif_displaymessage(sd->fd, output);
  3071. }
  3072. return;
  3073. }
  3074. /*==========================================
  3075. *
  3076. *------------------------------------------
  3077. */
  3078. int atcommand_memo(
  3079. const int fd, struct map_session_data* sd,
  3080. const char* command, const char* message)
  3081. {
  3082. int position = 0;
  3083. char output[200];
  3084. memset(output, '\0', sizeof(output));
  3085. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3086. atcommand_memo_sub(sd);
  3087. else {
  3088. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3089. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3090. clif_displaymessage(fd, "You are not authorised to memo this map.");
  3091. return -1;
  3092. }
  3093. if (sd->status.memo_point[position].map[0]) {
  3094. sprintf(output, msg_table[172], position, sd->status.memo_point[position].map, sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
  3095. clif_displaymessage(fd, output);
  3096. }
  3097. memcpy(sd->status.memo_point[position].map, map[sd->bl.m].name, 24);
  3098. sd->status.memo_point[position].x = sd->bl.x;
  3099. sd->status.memo_point[position].y = sd->bl.y;
  3100. clif_skill_memo(sd, 0);
  3101. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3102. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3103. atcommand_memo_sub(sd);
  3104. } else {
  3105. sprintf(output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3106. clif_displaymessage(fd, output);
  3107. atcommand_memo_sub(sd);
  3108. return -1;
  3109. }
  3110. }
  3111. return 0;
  3112. }
  3113. /*==========================================
  3114. *
  3115. *------------------------------------------
  3116. */
  3117. int atcommand_gat(
  3118. const int fd, struct map_session_data* sd,
  3119. const char* command, const char* message)
  3120. {
  3121. char output[200];
  3122. int y;
  3123. memset(output, '\0', sizeof(output));
  3124. for (y = 2; y >= -2; y--) {
  3125. sprintf(output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3126. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3127. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y),
  3128. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y),
  3129. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y),
  3130. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y),
  3131. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y));
  3132. clif_displaymessage(fd, output);
  3133. }
  3134. return 0;
  3135. }
  3136. /*==========================================
  3137. *
  3138. *------------------------------------------
  3139. */
  3140. int atcommand_packet(
  3141. const int fd, struct map_session_data* sd,
  3142. const char* command, const char* message)
  3143. {
  3144. int x = 0, y = 0;
  3145. if (!message || !*message || sscanf(message, "%d %d", &x, &y) < 2) {
  3146. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3147. return -1;
  3148. }
  3149. clif_status_change(&sd->bl, x, y);
  3150. return 0;
  3151. }
  3152. /*==========================================
  3153. * @stpoint (Rewritten by [Yor])
  3154. *------------------------------------------
  3155. */
  3156. int atcommand_statuspoint(
  3157. const int fd, struct map_session_data* sd,
  3158. const char* command, const char* message)
  3159. {
  3160. int point, new_status_point;
  3161. if (!message || !*message || (point = atoi(message)) == 0) {
  3162. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3163. return -1;
  3164. }
  3165. new_status_point = (int)sd->status.status_point + point;
  3166. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3167. new_status_point = 0x7FFF;
  3168. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3169. new_status_point = 0;
  3170. if (new_status_point != (int)sd->status.status_point) {
  3171. sd->status.status_point = (short)new_status_point;
  3172. clif_updatestatus(sd, SP_STATUSPOINT);
  3173. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3174. } else {
  3175. if (point < 0)
  3176. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3177. else
  3178. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3179. return -1;
  3180. }
  3181. return 0;
  3182. }
  3183. /*==========================================
  3184. * @skpoint (Rewritten by [Yor])
  3185. *------------------------------------------
  3186. */
  3187. int atcommand_skillpoint(
  3188. const int fd, struct map_session_data* sd,
  3189. const char* command, const char* message)
  3190. {
  3191. int point, new_skill_point;
  3192. if (!message || !*message || (point = atoi(message)) == 0) {
  3193. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3194. return -1;
  3195. }
  3196. new_skill_point = (int)sd->status.skill_point + point;
  3197. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3198. new_skill_point = 0x7FFF;
  3199. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3200. new_skill_point = 0;
  3201. if (new_skill_point != (int)sd->status.skill_point) {
  3202. sd->status.skill_point = (short)new_skill_point;
  3203. clif_updatestatus(sd, SP_SKILLPOINT);
  3204. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3205. } else {
  3206. if (point < 0)
  3207. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3208. else
  3209. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3210. return -1;
  3211. }
  3212. return 0;
  3213. }
  3214. /*==========================================
  3215. * @zeny (Rewritten by [Yor])
  3216. *------------------------------------------
  3217. */
  3218. int atcommand_zeny(
  3219. const int fd, struct map_session_data* sd,
  3220. const char* command, const char* message)
  3221. {
  3222. int zeny, new_zeny;
  3223. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3224. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3225. return -1;
  3226. }
  3227. new_zeny = sd->status.zeny + zeny;
  3228. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3229. new_zeny = MAX_ZENY;
  3230. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3231. new_zeny = 0;
  3232. if (new_zeny != sd->status.zeny) {
  3233. sd->status.zeny = new_zeny;
  3234. clif_updatestatus(sd, SP_ZENY);
  3235. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3236. } else {
  3237. if (zeny < 0)
  3238. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3239. else
  3240. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3241. return -1;
  3242. }
  3243. return 0;
  3244. }
  3245. /*==========================================
  3246. *
  3247. *------------------------------------------
  3248. */
  3249. int atcommand_param(
  3250. const int fd, struct map_session_data* sd,
  3251. const char* command, const char* message)
  3252. {
  3253. int i, index, value = 0, new_value;
  3254. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3255. short* status[] = {
  3256. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3257. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3258. };
  3259. char output[200];
  3260. memset(output, '\0', sizeof(output));
  3261. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3262. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3263. clif_displaymessage(fd, output);
  3264. return -1;
  3265. }
  3266. index = -1;
  3267. for (i = 0; param[i] != NULL; i++) {
  3268. if (strcmpi(command, param[i]) == 0) {
  3269. index = i;
  3270. break;
  3271. }
  3272. }
  3273. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3274. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3275. clif_displaymessage(fd, output);
  3276. return -1;
  3277. }
  3278. new_value = (int)*status[index] + value;
  3279. if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
  3280. new_value = battle_config.max_parameter;
  3281. else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3282. new_value = 1;
  3283. if (new_value != (int)*status[index]) {
  3284. *status[index] = new_value;
  3285. clif_updatestatus(sd, SP_STR + index);
  3286. clif_updatestatus(sd, SP_USTR + index);
  3287. pc_calcstatus(sd, 0);
  3288. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3289. } else {
  3290. if (value < 0)
  3291. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3292. else
  3293. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3294. return -1;
  3295. }
  3296. return 0;
  3297. }
  3298. /*==========================================
  3299. *
  3300. *------------------------------------------
  3301. */
  3302. //** Stat all by fritz (rewritten by [Yor])
  3303. int atcommand_stat_all(
  3304. const int fd, struct map_session_data* sd,
  3305. const char* command, const char* message)
  3306. {
  3307. int index, count, value = 0, new_value;
  3308. short* status[] = {
  3309. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3310. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3311. };
  3312. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3313. value = battle_config.max_parameter;
  3314. count = 0;
  3315. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3316. new_value = (int)*status[index] + value;
  3317. if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
  3318. new_value = battle_config.max_parameter;
  3319. else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3320. new_value = 1;
  3321. if (new_value != (int)*status[index]) {
  3322. *status[index] = new_value;
  3323. clif_updatestatus(sd, SP_STR + index);
  3324. clif_updatestatus(sd, SP_USTR + index);
  3325. pc_calcstatus(sd, 0);
  3326. count++;
  3327. }
  3328. }
  3329. if (count > 0) // if at least 1 stat modified
  3330. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3331. else {
  3332. if (value < 0)
  3333. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3334. else
  3335. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3336. return -1;
  3337. }
  3338. return 0;
  3339. }
  3340. /*==========================================
  3341. *
  3342. *------------------------------------------
  3343. */
  3344. int atcommand_guildlevelup(
  3345. const int fd, struct map_session_data* sd,
  3346. const char* command, const char* message)
  3347. {
  3348. int level = 0;
  3349. short added_level;
  3350. struct guild *guild_info;
  3351. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3352. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3353. return -1;
  3354. }
  3355. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3356. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3357. return -1;
  3358. }
  3359. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3360. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3361. return -1;
  3362. }
  3363. added_level = (short)level;
  3364. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3365. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3366. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3367. added_level = 1 - guild_info->guild_lv;
  3368. if (added_level != 0) {
  3369. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3370. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3371. } else {
  3372. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3373. return -1;
  3374. }
  3375. return 0;
  3376. }
  3377. /*==========================================
  3378. *
  3379. *------------------------------------------
  3380. */
  3381. int atcommand_makeegg(
  3382. const int fd, struct map_session_data* sd,
  3383. const char* command, const char* message)
  3384. {
  3385. struct item_data *item_data;
  3386. int id, pet_id;
  3387. if (!message || !*message) {
  3388. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3389. return -1;
  3390. }
  3391. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3392. id = item_data->nameid;
  3393. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3394. id = atoi(message);
  3395. pet_id = search_petDB_index(id, PET_CLASS);
  3396. if (pet_id < 0)
  3397. pet_id = search_petDB_index(id, PET_EGG);
  3398. if (pet_id >= 0) {
  3399. sd->catch_target_class = pet_db[pet_id].class;
  3400. intif_create_pet(
  3401. sd->status.account_id, sd->status.char_id,
  3402. pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
  3403. pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
  3404. 100, 0, 1, pet_db[pet_id].jname);
  3405. } else {
  3406. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3407. return -1;
  3408. }
  3409. return 0;
  3410. }
  3411. /*==========================================
  3412. *
  3413. *------------------------------------------
  3414. */
  3415. int atcommand_hatch(
  3416. const int fd, struct map_session_data* sd,
  3417. const char* command, const char* message)
  3418. {
  3419. if (sd->status.pet_id <= 0)
  3420. clif_sendegg(sd);
  3421. else {
  3422. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3423. return -1;
  3424. }
  3425. return 0;
  3426. }
  3427. /*==========================================
  3428. *
  3429. *------------------------------------------
  3430. */
  3431. int atcommand_petfriendly(
  3432. const int fd, struct map_session_data* sd,
  3433. const char* command, const char* message)
  3434. {
  3435. int friendly;
  3436. int t;
  3437. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3438. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3439. return -1;
  3440. }
  3441. if (sd->status.pet_id > 0 && sd->pd) {
  3442. if (friendly >= 0 && friendly <= 1000) {
  3443. if (friendly != sd->pet.intimate) {
  3444. t = sd->pet.intimate;
  3445. sd->pet.intimate = friendly;
  3446. clif_send_petstatus(sd);
  3447. if (battle_config.pet_status_support) {
  3448. if ((sd->pet.intimate > 0 && t <= 0) ||
  3449. (sd->pet.intimate <= 0 && t > 0)) {
  3450. if (sd->bl.prev != NULL)
  3451. pc_calcstatus(sd, 0);
  3452. else
  3453. pc_calcstatus(sd, 2);
  3454. }
  3455. }
  3456. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3457. } else {
  3458. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3459. return -1;
  3460. }
  3461. } else {
  3462. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3463. return -1;
  3464. }
  3465. } else {
  3466. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3467. return -1;
  3468. }
  3469. return 0;
  3470. }
  3471. /*==========================================
  3472. *
  3473. *------------------------------------------
  3474. */
  3475. int atcommand_pethungry(
  3476. const int fd, struct map_session_data* sd,
  3477. const char* command, const char* message)
  3478. {
  3479. int hungry;
  3480. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3481. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3482. return -1;
  3483. }
  3484. if (sd->status.pet_id > 0 && sd->pd) {
  3485. if (hungry >= 0 && hungry <= 100) {
  3486. if (hungry != sd->pet.hungry) {
  3487. sd->pet.hungry = hungry;
  3488. clif_send_petstatus(sd);
  3489. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3490. } else {
  3491. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3492. return -1;
  3493. }
  3494. } else {
  3495. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3496. return -1;
  3497. }
  3498. } else {
  3499. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3500. return -1;
  3501. }
  3502. return 0;
  3503. }
  3504. /*==========================================
  3505. *
  3506. *------------------------------------------
  3507. */
  3508. int atcommand_petrename(
  3509. const int fd, struct map_session_data* sd,
  3510. const char* command, const char* message)
  3511. {
  3512. if (sd->status.pet_id > 0 && sd->pd) {
  3513. if (sd->pet.rename_flag != 0) {
  3514. sd->pet.rename_flag = 0;
  3515. intif_save_petdata(sd->status.account_id, &sd->pet);
  3516. clif_send_petstatus(sd);
  3517. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3518. } else {
  3519. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3520. return -1;
  3521. }
  3522. } else {
  3523. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3524. return -1;
  3525. }
  3526. return 0;
  3527. }
  3528. /*==========================================
  3529. *
  3530. *------------------------------------------
  3531. */
  3532. int
  3533. atcommand_recall(
  3534. const int fd, struct map_session_data* sd,
  3535. const char* command, const char* message)
  3536. {
  3537. char character[100];
  3538. char output[200];
  3539. struct map_session_data *pl_sd = NULL;
  3540. nullpo_retr(-1, sd);
  3541. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3542. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3543. return -1;
  3544. }
  3545. memset(character, '\0', sizeof character);
  3546. if(sscanf(message, "%99[^\n]", character) < 1)
  3547. return -1;
  3548. if(strncmp(sd->status.name,character,24)==0)
  3549. return -1;
  3550. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3551. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3552. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3553. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3554. return -1;
  3555. }
  3556. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3557. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  3558. return -1;
  3559. }
  3560. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  3561. sprintf(output, msg_table[46], character); // %s recalled!
  3562. clif_displaymessage(fd, output);
  3563. } else {
  3564. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3565. return -1;
  3566. }
  3567. } else {
  3568. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3569. return -1;
  3570. }
  3571. return 0;
  3572. }
  3573. /*==========================================
  3574. *
  3575. *------------------------------------------
  3576. */
  3577. int atcommand_revive(
  3578. const int fd, struct map_session_data* sd,
  3579. const char* command, const char* message)
  3580. {
  3581. char character[100];
  3582. struct map_session_data *pl_sd;
  3583. memset(character, '\0', sizeof(character));
  3584. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3585. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3586. return -1;
  3587. }
  3588. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3589. if (pc_isdead(sd)) {
  3590. pl_sd->status.hp = pl_sd->status.max_hp;
  3591. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3592. pc_setstand(pl_sd);
  3593. if (battle_config.pc_invincible_time > 0)
  3594. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  3595. clif_updatestatus(pl_sd, SP_HP);
  3596. clif_updatestatus(pl_sd, SP_SP);
  3597. clif_resurrection(&pl_sd->bl, 1);
  3598. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3599. return 0;
  3600. }
  3601. return -1;
  3602. } else {
  3603. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3604. return -1;
  3605. }
  3606. return 0;
  3607. }
  3608. /*==========================================
  3609. *
  3610. *------------------------------------------
  3611. */
  3612. int atcommand_character_stats(
  3613. const int fd, struct map_session_data* sd,
  3614. const char* command, const char* message)
  3615. {
  3616. char character[100];
  3617. char job_jobname[100];
  3618. char output[200];
  3619. struct map_session_data *pl_sd;
  3620. int i;
  3621. memset(character, '\0', sizeof(character));
  3622. memset(job_jobname, '\0', sizeof(job_jobname));
  3623. memset(output, '\0', sizeof(output));
  3624. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3625. clif_displaymessage(fd, "Please, enter a player name (usage: @charstats <char name>).");
  3626. return -1;
  3627. }
  3628. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3629. struct {
  3630. const char* format;
  3631. int value;
  3632. } output_table[] = {
  3633. { "Base Level - %d", pl_sd->status.base_level },
  3634. { job_jobname, pl_sd->status.job_level },
  3635. { "Hp - %d", pl_sd->status.hp },
  3636. { "MaxHp - %d", pl_sd->status.max_hp },
  3637. { "Sp - %d", pl_sd->status.sp },
  3638. { "MaxSp - %d", pl_sd->status.max_sp },
  3639. { "Str - %3d", pl_sd->status.str },
  3640. { "Agi - %3d", pl_sd->status.agi },
  3641. { "Vit - %3d", pl_sd->status.vit },
  3642. { "Int - %3d", pl_sd->status.int_ },
  3643. { "Dex - %3d", pl_sd->status.dex },
  3644. { "Luk - %3d", pl_sd->status.luk },
  3645. { "Zeny - %d", pl_sd->status.zeny },
  3646. { NULL, 0 }
  3647. };
  3648. sprintf(job_jobname, "Job - %s %s", job_name(pl_sd->status.class), "(level %d)");
  3649. sprintf(output, msg_table[53], pl_sd->status.name); // '%s' stats:
  3650. clif_displaymessage(fd, output);
  3651. for (i = 0; output_table[i].format != NULL; i++) {
  3652. sprintf(output, output_table[i].format, output_table[i].value);
  3653. clif_displaymessage(fd, output);
  3654. }
  3655. } else {
  3656. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3657. return -1;
  3658. }
  3659. return 0;
  3660. }
  3661. /*==========================================
  3662. *
  3663. *------------------------------------------
  3664. */
  3665. //** Character Stats All by fritz
  3666. int atcommand_character_stats_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3667. {
  3668. char output[1024], gmlevel[1024];
  3669. int i;
  3670. int count;
  3671. struct map_session_data *pl_sd;
  3672. memset(output, '\0', sizeof(output));
  3673. memset(gmlevel, '\0', sizeof(gmlevel));
  3674. count = 0;
  3675. for(i = 0; i < fd_max; i++) {
  3676. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  3677. if (pc_isGM(pl_sd) > 0)
  3678. sprintf(gmlevel, "| GM Lvl: %d", pc_isGM(pl_sd));
  3679. else
  3680. sprintf(gmlevel, " ");
  3681. sprintf(output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d) | HP: %d/%d | SP: %d/%d", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level, pl_sd->status.hp, pl_sd->status.max_hp, pl_sd->status.sp, pl_sd->status.max_sp);
  3682. clif_displaymessage(fd, output);
  3683. sprintf(output, "STR: %d | AGI: %d | VIT: %d | INT: %d | DEX: %d | LUK: %d | Zeny: %d %s", pl_sd->status.str, pl_sd->status.agi, pl_sd->status.vit, pl_sd->status.int_, pl_sd->status.dex, pl_sd->status.luk, pl_sd->status.zeny, gmlevel);
  3684. clif_displaymessage(fd, output);
  3685. clif_displaymessage(fd, "--------");
  3686. count++;
  3687. }
  3688. }
  3689. if (count == 0)
  3690. clif_displaymessage(fd, msg_table[28]); // No player found.
  3691. else if (count == 1)
  3692. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  3693. else {
  3694. sprintf(output, msg_table[30], count); // %d players found.
  3695. clif_displaymessage(fd, output);
  3696. }
  3697. return 0;
  3698. }
  3699. /*==========================================
  3700. *
  3701. *------------------------------------------
  3702. */
  3703. int atcommand_character_option(
  3704. const int fd, struct map_session_data* sd,
  3705. const char* command, const char* message)
  3706. {
  3707. char character[100];
  3708. int opt1 = 0, opt2 = 0, opt3 = 0;
  3709. struct map_session_data* pl_sd;
  3710. memset(character, '\0', sizeof(character));
  3711. if (!message || !*message || sscanf(message, "%d %d %d %99[^\n]", &opt1, &opt2, &opt3, character) < 4 || opt1 < 0 || opt2 < 0 || opt3 < 0) {
  3712. clif_displaymessage(fd, "Please, enter valid options and a player name (usage: @charoption <param1> <param2> <param3> <charname>).");
  3713. return -1;
  3714. }
  3715. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3716. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change option only to lower or same level
  3717. pl_sd->opt1 = opt1;
  3718. pl_sd->opt2 = opt2;
  3719. pl_sd->status.option = opt3;
  3720. // fix pecopeco display
  3721. if (pl_sd->status.class == 13 || pl_sd->status.class == 21 || pl_sd->status.class == 4014 || pl_sd->status.class == 4022) {
  3722. if (!pc_isriding(pl_sd)) { // pl_sd have the new value...
  3723. if (pl_sd->status.class == 13)
  3724. pl_sd->status.class = pl_sd->view_class = 7;
  3725. else if (pl_sd->status.class == 21)
  3726. pl_sd->status.class = pl_sd->view_class = 14;
  3727. else if (pl_sd->status.class == 4014)
  3728. pl_sd->status.class = pl_sd->view_class = 4008;
  3729. else if (pl_sd->status.class == 4022)
  3730. pl_sd->status.class = pl_sd->view_class = 4015;
  3731. }
  3732. } else {
  3733. if (pc_isriding(pl_sd)) { // pl_sd have the new value...
  3734. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  3735. pl_sd->status.option &= ~0x0020;
  3736. } else {
  3737. if (pl_sd->status.class == 7)
  3738. pl_sd->status.class = pl_sd->view_class = 13;
  3739. else if (pl_sd->status.class == 14)
  3740. pl_sd->status.class = pl_sd->view_class = 21;
  3741. else if (pl_sd->status.class == 4008)
  3742. pl_sd->status.class = pl_sd->view_class = 4014;
  3743. else if (pl_sd->status.class == 4015)
  3744. pl_sd->status.class = pl_sd->view_class = 4022;
  3745. else
  3746. pl_sd->status.option &= ~0x0020;
  3747. }
  3748. }
  3749. }
  3750. clif_changeoption(&pl_sd->bl);
  3751. pc_calcstatus(pl_sd, 0);
  3752. clif_displaymessage(fd, msg_table[58]); // Character's options changed.
  3753. } else {
  3754. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3755. return -1;
  3756. }
  3757. } else {
  3758. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3759. return -1;
  3760. }
  3761. return 0;
  3762. }
  3763. /*==========================================
  3764. * charchangesex command (usage: charchangesex <player_name>)
  3765. *------------------------------------------
  3766. */
  3767. int atcommand_char_change_sex(
  3768. const int fd, struct map_session_data* sd,
  3769. const char* command, const char* message)
  3770. {
  3771. char character[100];
  3772. memset(character, '\0', sizeof(character));
  3773. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3774. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  3775. return -1;
  3776. }
  3777. // check player name
  3778. if (strlen(character) < 4) {
  3779. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3780. return -1;
  3781. } else if (strlen(character) > 23) {
  3782. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3783. return -1;
  3784. } else {
  3785. chrif_char_ask_name(sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
  3786. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3787. }
  3788. return 0;
  3789. }
  3790. /*==========================================
  3791. * charblock command (usage: charblock <player_name>)
  3792. * This command do a definitiv ban on a player
  3793. *------------------------------------------
  3794. */
  3795. int atcommand_char_block(
  3796. const int fd, struct map_session_data* sd,
  3797. const char* command, const char* message)
  3798. {
  3799. char character[100];
  3800. memset(character, '\0', sizeof(character));
  3801. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3802. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3803. return -1;
  3804. }
  3805. // check player name
  3806. if (strlen(character) < 4) {
  3807. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3808. return -1;
  3809. } else if (strlen(character) > 23) {
  3810. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3811. return -1;
  3812. } else {
  3813. chrif_char_ask_name(sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3814. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3815. }
  3816. return 0;
  3817. }
  3818. /*==========================================
  3819. * charban command (usage: charban <time> <player_name>)
  3820. * This command do a limited ban on a player
  3821. * Time is done as follows:
  3822. * Adjustment value (-1, 1, +1, etc...)
  3823. * Modified element:
  3824. * a or y: year
  3825. * m: month
  3826. * j or d: day
  3827. * h: hour
  3828. * mn: minute
  3829. * s: second
  3830. * <example> @ban +1m-2mn1s-6y test_player
  3831. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3832. *------------------------------------------
  3833. */
  3834. int atcommand_char_ban(
  3835. const int fd, struct map_session_data* sd,
  3836. const char* command, const char* message)
  3837. {
  3838. char modif[100], character[100];
  3839. char * modif_p;
  3840. int year, month, day, hour, minute, second, value;
  3841. memset(modif, '\0', sizeof(modif));
  3842. memset(character, '\0', sizeof(character));
  3843. if (!message || !*message || sscanf(message, "%s %99[^\n]", modif, character) < 2) {
  3844. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3845. return -1;
  3846. }
  3847. modif[sizeof(modif)-1] = '\0';
  3848. character[sizeof(character)-1] = '\0';
  3849. modif_p = modif;
  3850. year = month = day = hour = minute = second = 0;
  3851. while (modif_p[0] != '\0') {
  3852. value = atoi(modif_p);
  3853. if (value == 0)
  3854. modif_p++;
  3855. else {
  3856. if (modif_p[0] == '-' || modif_p[0] == '+')
  3857. modif_p++;
  3858. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3859. modif_p++;
  3860. if (modif_p[0] == 's') {
  3861. second = value;
  3862. modif_p++;
  3863. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3864. minute = value;
  3865. modif_p = modif_p + 2;
  3866. } else if (modif_p[0] == 'h') {
  3867. hour = value;
  3868. modif_p++;
  3869. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3870. day = value;
  3871. modif_p++;
  3872. } else if (modif_p[0] == 'm') {
  3873. month = value;
  3874. modif_p++;
  3875. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3876. year = value;
  3877. modif_p++;
  3878. } else if (modif_p[0] != '\0') {
  3879. modif_p++;
  3880. }
  3881. }
  3882. }
  3883. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3884. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  3885. return -1;
  3886. }
  3887. // check player name
  3888. if (strlen(character) < 4) {
  3889. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3890. return -1;
  3891. } else if (strlen(character) > 23) {
  3892. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3893. return -1;
  3894. } else {
  3895. chrif_char_ask_name(sd->status.account_id, character, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3896. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3897. }
  3898. return 0;
  3899. }
  3900. /*==========================================
  3901. * charunblock command (usage: charunblock <player_name>)
  3902. *------------------------------------------
  3903. */
  3904. int atcommand_char_unblock(
  3905. const int fd, struct map_session_data* sd,
  3906. const char* command, const char* message)
  3907. {
  3908. char character[100];
  3909. memset(character, '\0', sizeof(character));
  3910. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3911. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3912. return -1;
  3913. }
  3914. // check player name
  3915. if (strlen(character) < 4) {
  3916. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3917. return -1;
  3918. } else if (strlen(character) > 23) {
  3919. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3920. return -1;
  3921. } else {
  3922. // send answer to login server via char-server
  3923. chrif_char_ask_name(sd->status.account_id, character, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3924. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3925. }
  3926. return 0;
  3927. }
  3928. /*==========================================
  3929. * charunban command (usage: charunban <player_name>)
  3930. *------------------------------------------
  3931. */
  3932. int atcommand_char_unban(
  3933. const int fd, struct map_session_data* sd,
  3934. const char* command, const char* message)
  3935. {
  3936. char character[100];
  3937. memset(character, '\0', sizeof(character));
  3938. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3939. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3940. return -1;
  3941. }
  3942. // check player name
  3943. if (strlen(character) < 4) {
  3944. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3945. return -1;
  3946. } else if (strlen(character) > 23) {
  3947. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3948. return -1;
  3949. } else {
  3950. // send answer to login server via char-server
  3951. chrif_char_ask_name(sd->status.account_id, character, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3952. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3953. }
  3954. return 0;
  3955. }
  3956. /*==========================================
  3957. *
  3958. *------------------------------------------
  3959. */
  3960. int atcommand_character_save(
  3961. const int fd, struct map_session_data* sd,
  3962. const char* command, const char* message)
  3963. {
  3964. char map_name[100];
  3965. char character[100];
  3966. struct map_session_data* pl_sd;
  3967. int x = 0, y = 0;
  3968. int m;
  3969. memset(map_name, '\0', sizeof(map_name));
  3970. memset(character, '\0', sizeof(character));
  3971. if (!message || !*message || sscanf(message, "%99s %d %d %99[^\n]", map_name, &x, &y, character) < 4 || x < 0 || y < 0) {
  3972. clif_displaymessage(fd, "Please, enter a valid save point and a player name (usage: @charsave <map> <x> <y> <charname>).");
  3973. return -1;
  3974. }
  3975. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  3976. strcat(map_name, ".gat");
  3977. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3978. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change save point only to lower or same gm level
  3979. m = map_mapname2mapid(map_name);
  3980. if (m < 0) {
  3981. clif_displaymessage(fd, msg_table[1]); // Map not found.
  3982. return -1;
  3983. } else {
  3984. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3985. clif_displaymessage(fd, "You are not authorised to set this map as a save map.");
  3986. return -1;
  3987. }
  3988. pc_setsavepoint(pl_sd, map_name, x, y);
  3989. clif_displaymessage(fd, msg_table[57]); // Character's respawn point changed.
  3990. }
  3991. } else {
  3992. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3993. return -1;
  3994. }
  3995. } else {
  3996. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3997. return -1;
  3998. }
  3999. return 0;
  4000. }
  4001. /*==========================================
  4002. *
  4003. *------------------------------------------
  4004. */
  4005. int atcommand_night(
  4006. const int fd, struct map_session_data* sd,
  4007. const char* command, const char* message)
  4008. {
  4009. struct map_session_data *pl_sd;
  4010. int i;
  4011. if (night_flag != 1) {
  4012. night_flag = 1; // 0=day, 1=night [Yor]
  4013. for(i = 0; i < fd_max; i++) {
  4014. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !map[sd->bl.m].flag.indoors) {
  4015. //pl_sd->opt2 |= STATE_BLIND;
  4016. //clif_changeoption(&pl_sd->bl);
  4017. if (battle_config.night_darkness_level > 0)
  4018. clif_specialeffect(&pl_sd->bl, 474 + battle_config.night_darkness_level, 0);
  4019. else {
  4020. //clif_specialeffect(&pl_sd->bl, 483, 0); // default darkness level
  4021. pl_sd->opt2 |= STATE_BLIND;
  4022. clif_changeoption(&pl_sd->bl);
  4023. }
  4024. clif_displaymessage(pl_sd->fd, msg_table[59]); // Night has fallen.
  4025. }
  4026. }
  4027. } else {
  4028. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4029. return -1;
  4030. }
  4031. return 0;
  4032. }
  4033. /*==========================================
  4034. *
  4035. *------------------------------------------
  4036. */
  4037. int atcommand_day(
  4038. const int fd, struct map_session_data* sd,
  4039. const char* command, const char* message)
  4040. {
  4041. struct map_session_data *pl_sd;
  4042. int i;
  4043. if (night_flag != 0) {
  4044. night_flag = 0; // 0=day, 1=night [Yor]
  4045. for(i = 0; i < fd_max; i++) {
  4046. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4047. pl_sd->opt2 &= ~STATE_BLIND;
  4048. clif_changeoption(&pl_sd->bl);
  4049. clif_displaymessage(pl_sd->fd, msg_table[60]); // Day has arrived.
  4050. }
  4051. }
  4052. } else {
  4053. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4054. return -1;
  4055. }
  4056. return 0;
  4057. }
  4058. /*==========================================
  4059. *
  4060. *------------------------------------------
  4061. */
  4062. int atcommand_doom(
  4063. const int fd, struct map_session_data* sd,
  4064. const char* command, const char* message)
  4065. {
  4066. struct map_session_data *pl_sd;
  4067. int i;
  4068. for(i = 0; i < fd_max; i++) {
  4069. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd &&
  4070. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4071. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4072. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4073. }
  4074. }
  4075. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4076. return 0;
  4077. }
  4078. /*==========================================
  4079. *
  4080. *------------------------------------------
  4081. */
  4082. int atcommand_doommap(
  4083. const int fd, struct map_session_data* sd,
  4084. const char* command, const char* message)
  4085. {
  4086. struct map_session_data *pl_sd;
  4087. int i;
  4088. for (i = 0; i < fd_max; i++) {
  4089. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd && sd->bl.m == pl_sd->bl.m &&
  4090. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4091. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4092. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4093. }
  4094. }
  4095. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4096. return 0;
  4097. }
  4098. /*==========================================
  4099. *
  4100. *------------------------------------------
  4101. */
  4102. static void atcommand_raise_sub(struct map_session_data* sd)
  4103. {
  4104. if (sd && sd->state.auth && pc_isdead(sd)) {
  4105. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4106. sd->status.hp = sd->status.max_hp;
  4107. sd->status.sp = sd->status.max_sp;
  4108. pc_setstand(sd);
  4109. clif_updatestatus(sd, SP_HP);
  4110. clif_updatestatus(sd, SP_SP);
  4111. clif_resurrection(&sd->bl, 1);
  4112. if (battle_config.pc_invincible_time > 0)
  4113. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4114. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4115. }
  4116. }
  4117. /*==========================================
  4118. *
  4119. *------------------------------------------
  4120. */
  4121. int atcommand_raise(
  4122. const int fd, struct map_session_data* sd,
  4123. const char* command, const char* message)
  4124. {
  4125. int i;
  4126. for (i = 0; i < fd_max; i++) {
  4127. if (session[i])
  4128. atcommand_raise_sub(session[i]->session_data);
  4129. }
  4130. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4131. return 0;
  4132. }
  4133. /*==========================================
  4134. *
  4135. *------------------------------------------
  4136. */
  4137. int atcommand_raisemap(
  4138. const int fd, struct map_session_data* sd,
  4139. const char* command, const char* message)
  4140. {
  4141. struct map_session_data *pl_sd;
  4142. int i;
  4143. for (i = 0; i < fd_max; i++) {
  4144. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->bl.m == pl_sd->bl.m)
  4145. atcommand_raise_sub(pl_sd);
  4146. }
  4147. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4148. return 0;
  4149. }
  4150. /*==========================================
  4151. * atcommand_character_baselevel @charbaselvlで対象キャラのレベルを上げる
  4152. *------------------------------------------
  4153. */
  4154. int atcommand_character_baselevel(
  4155. const int fd, struct map_session_data* sd,
  4156. const char* command, const char* message)
  4157. {
  4158. struct map_session_data *pl_sd;
  4159. char character[100];
  4160. int level = 0, i;
  4161. memset(character, '\0', sizeof(character));
  4162. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4163. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charbaselvl <#> <nickname>).");
  4164. return -1;
  4165. }
  4166. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4167. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  4168. if (level > 0) {
  4169. if (pl_sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  4170. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  4171. return 0;
  4172. } // End Addition
  4173. if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
  4174. level = battle_config.maximum_level - pl_sd->status.base_level;
  4175. for (i = 1; i <= level; i++)
  4176. pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5;
  4177. pl_sd->status.base_level += level;
  4178. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4179. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4180. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4181. pc_calcstatus(pl_sd, 0);
  4182. pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp);
  4183. clif_misceffect(&pl_sd->bl, 0);
  4184. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  4185. } else {
  4186. if (pl_sd->status.base_level == 1) {
  4187. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  4188. return -1;
  4189. }
  4190. if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) // fix negativ overflow
  4191. level = 1 - pl_sd->status.base_level;
  4192. if (pl_sd->status.status_point > 0) {
  4193. for (i = 0; i > level; i--)
  4194. pl_sd->status.status_point -= (pl_sd->status.base_level + i + 14) / 5;
  4195. if (pl_sd->status.status_point < 0)
  4196. pl_sd->status.status_point = 0;
  4197. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4198. } // to add: remove status points from stats
  4199. pl_sd->status.base_level += level;
  4200. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4201. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4202. pc_calcstatus(pl_sd, 0);
  4203. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  4204. }
  4205. } else {
  4206. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4207. return -1;
  4208. }
  4209. } else {
  4210. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4211. return -1;
  4212. }
  4213. return 0; //正常終了
  4214. }
  4215. /*==========================================
  4216. * atcommand_character_joblevel @charjoblvlで対象キャラのJobレベルを上げる
  4217. *------------------------------------------
  4218. */
  4219. int atcommand_character_joblevel(
  4220. const int fd, struct map_session_data* sd,
  4221. const char* command, const char* message)
  4222. {
  4223. struct map_session_data *pl_sd;
  4224. char character[100];
  4225. int max_level = 50, level = 0;
  4226. //転生や養子の場合の元の職業を算出する
  4227. struct pc_base_job pl_s_class;
  4228. memset(character, '\0', sizeof(character));
  4229. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4230. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charjlvl <#> <nickname>).");
  4231. return -1;
  4232. }
  4233. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4234. pl_s_class = pc_calc_base_job(pl_sd->status.class);
  4235. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  4236. if (pl_s_class.job == 0)
  4237. max_level -= 40;
  4238. if ((pl_s_class.job == 23) || (pl_s_class.upper == 1 && pl_s_class.type == 2)) //スパノビと転生職はJobレベルの最高が70
  4239. // To-do: super novices has max level 99 - celest
  4240. max_level += 20;
  4241. if (level > 0) {
  4242. if (pl_sd->status.job_level == max_level) {
  4243. clif_displaymessage(fd, msg_table[67]); // Character's job level can't go any higher.
  4244. return -1;
  4245. }
  4246. if (pl_sd->status.job_level + level > max_level)
  4247. level = max_level - pl_sd->status.job_level;
  4248. pl_sd->status.job_level += level;
  4249. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4250. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4251. pl_sd->status.skill_point += level;
  4252. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4253. pc_calcstatus(pl_sd, 0);
  4254. clif_misceffect(&pl_sd->bl, 1);
  4255. clif_displaymessage(fd, msg_table[68]); // character's job level raised.
  4256. } else {
  4257. if (pl_sd->status.job_level == 1) {
  4258. clif_displaymessage(fd, msg_table[194]); // Character's job level can't go any lower.
  4259. return -1;
  4260. }
  4261. if (pl_sd->status.job_level + level < 1)
  4262. level = 1 - pl_sd->status.job_level;
  4263. pl_sd->status.job_level += level;
  4264. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4265. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4266. if (pl_sd->status.skill_point > 0) {
  4267. pl_sd->status.skill_point += level;
  4268. if (pl_sd->status.skill_point < 0)
  4269. pl_sd->status.skill_point = 0;
  4270. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4271. } // to add: remove status points from skills
  4272. pc_calcstatus(pl_sd, 0);
  4273. clif_displaymessage(fd, msg_table[69]); // Character's job level lowered.
  4274. }
  4275. } else {
  4276. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4277. return -1;
  4278. }
  4279. } else {
  4280. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4281. return -1;
  4282. }
  4283. return 0;
  4284. }
  4285. /*==========================================
  4286. *
  4287. *------------------------------------------
  4288. */
  4289. int atcommand_kick(
  4290. const int fd, struct map_session_data* sd,
  4291. const char* command, const char* message)
  4292. {
  4293. struct map_session_data *pl_sd;
  4294. char character[100];
  4295. memset(character, '\0', sizeof(character));
  4296. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4297. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4298. return -1;
  4299. }
  4300. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4301. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4302. clif_GM_kick(sd, pl_sd, 1);
  4303. else {
  4304. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4305. return -1;
  4306. }
  4307. } else {
  4308. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4309. return -1;
  4310. }
  4311. return 0;
  4312. }
  4313. /*==========================================
  4314. *
  4315. *------------------------------------------
  4316. */
  4317. int atcommand_kickall(
  4318. const int fd, struct map_session_data* sd,
  4319. const char* command, const char* message)
  4320. {
  4321. struct map_session_data *pl_sd;
  4322. int i;
  4323. for (i = 0; i < fd_max; i++) {
  4324. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4325. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4326. if (sd->status.account_id != pl_sd->status.account_id)
  4327. clif_GM_kick(sd, pl_sd, 0);
  4328. }
  4329. }
  4330. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4331. return 0;
  4332. }
  4333. /*==========================================
  4334. *
  4335. *------------------------------------------
  4336. */
  4337. int atcommand_allskill(
  4338. const int fd, struct map_session_data* sd,
  4339. const char* command, const char* message)
  4340. {
  4341. pc_allskillup(sd); // all skills
  4342. sd->status.skill_point = 0; // 0 skill points
  4343. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4344. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4345. return 0;
  4346. }
  4347. /*==========================================
  4348. *
  4349. *------------------------------------------
  4350. */
  4351. int atcommand_questskill(
  4352. const int fd, struct map_session_data* sd,
  4353. const char* command, const char* message)
  4354. {
  4355. int skill_id;
  4356. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4357. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4358. return -1;
  4359. }
  4360. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4361. if (skill_get_inf2(skill_id) & 0x01) {
  4362. if (pc_checkskill(sd, skill_id) == 0) {
  4363. pc_skill(sd, skill_id, 1, 0);
  4364. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4365. } else {
  4366. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4367. return -1;
  4368. }
  4369. } else {
  4370. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4371. return -1;
  4372. }
  4373. } else {
  4374. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4375. return -1;
  4376. }
  4377. return 0;
  4378. }
  4379. /*==========================================
  4380. *
  4381. *------------------------------------------
  4382. */
  4383. int atcommand_charquestskill(
  4384. const int fd, struct map_session_data* sd,
  4385. const char* command, const char* message)
  4386. {
  4387. char character[100];
  4388. struct map_session_data *pl_sd;
  4389. int skill_id = 0;
  4390. memset(character, '\0', sizeof(character));
  4391. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4392. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charquestskill <#:0+> <char_name>).");
  4393. return -1;
  4394. }
  4395. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4396. if (skill_get_inf2(skill_id) & 0x01) {
  4397. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4398. if (pc_checkskill(pl_sd, skill_id) == 0) {
  4399. pc_skill(pl_sd, skill_id, 1, 0);
  4400. clif_displaymessage(fd, msg_table[199]); // This player has learned the skill.
  4401. } else {
  4402. clif_displaymessage(fd, msg_table[200]); // This player already has this quest skill.
  4403. return -1;
  4404. }
  4405. } else {
  4406. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4407. return -1;
  4408. }
  4409. } else {
  4410. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4411. return -1;
  4412. }
  4413. } else {
  4414. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4415. return -1;
  4416. }
  4417. return 0;
  4418. }
  4419. /*==========================================
  4420. *
  4421. *------------------------------------------
  4422. */
  4423. int atcommand_lostskill(
  4424. const int fd, struct map_session_data* sd,
  4425. const char* command, const char* message)
  4426. {
  4427. int skill_id;
  4428. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4429. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4430. return -1;
  4431. }
  4432. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4433. if (skill_get_inf2(skill_id) & 0x01) {
  4434. if (pc_checkskill(sd, skill_id) > 0) {
  4435. sd->status.skill[skill_id].lv = 0;
  4436. sd->status.skill[skill_id].flag = 0;
  4437. clif_skillinfoblock(sd);
  4438. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4439. } else {
  4440. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4441. return -1;
  4442. }
  4443. } else {
  4444. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4445. return -1;
  4446. }
  4447. } else {
  4448. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4449. return -1;
  4450. }
  4451. return 0;
  4452. }
  4453. /*==========================================
  4454. *
  4455. *------------------------------------------
  4456. */
  4457. int atcommand_charlostskill(
  4458. const int fd, struct map_session_data* sd,
  4459. const char* command, const char* message)
  4460. {
  4461. char character[100];
  4462. struct map_session_data *pl_sd;
  4463. int skill_id = 0;
  4464. memset(character, '\0', sizeof(character));
  4465. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4466. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  4467. return -1;
  4468. }
  4469. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4470. if (skill_get_inf2(skill_id) & 0x01) {
  4471. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4472. if (pc_checkskill(pl_sd, skill_id) > 0) {
  4473. pl_sd->status.skill[skill_id].lv = 0;
  4474. pl_sd->status.skill[skill_id].flag = 0;
  4475. clif_skillinfoblock(pl_sd);
  4476. clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill.
  4477. } else {
  4478. clif_displaymessage(fd, msg_table[203]); // This player doesn't have this quest skill.
  4479. return -1;
  4480. }
  4481. } else {
  4482. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4483. return -1;
  4484. }
  4485. } else {
  4486. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4487. return -1;
  4488. }
  4489. } else {
  4490. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4491. return -1;
  4492. }
  4493. return 0;
  4494. }
  4495. /*==========================================
  4496. *
  4497. *------------------------------------------
  4498. */
  4499. int atcommand_spiritball(
  4500. const int fd, struct map_session_data* sd,
  4501. const char* command, const char* message)
  4502. {
  4503. int number;
  4504. if (!message || !*message || (number = atoi(message)) < 0) {
  4505. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4506. return -1;
  4507. }
  4508. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4509. if (number > 500)
  4510. number = 500;
  4511. if (number >= 0 && number <= 0x7FFF) {
  4512. if (sd->spiritball != number || number > 499) {
  4513. if (sd->spiritball > 0)
  4514. pc_delspiritball(sd, sd->spiritball, 1);
  4515. sd->spiritball = number;
  4516. clif_spiritball(sd);
  4517. // no message, player can look the difference
  4518. if (number > 1000)
  4519. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4520. } else {
  4521. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4522. return -1;
  4523. }
  4524. } else {
  4525. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4526. return -1;
  4527. }
  4528. return 0;
  4529. }
  4530. /*==========================================
  4531. *
  4532. *------------------------------------------
  4533. */
  4534. int atcommand_party(
  4535. const int fd, struct map_session_data* sd,
  4536. const char* command, const char* message)
  4537. {
  4538. char party[100];
  4539. memset(party, '\0', sizeof(party));
  4540. if (!message || !*message || sscanf(message, "%99[^\n]", party) < 1) {
  4541. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4542. return -1;
  4543. }
  4544. party_create(sd, party);
  4545. return 0;
  4546. }
  4547. /*==========================================
  4548. *
  4549. *------------------------------------------
  4550. */
  4551. int atcommand_guild(
  4552. const int fd, struct map_session_data* sd,
  4553. const char* command, const char* message)
  4554. {
  4555. char guild[100];
  4556. int prev;
  4557. memset(guild, '\0', sizeof(guild));
  4558. if (!message || !*message || sscanf(message, "%99[^\n]", guild) < 1) {
  4559. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4560. return -1;
  4561. }
  4562. prev = battle_config.guild_emperium_check;
  4563. battle_config.guild_emperium_check = 0;
  4564. guild_create(sd, guild);
  4565. battle_config.guild_emperium_check = prev;
  4566. return 0;
  4567. }
  4568. /*==========================================
  4569. *
  4570. *------------------------------------------
  4571. */
  4572. int atcommand_agitstart(
  4573. const int fd, struct map_session_data* sd,
  4574. const char* command, const char* message)
  4575. {
  4576. if (agit_flag == 1) {
  4577. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4578. return -1;
  4579. }
  4580. agit_flag = 1;
  4581. guild_agit_start();
  4582. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4583. return 0;
  4584. }
  4585. /*==========================================
  4586. *
  4587. *------------------------------------------
  4588. */
  4589. int atcommand_agitend(
  4590. const int fd, struct map_session_data* sd,
  4591. const char* command, const char* message)
  4592. {
  4593. if (agit_flag == 0) {
  4594. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4595. return -1;
  4596. }
  4597. agit_flag = 0;
  4598. guild_agit_end();
  4599. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4600. return 0;
  4601. }
  4602. /*==========================================
  4603. * @mapexitでマップサーバーを終了させる
  4604. *------------------------------------------
  4605. */
  4606. int atcommand_mapexit(
  4607. const int fd, struct map_session_data* sd,
  4608. const char* command, const char* message)
  4609. {
  4610. struct map_session_data *pl_sd;
  4611. int i;
  4612. for (i = 0; i < fd_max; i++) {
  4613. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4614. if (sd->status.account_id != pl_sd->status.account_id)
  4615. clif_GM_kick(sd, pl_sd, 0);
  4616. }
  4617. }
  4618. clif_GM_kick(sd, sd, 0);
  4619. runflag = 0;
  4620. return 0;
  4621. }
  4622. /*==========================================
  4623. * idsearch <part_of_name>: revrited by [Yor]
  4624. *------------------------------------------
  4625. */
  4626. int atcommand_idsearch(
  4627. const int fd, struct map_session_data* sd,
  4628. const char* command, const char* message)
  4629. {
  4630. char item_name[100];
  4631. char output[200];
  4632. int i, match;
  4633. struct item_data *item;
  4634. memset(item_name, '\0', sizeof(item_name));
  4635. memset(output, '\0', sizeof(output));
  4636. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4637. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4638. return -1;
  4639. }
  4640. sprintf(output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4641. clif_displaymessage(fd, output);
  4642. match = 0;
  4643. for(i = 0; i < 20000; i++) {
  4644. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4645. match++;
  4646. sprintf(output, msg_table[78], item->jname, item->nameid); // %s: %d
  4647. clif_displaymessage(fd, output);
  4648. }
  4649. }
  4650. sprintf(output, msg_table[79], match); // It is %d affair above.
  4651. clif_displaymessage(fd, output);
  4652. return 0;
  4653. }
  4654. /*==========================================
  4655. * Character Skill Reset
  4656. *------------------------------------------
  4657. */
  4658. int atcommand_charskreset(
  4659. const int fd, struct map_session_data* sd,
  4660. const char* command, const char* message)
  4661. {
  4662. char character[100];
  4663. char output[200];
  4664. struct map_session_data *pl_sd;
  4665. memset(character, '\0', sizeof(character));
  4666. memset(output, '\0', sizeof(output));
  4667. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4668. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  4669. return -1;
  4670. }
  4671. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4672. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  4673. pc_resetskill(pl_sd);
  4674. sprintf(output, msg_table[206], character); // '%s' skill points reseted!
  4675. clif_displaymessage(fd, output);
  4676. } else {
  4677. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4678. return -1;
  4679. }
  4680. } else {
  4681. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4682. return -1;
  4683. }
  4684. return 0;
  4685. }
  4686. /*==========================================
  4687. * Character Stat Reset
  4688. *------------------------------------------
  4689. */
  4690. int atcommand_charstreset(
  4691. const int fd, struct map_session_data* sd,
  4692. const char* command, const char* message)
  4693. {
  4694. char character[100];
  4695. char output[200];
  4696. struct map_session_data *pl_sd;
  4697. memset(character, '\0', sizeof(character));
  4698. memset(output, '\0', sizeof(output));
  4699. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4700. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  4701. return -1;
  4702. }
  4703. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4704. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  4705. pc_resetstate(pl_sd);
  4706. sprintf(output, msg_table[207], character); // '%s' stats points reseted!
  4707. clif_displaymessage(fd, output);
  4708. } else {
  4709. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4710. return -1;
  4711. }
  4712. } else {
  4713. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4714. return -1;
  4715. }
  4716. return 0;
  4717. }
  4718. /*==========================================
  4719. * Character Reset
  4720. *------------------------------------------
  4721. */
  4722. int atcommand_charreset(
  4723. const int fd, struct map_session_data* sd,
  4724. const char* command, const char* message)
  4725. {
  4726. char character[100];
  4727. char output[200];
  4728. struct map_session_data *pl_sd;
  4729. memset(character, '\0', sizeof(character));
  4730. memset(output, '\0', sizeof(output));
  4731. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4732. clif_displaymessage(fd, "Please, enter a player name (usage: @charreset <charname>).");
  4733. return -1;
  4734. }
  4735. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4736. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset a character only for lower or same GM level
  4737. pc_resetstate(pl_sd);
  4738. pc_resetskill(pl_sd);
  4739. sprintf(output, msg_table[208], character); // '%s' skill and stats points reseted!
  4740. clif_displaymessage(fd, output);
  4741. } else {
  4742. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4743. return -1;
  4744. }
  4745. } else {
  4746. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4747. return -1;
  4748. }
  4749. return 0;
  4750. }
  4751. /*==========================================
  4752. * Character Model by chbrules
  4753. *------------------------------------------
  4754. */
  4755. int atcommand_charmodel(
  4756. const int fd, struct map_session_data* sd,
  4757. const char* command, const char* message)
  4758. {
  4759. int hair_style = 0, hair_color = 0, cloth_color = 0;
  4760. struct map_session_data *pl_sd;
  4761. char character[100];
  4762. char output[200];
  4763. memset(character, '\0', sizeof(character));
  4764. memset(output, '\0', sizeof(output));
  4765. if (!message || !*message || sscanf(message, "%d %d %d %99[^\n]", &hair_style, &hair_color, &cloth_color, character) < 4 || hair_style < 0 || hair_color < 0 || cloth_color < 0) {
  4766. sprintf(output, "Please, enter a valid model and a player name (usage: @charmodel <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d> <name>).",
  4767. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  4768. clif_displaymessage(fd, output);
  4769. return -1;
  4770. }
  4771. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4772. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  4773. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  4774. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  4775. if (cloth_color != 0 &&
  4776. pl_sd->status.sex == 1 &&
  4777. (pl_sd->status.class == 12 || pl_sd->status.class == 17)) {
  4778. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  4779. return -1;
  4780. } else {
  4781. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  4782. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  4783. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  4784. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  4785. }
  4786. } else {
  4787. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4788. return -1;
  4789. }
  4790. } else {
  4791. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4792. return -1;
  4793. }
  4794. return 0;
  4795. }
  4796. /*==========================================
  4797. * Character Skill Point (Rewritten by [Yor])
  4798. *------------------------------------------
  4799. */
  4800. int atcommand_charskpoint(
  4801. const int fd, struct map_session_data* sd,
  4802. const char* command, const char* message)
  4803. {
  4804. struct map_session_data *pl_sd;
  4805. char character[100];
  4806. int new_skill_point;
  4807. int point = 0;
  4808. memset(character, '\0', sizeof(character));
  4809. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4810. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  4811. return -1;
  4812. }
  4813. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4814. new_skill_point = (int)pl_sd->status.skill_point + point;
  4815. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  4816. new_skill_point = 0x7FFF;
  4817. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  4818. new_skill_point = 0;
  4819. if (new_skill_point != (int)pl_sd->status.skill_point) {
  4820. pl_sd->status.skill_point = new_skill_point;
  4821. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4822. clif_displaymessage(fd, msg_table[209]); // Character's number of skill points changed!
  4823. } else {
  4824. if (point < 0)
  4825. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4826. else
  4827. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4828. return -1;
  4829. }
  4830. } else {
  4831. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4832. return -1;
  4833. }
  4834. return 0;
  4835. }
  4836. /*==========================================
  4837. * Character Status Point (rewritten by [Yor])
  4838. *------------------------------------------
  4839. */
  4840. int atcommand_charstpoint(
  4841. const int fd, struct map_session_data* sd,
  4842. const char* command, const char* message)
  4843. {
  4844. struct map_session_data *pl_sd;
  4845. char character[100];
  4846. int new_status_point;
  4847. int point = 0;
  4848. memset(character, '\0', sizeof(character));
  4849. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4850. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  4851. return -1;
  4852. }
  4853. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4854. new_status_point = (int)pl_sd->status.status_point + point;
  4855. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  4856. new_status_point = 0x7FFF;
  4857. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  4858. new_status_point = 0;
  4859. if (new_status_point != (int)pl_sd->status.status_point) {
  4860. pl_sd->status.status_point = new_status_point;
  4861. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4862. clif_displaymessage(fd, msg_table[210]); // Character's number of status points changed!
  4863. } else {
  4864. if (point < 0)
  4865. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4866. else
  4867. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4868. return -1;
  4869. }
  4870. } else {
  4871. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4872. return -1;
  4873. }
  4874. return 0;
  4875. }
  4876. /*==========================================
  4877. * Character Zeny Point (Rewritten by [Yor])
  4878. *------------------------------------------
  4879. */
  4880. int atcommand_charzeny(
  4881. const int fd, struct map_session_data* sd,
  4882. const char* command, const char* message)
  4883. {
  4884. struct map_session_data *pl_sd;
  4885. char character[100];
  4886. int zeny = 0, new_zeny;
  4887. memset(character, '\0', sizeof(character));
  4888. if (!message || !*message || sscanf(message, "%d %99[^\n]", &zeny, character) < 2 || zeny == 0) {
  4889. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charzeny <zeny> <name>).");
  4890. return -1;
  4891. }
  4892. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4893. new_zeny = pl_sd->status.zeny + zeny;
  4894. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  4895. new_zeny = MAX_ZENY;
  4896. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  4897. new_zeny = 0;
  4898. if (new_zeny != pl_sd->status.zeny) {
  4899. pl_sd->status.zeny = new_zeny;
  4900. clif_updatestatus(pl_sd, SP_ZENY);
  4901. clif_displaymessage(fd, msg_table[211]); // Character's number of zenys changed!
  4902. } else {
  4903. if (zeny < 0)
  4904. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4905. else
  4906. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4907. return -1;
  4908. }
  4909. } else {
  4910. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4911. return -1;
  4912. }
  4913. return 0;
  4914. }
  4915. /*==========================================
  4916. * Recall All Characters Online To Your Location
  4917. *------------------------------------------
  4918. */
  4919. int atcommand_recallall(
  4920. const int fd, struct map_session_data* sd,
  4921. const char* command, const char* message)
  4922. {
  4923. struct map_session_data *pl_sd;
  4924. int i;
  4925. int count;
  4926. char output[200];
  4927. memset(output, '\0', sizeof(output));
  4928. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4929. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4930. return -1;
  4931. }
  4932. count = 0;
  4933. for (i = 0; i < fd_max; i++) {
  4934. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id &&
  4935. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4936. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4937. count++;
  4938. else
  4939. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4940. }
  4941. }
  4942. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4943. if (count) {
  4944. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4945. clif_displaymessage(fd, output);
  4946. }
  4947. return 0;
  4948. }
  4949. /*==========================================
  4950. * Recall online characters of a guild to your location
  4951. *------------------------------------------
  4952. */
  4953. int atcommand_guildrecall(
  4954. const int fd, struct map_session_data* sd,
  4955. const char* command, const char* message)
  4956. {
  4957. struct map_session_data *pl_sd;
  4958. int i;
  4959. char guild_name[100];
  4960. char output[200];
  4961. struct guild *g;
  4962. int count;
  4963. memset(guild_name, '\0', sizeof(guild_name));
  4964. memset(output, '\0', sizeof(output));
  4965. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  4966. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4967. return -1;
  4968. }
  4969. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4970. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4971. return -1;
  4972. }
  4973. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4974. (g = guild_search(atoi(message))) != NULL) {
  4975. count = 0;
  4976. for (i = 0; i < fd_max; i++) {
  4977. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4978. sd->status.account_id != pl_sd->status.account_id &&
  4979. pl_sd->status.guild_id == g->guild_id) {
  4980. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4981. count++;
  4982. else
  4983. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4984. }
  4985. }
  4986. sprintf(output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4987. clif_displaymessage(fd, output);
  4988. if (count) {
  4989. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4990. clif_displaymessage(fd, output);
  4991. }
  4992. } else {
  4993. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4994. return -1;
  4995. }
  4996. return 0;
  4997. }
  4998. /*==========================================
  4999. * Recall online characters of a party to your location
  5000. *------------------------------------------
  5001. */
  5002. int atcommand_partyrecall(
  5003. const int fd, struct map_session_data* sd,
  5004. const char* command, const char* message)
  5005. {
  5006. int i;
  5007. struct map_session_data *pl_sd;
  5008. char party_name[100];
  5009. char output[200];
  5010. struct party *p;
  5011. int count;
  5012. memset(party_name, '\0', sizeof(party_name));
  5013. memset(output, '\0', sizeof(output));
  5014. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  5015. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  5016. return -1;
  5017. }
  5018. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  5019. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  5020. return -1;
  5021. }
  5022. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5023. (p = party_search(atoi(message))) != NULL) {
  5024. count = 0;
  5025. for (i = 0; i < fd_max; i++) {
  5026. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5027. sd->status.account_id != pl_sd->status.account_id &&
  5028. pl_sd->status.party_id == p->party_id) {
  5029. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  5030. count++;
  5031. else
  5032. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  5033. }
  5034. }
  5035. sprintf(output, msg_table[95], p->name); // All online characters of the %s party are near you.
  5036. clif_displaymessage(fd, output);
  5037. if (count) {
  5038. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  5039. clif_displaymessage(fd, output);
  5040. }
  5041. } else {
  5042. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5043. return -1;
  5044. }
  5045. return 0;
  5046. }
  5047. /*==========================================
  5048. *
  5049. *------------------------------------------
  5050. */
  5051. int atcommand_reloaditemdb(
  5052. const int fd, struct map_session_data* sd,
  5053. const char* command, const char* message)
  5054. {
  5055. itemdb_reload();
  5056. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  5057. return 0;
  5058. }
  5059. /*==========================================
  5060. *
  5061. *------------------------------------------
  5062. */
  5063. int atcommand_reloadmobdb(
  5064. const int fd, struct map_session_data* sd,
  5065. const char* command, const char* message)
  5066. {
  5067. mob_reload();
  5068. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  5069. return 0;
  5070. }
  5071. /*==========================================
  5072. *
  5073. *------------------------------------------
  5074. */
  5075. int atcommand_reloadskilldb(
  5076. const int fd, struct map_session_data* sd,
  5077. const char* command, const char* message)
  5078. {
  5079. skill_reload();
  5080. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  5081. return 0;
  5082. }
  5083. /*==========================================
  5084. *
  5085. *------------------------------------------
  5086. */
  5087. #ifndef TXT_ONLY
  5088. int atcommand_rehash(
  5089. #else /* TXT_ONLY */
  5090. int atcommand_reloadscript(
  5091. #endif /* TXT_ONLY */
  5092. const int fd, struct map_session_data* sd,
  5093. const char* command, const char* message)
  5094. {
  5095. #ifndef TXT_ONLY
  5096. atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." );
  5097. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  5098. rehash( fd, sd );
  5099. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  5100. #endif /* not TXT_ONLY */
  5101. do_init_npc();
  5102. do_init_script();
  5103. npc_event_do_oninit();
  5104. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  5105. return 0;
  5106. }
  5107. /*==========================================
  5108. *
  5109. *------------------------------------------
  5110. */
  5111. int atcommand_reloadgmdb( // by [Yor]
  5112. const int fd, struct map_session_data* sd,
  5113. const char* command, const char* message)
  5114. {
  5115. chrif_reloadGMdb();
  5116. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  5117. return 0;
  5118. }
  5119. /*==========================================
  5120. * @mapinfo <map name> [0-3] by MC_Cameri
  5121. * => Shows information about the map [map name]
  5122. * 0 = no additional information
  5123. * 1 = Show users in that map and their location
  5124. * 2 = Shows NPCs in that map
  5125. * 3 = Shows the shops/chats in that map (not implemented)
  5126. *------------------------------------------
  5127. */
  5128. int atcommand_mapinfo(
  5129. const int fd, struct map_session_data* sd,
  5130. const char* command, const char* message)
  5131. {
  5132. struct map_session_data *pl_sd;
  5133. struct npc_data *nd = NULL;
  5134. struct chat_data *cd = NULL;
  5135. char output[200], map_name[100];
  5136. char direction[12];
  5137. int m_id, i, chat_num, list = 0;
  5138. memset(output, '\0', sizeof(output));
  5139. memset(map_name, '\0', sizeof(map_name));
  5140. memset(direction, '\0', sizeof(direction));
  5141. sscanf(message, "%d %99[^\n]", &list, map_name);
  5142. if (list < 0 || list > 3) {
  5143. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5144. return -1;
  5145. }
  5146. if (map_name[0] == '\0')
  5147. strcpy(map_name, sd->mapname);
  5148. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  5149. strcat(map_name, ".gat");
  5150. if ((m_id = map_mapname2mapid(map_name)) < 0) {
  5151. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5152. return -1;
  5153. }
  5154. clif_displaymessage(fd, "------ Map Info ------");
  5155. sprintf(output, "Map Name: %s", map_name);
  5156. clif_displaymessage(fd, output);
  5157. sprintf(output, "Players In Map: %d", map[m_id].users);
  5158. clif_displaymessage(fd, output);
  5159. sprintf(output, "NPCs In Map: %d", map[m_id].npc_num);
  5160. clif_displaymessage(fd, output);
  5161. chat_num = 0;
  5162. for (i = 0; i < fd_max; i++) {
  5163. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5164. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5165. chat_num++;
  5166. }
  5167. }
  5168. sprintf(output, "Chats In Map: %d", chat_num);
  5169. clif_displaymessage(fd, output);
  5170. clif_displaymessage(fd, "------ Map Flags ------");
  5171. sprintf(output, "Player vs Player: %s | No Guild: %s | No Party: %s",
  5172. (map[m_id].flag.pvp) ? "True" : "False",
  5173. (map[m_id].flag.pvp_noguild) ? "True" : "False",
  5174. (map[m_id].flag.pvp_noparty) ? "True" : "False");
  5175. clif_displaymessage(fd, output);
  5176. sprintf(output, "Guild vs Guild: %s | No Party: %s", (map[m_id].flag.gvg) ? "True" : "False", (map[m_id].flag.gvg_noparty) ? "True" : "False");
  5177. clif_displaymessage(fd, output);
  5178. sprintf(output, "No Dead Branch: %s", (map[m_id].flag.nobranch) ? "True" : "False");
  5179. clif_displaymessage(fd, output);
  5180. sprintf(output, "No Memo: %s", (map[m_id].flag.nomemo) ? "True" : "False");
  5181. clif_displaymessage(fd, output);
  5182. sprintf(output, "No Penalty: %s", (map[m_id].flag.nopenalty) ? "True" : "False");
  5183. clif_displaymessage(fd, output);
  5184. sprintf(output, "No Return: %s", (map[m_id].flag.noreturn) ? "True" : "False");
  5185. clif_displaymessage(fd, output);
  5186. sprintf(output, "No Save: %s", (map[m_id].flag.nosave) ? "True" : "False");
  5187. clif_displaymessage(fd, output);
  5188. sprintf(output, "No Teleport: %s", (map[m_id].flag.noteleport) ? "True" : "False");
  5189. clif_displaymessage(fd, output);
  5190. sprintf(output, "No Monster Teleport: %s", (map[m_id].flag.monster_noteleport) ? "True" : "False");
  5191. clif_displaymessage(fd, output);
  5192. sprintf(output, "No Zeny Penalty: %s", (map[m_id].flag.nozenypenalty) ? "True" : "False");
  5193. clif_displaymessage(fd, output);
  5194. switch (list) {
  5195. case 0:
  5196. // Do nothing. It's list 0, no additional display.
  5197. break;
  5198. case 1:
  5199. clif_displaymessage(fd, "----- Players in Map -----");
  5200. for (i = 0; i < fd_max; i++) {
  5201. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && strcmp(pl_sd->mapname, map_name) == 0) {
  5202. sprintf(output, "Player '%s' (session #%d) | Location: %d,%d",
  5203. pl_sd->status.name, i, pl_sd->bl.x, pl_sd->bl.y);
  5204. clif_displaymessage(fd, output);
  5205. }
  5206. }
  5207. break;
  5208. case 2:
  5209. clif_displaymessage(fd, "----- NPCs in Map -----");
  5210. for (i = 0; i < map[m_id].npc_num;) {
  5211. nd = map[m_id].npc[i];
  5212. switch(nd->dir) {
  5213. case 0: strcpy(direction, "North"); break;
  5214. case 1: strcpy(direction, "North West"); break;
  5215. case 2: strcpy(direction, "West"); break;
  5216. case 3: strcpy(direction, "South West"); break;
  5217. case 4: strcpy(direction, "South"); break;
  5218. case 5: strcpy(direction, "South East"); break;
  5219. case 6: strcpy(direction, "East"); break;
  5220. case 7: strcpy(direction, "North East"); break;
  5221. case 9: strcpy(direction, "North"); break;
  5222. default: strcpy(direction, "Unknown"); break;
  5223. }
  5224. sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5225. ++i, nd->name, direction, nd->class, nd->bl.x, nd->bl.y);
  5226. clif_displaymessage(fd, output);
  5227. }
  5228. break;
  5229. case 3:
  5230. clif_displaymessage(fd, "----- Chats in Map -----");
  5231. for (i = 0; i < fd_max; i++) {
  5232. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5233. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5234. strcmp(pl_sd->mapname, map_name) == 0 &&
  5235. cd->usersd[0] == pl_sd) {
  5236. sprintf(output, "Chat %d: %s | Player: %s | Location: %d %d",
  5237. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5238. clif_displaymessage(fd, output);
  5239. sprintf(output, " Users: %d/%d | Password: %s | Public: %s",
  5240. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5241. clif_displaymessage(fd, output);
  5242. }
  5243. }
  5244. break;
  5245. default: // normally impossible to arrive here
  5246. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5247. return -1;
  5248. break;
  5249. }
  5250. return 0;
  5251. }
  5252. /*==========================================
  5253. *
  5254. *------------------------------------------
  5255. */
  5256. int atcommand_mount_peco(
  5257. const int fd, struct map_session_data* sd,
  5258. const char* command, const char* message)
  5259. {
  5260. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5261. clif_displaymessage(fd, msg_table[212]); // Cannot mount a Peco while in disguise.
  5262. return -1;
  5263. }
  5264. if (!pc_isriding(sd)) { // if actually no peco
  5265. if (sd->status.class == 7 || sd->status.class == 14 || sd->status.class == 4008 || sd->status.class == 4015) {
  5266. if (sd->status.class == 7)
  5267. sd->status.class = sd->view_class = 13;
  5268. else if (sd->status.class == 14)
  5269. sd->status.class = sd->view_class = 21;
  5270. else if (sd->status.class == 4008)
  5271. sd->status.class = sd->view_class = 4014;
  5272. else if (sd->status.class == 4015)
  5273. sd->status.class = sd->view_class = 4022;
  5274. pc_setoption(sd, sd->status.option | 0x0020);
  5275. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5276. } else {
  5277. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5278. return -1;
  5279. }
  5280. } else {
  5281. if (sd->status.class == 13)
  5282. sd->status.class = sd->view_class = 7;
  5283. else if (sd->status.class == 21)
  5284. sd->status.class = sd->view_class = 14;
  5285. else if (sd->status.class == 4014)
  5286. sd->status.class = sd->view_class = 4008;
  5287. else if (sd->status.class == 4022)
  5288. sd->status.class = sd->view_class = 4015;
  5289. pc_setoption(sd, sd->status.option & ~0x0020);
  5290. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5291. }
  5292. return 0;
  5293. }
  5294. /*==========================================
  5295. *
  5296. *------------------------------------------
  5297. */
  5298. int atcommand_char_mount_peco(
  5299. const int fd, struct map_session_data* sd,
  5300. const char* command, const char* message)
  5301. {
  5302. char character[100];
  5303. struct map_session_data *pl_sd;
  5304. memset(character, '\0', sizeof(character));
  5305. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5306. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5307. return -1;
  5308. }
  5309. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5310. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5311. clif_displaymessage(fd, msg_table[215]); // This player cannot mount a Peco while in disguise.
  5312. return -1;
  5313. }
  5314. if (!pc_isriding(pl_sd)) { // if actually no peco
  5315. if (pl_sd->status.class == 7 || pl_sd->status.class == 14 || pl_sd->status.class == 4008 || pl_sd->status.class == 4015) {
  5316. if (pl_sd->status.class == 7)
  5317. pl_sd->status.class = pl_sd->view_class = 13;
  5318. else if (pl_sd->status.class == 14)
  5319. pl_sd->status.class = pl_sd->view_class = 21;
  5320. else if (pl_sd->status.class == 4008)
  5321. pl_sd->status.class = pl_sd->view_class = 4014;
  5322. else if (pl_sd->status.class == 4015)
  5323. pl_sd->status.class = pl_sd->view_class = 4022;
  5324. pc_setoption(pl_sd, pl_sd->status.option | 0x0020);
  5325. clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco.
  5326. } else {
  5327. clif_displaymessage(fd, msg_table[217]); // This player can not mount a peco with his/her job.
  5328. return -1;
  5329. }
  5330. } else {
  5331. if (pl_sd->status.class == 13)
  5332. pl_sd->status.class = pl_sd->view_class = 7;
  5333. else if (pl_sd->status.class == 21)
  5334. pl_sd->status.class = pl_sd->view_class = 14;
  5335. else if (pl_sd->status.class == 4014)
  5336. pl_sd->status.class = pl_sd->view_class = 4008;
  5337. else if (pl_sd->status.class == 4022)
  5338. pl_sd->status.class = pl_sd->view_class = 4015;
  5339. pc_setoption(pl_sd, pl_sd->status.option & ~0x0020);
  5340. clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco.
  5341. }
  5342. } else {
  5343. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5344. return -1;
  5345. }
  5346. return 0;
  5347. }
  5348. /*==========================================
  5349. *Spy Commands by Syrus22
  5350. *------------------------------------------
  5351. */
  5352. int atcommand_guildspy(
  5353. const int fd, struct map_session_data* sd,
  5354. const char* command, const char* message)
  5355. {
  5356. char guild_name[100];
  5357. char output[200];
  5358. struct guild *g;
  5359. memset(guild_name, '\0', sizeof(guild_name));
  5360. memset(output, '\0', sizeof(output));
  5361. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  5362. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5363. return -1;
  5364. }
  5365. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5366. (g = guild_search(atoi(message))) != NULL) {
  5367. if (sd->guildspy == g->guild_id) {
  5368. sd->guildspy = 0;
  5369. sprintf(output, msg_table[103], g->name); // No longer spying on the %s guild.
  5370. clif_displaymessage(fd, output);
  5371. } else {
  5372. sd->guildspy = g->guild_id;
  5373. sprintf(output, msg_table[104], g->name); // Spying on the %s guild.
  5374. clif_displaymessage(fd, output);
  5375. }
  5376. } else {
  5377. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5378. return -1;
  5379. }
  5380. return 0;
  5381. }
  5382. /*==========================================
  5383. *
  5384. *------------------------------------------
  5385. */
  5386. int atcommand_partyspy(
  5387. const int fd, struct map_session_data* sd,
  5388. const char* command, const char* message)
  5389. {
  5390. char party_name[100];
  5391. char output[200];
  5392. struct party *p;
  5393. memset(party_name, '\0', sizeof(party_name));
  5394. memset(output, '\0', sizeof(output));
  5395. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  5396. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5397. return -1;
  5398. }
  5399. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5400. (p = party_search(atoi(message))) != NULL) {
  5401. if (sd->partyspy == p->party_id) {
  5402. sd->partyspy = 0;
  5403. sprintf(output, msg_table[105], p->name); // No longer spying on the %s party.
  5404. clif_displaymessage(fd, output);
  5405. } else {
  5406. sd->partyspy = p->party_id;
  5407. sprintf(output, msg_table[106], p->name); // Spying on the %s party.
  5408. clif_displaymessage(fd, output);
  5409. }
  5410. } else {
  5411. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5412. return -1;
  5413. }
  5414. return 0;
  5415. }
  5416. /*==========================================
  5417. * @repairall [Valaris]
  5418. *------------------------------------------
  5419. */
  5420. int atcommand_repairall(
  5421. const int fd, struct map_session_data* sd,
  5422. const char* command, const char* message)
  5423. {
  5424. int count, i;
  5425. count = 0;
  5426. for (i = 0; i < MAX_INVENTORY; i++) {
  5427. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5428. sd->status.inventory[i].attribute = 0;
  5429. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5430. count++;
  5431. }
  5432. }
  5433. if (count > 0) {
  5434. clif_misceffect(&sd->bl, 3);
  5435. clif_equiplist(sd);
  5436. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5437. } else {
  5438. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5439. return -1;
  5440. }
  5441. return 0;
  5442. }
  5443. /* Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5444. int atcommand_nuke(
  5445. const int fd, struct map_session_data* sd,
  5446. const char* command, const char* message)
  5447. {
  5448. char character[100];
  5449. struct map_session_data *pl_sd;
  5450. memset(character, '\0', sizeof(character));
  5451. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5452. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5453. return -1;
  5454. }
  5455. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5456. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5457. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5458. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5459. } else {
  5460. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5461. return -1;
  5462. }
  5463. } else {
  5464. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5465. return -1;
  5466. }
  5467. return 0;
  5468. }
  5469. */
  5470. /*==========================================
  5471. *
  5472. *------------------------------------------
  5473. */
  5474. int atcommand_enablenpc(const int fd, struct map_session_data* sd,
  5475. const char* command, const char* message)
  5476. {
  5477. char NPCname[100];
  5478. memset(NPCname, '\0', sizeof(NPCname));
  5479. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5480. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcon <NPC_name>).");
  5481. return -1;
  5482. }
  5483. if (npc_name2id(NPCname) != NULL) {
  5484. npc_enable(NPCname, 1);
  5485. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5486. } else {
  5487. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5488. return -1;
  5489. }
  5490. return 0;
  5491. }
  5492. /*==========================================
  5493. *
  5494. *------------------------------------------
  5495. */
  5496. int atcommand_disablenpc(const int fd, struct map_session_data* sd,
  5497. const char* command, const char* message)
  5498. {
  5499. char NPCname[100];
  5500. memset(NPCname, '\0', sizeof(NPCname));
  5501. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5502. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5503. return -1;
  5504. }
  5505. if (npc_name2id(NPCname) != NULL) {
  5506. npc_enable(NPCname, 0);
  5507. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5508. } else {
  5509. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5510. return -1;
  5511. }
  5512. return 0;
  5513. }
  5514. /*==========================================
  5515. * time in txt for time command (by [Yor])
  5516. *------------------------------------------
  5517. */
  5518. char * txt_time(unsigned int duration) {
  5519. int days, hours, minutes, seconds;
  5520. char temp[256];
  5521. static char temp1[256];
  5522. memset(temp, '\0', sizeof(temp));
  5523. memset(temp1, '\0', sizeof(temp1));
  5524. if (duration < 0)
  5525. duration = 0;
  5526. days = duration / (60 * 60 * 24);
  5527. duration = duration - (60 * 60 * 24 * days);
  5528. hours = duration / (60 * 60);
  5529. duration = duration - (60 * 60 * hours);
  5530. minutes = duration / 60;
  5531. seconds = duration - (60 * minutes);
  5532. if (days < 2)
  5533. sprintf(temp, msg_table[219], days); // %d day
  5534. else
  5535. sprintf(temp, msg_table[220], days); // %d days
  5536. if (hours < 2)
  5537. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5538. else
  5539. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5540. if (minutes < 2)
  5541. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5542. else
  5543. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5544. if (seconds < 2)
  5545. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5546. else
  5547. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5548. return temp1;
  5549. }
  5550. /*==========================================
  5551. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5552. * Calculation management of GM modification (@day/@night GM commands) is done
  5553. *------------------------------------------
  5554. */
  5555. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5556. const char* command, const char* message)
  5557. {
  5558. struct TimerData * timer_data;
  5559. struct TimerData * timer_data2;
  5560. time_t time_server; // variable for number of seconds (used with time() function)
  5561. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5562. char temp[256];
  5563. memset(temp, '\0', sizeof(temp));
  5564. time(&time_server); // get time in seconds since 1/1/1970
  5565. datetime = localtime(&time_server); // convert seconds in structure
  5566. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5567. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5568. clif_displaymessage(fd, temp);
  5569. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5570. if (night_flag == 0)
  5571. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5572. else
  5573. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5574. } else if (battle_config.night_duration == 0)
  5575. if (night_flag == 1) { // we start with night
  5576. timer_data = get_timer(day_timer_tid);
  5577. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5578. clif_displaymessage(fd, temp);
  5579. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5580. } else
  5581. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5582. else if (battle_config.day_duration == 0)
  5583. if (night_flag == 0) { // we start with day
  5584. timer_data = get_timer(night_timer_tid);
  5585. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5586. clif_displaymessage(fd, temp);
  5587. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5588. } else
  5589. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5590. else {
  5591. if (night_flag == 0) {
  5592. timer_data = get_timer(night_timer_tid);
  5593. timer_data2 = get_timer(day_timer_tid);
  5594. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5595. clif_displaymessage(fd, temp);
  5596. if (timer_data->tick > timer_data2->tick)
  5597. sprintf(temp, msg_table[237], txt_time((timer_data->interval - abs(timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5598. else
  5599. sprintf(temp, msg_table[237], txt_time(abs(timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in night for %s.
  5600. clif_displaymessage(fd, temp);
  5601. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5602. clif_displaymessage(fd, temp);
  5603. } else {
  5604. timer_data = get_timer(day_timer_tid);
  5605. timer_data2 = get_timer(night_timer_tid);
  5606. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5607. clif_displaymessage(fd, temp);
  5608. if (timer_data->tick > timer_data2->tick)
  5609. sprintf(temp, msg_table[239], txt_time((timer_data->interval - abs(timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5610. else
  5611. sprintf(temp, msg_table[239], txt_time(abs(timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5612. clif_displaymessage(fd, temp);
  5613. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5614. clif_displaymessage(fd, temp);
  5615. }
  5616. }
  5617. return 0;
  5618. }
  5619. /*==========================================
  5620. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5621. * removes <quantity> item from a character
  5622. * item can be equiped or not.
  5623. * Inspired from a old command created by RoVeRT
  5624. *------------------------------------------
  5625. */
  5626. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5627. const char* command, const char* message)
  5628. {
  5629. struct map_session_data *pl_sd;
  5630. char character[100];
  5631. char item_name[100];
  5632. int i, number = 0, item_id, item_position, count;
  5633. char output[200];
  5634. struct item_data *item_data;
  5635. memset(character, '\0', sizeof(character));
  5636. memset(item_name, '\0', sizeof(item_name));
  5637. memset(output, '\0', sizeof(output));
  5638. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, character) < 3 || number < 1) {
  5639. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5640. return -1;
  5641. }
  5642. item_id = 0;
  5643. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5644. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5645. item_id = item_data->nameid;
  5646. if (item_id > 500) {
  5647. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5648. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5649. item_position = pc_search_inventory(pl_sd, item_id);
  5650. if (item_position >= 0) {
  5651. count = 0;
  5652. for(i = 0; i < number && item_position >= 0; i++) {
  5653. pc_delitem(pl_sd, item_position, 1, 0);
  5654. count++;
  5655. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5656. }
  5657. sprintf(output, msg_table[113], count); // %d item(s) removed by a GM.
  5658. clif_displaymessage(pl_sd->fd, output);
  5659. if (number == count)
  5660. sprintf(output, msg_table[114], count); // %d item(s) removed from the player.
  5661. else
  5662. sprintf(output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5663. clif_displaymessage(fd, output);
  5664. } else {
  5665. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5666. return -1;
  5667. }
  5668. } else {
  5669. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5670. return -1;
  5671. }
  5672. } else {
  5673. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5674. return -1;
  5675. }
  5676. } else {
  5677. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5678. return -1;
  5679. }
  5680. return 0;
  5681. }
  5682. /*==========================================
  5683. * @jail <char_name> by [Yor]
  5684. * Special warp! No check with nowarp and nowarpto flag
  5685. *------------------------------------------
  5686. */
  5687. int atcommand_jail(
  5688. const int fd, struct map_session_data* sd,
  5689. const char* command, const char* message)
  5690. {
  5691. char character[100];
  5692. struct map_session_data *pl_sd;
  5693. int x, y;
  5694. memset(character, '\0', sizeof(character));
  5695. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5696. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5697. return -1;
  5698. }
  5699. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5700. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5701. switch(rand() % 2) {
  5702. case 0:
  5703. x = 24;
  5704. y = 75;
  5705. break;
  5706. default:
  5707. x = 49;
  5708. y = 75;
  5709. break;
  5710. }
  5711. if (pc_setpos(pl_sd, "sec_pri.gat", x, y, 3) == 0) {
  5712. pc_setsavepoint(pl_sd, "sec_pri.gat", x, y); // Save Char Respawn Point in the jail room [Lupus]
  5713. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5714. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5715. } else {
  5716. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5717. return -1;
  5718. }
  5719. } else {
  5720. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5721. return -1;
  5722. }
  5723. } else {
  5724. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5725. return -1;
  5726. }
  5727. return 0;
  5728. }
  5729. /*==========================================
  5730. * @unjail/@discharge <char_name> by [Yor]
  5731. * Special warp! No check with nowarp and nowarpto flag
  5732. *------------------------------------------
  5733. */
  5734. int atcommand_unjail(
  5735. const int fd, struct map_session_data* sd,
  5736. const char* command, const char* message)
  5737. {
  5738. char character[100];
  5739. struct map_session_data *pl_sd;
  5740. memset(character, '\0', sizeof(character));
  5741. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5742. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5743. return -1;
  5744. }
  5745. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5746. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5747. if (pl_sd->bl.m != map_mapname2mapid("sec_pri.gat")) {
  5748. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5749. return -1;
  5750. } else if (pc_setpos(pl_sd, "prontera.gat", 156, 191, 3) == 0) {
  5751. pc_setsavepoint(pl_sd, "prontera.gat", 156, 191); // Save char respawn point in Prontera
  5752. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5753. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5754. } else {
  5755. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5756. return -1;
  5757. }
  5758. } else {
  5759. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5760. return -1;
  5761. }
  5762. } else {
  5763. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5764. return -1;
  5765. }
  5766. return 0;
  5767. }
  5768. /*==========================================
  5769. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5770. *------------------------------------------
  5771. */
  5772. int atcommand_disguise(
  5773. const int fd, struct map_session_data* sd,
  5774. const char* command, const char* message)
  5775. {
  5776. int mob_id = 0;
  5777. if (!message || !*message) {
  5778. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5779. return -1;
  5780. }
  5781. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5782. mob_id = atoi(message);
  5783. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5784. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5785. (mob_id >= 813 && mob_id <= 834) || // NPC
  5786. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5787. if (pc_isriding(sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5788. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5789. return -1;
  5790. }
  5791. sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5792. sd->disguise = mob_id;
  5793. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5794. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5795. } else {
  5796. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5797. return -1;
  5798. }
  5799. return 0;
  5800. }
  5801. /*==========================================
  5802. * @undisguise by [Yor]
  5803. *------------------------------------------
  5804. */
  5805. int atcommand_undisguise(
  5806. const int fd, struct map_session_data* sd,
  5807. const char* command, const char* message)
  5808. {
  5809. if (sd->disguise) {
  5810. clif_clearchar(&sd->bl, 9);
  5811. sd->disguise = 0;
  5812. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5813. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5814. } else {
  5815. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5816. return -1;
  5817. }
  5818. return 0;
  5819. }
  5820. /*==========================================
  5821. * @broadcast by [Valaris]
  5822. *------------------------------------------
  5823. */
  5824. int atcommand_broadcast(
  5825. const int fd, struct map_session_data* sd,
  5826. const char* command, const char* message)
  5827. {
  5828. char output[200];
  5829. memset(output, '\0', sizeof(output));
  5830. if (!message || !*message) {
  5831. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5832. return -1;
  5833. }
  5834. sprintf(output, "%s : %s", sd->status.name, message);
  5835. intif_GMmessage(output, strlen(output) + 1, 0);
  5836. return 0;
  5837. }
  5838. /*==========================================
  5839. * @localbroadcast by [Valaris]
  5840. *------------------------------------------
  5841. */
  5842. int atcommand_localbroadcast(
  5843. const int fd, struct map_session_data* sd,
  5844. const char* command, const char* message)
  5845. {
  5846. char output[200];
  5847. memset(output, '\0', sizeof(output));
  5848. if (!message || !*message) {
  5849. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5850. return -1;
  5851. }
  5852. sprintf(output, "%s : %s", sd->status.name, message);
  5853. clif_GMmessage(&sd->bl, output, strlen(output) + 1, 1); // 1: ALL_SAMEMAP
  5854. return 0;
  5855. }
  5856. /*==========================================
  5857. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5858. *------------------------------------------
  5859. */
  5860. int atcommand_chardisguise(
  5861. const int fd, struct map_session_data* sd,
  5862. const char* command, const char* message)
  5863. {
  5864. int mob_id;
  5865. char character[100];
  5866. char mob_name[100];
  5867. struct map_session_data* pl_sd;
  5868. memset(character, '\0', sizeof(character));
  5869. memset(mob_name, '\0', sizeof(mob_name));
  5870. if (!message || !*message || sscanf(message, "%s %99[^\n]", mob_name, character) < 2) {
  5871. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5872. return -1;
  5873. }
  5874. if ((mob_id = mobdb_searchname(mob_name)) == 0) // check name first (to avoid possible name begining by a number)
  5875. mob_id = atoi(mob_name);
  5876. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5877. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5878. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5879. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5880. (mob_id >= 813 && mob_id <= 834) || // NPC
  5881. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5882. if (pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5883. clif_displaymessage(fd, msg_table[228]); // Character cannot wear disguise while riding a Peco.
  5884. return -1;
  5885. }
  5886. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5887. pl_sd->disguise = mob_id;
  5888. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5889. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5890. } else {
  5891. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5892. return -1;
  5893. }
  5894. } else {
  5895. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5896. return -1;
  5897. }
  5898. } else {
  5899. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5900. return -1;
  5901. }
  5902. return 0;
  5903. }
  5904. /*==========================================
  5905. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5906. *------------------------------------------
  5907. */
  5908. int atcommand_charundisguise(
  5909. const int fd, struct map_session_data* sd,
  5910. const char* command, const char* message)
  5911. {
  5912. char character[100];
  5913. struct map_session_data* pl_sd;
  5914. memset(character, '\0', sizeof(character));
  5915. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5916. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5917. return -1;
  5918. }
  5919. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5920. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5921. if (pl_sd->disguise) {
  5922. clif_clearchar(&pl_sd->bl, 9);
  5923. pl_sd->disguise = 0;
  5924. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5925. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5926. } else {
  5927. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5928. return -1;
  5929. }
  5930. } else {
  5931. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5932. return -1;
  5933. }
  5934. } else {
  5935. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5936. return -1;
  5937. }
  5938. return 0;
  5939. }
  5940. /*==========================================
  5941. * @email <actual@email> <new@email> by [Yor]
  5942. *------------------------------------------
  5943. */
  5944. int atcommand_email(
  5945. const int fd, struct map_session_data* sd,
  5946. const char* command, const char* message)
  5947. {
  5948. char actual_email[100];
  5949. char new_email[100];
  5950. memset(actual_email, '\0', sizeof(actual_email));
  5951. memset(new_email, '\0', sizeof(new_email));
  5952. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5953. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5954. return -1;
  5955. }
  5956. if (e_mail_check(actual_email) == 0) {
  5957. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5958. return -1;
  5959. } else if (e_mail_check(new_email) == 0) {
  5960. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5961. return -1;
  5962. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5963. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5964. return -1;
  5965. } else if (strcmpi(actual_email, new_email) == 0) {
  5966. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5967. return -1;
  5968. } else {
  5969. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5970. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5971. }
  5972. return 0;
  5973. }
  5974. /*==========================================
  5975. *@effect
  5976. *------------------------------------------
  5977. */
  5978. int atcommand_effect(
  5979. const int fd, struct map_session_data* sd,
  5980. const char* command, const char* message)
  5981. {
  5982. struct map_session_data *pl_sd;
  5983. int type = 0, flag = 0, i;
  5984. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5985. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5986. return -1;
  5987. }
  5988. if(flag <=0){
  5989. clif_specialeffect(&sd->bl, type, flag);
  5990. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5991. }
  5992. else{
  5993. for (i = 0; i < fd_max; i++) {
  5994. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  5995. clif_specialeffect(&pl_sd->bl, type, flag);
  5996. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5997. }
  5998. }
  5999. }
  6000. return 0;
  6001. }
  6002. /*==========================================
  6003. * @charitemlist <character>: Displays the list of a player's items.
  6004. *------------------------------------------
  6005. */
  6006. int
  6007. atcommand_character_item_list(
  6008. const int fd, struct map_session_data* sd,
  6009. const char* command, const char* message)
  6010. {
  6011. struct map_session_data *pl_sd;
  6012. struct item_data *item_data, *item_temp;
  6013. int i, j, equip, count, counter, counter2;
  6014. char character[100], output[200], equipstr[100], outputtmp[200];
  6015. memset(character, '\0', sizeof(character));
  6016. memset(output, '\0', sizeof(output));
  6017. memset(equipstr, '\0', sizeof(equipstr));
  6018. memset(outputtmp, '\0', sizeof(outputtmp));
  6019. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  6020. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6021. return -1;
  6022. }
  6023. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6024. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6025. counter = 0;
  6026. count = 0;
  6027. for (i = 0; i < MAX_INVENTORY; i++) {
  6028. if (pl_sd->status.inventory[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.inventory[i].nameid)) != NULL) {
  6029. counter = counter + pl_sd->status.inventory[i].amount;
  6030. count++;
  6031. if (count == 1) {
  6032. sprintf(output, "------ Items list of '%s' ------", pl_sd->status.name);
  6033. clif_displaymessage(fd, output);
  6034. }
  6035. if ((equip = pl_sd->status.inventory[i].equip)) {
  6036. strcpy(equipstr, "| equiped: ");
  6037. if (equip & 4)
  6038. strcat(equipstr, "robe/gargment, ");
  6039. if (equip & 8)
  6040. strcat(equipstr, "left accessory, ");
  6041. if (equip & 16)
  6042. strcat(equipstr, "body/armor, ");
  6043. if ((equip & 34) == 2)
  6044. strcat(equipstr, "right hand, ");
  6045. if ((equip & 34) == 32)
  6046. strcat(equipstr, "left hand, ");
  6047. if ((equip & 34) == 34)
  6048. strcat(equipstr, "both hands, ");
  6049. if (equip & 64)
  6050. strcat(equipstr, "feet, ");
  6051. if (equip & 128)
  6052. strcat(equipstr, "right accessory, ");
  6053. if ((equip & 769) == 1)
  6054. strcat(equipstr, "lower head, ");
  6055. if ((equip & 769) == 256)
  6056. strcat(equipstr, "top head, ");
  6057. if ((equip & 769) == 257)
  6058. strcat(equipstr, "lower/top head, ");
  6059. if ((equip & 769) == 512)
  6060. strcat(equipstr, "mid head, ");
  6061. if ((equip & 769) == 512)
  6062. strcat(equipstr, "lower/mid head, ");
  6063. if ((equip & 769) == 769)
  6064. strcat(equipstr, "lower/mid/top head, ");
  6065. // remove final ', '
  6066. equipstr[strlen(equipstr) - 2] = '\0';
  6067. } else
  6068. memset(equipstr, '\0', sizeof(equipstr));
  6069. if (sd->status.inventory[i].refine)
  6070. sprintf(output, "%d %s %+d (%s %+d, id: %d) %s", pl_sd->status.inventory[i].amount, item_data->name, pl_sd->status.inventory[i].refine, item_data->jname, pl_sd->status.inventory[i].refine, pl_sd->status.inventory[i].nameid, equipstr);
  6071. else
  6072. sprintf(output, "%d %s (%s, id: %d) %s", pl_sd->status.inventory[i].amount, item_data->name, item_data->jname, pl_sd->status.inventory[i].nameid, equipstr);
  6073. clif_displaymessage(fd, output);
  6074. memset(output, '\0', sizeof(output));
  6075. counter2 = 0;
  6076. for (j = 0; j < item_data->slot; j++) {
  6077. if (pl_sd->status.inventory[i].card[j]) {
  6078. if ((item_temp = itemdb_search(pl_sd->status.inventory[i].card[j])) != NULL) {
  6079. if (output[0] == '\0')
  6080. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6081. else
  6082. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6083. strcat(output, outputtmp);
  6084. }
  6085. }
  6086. }
  6087. if (output[0] != '\0') {
  6088. output[strlen(output) - 2] = ')';
  6089. output[strlen(output) - 1] = '\0';
  6090. clif_displaymessage(fd, output);
  6091. }
  6092. }
  6093. }
  6094. if (count == 0)
  6095. clif_displaymessage(fd, "No item found on this player.");
  6096. else {
  6097. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6098. clif_displaymessage(fd, output);
  6099. }
  6100. } else {
  6101. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6102. return -1;
  6103. }
  6104. } else {
  6105. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6106. return -1;
  6107. }
  6108. return 0;
  6109. }
  6110. /*==========================================
  6111. * @charstoragelist <character>: Displays the items list of a player's storage.
  6112. *------------------------------------------
  6113. */
  6114. int
  6115. atcommand_character_storage_list(
  6116. const int fd, struct map_session_data* sd,
  6117. const char* command, const char* message)
  6118. {
  6119. struct storage *stor;
  6120. struct map_session_data *pl_sd;
  6121. struct item_data *item_data, *item_temp;
  6122. int i, j, count, counter, counter2;
  6123. char character[100], output[200], outputtmp[200];
  6124. memset(character, '\0', sizeof(character));
  6125. memset(output, '\0', sizeof(output));
  6126. memset(outputtmp, '\0', sizeof(outputtmp));
  6127. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  6128. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6129. return -1;
  6130. }
  6131. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6132. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6133. if((stor = account2storage2(pl_sd->status.account_id)) != NULL) {
  6134. counter = 0;
  6135. count = 0;
  6136. for (i = 0; i < MAX_STORAGE; i++) {
  6137. if (stor->storage[i].nameid > 0 && (item_data = itemdb_search(stor->storage[i].nameid)) != NULL) {
  6138. counter = counter + stor->storage[i].amount;
  6139. count++;
  6140. if (count == 1) {
  6141. sprintf(output, "------ Storage items list of '%s' ------", pl_sd->status.name);
  6142. clif_displaymessage(fd, output);
  6143. }
  6144. if (stor->storage[i].refine)
  6145. sprintf(output, "%d %s %+d (%s %+d, id: %d)", stor->storage[i].amount, item_data->name, stor->storage[i].refine, item_data->jname, stor->storage[i].refine, stor->storage[i].nameid);
  6146. else
  6147. sprintf(output, "%d %s (%s, id: %d)", stor->storage[i].amount, item_data->name, item_data->jname, stor->storage[i].nameid);
  6148. clif_displaymessage(fd, output);
  6149. memset(output, '\0', sizeof(output));
  6150. counter2 = 0;
  6151. for (j = 0; j < item_data->slot; j++) {
  6152. if (stor->storage[i].card[j]) {
  6153. if ((item_temp = itemdb_search(stor->storage[i].card[j])) != NULL) {
  6154. if (output[0] == '\0')
  6155. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6156. else
  6157. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6158. strcat(output, outputtmp);
  6159. }
  6160. }
  6161. }
  6162. if (output[0] != '\0') {
  6163. output[strlen(output) - 2] = ')';
  6164. output[strlen(output) - 1] = '\0';
  6165. clif_displaymessage(fd, output);
  6166. }
  6167. }
  6168. }
  6169. if (count == 0)
  6170. clif_displaymessage(fd, "No item found in the storage of this player.");
  6171. else {
  6172. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6173. clif_displaymessage(fd, output);
  6174. }
  6175. } else {
  6176. clif_displaymessage(fd, "This player has no storage.");
  6177. return 0;
  6178. }
  6179. } else {
  6180. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6181. return -1;
  6182. }
  6183. } else {
  6184. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6185. return -1;
  6186. }
  6187. return 0;
  6188. }
  6189. /*==========================================
  6190. * @charcartlist <character>: Displays the items list of a player's cart.
  6191. *------------------------------------------
  6192. */
  6193. int
  6194. atcommand_character_cart_list(
  6195. const int fd, struct map_session_data* sd,
  6196. const char* command, const char* message)
  6197. {
  6198. struct map_session_data *pl_sd;
  6199. struct item_data *item_data, *item_temp;
  6200. int i, j, count, counter, counter2;
  6201. char character[100], output[200], outputtmp[200];
  6202. memset(character, '\0', sizeof(character));
  6203. memset(output, '\0', sizeof(output));
  6204. memset(outputtmp, '\0', sizeof(outputtmp));
  6205. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  6206. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6207. return -1;
  6208. }
  6209. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6210. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6211. counter = 0;
  6212. count = 0;
  6213. for (i = 0; i < MAX_CART; i++) {
  6214. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6215. counter = counter + pl_sd->status.cart[i].amount;
  6216. count++;
  6217. if (count == 1) {
  6218. sprintf(output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6219. clif_displaymessage(fd, output);
  6220. }
  6221. if (pl_sd->status.cart[i].refine)
  6222. sprintf(output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  6223. else
  6224. sprintf(output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  6225. clif_displaymessage(fd, output);
  6226. memset(output, '\0', sizeof(output));
  6227. counter2 = 0;
  6228. for (j = 0; j < item_data->slot; j++) {
  6229. if (pl_sd->status.cart[i].card[j]) {
  6230. if ((item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6231. if (output[0] == '\0')
  6232. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6233. else
  6234. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6235. strcat(output, outputtmp);
  6236. }
  6237. }
  6238. }
  6239. if (output[0] != '\0') {
  6240. output[strlen(output) - 2] = ')';
  6241. output[strlen(output) - 1] = '\0';
  6242. clif_displaymessage(fd, output);
  6243. }
  6244. }
  6245. }
  6246. if (count == 0)
  6247. clif_displaymessage(fd, "No item found in the cart of this player.");
  6248. else {
  6249. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6250. clif_displaymessage(fd, output);
  6251. }
  6252. } else {
  6253. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6254. return -1;
  6255. }
  6256. } else {
  6257. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6258. return -1;
  6259. }
  6260. return 0;
  6261. }
  6262. /*==========================================
  6263. * @killer by MouseJstr
  6264. * enable killing players even when not in pvp
  6265. *------------------------------------------
  6266. */
  6267. int
  6268. atcommand_killer(
  6269. const int fd, struct map_session_data* sd,
  6270. const char* command, const char* message)
  6271. {
  6272. sd->special_state.killer = !sd->special_state.killer;
  6273. if(sd->special_state.killer)
  6274. clif_displaymessage(fd, msg_table[241]);
  6275. else
  6276. clif_displaymessage(fd, msg_table[242]);
  6277. return 0;
  6278. }
  6279. /*==========================================
  6280. * @killable by MouseJstr
  6281. * enable other people killing you
  6282. *------------------------------------------
  6283. */
  6284. int
  6285. atcommand_killable(
  6286. const int fd, struct map_session_data* sd,
  6287. const char* command, const char* message)
  6288. {
  6289. sd->special_state.killable = !sd->special_state.killable;
  6290. if(sd->special_state.killable)
  6291. clif_displaymessage(fd, msg_table[242]);
  6292. else
  6293. clif_displaymessage(fd, msg_table[241]);
  6294. return 0;
  6295. }
  6296. /*==========================================
  6297. * @charkillable by MouseJstr
  6298. * enable another player to be killed
  6299. *------------------------------------------
  6300. */
  6301. int
  6302. atcommand_charkillable(
  6303. const int fd, struct map_session_data* sd,
  6304. const char* command, const char* message)
  6305. {
  6306. struct map_session_data *pl_sd = NULL;
  6307. if (!message || !*message)
  6308. return -1;
  6309. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6310. return -1;
  6311. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6312. if(pl_sd->special_state.killable)
  6313. clif_displaymessage(fd, "The player is now killable");
  6314. else
  6315. clif_displaymessage(fd, "The player is no longer killable");
  6316. return 0;
  6317. }
  6318. /*==========================================
  6319. * @skillon by MouseJstr
  6320. * turn skills on for the map
  6321. *------------------------------------------
  6322. */
  6323. int
  6324. atcommand_skillon(
  6325. const int fd, struct map_session_data* sd,
  6326. const char* command, const char* message)
  6327. {
  6328. map[sd->bl.m].flag.noskill = 0;
  6329. clif_displaymessage(fd, msg_table[244]);
  6330. return 0;
  6331. }
  6332. /*==========================================
  6333. * @skilloff by MouseJstr
  6334. * Turn skills off on the map
  6335. *------------------------------------------
  6336. */
  6337. int
  6338. atcommand_skilloff(
  6339. const int fd, struct map_session_data* sd,
  6340. const char* command, const char* message)
  6341. {
  6342. map[sd->bl.m].flag.noskill = 1;
  6343. clif_displaymessage(fd, msg_table[243]);
  6344. return 0;
  6345. }
  6346. /*==========================================
  6347. * @npcmove by MouseJstr
  6348. *
  6349. * move a npc
  6350. *------------------------------------------
  6351. */
  6352. int
  6353. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6354. const char* command, const char* message)
  6355. {
  6356. char character[100];
  6357. int x = 0, y = 0;
  6358. struct npc_data *nd = 0;
  6359. if( sd == NULL )
  6360. return -1;
  6361. if (!message || !*message)
  6362. return -1;
  6363. memset(character, '\0', sizeof character);
  6364. if (sscanf(message, "%d %d %99[^\n]", &x, &y, character) < 4)
  6365. return -1;
  6366. nd=npc_name2id(character);
  6367. if (nd==NULL)
  6368. return -1;
  6369. npc_enable(character, 0);
  6370. nd->bl.x = x;
  6371. nd->bl.y = y;
  6372. npc_enable(character, 1);
  6373. return 0;
  6374. }
  6375. /*==========================================
  6376. * @addwarp by MouseJstr
  6377. *
  6378. * Create a new static warp point.
  6379. *------------------------------------------
  6380. */
  6381. int
  6382. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6383. const char* command, const char* message)
  6384. {
  6385. char w1[64], w3[64], w4[64];
  6386. char map[30], output[200];
  6387. int x,y,ret;
  6388. if (!message || !*message)
  6389. return -1;
  6390. if (sscanf(message, "%99s %d %d[^\n]", map, &x, &y ) < 3)
  6391. return -1;
  6392. sprintf(w1,"%s,%d,%d", sd->mapname, sd->bl.x, sd->bl.y);
  6393. sprintf(w3,"%s%d%d%d%d", map,sd->bl.x, sd->bl.y, x, y);
  6394. sprintf(w4,"1,1,%s.gat,%d,%d", map, x, y);
  6395. ret = npc_parse_warp(w1, "warp", w3, w4);
  6396. sprintf(output, "New warp NPC => %s",w3);
  6397. clif_displaymessage(fd, output);
  6398. return ret;
  6399. }
  6400. /*==========================================
  6401. * @follow by [MouseJstr]
  6402. *
  6403. * Follow a player .. staying no more then 5 spaces away
  6404. *------------------------------------------
  6405. */
  6406. int
  6407. atcommand_follow(const int fd, struct map_session_data* sd,
  6408. const char* command, const char* message)
  6409. {
  6410. struct map_session_data *pl_sd = NULL;
  6411. if (!message || !*message)
  6412. return -1;
  6413. if((pl_sd=map_nick2sd((char *) message)) != NULL)
  6414. pc_follow(sd, pl_sd->bl.id);
  6415. else
  6416. return 1;
  6417. return 0;
  6418. }
  6419. /*==========================================
  6420. * @chareffect by [MouseJstr]
  6421. *
  6422. * Create a effect localized on another character
  6423. *------------------------------------------
  6424. */
  6425. int
  6426. atcommand_chareffect(const int fd, struct map_session_data* sd,
  6427. const char* command, const char* message)
  6428. {
  6429. struct map_session_data *pl_sd = NULL;
  6430. char target[255];
  6431. int type = 0;
  6432. if (!message || !*message || sscanf(message, "%d %s", &type, target) != 2) {
  6433. clif_displaymessage(fd, "usage: @chareffect <type+> <target>.");
  6434. return -1;
  6435. }
  6436. if((pl_sd=map_nick2sd((char *) target)) == NULL)
  6437. return -1;
  6438. clif_specialeffect(&pl_sd->bl, type, 0);
  6439. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  6440. return 0;
  6441. }
  6442. /*==========================================
  6443. * @dropall by [MouseJstr]
  6444. *
  6445. * Drop all your possession on the ground
  6446. *------------------------------------------
  6447. */
  6448. int
  6449. atcommand_dropall(const int fd, struct map_session_data* sd,
  6450. const char* command, const char* message)
  6451. {
  6452. int i;
  6453. for (i = 0; i < MAX_INVENTORY; i++) {
  6454. if (sd->status.inventory[i].amount) {
  6455. if(sd->status.inventory[i].equip != 0)
  6456. pc_unequipitem(sd, i, 0, BF_NORMAL);
  6457. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6458. }
  6459. }
  6460. return 0;
  6461. }
  6462. /*==========================================
  6463. * @chardropall by [MouseJstr]
  6464. *
  6465. * Throw all the characters possessions on the ground. Normally
  6466. * done in response to them being disrespectful of a GM
  6467. *------------------------------------------
  6468. */
  6469. int
  6470. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6471. const char* command, const char* message)
  6472. {
  6473. int i;
  6474. struct map_session_data *pl_sd = NULL;
  6475. if (!message || !*message)
  6476. return -1;
  6477. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6478. return -1;
  6479. for (i = 0; i < MAX_INVENTORY; i++) {
  6480. if (pl_sd->status.inventory[i].amount) {
  6481. if(pl_sd->status.inventory[i].equip != 0)
  6482. pc_unequipitem(pl_sd, i, 0, BF_NORMAL);
  6483. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6484. }
  6485. }
  6486. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6487. clif_displaymessage(fd, "It is done");
  6488. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6489. return 0;
  6490. }
  6491. /*==========================================
  6492. * @storeall by [MouseJstr]
  6493. *
  6494. * Put everything into storage to simplify your inventory to make
  6495. * debugging easie
  6496. *------------------------------------------
  6497. */
  6498. int
  6499. atcommand_storeall(const int fd, struct map_session_data* sd,
  6500. const char* command, const char* message)
  6501. {
  6502. int i;
  6503. if (storage_storageopen(sd) == 1) {
  6504. clif_displaymessage(fd, "run this command again..");
  6505. return 0;
  6506. }
  6507. for (i = 0; i < MAX_INVENTORY; i++) {
  6508. if (sd->status.inventory[i].amount) {
  6509. if(sd->status.inventory[i].equip != 0)
  6510. pc_unequipitem(sd, i, 0, BF_NORMAL);
  6511. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6512. }
  6513. }
  6514. storage_storageclose(sd);
  6515. clif_displaymessage(fd, "It is done");
  6516. return 0;
  6517. }
  6518. /*==========================================
  6519. * @charstoreall by [MouseJstr]
  6520. *
  6521. * A way to screw with players who piss you off
  6522. *------------------------------------------
  6523. */
  6524. int
  6525. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6526. const char* command, const char* message)
  6527. {
  6528. int i;
  6529. struct map_session_data *pl_sd = NULL;
  6530. if (!message || !*message)
  6531. return -1;
  6532. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6533. return -1;
  6534. if (storage_storageopen(pl_sd) == 1) {
  6535. clif_displaymessage(fd, "Had to open the characters storage window...");
  6536. clif_displaymessage(fd, "run this command again..");
  6537. return 0;
  6538. }
  6539. for (i = 0; i < MAX_INVENTORY; i++) {
  6540. if (pl_sd->status.inventory[i].amount) {
  6541. if(pl_sd->status.inventory[i].equip != 0)
  6542. pc_unequipitem(pl_sd, i, 0, BF_NORMAL);
  6543. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6544. }
  6545. }
  6546. storage_storageclose(pl_sd);
  6547. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6548. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6549. clif_displaymessage(pl_sd->fd, " -- the management");
  6550. clif_displaymessage(fd, "It is done");
  6551. return 0;
  6552. }
  6553. /*==========================================
  6554. * @skillid by [MouseJstr]
  6555. *
  6556. * lookup a skill by name
  6557. *------------------------------------------
  6558. */
  6559. int
  6560. atcommand_skillid(const int fd, struct map_session_data* sd,
  6561. const char* command, const char* message)
  6562. {
  6563. int skillen = 0, idx = 0;
  6564. if (!message || !*message)
  6565. return -1;
  6566. skillen = strlen(message);
  6567. while (skill_names[idx].id != 0) {
  6568. if ((strnicmp(skill_names[idx].name, message, skillen) == 0) ||
  6569. (strnicmp(skill_names[idx].desc, message, skillen) == 0)) {
  6570. char output[255];
  6571. sprintf(output, "skill %d: %s", skill_names[idx].id, skill_names[idx].desc);
  6572. clif_displaymessage(fd, output);
  6573. }
  6574. idx++;
  6575. }
  6576. return 0;
  6577. }
  6578. /*==========================================
  6579. * @useskill by [MouseJstr]
  6580. *
  6581. * A way of using skills without having to find them in the skills menu
  6582. *------------------------------------------
  6583. */
  6584. int
  6585. atcommand_useskill(const int fd, struct map_session_data* sd,
  6586. const char* command, const char* message)
  6587. {
  6588. struct map_session_data *pl_sd = NULL;
  6589. int skillnum;
  6590. int skilllv;
  6591. int inf;
  6592. char target[255];
  6593. if (!message || !*message)
  6594. return -1;
  6595. if(sscanf(message, "%d %d %s", &skillnum, &skilllv, target) != 3) {
  6596. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6597. return -1;
  6598. }
  6599. if((pl_sd=map_nick2sd(target)) == NULL) {
  6600. return -1;
  6601. }
  6602. inf = skill_get_inf(skillnum);
  6603. if ((inf == 2) || (inf == 1))
  6604. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6605. else
  6606. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6607. return 0;
  6608. }
  6609. /*==========================================
  6610. * It is made to rain.
  6611. *------------------------------------------
  6612. */
  6613. int
  6614. atcommand_rain(
  6615. const int fd, struct map_session_data* sd,
  6616. const char* command, const char* message)
  6617. {
  6618. int effno = 0;
  6619. effno = 161;
  6620. nullpo_retr(-1, sd);
  6621. if (effno < 0 || map[sd->bl.m].flag.rain)
  6622. return -1;
  6623. map[sd->bl.m].flag.rain=1;
  6624. clif_specialeffect(&sd->bl,effno,2);
  6625. return 0;
  6626. }
  6627. /*==========================================
  6628. * It is made to snow.
  6629. *------------------------------------------
  6630. */
  6631. int
  6632. atcommand_snow(
  6633. const int fd, struct map_session_data* sd,
  6634. const char* command, const char* message)
  6635. {
  6636. int effno = 0;
  6637. effno = 162;
  6638. nullpo_retr(-1, sd);
  6639. if (effno < 0 || map[sd->bl.m].flag.snow)
  6640. return -1;
  6641. map[sd->bl.m].flag.snow=1;
  6642. clif_specialeffect(&sd->bl,effno,2);
  6643. return 0;
  6644. }
  6645. /*==========================================
  6646. * Cherry tree snowstorm is made to fall. (Sakura)
  6647. *------------------------------------------
  6648. */
  6649. int
  6650. atcommand_sakura(
  6651. const int fd, struct map_session_data* sd,
  6652. const char* command, const char* message)
  6653. {
  6654. int effno = 0;
  6655. effno = 163;
  6656. nullpo_retr(-1, sd);
  6657. if (effno < 0 || map[sd->bl.m].flag.sakura)
  6658. return -1;
  6659. map[sd->bl.m].flag.sakura=1;
  6660. clif_specialeffect(&sd->bl,effno,2);
  6661. return 0;
  6662. }
  6663. /*==========================================
  6664. * Fog hangs over.
  6665. *------------------------------------------
  6666. */
  6667. int
  6668. atcommand_fog(
  6669. const int fd, struct map_session_data* sd,
  6670. const char* command, const char* message)
  6671. {
  6672. int effno = 0;
  6673. effno = 233;
  6674. nullpo_retr(-1, sd);
  6675. if (effno < 0 || map[sd->bl.m].flag.fog)
  6676. return -1;
  6677. map[sd->bl.m].flag.fog=1;
  6678. clif_specialeffect(&sd->bl,effno,2);
  6679. return 0;
  6680. }
  6681. /*==========================================
  6682. * Fallen leaves fall.
  6683. *------------------------------------------
  6684. */
  6685. int
  6686. atcommand_leaves(
  6687. const int fd, struct map_session_data* sd,
  6688. const char* command, const char* message)
  6689. {
  6690. int effno = 0;
  6691. effno = 333;
  6692. nullpo_retr(-1, sd);
  6693. if (effno < 0 || map[sd->bl.m].flag.leaves)
  6694. return -1;
  6695. map[sd->bl.m].flag.leaves=1;
  6696. clif_specialeffect(&sd->bl,effno,2);
  6697. return 0;
  6698. }
  6699. /*==========================================
  6700. *
  6701. *------------------------------------------
  6702. */
  6703. int
  6704. atcommand_summon(
  6705. const int fd, struct map_session_data* sd,
  6706. const char* command, const char* message)
  6707. {
  6708. char name[100];
  6709. int mob_id = 0;
  6710. int x = 0;
  6711. int y = 0;
  6712. int id = 0;
  6713. struct mob_data *md;
  6714. unsigned int tick=gettick();
  6715. nullpo_retr(-1, sd);
  6716. if (!message || !*message)
  6717. return -1;
  6718. if (sscanf(message, "%99s", name) < 1)
  6719. return -1;
  6720. if ((mob_id = atoi(name)) == 0)
  6721. mob_id = mobdb_searchname(name);
  6722. if(mob_id == 0)
  6723. return -1;
  6724. x = sd->bl.x + (rand() % 10 - 5);
  6725. y = sd->bl.y + (rand() % 10 - 5);
  6726. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  6727. if((md=(struct mob_data *)map_id2bl(id))){
  6728. md->master_id=sd->bl.id;
  6729. md->state.special_mob_ai=1;
  6730. md->mode=mob_db[md->class].mode|0x04;
  6731. md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0);
  6732. clif_misceffect2(&md->bl,344);
  6733. }
  6734. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  6735. return 0;
  6736. }
  6737. /*==========================================
  6738. * @adjcmdlvl by [MouseJstr]
  6739. *
  6740. * Temp adjust the GM level required to use a GM command
  6741. *
  6742. * Used during beta testing to allow players to use GM commands
  6743. * for short periods of time
  6744. *------------------------------------------
  6745. */
  6746. int
  6747. atcommand_adjcmdlvl(
  6748. const int fd, struct map_session_data* sd,
  6749. const char* command, const char* message)
  6750. {
  6751. int i, newlev;
  6752. char cmd[100];
  6753. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  6754. clif_displaymessage(fd, "usage: @adjcmdlvl <lvl> <command>.");
  6755. return -1;
  6756. }
  6757. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  6758. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  6759. atcommand_info[i].level = newlev;
  6760. clif_displaymessage(fd, "@command level changed.");
  6761. return 0;
  6762. }
  6763. clif_displaymessage(fd, "@command not found.");
  6764. return -1;
  6765. }
  6766. /*==========================================
  6767. * @adjgmlvl by [MouseJstr]
  6768. *
  6769. * Create a temp GM
  6770. *
  6771. * Used during beta testing to allow players to use GM commands
  6772. * for short periods of time
  6773. *------------------------------------------
  6774. */
  6775. int
  6776. atcommand_adjgmlvl(
  6777. const int fd, struct map_session_data* sd,
  6778. const char* command, const char* message)
  6779. {
  6780. int newlev;
  6781. char user[100];
  6782. struct map_session_data *pl_sd;
  6783. if (!message || !*message || sscanf(message, "%d %[^\r\n]", &newlev, user) != 2) {
  6784. clif_displaymessage(fd, "usage: @adjgmlvl <lvl> <user>.");
  6785. return -1;
  6786. }
  6787. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  6788. return -1;
  6789. pc_set_gm_level(pl_sd->status.account_id, newlev);
  6790. return 0;
  6791. }
  6792. /*==========================================
  6793. * @trade by [MouseJstr]
  6794. *
  6795. * Open a trade window with a remote player
  6796. *
  6797. * If I have to jump to a remote player one more time, I am
  6798. * gonna scream!
  6799. *------------------------------------------
  6800. */
  6801. int
  6802. atcommand_trade(
  6803. const int fd, struct map_session_data* sd,
  6804. const char* command, const char* message)
  6805. {
  6806. struct map_session_data *pl_sd = NULL;
  6807. if (!message || !*message)
  6808. return -1;
  6809. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6810. trade_traderequest(sd, pl_sd->bl.id);
  6811. return 0;
  6812. }
  6813. return -1;
  6814. }
  6815. /*==========================================
  6816. * @setbattleflag by [MouseJstr]
  6817. *
  6818. * set a battle_config flag without having to reboot
  6819. */
  6820. int
  6821. atcommand_setbattleflag(
  6822. const int fd, struct map_session_data* sd,
  6823. const char* command, const char* message)
  6824. {
  6825. char flag[128], value[128];
  6826. if (!message || !*message || sscanf(message, "%s %s", flag, value) != 2) {
  6827. clif_displaymessage(fd, "usage: @setbattleflag <flag> <value>.");
  6828. return -1;
  6829. }
  6830. if (battle_set_value(flag, value) == 0)
  6831. clif_displaymessage(fd, "unknown battle_config flag");
  6832. else
  6833. clif_displaymessage(fd, "battle_config set as requested");
  6834. return 0;
  6835. }
  6836. /*===========================
  6837. * @unmute [Valaris]
  6838. *===========================
  6839. */
  6840. int atcommand_unmute(
  6841. const int fd, struct map_session_data* sd,
  6842. const char* command, const char* message)
  6843. {
  6844. struct map_session_data *pl_sd = NULL;
  6845. if (!message || !*message)
  6846. return -1;
  6847. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6848. if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) {
  6849. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  6850. skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  6851. clif_displaymessage(sd->fd,"Player unmuted");
  6852. }
  6853. else
  6854. clif_displaymessage(sd->fd,"Player is not muted");
  6855. }
  6856. return 0;
  6857. }
  6858. /*==========================================
  6859. * @uptime by MC Cameri
  6860. *------------------------------------------
  6861. */
  6862. int
  6863. atcommand_uptime(
  6864. const int fd, struct map_session_data* sd,
  6865. const char* command, const char* message)
  6866. {
  6867. char output[200];
  6868. long seconds = 0, day = 24*60*60, hour = 60*60,
  6869. minute = 60, days = 0, hours = 0, minutes = 0;
  6870. seconds = (gettick()-ticks)/CLOCKS_PER_SEC;
  6871. days = seconds/day;
  6872. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6873. hours = seconds/hour;
  6874. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6875. minutes = seconds/minute;
  6876. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6877. snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds);
  6878. clif_displaymessage(fd,output);
  6879. return 0;
  6880. }
  6881. /*==========================================
  6882. * @changesex <sex>
  6883. * => Changes one's sex. Argument sex can be
  6884. * 0 or 1, m or f, male or female.
  6885. *------------------------------------------
  6886. */
  6887. int
  6888. atcommand_changesex(
  6889. const int fd, struct map_session_data* sd,
  6890. const char* command, const char* message)
  6891. {
  6892. chrif_changesex(sd->status.account_id, ((sd->status.sex+1)%2));
  6893. return 0;
  6894. }
  6895. /*================================================
  6896. * @mute - Mutes a player for a set amount of time
  6897. *------------------------------------------------
  6898. */
  6899. int atcommand_mute(
  6900. const int fd, struct map_session_data* sd,
  6901. const char* command, const char* message)
  6902. {
  6903. struct map_session_data *pl_sd = NULL;
  6904. char character[100];
  6905. int manner;
  6906. if (!message || !*message || sscanf(message, "%d %99[^\n]", &manner, character) < 1) {
  6907. clif_displaymessage(fd, "usage: @mute <time> <character name>.");
  6908. return -1;
  6909. }
  6910. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6911. pl_sd->status.manner -= manner;
  6912. if(pl_sd->status.manner < 0)
  6913. skill_status_change_start(&pl_sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  6914. }
  6915. else {
  6916. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6917. return -1;
  6918. }
  6919. return 0;
  6920. }
  6921. /*==========================================
  6922. * @refresh (like @jumpto <<yourself>>)
  6923. *------------------------------------------
  6924. */
  6925. int atcommand_refresh(
  6926. const int fd, struct map_session_data* sd,
  6927. const char* command, const char* message)
  6928. {
  6929. nullpo_retr(-1, sd);
  6930. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  6931. return 0;
  6932. }
  6933. /*==========================================
  6934. * @petid <part of pet name>
  6935. * => Displays a list of matching pets.
  6936. *------------------------------------------
  6937. */
  6938. int
  6939. atcommand_petid(const int fd, struct map_session_data* sd,
  6940. const char* command, const char* message)
  6941. {
  6942. char searchtext[100];
  6943. char temp0[100];
  6944. char temp1[100];
  6945. int cnt = 0, i = 0;
  6946. nullpo_retr(-1, sd);
  6947. if (!message || !*message)
  6948. return -1;
  6949. if (sscanf(message, "%99s", searchtext) < 1)
  6950. return -1;
  6951. str_lower(searchtext);
  6952. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  6953. clif_displaymessage(fd,temp0);
  6954. while (i < MAX_PET_DB) {
  6955. strcpy(temp1,pet_db[i].name);
  6956. strcpy(temp1, str_lower(temp1));
  6957. strcpy(temp0,pet_db[i].jname);
  6958. strcpy(temp0, str_lower(temp1));
  6959. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  6960. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class,
  6961. pet_db[i].jname);
  6962. if (cnt >= 100) { // Only if there are custom pets
  6963. clif_displaymessage(fd, "Be more specific, can't send more than"
  6964. " 100 results.");
  6965. } else {
  6966. clif_displaymessage(fd, temp0);
  6967. }
  6968. cnt++;
  6969. }
  6970. i++;
  6971. }
  6972. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  6973. clif_displaymessage(fd, temp0);
  6974. return 0;
  6975. }
  6976. /*==========================================
  6977. * @identify
  6978. * => GM's magnifier.
  6979. *------------------------------------------
  6980. */
  6981. int
  6982. atcommand_identify(
  6983. const int fd, struct map_session_data* sd,
  6984. const char* command, const char* message)
  6985. {
  6986. nullpo_retr(-1, sd);
  6987. int i,num;
  6988. for(i=num=0;i<MAX_INVENTORY;i++){
  6989. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6990. num++;
  6991. }
  6992. }
  6993. if (num > 0) {
  6994. clif_item_identify_list(sd);
  6995. } else {
  6996. clif_displaymessage(fd,"There are no items to appraise.");
  6997. }
  6998. return 0;
  6999. }
  7000. /*==========================================
  7001. * @gmotd (Global MOTD)
  7002. * by davidsiaw :P
  7003. *------------------------------------------
  7004. */
  7005. int
  7006. atcommand_gmotd(
  7007. const int fd, struct map_session_data* sd,
  7008. const char* command, const char* message)
  7009. {
  7010. char buf[256];
  7011. FILE *fp;
  7012. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7013. while (fgets(buf, 250, fp) != NULL){
  7014. int i;
  7015. for( i=0; buf[i]; i++){
  7016. if( buf[i]=='\r' || buf[i]=='\n'){
  7017. buf[i]=0;
  7018. break;
  7019. }
  7020. }
  7021. intif_GMmessage(buf,strlen(buf)+1,8);
  7022. }
  7023. fclose(fp);
  7024. }
  7025. return 0;
  7026. }
  7027. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7028. /*==========================================
  7029. * Mail System commands by [Valaris]
  7030. *------------------------------------------
  7031. */
  7032. int atcommand_listmail(
  7033. const int fd, struct map_session_data* sd,
  7034. const char* command, const char* message)
  7035. {
  7036. if(!battle_config.mail_system)
  7037. return 0;
  7038. nullpo_retr(-1, sd);
  7039. if(strlen(command)==12)
  7040. mail_check(sd,3);
  7041. else if(strlen(command)==9)
  7042. mail_check(sd,2);
  7043. else
  7044. mail_check(sd,1);
  7045. return 0;
  7046. }
  7047. int atcommand_readmail(
  7048. const int fd, struct map_session_data* sd,
  7049. const char* command, const char* message)
  7050. {
  7051. if(!battle_config.mail_system)
  7052. return 0;
  7053. nullpo_retr(-1, sd);
  7054. if (!message || !*message) {
  7055. clif_displaymessage(sd->fd,"You must specify a message number.");
  7056. return 0;
  7057. }
  7058. if(strlen(command)==11)
  7059. mail_delete(sd,atoi(message));
  7060. else
  7061. mail_read(sd,atoi(message));
  7062. return 0;
  7063. }
  7064. int atcommand_sendmail(
  7065. const int fd, struct map_session_data* sd,
  7066. const char* command, const char* message)
  7067. {
  7068. char name[24],text[80];
  7069. if(!battle_config.mail_system)
  7070. return 0;
  7071. nullpo_retr(-1, sd);
  7072. if (!message || !*message) {
  7073. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7074. return 0;
  7075. }
  7076. if ((sscanf(message, "\"%[^\"]\" %79[^\n]", name, text) < 2) &&
  7077. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7078. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7079. return 0;
  7080. }
  7081. if(strlen(command)==17)
  7082. mail_send(sd,name,text,1);
  7083. else
  7084. mail_send(sd,name,text,0);
  7085. return 0;
  7086. }
  7087. /*==========================================
  7088. * Refresh online command for SQL [Valaris]
  7089. * Will refresh and check online column of
  7090. * players and set correctly.
  7091. *------------------------------------------
  7092. */
  7093. int atcommand_refreshonline(
  7094. const int fd, struct map_session_data* sd,
  7095. const char* command, const char* message)
  7096. {
  7097. nullpo_retr(-1, sd);
  7098. char_online_check();
  7099. return 0;
  7100. }
  7101. #endif /* end sql only */