atcommand.c 264 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800
  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. char msg_table[1000][256]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  34. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  35. ACMD_FUNC(broadcast);
  36. ACMD_FUNC(localbroadcast);
  37. ACMD_FUNC(rura);
  38. ACMD_FUNC(where);
  39. ACMD_FUNC(jumpto);
  40. ACMD_FUNC(jump);
  41. ACMD_FUNC(who);
  42. ACMD_FUNC(who2);
  43. ACMD_FUNC(who3);
  44. ACMD_FUNC(whomap);
  45. ACMD_FUNC(whomap2);
  46. ACMD_FUNC(whomap3);
  47. ACMD_FUNC(whogm); // by Yor
  48. ACMD_FUNC(whozeny); // [Valaris]
  49. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  50. ACMD_FUNC(save);
  51. ACMD_FUNC(load);
  52. ACMD_FUNC(speed);
  53. ACMD_FUNC(storage);
  54. ACMD_FUNC(guildstorage);
  55. ACMD_FUNC(option);
  56. ACMD_FUNC(hide);
  57. ACMD_FUNC(jobchange);
  58. ACMD_FUNC(die);
  59. ACMD_FUNC(kill);
  60. ACMD_FUNC(alive);
  61. ACMD_FUNC(kami);
  62. ACMD_FUNC(heal);
  63. ACMD_FUNC(item);
  64. ACMD_FUNC(item2);
  65. ACMD_FUNC(itemreset);
  66. ACMD_FUNC(itemcheck);
  67. ACMD_FUNC(baselevelup);
  68. ACMD_FUNC(joblevelup);
  69. ACMD_FUNC(help);
  70. ACMD_FUNC(gm);
  71. ACMD_FUNC(pvpoff);
  72. ACMD_FUNC(pvpon);
  73. ACMD_FUNC(gvgoff);
  74. ACMD_FUNC(gvgon);
  75. ACMD_FUNC(model);
  76. ACMD_FUNC(go);
  77. ACMD_FUNC(monster);
  78. ACMD_FUNC(monstersmall);
  79. ACMD_FUNC(monsterbig);
  80. ACMD_FUNC(spawn);
  81. ACMD_FUNC(killmonster);
  82. ACMD_FUNC(killmonster2);
  83. ACMD_FUNC(refine);
  84. ACMD_FUNC(produce);
  85. ACMD_FUNC(memo);
  86. ACMD_FUNC(gat);
  87. ACMD_FUNC(packet);
  88. ACMD_FUNC(statuspoint);
  89. ACMD_FUNC(skillpoint);
  90. ACMD_FUNC(zeny);
  91. ACMD_FUNC(param);
  92. ACMD_FUNC(guildlevelup);
  93. ACMD_FUNC(makeegg);
  94. ACMD_FUNC(hatch);
  95. ACMD_FUNC(petfriendly);
  96. ACMD_FUNC(pethungry);
  97. ACMD_FUNC(petrename);
  98. ACMD_FUNC(recall);
  99. ACMD_FUNC(recallall);
  100. ACMD_FUNC(revive);
  101. ACMD_FUNC(character_stats_all);
  102. ACMD_FUNC(character_save);
  103. ACMD_FUNC(night);
  104. ACMD_FUNC(day);
  105. ACMD_FUNC(doom);
  106. ACMD_FUNC(doommap);
  107. ACMD_FUNC(raise);
  108. ACMD_FUNC(raisemap);
  109. ACMD_FUNC(character_baselevel);
  110. ACMD_FUNC(character_joblevel);
  111. ACMD_FUNC(kick);
  112. ACMD_FUNC(kickall);
  113. ACMD_FUNC(allskill);
  114. ACMD_FUNC(questskill);
  115. ACMD_FUNC(charquestskill);
  116. ACMD_FUNC(lostskill);
  117. ACMD_FUNC(charlostskill);
  118. ACMD_FUNC(spiritball);
  119. ACMD_FUNC(party);
  120. ACMD_FUNC(guild);
  121. ACMD_FUNC(charskreset);
  122. ACMD_FUNC(charstreset);
  123. ACMD_FUNC(charreset);
  124. ACMD_FUNC(charstpoint);
  125. ACMD_FUNC(charmodel);
  126. ACMD_FUNC(charskpoint);
  127. ACMD_FUNC(agitstart);
  128. ACMD_FUNC(agitend);
  129. ACMD_FUNC(reloaditemdb);
  130. ACMD_FUNC(reloadmobdb);
  131. ACMD_FUNC(reloadskilldb);
  132. ACMD_FUNC(reloadscript);
  133. ACMD_FUNC(reloadgmdb); // by Yor
  134. ACMD_FUNC(mapexit);
  135. ACMD_FUNC(idsearch);
  136. ACMD_FUNC(mapinfo);
  137. ACMD_FUNC(dye); //** by fritz
  138. ACMD_FUNC(hair_style); //** by fritz
  139. ACMD_FUNC(hair_color); //** by fritz
  140. ACMD_FUNC(stat_all); //** by fritz
  141. ACMD_FUNC(char_change_sex); // by Yor
  142. ACMD_FUNC(char_block); // by Yor
  143. ACMD_FUNC(char_ban); // by Yor
  144. ACMD_FUNC(char_unblock); // by Yor
  145. ACMD_FUNC(char_unban); // by Yor
  146. ACMD_FUNC(mount_peco); // by Valaris
  147. ACMD_FUNC(char_mount_peco); // by Yor
  148. ACMD_FUNC(guildspy); // [Syrus22]
  149. ACMD_FUNC(partyspy); // [Syrus22]
  150. ACMD_FUNC(repairall); // [Valaris]
  151. ACMD_FUNC(guildrecall); // by Yor
  152. ACMD_FUNC(partyrecall); // by Yor
  153. ACMD_FUNC(nuke); // [Valaris]
  154. ACMD_FUNC(enablenpc);
  155. ACMD_FUNC(disablenpc);
  156. ACMD_FUNC(servertime); // by Yor
  157. ACMD_FUNC(chardelitem); // by Yor
  158. ACMD_FUNC(jail); // by Yor
  159. ACMD_FUNC(unjail); // by Yor
  160. ACMD_FUNC(disguise); // [Valaris]
  161. ACMD_FUNC(undisguise); // by Yor
  162. ACMD_FUNC(chardisguise); // Kalaspuff
  163. ACMD_FUNC(charundisguise); // Kalaspuff
  164. ACMD_FUNC(email); // by Yor
  165. ACMD_FUNC(effect);//by Apple
  166. ACMD_FUNC(character_cart_list); // by Yor
  167. ACMD_FUNC(addwarp); // by MouseJstr
  168. ACMD_FUNC(follow); // by MouseJstr
  169. ACMD_FUNC(skillon); // by MouseJstr
  170. ACMD_FUNC(skilloff); // by MouseJstr
  171. ACMD_FUNC(killer); // by MouseJstr
  172. ACMD_FUNC(npcmove); // by MouseJstr
  173. ACMD_FUNC(killable); // by MouseJstr
  174. ACMD_FUNC(charkillable); // by MouseJstr
  175. ACMD_FUNC(dropall); // by MouseJstr
  176. ACMD_FUNC(chardropall); // by MouseJstr
  177. ACMD_FUNC(storeall); // by MouseJstr
  178. ACMD_FUNC(charstoreall); // by MouseJstr
  179. ACMD_FUNC(skillid); // by MouseJstr
  180. ACMD_FUNC(useskill); // by MouseJstr
  181. ACMD_FUNC(summon);
  182. ACMD_FUNC(rain);
  183. ACMD_FUNC(snow);
  184. ACMD_FUNC(sakura);
  185. ACMD_FUNC(fog);
  186. ACMD_FUNC(leaves);
  187. ACMD_FUNC(adjgmlvl); // by MouseJstr
  188. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  189. ACMD_FUNC(trade); // by MouseJstr
  190. ACMD_FUNC(send); // by davidsiaw
  191. ACMD_FUNC(setbattleflag); // by MouseJstr
  192. ACMD_FUNC(unmute); // [Valaris]
  193. ACMD_FUNC(clearweather); // Dexity
  194. ACMD_FUNC(uptime); // by MC Cameri
  195. ACMD_FUNC(changesex); // by MC Cameri
  196. ACMD_FUNC(mute); // celest
  197. ACMD_FUNC(refresh); // by MC Cameri
  198. ACMD_FUNC(petid); // by MC Cameri
  199. ACMD_FUNC(identify); // by MC Cameri
  200. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  201. ACMD_FUNC(misceffect); // by MC Cameri
  202. ACMD_FUNC(mobsearch);
  203. ACMD_FUNC(cleanmap);
  204. ACMD_FUNC(giveitem);
  205. #ifndef TXT_ONLY
  206. ACMD_FUNC(checkmail); // [Valaris]
  207. ACMD_FUNC(listmail); // [Valaris]
  208. ACMD_FUNC(listnewmail); // [Valaris]
  209. ACMD_FUNC(readmail); // [Valaris]
  210. ACMD_FUNC(sendmail); // [Valaris]
  211. ACMD_FUNC(sendprioritymail); // [Valaris]
  212. ACMD_FUNC(deletemail); // [Valaris]
  213. ACMD_FUNC(sound); // [Valaris]
  214. ACMD_FUNC(refreshonline); // [Valaris]
  215. #endif /* TXT_ONLY */
  216. ACMD_FUNC(skilltree); // by MouseJstr
  217. ACMD_FUNC(marry); // by MouseJstr
  218. ACMD_FUNC(divorce); // by MouseJstr
  219. ACMD_FUNC(rings); // by MouseJstr
  220. ACMD_FUNC(grind); // by MouseJstr
  221. ACMD_FUNC(grind2); // by MouseJstr
  222. ACMD_FUNC(jumptoid); // by Dino9021
  223. ACMD_FUNC(jumptoid2); // by Dino9021
  224. ACMD_FUNC(recallid); // by Dino9021
  225. ACMD_FUNC(recallid2); // by Dino9021
  226. ACMD_FUNC(kickid); // by Dino9021
  227. ACMD_FUNC(kickid2); // by Dino9021
  228. ACMD_FUNC(reviveid); // by Dino9021
  229. ACMD_FUNC(reviveid2); // by Dino9021
  230. ACMD_FUNC(killid); // by Dino9021
  231. ACMD_FUNC(killid2); // by Dino9021
  232. ACMD_FUNC(charkillableid); // by Dino9021
  233. ACMD_FUNC(charkillableid2); // by Dino9021
  234. /*==========================================
  235. *AtCommandInfo atcommand_info[]構造体の定義
  236. *------------------------------------------
  237. */
  238. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  239. // to set default level, read atcommand_athena.conf first please.
  240. static AtCommandInfo atcommand_info[] = {
  241. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  242. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  243. { AtCommand_Where, "@where", 1, atcommand_where },
  244. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  245. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  246. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  247. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  248. { AtCommand_Who, "@who", 20, atcommand_who },
  249. { AtCommand_Who, "@whois", 20, atcommand_who },
  250. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  251. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  252. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  253. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  254. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  255. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  256. { AtCommand_Save, "@save", 40, atcommand_save },
  257. { AtCommand_Load, "@return", 40, atcommand_load },
  258. { AtCommand_Load, "@load", 40, atcommand_load },
  259. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  260. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  261. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  262. { AtCommand_Option, "@option", 40, atcommand_option },
  263. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  264. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  265. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  266. { AtCommand_Die, "@die", 1, atcommand_die },
  267. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  268. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  269. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  270. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  271. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  272. { AtCommand_Item, "@item", 60, atcommand_item },
  273. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  274. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  275. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  276. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  277. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  278. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  279. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  280. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  281. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  282. { AtCommand_H, "@h", 20, atcommand_help },
  283. { AtCommand_Help, "@help", 20, atcommand_help },
  284. { AtCommand_GM, "@gm", 100, atcommand_gm },
  285. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  286. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  287. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  288. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  289. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  290. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  291. { AtCommand_Model, "@model", 20, atcommand_model },
  292. { AtCommand_Go, "@go", 10, atcommand_go },
  293. { AtCommand_Spawn, "@monster", 50, atcommand_spawn },
  294. { AtCommand_Spawn, "@spawn", 50, atcommand_spawn },
  295. // { AtCommand_Spawn, "@summon", 50, atcommand_spawn },
  296. { AtCommand_Monster, "@monster2", 50, atcommand_monster },
  297. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  298. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  299. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  300. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  301. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  302. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  303. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  304. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  305. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  306. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  307. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  308. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  309. { AtCommand_Strength, "@str", 60, atcommand_param },
  310. { AtCommand_Agility, "@agi", 60, atcommand_param },
  311. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  312. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  313. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  314. { AtCommand_Luck, "@luk", 60, atcommand_param },
  315. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  316. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  317. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  318. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  319. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  320. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  321. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  322. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  323. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  324. { AtCommand_Night, "@night", 80, atcommand_night },
  325. { AtCommand_Day, "@day", 80, atcommand_day },
  326. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  327. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  328. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  329. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  330. { AtCommand_CharacterBaseLevel, "@charbaselvl", 60, atcommand_character_baselevel },
  331. { AtCommand_CharacterJobLevel, "@charjlvl", 60, atcommand_character_joblevel },
  332. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  333. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  334. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  335. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  336. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  337. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  338. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  339. { AtCommand_CharQuestSkill, "@charquestskill", 60, atcommand_charquestskill },
  340. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  341. { AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill },
  342. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  343. { AtCommand_Party, "@party", 1, atcommand_party },
  344. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  345. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  346. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  347. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  348. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  349. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  350. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  351. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  352. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  353. { AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset },
  354. { AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset },
  355. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  356. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  357. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  358. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  359. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  360. { AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel },
  361. { AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint },
  362. { AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint },
  363. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  364. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  365. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  366. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  367. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  368. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  369. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  370. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  371. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  372. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  373. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  374. // { AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex }, // by Yor
  375. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  376. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  377. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  378. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  379. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  380. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  381. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  382. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  383. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  384. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  385. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  386. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  387. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  388. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  389. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  390. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  391. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  392. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  393. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  394. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  395. { AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc }, // []
  396. { AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // []
  397. { AtCommand_ServerTime, "@time", 0, atcommand_servertime }, // by Yor
  398. { AtCommand_ServerTime, "@date", 0, atcommand_servertime }, // by Yor
  399. { AtCommand_ServerTime, "@server_date", 0, atcommand_servertime }, // by Yor
  400. { AtCommand_ServerTime, "@serverdate", 0, atcommand_servertime }, // by Yor
  401. { AtCommand_ServerTime, "@server_time", 0, atcommand_servertime }, // by Yor
  402. { AtCommand_ServerTime, "@servertime", 0, atcommand_servertime }, // by Yor
  403. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  404. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  405. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  406. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  407. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  408. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  409. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  410. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  411. { AtCommand_EMail, "@email", 0, atcommand_email }, // by Yor
  412. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  413. // { AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list }, // by Yor, now #itemlist
  414. // { AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list }, // by Yor, now #storagelist
  415. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  416. { AtCommand_Follow, "@follow", 10, atcommand_follow }, // by MouseJstr
  417. { AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp }, // by MouseJstr
  418. { AtCommand_SkillOn, "@skillon", 20, atcommand_skillon }, // by MouseJstr
  419. { AtCommand_SkillOff, "@skilloff", 20, atcommand_skilloff }, // by MouseJstr
  420. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  421. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  422. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  423. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  424. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  425. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  426. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  427. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  428. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  429. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  430. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  431. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  432. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  433. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  434. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  435. /*
  436. { AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle },
  437. { AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance },
  438. { AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect },
  439. */
  440. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  441. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  442. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  443. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  444. { AtCommand_Send, "@send", 60, atcommand_send },
  445. { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag },
  446. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  447. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  448. { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri
  449. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri
  450. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  451. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  452. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  453. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy",40, atcommand_happyhappyjoyjoy }, // [Valaris]
  454. { AtCommand_Refresh, "@refresh", 0, atcommand_refresh }, // by MC Cameri
  455. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  456. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  457. { AtCommand_Gmotd, "@gmotd", 0, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  458. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  459. { AtCommand_MobSearch, "@mobsearch", 0, atcommand_mobsearch },
  460. { AtCommand_CleanMap, "@cleanmap", 0, atcommand_cleanmap },
  461. { AtCommand_GiveItem, "@giveitem", 0, atcommand_giveitem },
  462. #ifndef TXT_ONLY // sql-only commands
  463. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  464. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  465. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  466. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  467. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  468. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  469. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  470. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  471. #endif /* TXT_ONLY */
  472. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  473. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  474. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  475. { AtCommand_Rings, "@rings", 40, atcommand_rings }, // [MouseJstr]
  476. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  477. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  478. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  479. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  480. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  481. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  482. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  483. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  484. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  485. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  486. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  487. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  488. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  489. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  490. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  491. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  492. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  493. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  494. // add new commands before this line
  495. { AtCommand_Unknown, NULL, 1, NULL }
  496. };
  497. /*====================================================
  498. * This function return the name of the job (by [Yor])
  499. *----------------------------------------------------
  500. */
  501. char * job_name(int class) {
  502. switch (class) {
  503. case 0: return "Novice";
  504. case 1: return "Swordsman";
  505. case 2: return "Mage";
  506. case 3: return "Archer";
  507. case 4: return "Acolyte";
  508. case 5: return "Merchant";
  509. case 6: return "Thief";
  510. case 7: return "Knight";
  511. case 8: return "Priest";
  512. case 9: return "Wizard";
  513. case 10: return "Blacksmith";
  514. case 11: return "Hunter";
  515. case 12: return "Assassin";
  516. case 13: return "Knight 2";
  517. case 14: return "Crusader";
  518. case 15: return "Monk";
  519. case 16: return "Sage";
  520. case 17: return "Rogue";
  521. case 18: return "Alchemist";
  522. case 19: return "Bard";
  523. case 20: return "Dancer";
  524. case 21: return "Crusader 2";
  525. case 22: return "Wedding";
  526. case 23: return "Super Novice";
  527. case 4001: return "Novice High";
  528. case 4002: return "Swordsman High";
  529. case 4003: return "Mage High";
  530. case 4004: return "Archer High";
  531. case 4005: return "Acolyte High";
  532. case 4006: return "Merchant High";
  533. case 4007: return "Thief High";
  534. case 4008: return "Lord Knight";
  535. case 4009: return "High Priest";
  536. case 4010: return "High Wizard";
  537. case 4011: return "Whitesmith";
  538. case 4012: return "Sniper";
  539. case 4013: return "Assassin Cross";
  540. case 4014: return "Peko Knight";
  541. case 4015: return "Paladin";
  542. case 4016: return "Champion";
  543. case 4017: return "Professor";
  544. case 4018: return "Stalker";
  545. case 4019: return "Creator";
  546. case 4020: return "Clown";
  547. case 4021: return "Gypsy";
  548. case 4022: return "Peko Paladin";
  549. case 4023: return "Baby Novice";
  550. case 4024: return "Baby Swordsman";
  551. case 4025: return "Baby Mage";
  552. case 4026: return "Baby Archer";
  553. case 4027: return "Baby Acolyte";
  554. case 4028: return "Baby Merchant";
  555. case 4029: return "Baby Thief";
  556. case 4030: return "Baby Knight";
  557. case 4031: return "Baby Priest";
  558. case 4032: return "Baby Wizard";
  559. case 4033: return "Baby Blacksmith";
  560. case 4034: return "Baby Hunter";
  561. case 4035: return "Baby Assassin";
  562. case 4036: return "Baby Peco Knight";
  563. case 4037: return "Baby Crusader";
  564. case 4038: return "Baby Monk";
  565. case 4039: return "Baby Sage";
  566. case 4040: return "Baby Rogue";
  567. case 4041: return "Baby Alchemist";
  568. case 4042: return "Baby Bard";
  569. case 4043: return "Baby Dancer";
  570. case 4044: return "Baby Peco Crusader";
  571. case 4045: return "Super Baby";
  572. }
  573. return "Unknown Job";
  574. }
  575. /*==========================================
  576. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  577. *------------------------------------------
  578. */
  579. char *estr_lower(char *str)
  580. {
  581. int i;
  582. for (i=0; str[i]; i++)
  583. if ((str[i] >= 65) && (str[i] <= 90))
  584. str[i] += 32;
  585. return str;
  586. }
  587. // compare function for sorting high to lowest
  588. int hightolow_compare (const void * a, const void * b)
  589. {
  590. return ( *(int*)b - *(int*)a );
  591. }
  592. // compare function for sorting lowest to highest
  593. int lowtohigh_compare (const void * a, const void * b)
  594. {
  595. return ( *(int*)a - *(int*)b );
  596. }
  597. //-----------------------------------------------------------
  598. // Return the message string of the specified number by [Yor]
  599. //-----------------------------------------------------------
  600. char * msg_txt(int msg_number) {
  601. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])) &&
  602. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  603. return msg_table[msg_number];
  604. return "??";
  605. }
  606. //------------------------------------------------------------
  607. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  608. //------------------------------------------------------------
  609. int e_mail_check(unsigned char *email) {
  610. char ch;
  611. unsigned char* last_arobas;
  612. // athena limits
  613. if (strlen(email) < 3 || strlen(email) > 39)
  614. return 0;
  615. // part of RFC limits (official reference of e-mail description)
  616. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  617. return 0;
  618. if (email[strlen(email)-1] == '.')
  619. return 0;
  620. last_arobas = strrchr(email, '@');
  621. if (strstr(last_arobas, "@.") != NULL ||
  622. strstr(last_arobas, "..") != NULL)
  623. return 0;
  624. for(ch = 1; ch < 32; ch++) {
  625. if (strchr(last_arobas, ch) != NULL) {
  626. return 0;
  627. break;
  628. }
  629. }
  630. if (strchr(last_arobas, ' ') != NULL ||
  631. strchr(last_arobas, ';') != NULL)
  632. return 0;
  633. // all correct
  634. return 1;
  635. }
  636. /*==========================================
  637. * get_atcommand_level @コマンドの必要レベルを取得
  638. *------------------------------------------
  639. */
  640. int get_atcommand_level(const AtCommandType type) {
  641. int i;
  642. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  643. if (atcommand_info[i].type == type)
  644. return atcommand_info[i].level;
  645. return 100; // 100: command can not be used
  646. }
  647. /*==========================================
  648. *is_atcommand @コマンドに存在するかどうか確認する
  649. *------------------------------------------
  650. */
  651. AtCommandType
  652. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  653. const char* str = message;
  654. int s_flag = 0;
  655. AtCommandInfo info;
  656. AtCommandType type;
  657. nullpo_retr(AtCommand_None, sd);
  658. if (!battle_config.allow_atcommand_when_mute &&
  659. sd->sc_count && sd->sc_data[SC_NOCHAT].timer != -1) {
  660. return AtCommand_Unknown;
  661. }
  662. if (!message || !*message)
  663. return AtCommand_None;
  664. memset(&info, 0, sizeof(info));
  665. str += strlen(sd->status.name);
  666. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  667. if (*str == ':')
  668. s_flag = 1;
  669. str++;
  670. }
  671. if (!*str)
  672. return AtCommand_None;
  673. type = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  674. if (type != AtCommand_None) {
  675. char command[100];
  676. char output[200];
  677. const char* p = str;
  678. memset(command, '\0', sizeof(command));
  679. memset(output, '\0', sizeof(output));
  680. while (*p && !isspace(*p))
  681. p++;
  682. if (p - str >= sizeof(command)) // too long
  683. return AtCommand_Unknown;
  684. strncpy(command, str, p - str);
  685. while (isspace(*p))
  686. p++;
  687. if (type == AtCommand_Unknown || info.proc == NULL) {
  688. sprintf(output, msg_table[153], command); // %s is Unknown Command.
  689. clif_displaymessage(fd, output);
  690. } else {
  691. if (info.proc(fd, sd, command, p) != 0) {
  692. // Command can not be executed
  693. sprintf(output, msg_table[154], command); // %s failed.
  694. clif_displaymessage(fd, output);
  695. }
  696. }
  697. // ToDo: Fix Logs :)
  698. //if((log_config.gm) && (info.level >= log_config.gm))
  699. // log_atcommand(sd, message);
  700. return info.type;
  701. }
  702. return AtCommand_None;
  703. }
  704. /*==========================================
  705. *
  706. *------------------------------------------
  707. */
  708. AtCommandType atcommand(const int level, const char* message, struct AtCommandInfo* info) {
  709. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  710. if (!info)
  711. return AtCommand_None;
  712. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  713. return AtCommand_None;
  714. if (!p || !*p) {
  715. fprintf(stderr, "at command message is empty\n");
  716. return AtCommand_None;
  717. }
  718. if (*p == command_symbol) { // check first char.
  719. char command[101];
  720. int i = 0;
  721. memset(info, 0, sizeof(AtCommandInfo));
  722. sscanf(p, "%100s", command);
  723. command[sizeof(command)-1] = '\0';
  724. while (atcommand_info[i].type != AtCommand_Unknown) {
  725. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  726. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  727. break;
  728. }
  729. i++;
  730. }
  731. if (atcommand_info[i].type == AtCommand_Unknown) {
  732. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  733. if (level == 0)
  734. return AtCommand_None;
  735. else
  736. return AtCommand_Unknown;
  737. }
  738. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  739. } else {
  740. return AtCommand_None;
  741. }
  742. return info->type;
  743. }
  744. /*==========================================
  745. *
  746. *------------------------------------------
  747. */
  748. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  749. int flag = va_arg(ap, int);
  750. nullpo_retr(0, bl);
  751. if (flag)
  752. mob_damage(NULL, (struct mob_data *)bl, ((struct mob_data *)bl)->hp, 2);
  753. else
  754. mob_delete((struct mob_data *)bl);
  755. return 0;
  756. }
  757. /*==========================================
  758. * Mob search
  759. *------------------------------------------
  760. */
  761. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  762. {
  763. int mob_id,fd;
  764. static int number=0;
  765. struct mob_data *md;
  766. char output[128];
  767. nullpo_retr(0, bl);
  768. if(!ap){
  769. number=0;
  770. return 0;
  771. }
  772. mob_id = va_arg(ap,int);
  773. fd = va_arg(ap,const int);
  774. md = (struct mob_data *)bl;
  775. if(md && fd && (mob_id==-1 || (md->class==mob_id))){
  776. snprintf(output, sizeof output, "%2d[%3d:%3d] %s",
  777. ++number,bl->x, bl->y,md->name);
  778. clif_displaymessage(fd, output);
  779. }
  780. return 0;
  781. }
  782. /*==========================================
  783. * cleanmap
  784. *------------------------------------------
  785. */
  786. static int atcommand_cleanmap_sub(struct block_list *bl,va_list ap)
  787. {
  788. struct flooritem_data *fitem;
  789. nullpo_retr(0, bl);
  790. fitem = (struct flooritem_data *)bl;
  791. if(fitem==NULL || fitem->bl.type!=BL_ITEM){
  792. if(battle_config.error_log)
  793. printf("map_clearflooritem_timer : error\n");
  794. return 1;
  795. }
  796. delete_timer(fitem->cleartimer,map_clearflooritem_timer);
  797. if(fitem->item_data.card[0] == (short)0xff00)
  798. intif_delete_petdata(*((long *)(&fitem->item_data.card[1])));
  799. clif_clearflooritem(fitem,0);
  800. map_delobject(fitem->bl.id);
  801. return 0;
  802. }
  803. static int atkillnpc_sub(struct block_list *bl, va_list ap)
  804. {
  805. int flag = va_arg(ap,int);
  806. nullpo_retr(0, bl);
  807. npc_delete((struct npc_data *)bl);
  808. flag = 0;
  809. return 0;
  810. }
  811. void rehash( const int fd, struct map_session_data* sd )
  812. {
  813. int map_id = 0;
  814. int LOADED_MAPS = map_num;
  815. for (map_id = 0; map_id < LOADED_MAPS;map_id++) {
  816. if (map_id > LOADED_MAPS)
  817. break;
  818. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, 0);
  819. map_foreachinarea(atkillnpc_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_NPC, 0);
  820. }
  821. }
  822. /*==========================================
  823. * Read Message Data
  824. *------------------------------------------
  825. */
  826. int msg_config_read(const char *cfgName) {
  827. int msg_number;
  828. char line[1024], w1[1024], w2[1024];
  829. FILE *fp;
  830. if ((fp = fopen(cfgName, "r")) == NULL) {
  831. printf("Messages file not found: %s\n", cfgName);
  832. return 1;
  833. }
  834. while(fgets(line, sizeof(line)-1, fp)) {
  835. if (line[0] == '/' && line[1] == '/')
  836. continue;
  837. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  838. if (strcmpi(w1, "import") == 0) {
  839. msg_config_read(w2);
  840. } else {
  841. msg_number = atoi(w1);
  842. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])))
  843. strcpy(msg_table[msg_number], w2);
  844. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  845. }
  846. }
  847. }
  848. fclose(fp);
  849. return 0;
  850. }
  851. /*==========================================
  852. *
  853. *------------------------------------------
  854. */
  855. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  856. int i;
  857. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  858. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  859. return &atcommand_info[i];
  860. return NULL;
  861. }
  862. /*==========================================
  863. *
  864. *------------------------------------------
  865. */
  866. int atcommand_config_read(const char *cfgName) {
  867. char line[1024], w1[1024], w2[1024];
  868. AtCommandInfo* p;
  869. FILE* fp;
  870. if ((fp = fopen(cfgName, "r")) == NULL) {
  871. printf("At commands configuration file not found: %s\n", cfgName);
  872. return 1;
  873. }
  874. while (fgets(line, sizeof(line)-1, fp)) {
  875. if (line[0] == '/' && line[1] == '/')
  876. continue;
  877. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  878. continue;
  879. p = get_atcommandinfo_byname(w1);
  880. if (p != NULL) {
  881. p->level = atoi(w2);
  882. if (p->level > 100)
  883. p->level = 100;
  884. else if (p->level < 0)
  885. p->level = 0;
  886. }
  887. if (strcmpi(w1, "import") == 0)
  888. atcommand_config_read(w2);
  889. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  890. w2[0] != '/' && // symbol of standard ragnarok GM commands
  891. w2[0] != '%' && // symbol of party chat speaking
  892. w2[0] != '#') // symbol of charcommand
  893. command_symbol = w2[0];
  894. }
  895. fclose(fp);
  896. return 0;
  897. }
  898. /*==========================================
  899. // @ command processing functions
  900. *------------------------------------------
  901. */
  902. /*==========================================
  903. * @send (used for testing packet sends from the client)
  904. *------------------------------------------
  905. */
  906. int atcommand_send(
  907. const int fd, struct map_session_data* sd,
  908. const char* command, const char* message)
  909. {
  910. int a = atoi(message);
  911. if (a)
  912. {
  913. unsigned char buf[1024];
  914. switch(a)
  915. {
  916. case 1:
  917. WBUFW(buf,0)=0x18d;
  918. case 2:
  919. WBUFW(buf,0)=0x18e;
  920. case 3:
  921. WBUFW(buf,0)=0x18f;
  922. case 4:
  923. WBUFW(buf,0)=0x190;
  924. }
  925. }
  926. return 0;
  927. }
  928. // @rura
  929. /*==========================================
  930. *
  931. *------------------------------------------
  932. */
  933. int atcommand_rura(
  934. const int fd, struct map_session_data* sd,
  935. const char* command, const char* message)
  936. {
  937. char map_name[100];
  938. int x = 0, y = 0;
  939. int m;
  940. nullpo_retr(-1, sd);
  941. memset(map_name, '\0', sizeof(map_name));
  942. if (!message || !*message || sscanf(message, "%99s %d %d", map_name, &x, &y) < 1) {
  943. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  944. return -1;
  945. }
  946. if (x <= 0)
  947. x = rand() % 399 + 1;
  948. if (y <= 0)
  949. y = rand() % 399 + 1;
  950. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  951. strcat(map_name, ".gat");
  952. if (x > 0 && x < 400 && y > 0 && y < 400) {
  953. m = map_mapname2mapid(map_name);
  954. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  955. clif_displaymessage(fd, "You are not authorised to warp you to this map.");
  956. return -1;
  957. }
  958. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  959. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  960. return -1;
  961. }
  962. if (pc_setpos(sd, map_name, x, y, 3) == 0)
  963. clif_displaymessage(fd, msg_table[0]); // Warped.
  964. else {
  965. clif_displaymessage(fd, msg_table[1]); // Map not found.
  966. return -1;
  967. }
  968. } else {
  969. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  970. return -1;
  971. }
  972. return 0;
  973. }
  974. /*==========================================
  975. *
  976. *------------------------------------------
  977. */
  978. int atcommand_where(
  979. const int fd, struct map_session_data* sd,
  980. const char* command, const char* message)
  981. {
  982. char character[100];
  983. char output[200];
  984. struct map_session_data *pl_sd = NULL;
  985. nullpo_retr(-1, sd);
  986. if (!message || !*message)
  987. return -1;
  988. memset(character, '\0', sizeof character);
  989. if (sscanf(message, "%99[^\n]", character) < 1)
  990. return -1;
  991. if(strncmp(sd->status.name,character,24)==0)
  992. return -1;
  993. if ((pl_sd = map_nick2sd(character)) == NULL) {
  994. snprintf(output, sizeof output, "%s %d %d",
  995. sd->mapname, sd->bl.x, sd->bl.y);
  996. clif_displaymessage(fd, output);
  997. return -1;
  998. }
  999. snprintf(output, sizeof output, "%s %s %d %d",
  1000. character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1001. clif_displaymessage(fd, output);
  1002. return 0;
  1003. }
  1004. /*==========================================
  1005. *
  1006. *------------------------------------------
  1007. */
  1008. int atcommand_jumpto(
  1009. const int fd, struct map_session_data* sd,
  1010. const char* command, const char* message)
  1011. {
  1012. char character[100];
  1013. char output[200];
  1014. struct map_session_data *pl_sd = NULL;
  1015. nullpo_retr(-1, sd);
  1016. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1017. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1018. return -1;
  1019. }
  1020. memset(character, '\0', sizeof character);
  1021. if (sscanf(message, "%99[^\n]", character) < 1)
  1022. return -1;
  1023. if(strncmp(sd->status.name,character,24)==0) //Yourself mate? Tsk tsk tsk.
  1024. return -1;
  1025. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1026. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1027. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  1028. return -1;
  1029. }
  1030. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1031. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1032. return -1;
  1033. }
  1034. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  1035. sprintf(output, msg_table[4], character); // Jump to %s
  1036. clif_displaymessage(fd, output);
  1037. } else {
  1038. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1039. return -1;
  1040. }
  1041. return 0;
  1042. }
  1043. /*==========================================
  1044. *
  1045. *------------------------------------------
  1046. */
  1047. int atcommand_jump(
  1048. const int fd, struct map_session_data* sd,
  1049. const char* command, const char* message)
  1050. {
  1051. char output[200];
  1052. int x = 0, y = 0;
  1053. nullpo_retr(-1, sd);
  1054. memset(output, '\0', sizeof(output));
  1055. sscanf(message, "%d %d", &x, &y);
  1056. if (x <= 0)
  1057. x = rand() % 399 + 1;
  1058. if (y <= 0)
  1059. y = rand() % 399 + 1;
  1060. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1061. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1062. clif_displaymessage(fd, "You are not authorised to warp you to your actual map.");
  1063. return -1;
  1064. }
  1065. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1066. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1067. return -1;
  1068. }
  1069. pc_setpos(sd, sd->mapname, x, y, 3);
  1070. sprintf(output, msg_table[5], x, y); // Jump to %d %d
  1071. clif_displaymessage(fd, output);
  1072. } else {
  1073. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1074. return -1;
  1075. }
  1076. return 0;
  1077. }
  1078. /*==========================================
  1079. *
  1080. *------------------------------------------
  1081. */
  1082. int atcommand_who(
  1083. const int fd, struct map_session_data* sd,
  1084. const char* command, const char* message)
  1085. {
  1086. char output[200];
  1087. struct map_session_data *pl_sd;
  1088. int i, j, count;
  1089. int pl_GM_level, GM_level;
  1090. char match_text[100];
  1091. char player_name[24];
  1092. nullpo_retr(-1, sd);
  1093. memset(output, '\0', sizeof(output));
  1094. memset(match_text, '\0', sizeof(match_text));
  1095. memset(player_name, '\0', sizeof(player_name));
  1096. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1097. strcpy(match_text, "");
  1098. for (j = 0; match_text[j]; j++)
  1099. match_text[j] = tolower(match_text[j]);
  1100. count = 0;
  1101. GM_level = pc_isGM(sd);
  1102. for (i = 0; i < fd_max; i++) {
  1103. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1104. pl_GM_level = pc_isGM(pl_sd);
  1105. 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
  1106. memcpy(player_name, pl_sd->status.name, 24);
  1107. for (j = 0; player_name[j]; j++)
  1108. player_name[j] = tolower(player_name[j]);
  1109. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1110. if (pl_GM_level > 0)
  1111. sprintf(output, "(CID:%d/AID:%d) Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.char_id, pl_sd->status.account_id, pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1112. else
  1113. sprintf(output, "(CID:%d/AID:%d) Name: %s | Location: %s %d %d", pl_sd->status.char_id, pl_sd->status.account_id, pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1114. clif_displaymessage(fd, output);
  1115. count++;
  1116. }
  1117. }
  1118. }
  1119. }
  1120. if (count == 0)
  1121. clif_displaymessage(fd, msg_table[28]); // No player found.
  1122. else if (count == 1)
  1123. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1124. else {
  1125. sprintf(output, msg_table[30], count); // %d players found.
  1126. clif_displaymessage(fd, output);
  1127. }
  1128. return 0;
  1129. }
  1130. /*==========================================
  1131. *
  1132. *------------------------------------------
  1133. */
  1134. int atcommand_who2(
  1135. const int fd, struct map_session_data* sd,
  1136. const char* command, const char* message)
  1137. {
  1138. char output[200];
  1139. struct map_session_data *pl_sd;
  1140. int i, j, count;
  1141. int pl_GM_level, GM_level;
  1142. char match_text[100];
  1143. char player_name[24];
  1144. nullpo_retr(-1, sd);
  1145. memset(output, '\0', sizeof(output));
  1146. memset(match_text, '\0', sizeof(match_text));
  1147. memset(player_name, '\0', sizeof(player_name));
  1148. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1149. strcpy(match_text, "");
  1150. for (j = 0; match_text[j]; j++)
  1151. match_text[j] = tolower(match_text[j]);
  1152. count = 0;
  1153. GM_level = pc_isGM(sd);
  1154. for (i = 0; i < fd_max; i++) {
  1155. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1156. pl_GM_level = pc_isGM(pl_sd);
  1157. 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
  1158. memcpy(player_name, pl_sd->status.name, 24);
  1159. for (j = 0; player_name[j]; j++)
  1160. player_name[j] = tolower(player_name[j]);
  1161. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1162. if (pl_GM_level > 0)
  1163. 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);
  1164. else
  1165. 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);
  1166. clif_displaymessage(fd, output);
  1167. count++;
  1168. }
  1169. }
  1170. }
  1171. }
  1172. if (count == 0)
  1173. clif_displaymessage(fd, msg_table[28]); // No player found.
  1174. else if (count == 1)
  1175. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1176. else {
  1177. sprintf(output, msg_table[30], count); // %d players found.
  1178. clif_displaymessage(fd, output);
  1179. }
  1180. return 0;
  1181. }
  1182. /*==========================================
  1183. *
  1184. *------------------------------------------
  1185. */
  1186. int atcommand_who3(
  1187. const int fd, struct map_session_data* sd,
  1188. const char* command, const char* message)
  1189. {
  1190. char temp0[100];
  1191. char temp1[100];
  1192. char output[200];
  1193. struct map_session_data *pl_sd;
  1194. int i, j, count;
  1195. int pl_GM_level, GM_level;
  1196. char match_text[100];
  1197. char player_name[24];
  1198. struct guild *g;
  1199. struct party *p;
  1200. nullpo_retr(-1, sd);
  1201. memset(temp0, '\0', sizeof(temp0));
  1202. memset(temp1, '\0', sizeof(temp1));
  1203. memset(output, '\0', sizeof(output));
  1204. memset(match_text, '\0', sizeof(match_text));
  1205. memset(player_name, '\0', sizeof(player_name));
  1206. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1207. strcpy(match_text, "");
  1208. for (j = 0; match_text[j]; j++)
  1209. match_text[j] = tolower(match_text[j]);
  1210. count = 0;
  1211. GM_level = pc_isGM(sd);
  1212. for (i = 0; i < fd_max; i++) {
  1213. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1214. pl_GM_level = pc_isGM(pl_sd);
  1215. 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
  1216. memcpy(player_name, pl_sd->status.name, 24);
  1217. for (j = 0; player_name[j]; j++)
  1218. player_name[j] = tolower(player_name[j]);
  1219. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1220. g = guild_search(pl_sd->status.guild_id);
  1221. if (g == NULL)
  1222. sprintf(temp1, "None");
  1223. else
  1224. sprintf(temp1, "%s", g->name);
  1225. p = party_search(pl_sd->status.party_id);
  1226. if (p == NULL)
  1227. sprintf(temp0, "None");
  1228. else
  1229. sprintf(temp0, "%s", p->name);
  1230. if (pl_GM_level > 0)
  1231. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1232. else
  1233. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1234. clif_displaymessage(fd, output);
  1235. count++;
  1236. }
  1237. }
  1238. }
  1239. }
  1240. if (count == 0)
  1241. clif_displaymessage(fd, msg_table[28]); // No player found.
  1242. else if (count == 1)
  1243. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1244. else {
  1245. sprintf(output, msg_table[30], count); // %d players found.
  1246. clif_displaymessage(fd, output);
  1247. }
  1248. return 0;
  1249. }
  1250. /*==========================================
  1251. *
  1252. *------------------------------------------
  1253. */
  1254. int atcommand_whomap(
  1255. const int fd, struct map_session_data* sd,
  1256. const char* command, const char* message)
  1257. {
  1258. char output[200];
  1259. struct map_session_data *pl_sd;
  1260. int i, count;
  1261. int pl_GM_level, GM_level;
  1262. int map_id;
  1263. char map_name[100];
  1264. memset(output, '\0', sizeof(output));
  1265. memset(map_name, '\0', sizeof(map_name));
  1266. if (!message || !*message)
  1267. map_id = sd->bl.m;
  1268. else {
  1269. sscanf(message, "%99s", map_name);
  1270. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1271. strcat(map_name, ".gat");
  1272. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1273. map_id = sd->bl.m;
  1274. }
  1275. count = 0;
  1276. GM_level = pc_isGM(sd);
  1277. for (i = 0; i < fd_max; i++) {
  1278. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1279. pl_GM_level = pc_isGM(pl_sd);
  1280. 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
  1281. if (pl_sd->bl.m == map_id) {
  1282. if (pl_GM_level > 0)
  1283. 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);
  1284. else
  1285. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1286. clif_displaymessage(fd, output);
  1287. count++;
  1288. }
  1289. }
  1290. }
  1291. }
  1292. if (count == 0)
  1293. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1294. else if (count == 1)
  1295. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1296. else {
  1297. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1298. }
  1299. clif_displaymessage(fd, output);
  1300. return 0;
  1301. }
  1302. /*==========================================
  1303. *
  1304. *------------------------------------------
  1305. */
  1306. int atcommand_whomap2(
  1307. const int fd, struct map_session_data* sd,
  1308. const char* command, const char* message)
  1309. {
  1310. char output[200];
  1311. struct map_session_data *pl_sd;
  1312. int i, count;
  1313. int pl_GM_level, GM_level;
  1314. int map_id = 0;
  1315. char map_name[100];
  1316. nullpo_retr(-1, sd);
  1317. memset(output, '\0', sizeof(output));
  1318. memset(map_name, '\0', sizeof(map_name));
  1319. if (!message || !*message)
  1320. map_id = sd->bl.m;
  1321. else {
  1322. sscanf(message, "%99s", map_name);
  1323. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1324. strcat(map_name, ".gat");
  1325. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1326. map_id = sd->bl.m;
  1327. }
  1328. count = 0;
  1329. GM_level = pc_isGM(sd);
  1330. for (i = 0; i < fd_max; i++) {
  1331. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1332. pl_GM_level = pc_isGM(pl_sd);
  1333. 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
  1334. if (pl_sd->bl.m == map_id) {
  1335. if (pl_GM_level > 0)
  1336. 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);
  1337. else
  1338. 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);
  1339. clif_displaymessage(fd, output);
  1340. count++;
  1341. }
  1342. }
  1343. }
  1344. }
  1345. if (count == 0)
  1346. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1347. else if (count == 1)
  1348. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1349. else {
  1350. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1351. }
  1352. clif_displaymessage(fd, output);
  1353. return 0;
  1354. }
  1355. /*==========================================
  1356. *
  1357. *------------------------------------------
  1358. */
  1359. int atcommand_whomap3(
  1360. const int fd, struct map_session_data* sd,
  1361. const char* command, const char* message)
  1362. {
  1363. char temp0[100];
  1364. char temp1[100];
  1365. char output[200];
  1366. struct map_session_data *pl_sd;
  1367. int i, count;
  1368. int pl_GM_level, GM_level;
  1369. int map_id = 0;
  1370. char map_name[100];
  1371. struct guild *g;
  1372. struct party *p;
  1373. nullpo_retr(-1, sd);
  1374. memset(temp0, '\0', sizeof(temp0));
  1375. memset(temp1, '\0', sizeof(temp1));
  1376. memset(output, '\0', sizeof(output));
  1377. memset(map_name, '\0', sizeof(map_name));
  1378. if (!message || !*message)
  1379. map_id = sd->bl.m;
  1380. else {
  1381. sscanf(message, "%99s", map_name);
  1382. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1383. strcat(map_name, ".gat");
  1384. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1385. map_id = sd->bl.m;
  1386. }
  1387. count = 0;
  1388. GM_level = pc_isGM(sd);
  1389. for (i = 0; i < fd_max; i++) {
  1390. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1391. pl_GM_level = pc_isGM(pl_sd);
  1392. 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
  1393. if (pl_sd->bl.m == map_id) {
  1394. g = guild_search(pl_sd->status.guild_id);
  1395. if (g == NULL)
  1396. sprintf(temp1, "None");
  1397. else
  1398. sprintf(temp1, "%s", g->name);
  1399. p = party_search(pl_sd->status.party_id);
  1400. if (p == NULL)
  1401. sprintf(temp0, "None");
  1402. else
  1403. sprintf(temp0, "%s", p->name);
  1404. if (pl_GM_level > 0)
  1405. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1406. else
  1407. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1408. clif_displaymessage(fd, output);
  1409. count++;
  1410. }
  1411. }
  1412. }
  1413. }
  1414. if (count == 0)
  1415. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1416. else if (count == 1)
  1417. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1418. else {
  1419. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1420. }
  1421. clif_displaymessage(fd, output);
  1422. return 0;
  1423. }
  1424. /*==========================================
  1425. *
  1426. *------------------------------------------
  1427. */
  1428. int atcommand_whogm(
  1429. const int fd, struct map_session_data* sd,
  1430. const char* command, const char* message)
  1431. {
  1432. char temp0[100];
  1433. char temp1[100];
  1434. char output[200];
  1435. struct map_session_data *pl_sd;
  1436. int i, j, count;
  1437. int pl_GM_level, GM_level;
  1438. char match_text[100];
  1439. char player_name[24];
  1440. struct guild *g;
  1441. struct party *p;
  1442. nullpo_retr(-1, sd);
  1443. memset(temp0, '\0', sizeof(temp0));
  1444. memset(temp1, '\0', sizeof(temp1));
  1445. memset(output, '\0', sizeof(output));
  1446. memset(match_text, '\0', sizeof(match_text));
  1447. memset(player_name, '\0', sizeof(player_name));
  1448. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1449. strcpy(match_text, "");
  1450. for (j = 0; match_text[j]; j++)
  1451. match_text[j] = tolower(match_text[j]);
  1452. count = 0;
  1453. GM_level = pc_isGM(sd);
  1454. for (i = 0; i < fd_max; i++) {
  1455. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1456. pl_GM_level = pc_isGM(pl_sd);
  1457. if (pl_GM_level > 0) {
  1458. 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
  1459. memcpy(player_name, pl_sd->status.name, 24);
  1460. for (j = 0; player_name[j]; j++)
  1461. player_name[j] = tolower(player_name[j]);
  1462. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1463. 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);
  1464. clif_displaymessage(fd, output);
  1465. sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class), pl_sd->status.job_level);
  1466. clif_displaymessage(fd, output);
  1467. g = guild_search(pl_sd->status.guild_id);
  1468. if (g == NULL)
  1469. sprintf(temp1, "None");
  1470. else
  1471. sprintf(temp1, "%s", g->name);
  1472. p = party_search(pl_sd->status.party_id);
  1473. if (p == NULL)
  1474. sprintf(temp0, "None");
  1475. else
  1476. sprintf(temp0, "%s", p->name);
  1477. sprintf(output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1478. clif_displaymessage(fd, output);
  1479. count++;
  1480. }
  1481. }
  1482. }
  1483. }
  1484. }
  1485. if (count == 0)
  1486. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1487. else if (count == 1)
  1488. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1489. else {
  1490. sprintf(output, msg_table[152], count); // %d GMs found.
  1491. clif_displaymessage(fd, output);
  1492. }
  1493. return 0;
  1494. }
  1495. int atcommand_whozeny(
  1496. const int fd, struct map_session_data* sd,
  1497. const char* command, const char* message)
  1498. {
  1499. char output[200];
  1500. struct map_session_data *pl_sd;
  1501. int i, j, count,c;
  1502. char match_text[100];
  1503. char player_name[24];
  1504. int zeny[clif_countusers()];
  1505. int counted[clif_countusers()];
  1506. nullpo_retr(-1, sd);
  1507. memset(output, '\0', sizeof(output));
  1508. memset(match_text, '\0', sizeof(match_text));
  1509. memset(player_name, '\0', sizeof(player_name));
  1510. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1511. strcpy(match_text, "");
  1512. for (j = 0; match_text[j]; j++)
  1513. match_text[j] = tolower(match_text[j]);
  1514. count = 0;
  1515. for (i = 0; i < fd_max; i++) {
  1516. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1517. memcpy(player_name, pl_sd->status.name, 24);
  1518. for (j = 0; player_name[j]; j++)
  1519. player_name[j] = tolower(player_name[j]);
  1520. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1521. zeny[count]=pl_sd->status.zeny;
  1522. counted[i]=0;
  1523. count++;
  1524. }
  1525. }
  1526. }
  1527. qsort(zeny, count, sizeof(int), hightolow_compare);
  1528. for (c = 0; c < count && c < 50; c++) {
  1529. if(!zeny[c])
  1530. continue;
  1531. for (i = 0; i < fd_max; i++) {
  1532. if(!zeny[c])
  1533. continue;
  1534. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && zeny[c] && counted[i]==0) {
  1535. if(pl_sd->status.zeny==zeny[c]) {
  1536. sprintf(output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1537. clif_displaymessage(fd, output);
  1538. zeny[c]=0;
  1539. counted[i]=1;
  1540. }
  1541. }
  1542. }
  1543. }
  1544. if (count == 0)
  1545. clif_displaymessage(fd, msg_table[28]); // No player found.
  1546. else if (count == 1)
  1547. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1548. else {
  1549. sprintf(output, msg_table[30], count); // %d players found.
  1550. clif_displaymessage(fd, output);
  1551. }
  1552. return 0;
  1553. }
  1554. // cause random emote on all online players [Valaris]
  1555. int atcommand_happyhappyjoyjoy(
  1556. const int fd, struct map_session_data* sd,
  1557. const char* command, const char* message)
  1558. {
  1559. struct map_session_data *pl_sd;
  1560. int i,e;
  1561. nullpo_retr(-1, sd);
  1562. for (i = 0; i < fd_max; i++) {
  1563. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1564. e=rand()%40;
  1565. if(e==34)
  1566. e = 0;
  1567. clif_emotion(&pl_sd->bl,e);
  1568. }
  1569. }
  1570. return 0;
  1571. }
  1572. /*==========================================
  1573. *
  1574. *------------------------------------------
  1575. */
  1576. int atcommand_save(
  1577. const int fd, struct map_session_data* sd,
  1578. const char* command, const char* message)
  1579. {
  1580. nullpo_retr(-1, sd);
  1581. pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y);
  1582. if (sd->status.pet_id > 0 && sd->pd)
  1583. intif_save_petdata(sd->status.account_id, &sd->pet);
  1584. pc_makesavestatus(sd);
  1585. chrif_save(sd);
  1586. storage_storage_save(sd);
  1587. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1588. return 0;
  1589. }
  1590. /*==========================================
  1591. *
  1592. *------------------------------------------
  1593. */
  1594. int atcommand_load(
  1595. const int fd, struct map_session_data* sd,
  1596. const char* command, const char* message)
  1597. {
  1598. int m;
  1599. nullpo_retr(-1, sd);
  1600. m = map_mapname2mapid(sd->status.save_point.map);
  1601. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1602. clif_displaymessage(fd, "You are not authorised to warp you to your save map.");
  1603. return -1;
  1604. }
  1605. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1606. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1607. return -1;
  1608. }
  1609. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1610. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1611. return 0;
  1612. }
  1613. /*==========================================
  1614. *
  1615. *------------------------------------------
  1616. */
  1617. int atcommand_speed(
  1618. const int fd, struct map_session_data* sd,
  1619. const char* command, const char* message)
  1620. {
  1621. char output[200];
  1622. int speed;
  1623. nullpo_retr(-1, sd);
  1624. memset(output, '\0', sizeof(output));
  1625. if (!message || !*message) {
  1626. sprintf(output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1627. clif_displaymessage(fd, output);
  1628. return -1;
  1629. }
  1630. speed = atoi(message);
  1631. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1632. sd->speed = speed;
  1633. //sd->walktimer = x;
  1634. //この文を追加 by れ�
  1635. clif_updatestatus(sd, SP_SPEED);
  1636. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1637. } else {
  1638. sprintf(output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1639. clif_displaymessage(fd, output);
  1640. return -1;
  1641. }
  1642. return 0;
  1643. }
  1644. /*==========================================
  1645. *
  1646. *------------------------------------------
  1647. */
  1648. int atcommand_storage(
  1649. const int fd, struct map_session_data* sd,
  1650. const char* command, const char* message)
  1651. {
  1652. nullpo_retr(-1, sd);
  1653. storage_storageopen(sd);
  1654. return 0;
  1655. }
  1656. /*==========================================
  1657. *
  1658. *------------------------------------------
  1659. */
  1660. int atcommand_guildstorage(
  1661. const int fd, struct map_session_data* sd,
  1662. const char* command, const char* message)
  1663. {
  1664. nullpo_retr(-1, sd);
  1665. if (sd->status.guild_id > 0)
  1666. storage_guild_storageopen(sd);
  1667. return 0;
  1668. }
  1669. /*==========================================
  1670. *
  1671. *------------------------------------------
  1672. */
  1673. int atcommand_option(
  1674. const int fd, struct map_session_data* sd,
  1675. const char* command, const char* message)
  1676. {
  1677. int param1 = 0, param2 = 0, param3 = 0;
  1678. nullpo_retr(-1, sd);
  1679. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1680. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1681. return -1;
  1682. }
  1683. sd->opt1 = param1;
  1684. sd->opt2 = param2;
  1685. if (!(sd->status.option & CART_MASK) && param3 & CART_MASK) {
  1686. clif_cart_itemlist(sd);
  1687. clif_cart_equiplist(sd);
  1688. clif_updatestatus(sd, SP_CARTINFO);
  1689. }
  1690. sd->status.option = param3;
  1691. // fix pecopeco display
  1692. if (sd->status.class == 13 || sd->status.class == 21 || sd->status.class == 4014 || sd->status.class == 4022) {
  1693. if (!pc_isriding(sd)) { // sd have the new value...
  1694. if (sd->status.class == 13)
  1695. sd->status.class = sd->view_class = 7;
  1696. else if (sd->status.class == 21)
  1697. sd->status.class = sd->view_class = 14;
  1698. else if (sd->status.class == 4014)
  1699. sd->status.class = sd->view_class = 4008;
  1700. else if (sd->status.class == 4022)
  1701. sd->status.class = sd->view_class = 4015;
  1702. }
  1703. } else {
  1704. if (pc_isriding(sd)) { // sd have the new value...
  1705. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  1706. sd->status.option &= ~0x0020;
  1707. } else {
  1708. if (sd->status.class == 7)
  1709. sd->status.class = sd->view_class = 13;
  1710. else if (sd->status.class == 14)
  1711. sd->status.class = sd->view_class = 21;
  1712. else if (sd->status.class == 4008)
  1713. sd->status.class = sd->view_class = 4014;
  1714. else if (sd->status.class == 4015)
  1715. sd->status.class = sd->view_class = 4022;
  1716. else
  1717. sd->status.option &= ~0x0020;
  1718. }
  1719. }
  1720. }
  1721. clif_changeoption(&sd->bl);
  1722. pc_calcstatus(sd, 0);
  1723. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1724. return 0;
  1725. }
  1726. /*==========================================
  1727. *
  1728. *------------------------------------------
  1729. */
  1730. int atcommand_hide(
  1731. const int fd, struct map_session_data* sd,
  1732. const char* command, const char* message)
  1733. {
  1734. nullpo_retr(-1, sd);
  1735. if (sd->status.option & OPTION_HIDE) {
  1736. sd->status.option &= ~OPTION_HIDE;
  1737. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1738. } else {
  1739. sd->status.option |= OPTION_HIDE;
  1740. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1741. }
  1742. clif_changeoption(&sd->bl);
  1743. return 0;
  1744. }
  1745. /*==========================================
  1746. * 転職する upperを指定すると転生や養子にもなれる
  1747. *------------------------------------------
  1748. */
  1749. int atcommand_jobchange(
  1750. const int fd, struct map_session_data* sd,
  1751. const char* command, const char* message)
  1752. {
  1753. int job = 0, upper = -1;
  1754. nullpo_retr(-1, sd);
  1755. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1756. int i, found = 0;
  1757. const struct { char name[16]; int id; } jobs[] = {
  1758. { "novice", 0 },
  1759. { "swordsman", 1 },
  1760. { "mage", 2 },
  1761. { "archer", 3 },
  1762. { "acolyte", 4 },
  1763. { "merchant", 5 },
  1764. { "thief", 6 },
  1765. { "knight", 7 },
  1766. { "priest", 8 },
  1767. { "priestess", 8 },
  1768. { "wizard", 9 },
  1769. { "blacksmith", 10 },
  1770. { "hunter", 11 },
  1771. { "assassin", 12 },
  1772. { "crusader", 14 },
  1773. { "monk", 15 },
  1774. { "sage", 16 },
  1775. { "rogue", 17 },
  1776. { "alchemist", 18 },
  1777. { "bard", 19 },
  1778. { "dancer", 20 },
  1779. { "super novice", 23 },
  1780. { "supernovice", 23 },
  1781. { "high novice", 4001 },
  1782. { "swordsman high", 4002 },
  1783. { "mage high", 4003 },
  1784. { "archer high", 4004 },
  1785. { "acolyte high", 4005 },
  1786. { "merchant high", 4006 },
  1787. { "thief high", 4007 },
  1788. { "lord knight", 4008 },
  1789. { "high priest", 4009 },
  1790. { "high priestess", 4009 },
  1791. { "high wizard", 4010 },
  1792. { "whitesmith", 4011 },
  1793. { "sniper", 4012 },
  1794. { "assassin cross", 4013 },
  1795. { "paladin", 4015 },
  1796. { "champion", 4016 },
  1797. { "professor", 4017 },
  1798. { "stalker", 4018 },
  1799. { "creator", 4019 },
  1800. { "clown", 4020 },
  1801. { "gypsy", 4021 },
  1802. { "baby novice", 4023 },
  1803. { "baby swordsman", 4024 },
  1804. { "baby mage", 4025 },
  1805. { "baby archer", 4026 },
  1806. { "baby acolyte", 4027 },
  1807. { "baby merchant", 4028 },
  1808. { "baby thief", 4029 },
  1809. { "baby knight", 4030 },
  1810. { "baby priest", 4031 },
  1811. { "baby priestess", 4031 },
  1812. { "baby wizard", 4032 },
  1813. { "baby blacksmith",4033 },
  1814. { "baby hunter", 4034 },
  1815. { "baby assassin", 4035 },
  1816. { "baby crusader", 4037 },
  1817. { "baby monk", 4038 },
  1818. { "baby sage", 4039 },
  1819. { "baby rogue", 4040 },
  1820. { "baby alchemist", 4041 },
  1821. { "baby bard", 4042 },
  1822. { "baby dancer", 4043 },
  1823. { "super baby", 4045 },
  1824. };
  1825. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  1826. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1827. job = jobs[i].id;
  1828. upper = 0;
  1829. found = 1;
  1830. break;
  1831. }
  1832. }
  1833. if (!found) {
  1834. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  1835. return -1;
  1836. }
  1837. }
  1838. if (job == 37 ||job == 45)
  1839. return 0;
  1840. if ((job >= 0 && job < MAX_PC_CLASS)) {
  1841. int j;
  1842. // fix pecopeco display
  1843. if ((job != 13 && job != 21 && job != 4014 && job != 4022)) {
  1844. if (pc_isriding(sd)) {
  1845. if (sd->status.class == 13)
  1846. sd->status.class = sd->view_class = 7;
  1847. if (sd->status.class == 21)
  1848. sd->status.class = sd->view_class = 14;
  1849. if (sd->status.class == 4014)
  1850. sd->status.class = sd->view_class = 4008;
  1851. if (sd->status.class == 4022)
  1852. sd->status.class = sd->view_class = 4015;
  1853. sd->status.option &= ~0x0020;
  1854. clif_changeoption(&sd->bl);
  1855. pc_calcstatus(sd, 0);
  1856. }
  1857. } else {
  1858. if (!pc_isriding(sd)) {
  1859. if (job == 13)
  1860. job = 7;
  1861. if (job == 21)
  1862. job = 14;
  1863. if (job == 4014)
  1864. job = 4008;
  1865. if (job == 4022)
  1866. job = 4015;
  1867. }
  1868. }
  1869. for (j=0; j < MAX_INVENTORY; j++) {
  1870. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  1871. pc_unequipitem(sd, j, 3);
  1872. }
  1873. if (pc_jobchange(sd, job, upper) == 0)
  1874. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  1875. else {
  1876. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  1877. return -1;
  1878. }
  1879. } else {
  1880. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  1881. return -1;
  1882. }
  1883. return 0;
  1884. }
  1885. /*==========================================
  1886. *
  1887. *------------------------------------------
  1888. */
  1889. int atcommand_die(
  1890. const int fd, struct map_session_data* sd,
  1891. const char* command, const char* message)
  1892. {
  1893. nullpo_retr(-1, sd);
  1894. clif_specialeffect(&sd->bl,450,1);
  1895. pc_damage(NULL, sd, sd->status.hp + 1);
  1896. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  1897. return 0;
  1898. }
  1899. /*==========================================
  1900. *
  1901. *------------------------------------------
  1902. */
  1903. int atcommand_kill(
  1904. const int fd, struct map_session_data* sd,
  1905. const char* command, const char* message)
  1906. {
  1907. char character[100];
  1908. struct map_session_data *pl_sd;
  1909. nullpo_retr(-1, sd);
  1910. memset(character, '\0', sizeof(character));
  1911. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1912. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  1913. return -1;
  1914. }
  1915. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1916. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  1917. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  1918. clif_displaymessage(fd, msg_table[14]); // Character killed.
  1919. } else {
  1920. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1921. return -1;
  1922. }
  1923. } else {
  1924. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1925. return -1;
  1926. }
  1927. return 0;
  1928. }
  1929. /*==========================================
  1930. *
  1931. *------------------------------------------
  1932. */
  1933. int atcommand_alive(
  1934. const int fd, struct map_session_data* sd,
  1935. const char* command, const char* message)
  1936. {
  1937. nullpo_retr(-1, sd);
  1938. if (pc_isdead(sd)) {
  1939. sd->status.hp = sd->status.max_hp;
  1940. sd->status.sp = sd->status.max_sp;
  1941. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1942. pc_setstand(sd);
  1943. if (battle_config.pc_invincible_time > 0)
  1944. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  1945. clif_updatestatus(sd, SP_HP);
  1946. clif_updatestatus(sd, SP_SP);
  1947. clif_resurrection(&sd->bl, 1);
  1948. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  1949. return 0;
  1950. }
  1951. return -1;
  1952. }
  1953. /*==========================================
  1954. *
  1955. *------------------------------------------
  1956. */
  1957. int atcommand_kami(
  1958. const int fd, struct map_session_data* sd,
  1959. const char* command, const char* message)
  1960. {
  1961. char output[200];
  1962. nullpo_retr(-1, sd);
  1963. memset(output, '\0', sizeof(output));
  1964. if (!message || !*message) {
  1965. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1966. return -1;
  1967. }
  1968. sscanf(message, "%199[^\n]", output);
  1969. intif_GMmessage(output, strlen(output) + 1, (*(command + 5) == 'b') ? 0x10 : 0);
  1970. return 0;
  1971. }
  1972. /*==========================================
  1973. *
  1974. *------------------------------------------
  1975. */
  1976. int atcommand_heal(
  1977. const int fd, struct map_session_data* sd,
  1978. const char* command, const char* message)
  1979. {
  1980. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1981. nullpo_retr(-1, sd);
  1982. sscanf(message, "%d %d", &hp, &sp);
  1983. if (hp == 0 && sp == 0) {
  1984. hp = sd->status.max_hp - sd->status.hp;
  1985. sp = sd->status.max_sp - sd->status.sp;
  1986. } else {
  1987. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  1988. hp = sd->status.max_hp - sd->status.hp;
  1989. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  1990. hp = 1 - sd->status.hp;
  1991. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  1992. sp = sd->status.max_sp - sd->status.sp;
  1993. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  1994. sp = 1 - sd->status.sp;
  1995. }
  1996. if (hp > 0) // display like heal
  1997. clif_heal(fd, SP_HP, hp);
  1998. else if (hp < 0) // display like damage
  1999. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2000. if (sp > 0) // no display when we lost SP
  2001. clif_heal(fd, SP_SP, sp);
  2002. if (hp != 0 || sp != 0) {
  2003. pc_heal(sd, hp, sp);
  2004. if (hp >= 0 && sp >= 0)
  2005. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2006. else
  2007. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2008. } else {
  2009. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2010. return -1;
  2011. }
  2012. return 0;
  2013. }
  2014. /*==========================================
  2015. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2016. *------------------------------------------
  2017. */
  2018. int atcommand_item(
  2019. const int fd, struct map_session_data* sd,
  2020. const char* command, const char* message)
  2021. {
  2022. char item_name[100];
  2023. int number = 0, item_id, flag;
  2024. struct item item_tmp;
  2025. struct item_data *item_data;
  2026. int get_count, i, pet_id;
  2027. nullpo_retr(-1, sd);
  2028. memset(item_name, '\0', sizeof(item_name));
  2029. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2030. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2031. return -1;
  2032. }
  2033. if (number <= 0)
  2034. number = 1;
  2035. item_id = 0;
  2036. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2037. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2038. item_id = item_data->nameid;
  2039. if (item_id >= 500) {
  2040. get_count = number;
  2041. // check pet egg
  2042. pet_id = search_petDB_index(item_id, PET_EGG);
  2043. if (item_data->type == 4 || item_data->type == 5 ||
  2044. item_data->type == 7 || item_data->type == 8) {
  2045. get_count = 1;
  2046. }
  2047. for (i = 0; i < number; i += get_count) {
  2048. // if pet egg
  2049. if (pet_id >= 0) {
  2050. sd->catch_target_class = pet_db[pet_id].class;
  2051. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2052. pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
  2053. pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
  2054. 100, 0, 1, pet_db[pet_id].jname);
  2055. // if not pet egg
  2056. } else {
  2057. memset(&item_tmp, 0, sizeof(item_tmp));
  2058. item_tmp.nameid = item_id;
  2059. item_tmp.identify = 1;
  2060. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2061. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2062. }
  2063. }
  2064. clif_displaymessage(fd, msg_table[18]); // Item created.
  2065. } else {
  2066. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2067. return -1;
  2068. }
  2069. return 0;
  2070. }
  2071. /*==========================================
  2072. *
  2073. *------------------------------------------
  2074. */
  2075. int atcommand_item2(
  2076. const int fd, struct map_session_data* sd,
  2077. const char* command, const char* message)
  2078. {
  2079. struct item item_tmp;
  2080. struct item_data *item_data;
  2081. char item_name[100];
  2082. int item_id, number = 0;
  2083. int identify = 0, refine = 0, attr = 0;
  2084. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2085. int flag;
  2086. int loop, get_count, i;
  2087. nullpo_retr(-1, sd);
  2088. memset(item_name, '\0', sizeof(item_name));
  2089. 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) {
  2090. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2091. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2092. return -1;
  2093. }
  2094. if (number <= 0)
  2095. number = 1;
  2096. item_id = 0;
  2097. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2098. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2099. item_id = item_data->nameid;
  2100. if (item_id > 500) {
  2101. loop = 1;
  2102. get_count = number;
  2103. if (item_data->type == 4 || item_data->type == 5 ||
  2104. item_data->type == 7 || item_data->type == 8) {
  2105. loop = number;
  2106. get_count = 1;
  2107. if (item_data->type == 7) {
  2108. identify = 1;
  2109. refine = 0;
  2110. }
  2111. if (item_data->type == 8)
  2112. refine = 0;
  2113. if (refine > 10)
  2114. refine = 10;
  2115. } else {
  2116. identify = 1;
  2117. refine = attr = 0;
  2118. }
  2119. for (i = 0; i < loop; i++) {
  2120. memset(&item_tmp, 0, sizeof(item_tmp));
  2121. item_tmp.nameid = item_id;
  2122. item_tmp.identify = identify;
  2123. item_tmp.refine = refine;
  2124. item_tmp.attribute = attr;
  2125. item_tmp.card[0] = c1;
  2126. item_tmp.card[1] = c2;
  2127. item_tmp.card[2] = c3;
  2128. item_tmp.card[3] = c4;
  2129. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2130. clif_additem(sd, 0, 0, flag);
  2131. }
  2132. clif_displaymessage(fd, msg_table[18]); // Item created.
  2133. } else {
  2134. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2135. return -1;
  2136. }
  2137. return 0;
  2138. }
  2139. /*==========================================
  2140. *
  2141. *------------------------------------------
  2142. */
  2143. int atcommand_itemreset(
  2144. const int fd, struct map_session_data* sd,
  2145. const char* command, const char* message)
  2146. {
  2147. int i;
  2148. nullpo_retr(-1, sd);
  2149. for (i = 0; i < MAX_INVENTORY; i++) {
  2150. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0)
  2151. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2152. }
  2153. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2154. return 0;
  2155. }
  2156. /*==========================================
  2157. *
  2158. *------------------------------------------
  2159. */
  2160. int atcommand_itemcheck(
  2161. const int fd, struct map_session_data* sd,
  2162. const char* command, const char* message)
  2163. {
  2164. nullpo_retr(-1, sd);
  2165. pc_checkitem(sd);
  2166. return 0;
  2167. }
  2168. /*==========================================
  2169. *
  2170. *------------------------------------------
  2171. */
  2172. int atcommand_baselevelup(
  2173. const int fd, struct map_session_data* sd,
  2174. const char* command, const char* message)
  2175. {
  2176. int level, i;
  2177. nullpo_retr(-1, sd);
  2178. if (!message || !*message || (level = atoi(message)) == 0) {
  2179. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2180. return -1;
  2181. }
  2182. if (level > 0) {
  2183. if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  2184. clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher.
  2185. return -1;
  2186. } // End Addition
  2187. if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
  2188. level = battle_config.maximum_level - sd->status.base_level;
  2189. for (i = 1; i <= level; i++)
  2190. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2191. sd->status.base_level += level;
  2192. clif_updatestatus(sd, SP_BASELEVEL);
  2193. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2194. clif_updatestatus(sd, SP_STATUSPOINT);
  2195. pc_calcstatus(sd, 0);
  2196. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2197. clif_misceffect(&sd->bl, 0);
  2198. clif_displaymessage(fd, msg_table[21]); // Base level raised.
  2199. } else {
  2200. if (sd->status.base_level == 1) {
  2201. clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower.
  2202. return -1;
  2203. }
  2204. if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow
  2205. level = 1 - sd->status.base_level;
  2206. if (sd->status.status_point > 0) {
  2207. for (i = 0; i > level; i--)
  2208. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2209. if (sd->status.status_point < 0)
  2210. sd->status.status_point = 0;
  2211. clif_updatestatus(sd, SP_STATUSPOINT);
  2212. } // to add: remove status points from stats
  2213. sd->status.base_level += level;
  2214. clif_updatestatus(sd, SP_BASELEVEL);
  2215. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2216. pc_calcstatus(sd, 0);
  2217. clif_displaymessage(fd, msg_table[22]); // Base level lowered.
  2218. }
  2219. return 0;
  2220. }
  2221. /*==========================================
  2222. *
  2223. *------------------------------------------
  2224. */
  2225. int atcommand_joblevelup(
  2226. const int fd, struct map_session_data* sd,
  2227. const char* command, const char* message)
  2228. {
  2229. int up_level = 50, level;
  2230. struct pc_base_job s_class;
  2231. nullpo_retr(-1, sd);
  2232. s_class = pc_calc_base_job(sd->status.class);
  2233. if (!message || !*message || (level = atoi(message)) == 0) {
  2234. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2235. return -1;
  2236. }
  2237. if (s_class.job == 0)
  2238. up_level -= 40;
  2239. // super novices can go up to 99 [celest]
  2240. else if (s_class.job == 23)
  2241. up_level += 49;
  2242. else if (sd->status.class > 4007 && sd->status.class < 4023)
  2243. up_level += 20;
  2244. if (level > 0) {
  2245. if (sd->status.job_level == up_level) {
  2246. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2247. return -1;
  2248. }
  2249. if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow
  2250. level = up_level - sd->status.job_level;
  2251. sd->status.job_level += level;
  2252. clif_updatestatus(sd, SP_JOBLEVEL);
  2253. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2254. sd->status.skill_point += level;
  2255. clif_updatestatus(sd, SP_SKILLPOINT);
  2256. pc_calcstatus(sd, 0);
  2257. clif_misceffect(&sd->bl, 1);
  2258. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2259. } else {
  2260. if (sd->status.job_level == 1) {
  2261. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2262. return -1;
  2263. }
  2264. if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow
  2265. level = 1 - sd->status.job_level;
  2266. sd->status.job_level += level;
  2267. clif_updatestatus(sd, SP_JOBLEVEL);
  2268. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2269. if (sd->status.skill_point > 0) {
  2270. sd->status.skill_point += level;
  2271. if (sd->status.skill_point < 0)
  2272. sd->status.skill_point = 0;
  2273. clif_updatestatus(sd, SP_SKILLPOINT);
  2274. } // to add: remove status points from skills
  2275. pc_calcstatus(sd, 0);
  2276. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2277. }
  2278. return 0;
  2279. }
  2280. /*==========================================
  2281. *
  2282. *------------------------------------------
  2283. */
  2284. int atcommand_help(
  2285. const int fd, struct map_session_data* sd,
  2286. const char* command, const char* message)
  2287. {
  2288. char buf[2048], w1[2048], w2[2048];
  2289. int i, gm_level;
  2290. FILE* fp;
  2291. nullpo_retr(-1, sd);
  2292. memset(buf, '\0', sizeof(buf));
  2293. if ((fp = fopen(help_txt, "r")) != NULL) {
  2294. clif_displaymessage(fd, msg_table[26]); // Help commands:
  2295. gm_level = pc_isGM(sd);
  2296. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2297. if (buf[0] == '/' && buf[1] == '/')
  2298. continue;
  2299. for (i = 0; buf[i] != '\0'; i++) {
  2300. if (buf[i] == '\r' || buf[i] == '\n') {
  2301. buf[i] = '\0';
  2302. break;
  2303. }
  2304. }
  2305. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2306. clif_displaymessage(fd, buf);
  2307. else if (gm_level >= atoi(w1))
  2308. clif_displaymessage(fd, w2);
  2309. }
  2310. fclose(fp);
  2311. } else {
  2312. clif_displaymessage(fd, msg_table[27]); // File help.txt not found.
  2313. return -1;
  2314. }
  2315. return 0;
  2316. }
  2317. /*==========================================
  2318. *
  2319. *------------------------------------------
  2320. */
  2321. int atcommand_gm(
  2322. const int fd, struct map_session_data* sd,
  2323. const char* command, const char* message)
  2324. {
  2325. char password[100];
  2326. nullpo_retr(-1, sd);
  2327. memset(password, '\0', sizeof(password));
  2328. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2329. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2330. return -1;
  2331. }
  2332. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  2333. clif_displaymessage(fd, msg_table[50]); // You already have some GM powers.
  2334. return -1;
  2335. } else
  2336. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2337. return 0;
  2338. }
  2339. /*==========================================
  2340. *
  2341. *------------------------------------------
  2342. */
  2343. int atcommand_pvpoff(
  2344. const int fd, struct map_session_data* sd,
  2345. const char* command, const char* message)
  2346. {
  2347. struct map_session_data *pl_sd;
  2348. int i;
  2349. nullpo_retr(-1, sd);
  2350. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2351. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2352. return -1;
  2353. }
  2354. if (map[sd->bl.m].flag.pvp) {
  2355. map[sd->bl.m].flag.pvp = 0;
  2356. clif_send0199(sd->bl.m, 0);
  2357. for (i = 0; i < fd_max; i++) { //人数分ループ
  2358. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2359. if (sd->bl.m == pl_sd->bl.m) {
  2360. clif_pvpset(pl_sd, 0, 0, 2);
  2361. if (pl_sd->pvp_timer != -1) {
  2362. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2363. pl_sd->pvp_timer = -1;
  2364. }
  2365. }
  2366. }
  2367. }
  2368. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2369. } else {
  2370. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2371. return -1;
  2372. }
  2373. return 0;
  2374. }
  2375. /*==========================================
  2376. *
  2377. *------------------------------------------
  2378. */
  2379. int atcommand_pvpon(
  2380. const int fd, struct map_session_data* sd,
  2381. const char* command, const char* message)
  2382. {
  2383. struct map_session_data *pl_sd;
  2384. int i;
  2385. nullpo_retr(-1, sd);
  2386. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2387. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2388. return -1;
  2389. }
  2390. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2391. map[sd->bl.m].flag.pvp = 1;
  2392. clif_send0199(sd->bl.m, 1);
  2393. for (i = 0; i < fd_max; i++) {
  2394. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2395. if (sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2396. pl_sd->pvp_timer = add_timer(gettick() + 200,
  2397. pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2398. pl_sd->pvp_rank = 0;
  2399. pl_sd->pvp_lastusers = 0;
  2400. pl_sd->pvp_point = 5;
  2401. }
  2402. }
  2403. }
  2404. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2405. } else {
  2406. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2407. return -1;
  2408. }
  2409. return 0;
  2410. }
  2411. /*==========================================
  2412. *
  2413. *------------------------------------------
  2414. */
  2415. int atcommand_gvgoff(
  2416. const int fd, struct map_session_data* sd,
  2417. const char* command, const char* message)
  2418. {
  2419. nullpo_retr(-1, sd);
  2420. if (map[sd->bl.m].flag.gvg) {
  2421. map[sd->bl.m].flag.gvg = 0;
  2422. clif_send0199(sd->bl.m, 0);
  2423. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2424. } else {
  2425. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2426. return -1;
  2427. }
  2428. return 0;
  2429. }
  2430. /*==========================================
  2431. *
  2432. *------------------------------------------
  2433. */
  2434. int atcommand_gvgon(
  2435. const int fd, struct map_session_data* sd,
  2436. const char* command, const char* message)
  2437. {
  2438. nullpo_retr(-1, sd);
  2439. if (!map[sd->bl.m].flag.gvg) {
  2440. map[sd->bl.m].flag.gvg = 1;
  2441. clif_send0199(sd->bl.m, 3);
  2442. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2443. } else {
  2444. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2445. return -1;
  2446. }
  2447. return 0;
  2448. }
  2449. /*==========================================
  2450. *
  2451. *------------------------------------------
  2452. */
  2453. int atcommand_model(
  2454. const int fd, struct map_session_data* sd,
  2455. const char* command, const char* message)
  2456. {
  2457. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2458. char output[200];
  2459. nullpo_retr(-1, sd);
  2460. memset(output, '\0', sizeof(output));
  2461. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2462. sprintf(output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2463. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2464. clif_displaymessage(fd, output);
  2465. return -1;
  2466. }
  2467. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2468. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2469. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2470. //服の色変更
  2471. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2472. //服の色未実装職の判定
  2473. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2474. return -1;
  2475. } else {
  2476. pc_changelook(sd, LOOK_HAIR, hair_style);
  2477. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2478. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2479. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2480. }
  2481. } else {
  2482. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2483. return -1;
  2484. }
  2485. return 0;
  2486. }
  2487. /*==========================================
  2488. * @dye && @ccolor
  2489. *------------------------------------------
  2490. */
  2491. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2492. {
  2493. int cloth_color = 0;
  2494. char output[200];
  2495. nullpo_retr(-1, sd);
  2496. memset(output, '\0', sizeof(output));
  2497. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2498. sprintf(output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2499. clif_displaymessage(fd, output);
  2500. return -1;
  2501. }
  2502. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2503. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2504. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2505. } else {
  2506. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2507. return -1;
  2508. }
  2509. return 0;
  2510. }
  2511. /*==========================================
  2512. * @hairstyle && @hstyle
  2513. *------------------------------------------
  2514. */
  2515. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2516. {
  2517. int hair_style = 0;
  2518. char output[200];
  2519. nullpo_retr(-1, sd);
  2520. memset(output, '\0', sizeof(output));
  2521. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2522. sprintf(output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2523. clif_displaymessage(fd, output);
  2524. return -1;
  2525. }
  2526. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2527. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2528. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2529. return -1;
  2530. } else {
  2531. pc_changelook(sd, LOOK_HAIR, hair_style);
  2532. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2533. }
  2534. } else {
  2535. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2536. return -1;
  2537. }
  2538. return 0;
  2539. }
  2540. /*==========================================
  2541. * @charhairstyle by [MouseJstr]
  2542. *------------------------------------------
  2543. */
  2544. int
  2545. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2546. const char* command, const char* message)
  2547. {
  2548. nullpo_retr(-1, sd);
  2549. return 0;
  2550. }
  2551. /*==========================================
  2552. * @haircolor && @hcolor
  2553. *------------------------------------------
  2554. */
  2555. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2556. {
  2557. int hair_color = 0;
  2558. char output[200];
  2559. nullpo_retr(-1, sd);
  2560. memset(output, '\0', sizeof(output));
  2561. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2562. sprintf(output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2563. clif_displaymessage(fd, output);
  2564. return -1;
  2565. }
  2566. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2567. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class == 12 || sd->status.class == 17)) {
  2568. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2569. return -1;
  2570. } else {
  2571. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2572. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2573. }
  2574. } else {
  2575. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2576. return -1;
  2577. }
  2578. return 0;
  2579. }
  2580. /*==========================================
  2581. * @go [city_number/city_name]: improved by [yor] to add city names and help
  2582. *------------------------------------------
  2583. */
  2584. int atcommand_go(
  2585. const int fd, struct map_session_data* sd,
  2586. const char* command, const char* message)
  2587. {
  2588. int i;
  2589. int town;
  2590. char map_name[100];
  2591. char output[200];
  2592. int m;
  2593. const struct { char map[16]; int x, y; } data[] = {
  2594. { "prontera.gat", 156, 191 }, // 0=Prontera
  2595. { "morocc.gat", 156, 93 }, // 1=Morroc
  2596. { "geffen.gat", 119, 59 }, // 2=Geffen
  2597. { "payon.gat", 162, 233 }, // 3=Payon
  2598. { "alberta.gat", 192, 147 }, // 4=Alberta
  2599. { "izlude.gat", 128, 114 }, // 5=Izlude
  2600. { "aldebaran.gat",140, 131 }, // 6=Al de Baran
  2601. { "xmas.gat", 147, 134 }, // 7=Lutie
  2602. { "comodo.gat", 209, 143 }, // 8=Comodo
  2603. { "yuno.gat", 157, 51 }, // 9=Yuno
  2604. { "amatsu.gat", 198, 84 }, // 10=Amatsu
  2605. { "gonryun.gat", 160, 120 }, // 11=Gon Ryun
  2606. { "umbala.gat", 89, 157 }, // 12=Umbala
  2607. { "niflheim.gat", 21, 153 }, // 13=Niflheim
  2608. { "louyang.gat", 217, 40 }, // 14=Lou Yang
  2609. { "new_1-1.gat", 53, 111 }, // 15=Start point
  2610. { "sec_pri.gat", 23, 61 }, // 16=Prison
  2611. { "jawaii.gat", 249, 127 }, // 17=Jawaii
  2612. { "ayothaya.gat", 151, 117 }, // 18=Ayothaya
  2613. };
  2614. nullpo_retr(-1, sd);
  2615. if(map[sd->bl.m].flag.nogo) {
  2616. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2617. return 0;
  2618. }
  2619. memset(map_name, '\0', sizeof(map_name));
  2620. memset(output, '\0', sizeof(output));
  2621. // get the number
  2622. town = atoi(message);
  2623. // if no value, display all value
  2624. if (!message || !*message || sscanf(message, "%99s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2625. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2626. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2627. clif_displaymessage(fd, "-3=(Memo point 2) 4=Alberta 11=Gon Ryun");
  2628. clif_displaymessage(fd, "-2=(Memo point 1) 5=Izlude 12=Umbala");
  2629. clif_displaymessage(fd, "-1=(Memo point 0) 6=Al de Baran 13=Niflheim");
  2630. clif_displaymessage(fd, " 0=Prontera 7=Lutie 14=Lou Yang");
  2631. clif_displaymessage(fd, " 1=Morroc 8=Comodo 15=Start point");
  2632. clif_displaymessage(fd, " 2=Geffen 9=Yuno 16=Prison");
  2633. clif_displaymessage(fd, " 3=Payon 10=Amatsu 17=Jawaii");
  2634. clif_displaymessage(fd, " 18=Ayothaya");
  2635. return -1;
  2636. } else {
  2637. // get possible name of the city and add .gat if not in the name
  2638. map_name[sizeof(map_name)-1] = '\0';
  2639. for (i = 0; map_name[i]; i++)
  2640. map_name[i] = tolower(map_name[i]);
  2641. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  2642. strcat(map_name, ".gat");
  2643. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2644. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2645. town = 0;
  2646. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2647. town = 1;
  2648. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2649. town = 2;
  2650. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2651. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2652. town = 3;
  2653. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2654. town = 4;
  2655. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2656. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2657. town = 5;
  2658. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2659. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2660. town = 6;
  2661. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2662. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2663. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2664. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2665. town = 7;
  2666. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2667. town = 8;
  2668. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2669. town = 9;
  2670. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2671. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2672. town = 10;
  2673. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2674. town = 11;
  2675. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2676. town = 12;
  2677. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2678. town = 13;
  2679. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2680. town = 14;
  2681. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2682. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2683. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2684. town = 15;
  2685. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2686. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2687. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2688. town = 16;
  2689. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2690. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2691. town = 17;
  2692. } else if (strncmp(map_name, "ayothaya.gat", 4) == 0 || // 3 first characters
  2693. strncmp(map_name, "ayotaya.gat", 4) == 0) { // writing error (3 first characters)
  2694. town = 18;
  2695. }
  2696. if (town >= -3 && town <= -1) {
  2697. if (sd->status.memo_point[-town-1].map[0]) {
  2698. m = map_mapname2mapid(sd->status.memo_point[-town-1].map);
  2699. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2700. clif_displaymessage(fd, "You are not authorised to warp you to this memo map.");
  2701. return -1;
  2702. }
  2703. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2704. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2705. return -1;
  2706. }
  2707. 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) {
  2708. clif_displaymessage(fd, msg_table[0]); // Warped.
  2709. } else {
  2710. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2711. return -1;
  2712. }
  2713. } else {
  2714. sprintf(output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2715. clif_displaymessage(fd, output);
  2716. return -1;
  2717. }
  2718. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2719. m = map_mapname2mapid((char *)data[town].map);
  2720. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2721. clif_displaymessage(fd, "You are not authorised to warp you to this destination map.");
  2722. return -1;
  2723. }
  2724. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2725. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2726. return -1;
  2727. }
  2728. if (pc_setpos(sd, (char *)data[town].map, data[town].x, data[town].y, 3) == 0) {
  2729. clif_displaymessage(fd, msg_table[0]); // Warped.
  2730. } else {
  2731. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2732. return -1;
  2733. }
  2734. } else { // if you arrive here, you have an error in town variable when reading of names
  2735. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2736. return -1;
  2737. }
  2738. }
  2739. return 0;
  2740. }
  2741. /*==========================================
  2742. *
  2743. *------------------------------------------
  2744. */
  2745. int atcommand_monster(
  2746. const int fd, struct map_session_data* sd,
  2747. const char* command, const char* message)
  2748. {
  2749. char name[100];
  2750. char monster[100];
  2751. char output[200];
  2752. int mob_id;
  2753. int number = 0;
  2754. int x = 0, y = 0;
  2755. int count;
  2756. int i, j, k;
  2757. int mx, my, range;
  2758. nullpo_retr(-1, sd);
  2759. memset(name, '\0', sizeof(name));
  2760. memset(monster, '\0', sizeof(monster));
  2761. memset(output, '\0', sizeof(output));
  2762. if (!message || !*message ||
  2763. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2764. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2765. sscanf(message, "%99s %99s %d %d %d", name, monster, &number, &x, &y) < 2)) {
  2766. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2767. return -1;
  2768. }
  2769. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2770. mob_id = mobdb_checkid(atoi(monster));
  2771. if (mob_id == 0) {
  2772. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2773. return -1;
  2774. }
  2775. if (mob_id == 1288) {
  2776. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2777. return -1;
  2778. }
  2779. if (number <= 0)
  2780. number = 1;
  2781. if (strlen(name) < 1)
  2782. strcpy(name, "--ja--");
  2783. // 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
  2784. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2785. number = battle_config.atc_spawn_quantity_limit;
  2786. if (battle_config.etc_log)
  2787. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2788. count = 0;
  2789. range = sqrt(number) / 2;
  2790. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2791. for (i = 0; i < number; i++) {
  2792. j = 0;
  2793. k = 0;
  2794. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2795. if (x <= 0)
  2796. mx = sd->bl.x + (rand() % range - (range / 2));
  2797. else
  2798. mx = x;
  2799. if (y <= 0)
  2800. my = sd->bl.y + (rand() % range - (range / 2));
  2801. else
  2802. my = y;
  2803. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2804. }
  2805. count += (k != 0) ? 1 : 0;
  2806. }
  2807. if (count != 0)
  2808. if (number == count)
  2809. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2810. else {
  2811. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2812. clif_displaymessage(fd, output);
  2813. }
  2814. else {
  2815. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2816. return -1;
  2817. }
  2818. return 0;
  2819. }
  2820. /*==========================================
  2821. *
  2822. *------------------------------------------
  2823. */
  2824. int atcommand_spawn(
  2825. const int fd, struct map_session_data* sd,
  2826. const char* command, const char* message) {
  2827. char name[100];
  2828. char monster[100];
  2829. char output[200];
  2830. int mob_id;
  2831. int number = 0;
  2832. int x = 0, y = 0;
  2833. int count;
  2834. int i, j, k;
  2835. int mx, my, range;
  2836. nullpo_retr(-1, sd);
  2837. memset(name, '\0', sizeof(name));
  2838. memset(monster, '\0', sizeof(monster));
  2839. memset(output, '\0', sizeof(output));
  2840. if (!message || !*message ||
  2841. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2842. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2843. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1)) {
  2844. clif_displaymessage(fd, msg_table[143]); // Give a monster name/id please.
  2845. return -1;
  2846. }
  2847. // If monster identifier/name argument is a name
  2848. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2849. mob_id = mobdb_checkid(atoi(monster));
  2850. if (mob_id == 0) {
  2851. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2852. return -1;
  2853. }
  2854. if (mob_id == 1288) {
  2855. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2856. return -1;
  2857. }
  2858. if (number <= 0)
  2859. number = 1;
  2860. if (strlen(name) < 1)
  2861. strcpy(name, "--ja--");
  2862. // 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
  2863. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2864. number = battle_config.atc_spawn_quantity_limit;
  2865. if (battle_config.etc_log)
  2866. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2867. count = 0;
  2868. range = sqrt(number) / 2;
  2869. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2870. for (i = 0; i < number; i++) {
  2871. j = 0;
  2872. k = 0;
  2873. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2874. if (x <= 0)
  2875. mx = sd->bl.x + (rand() % range - (range / 2));
  2876. else
  2877. mx = x;
  2878. if (y <= 0)
  2879. my = sd->bl.y + (rand() % range - (range / 2));
  2880. else
  2881. my = y;
  2882. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2883. }
  2884. count += (k != 0) ? 1 : 0;
  2885. }
  2886. if (count != 0)
  2887. if (number == count)
  2888. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2889. else {
  2890. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2891. clif_displaymessage(fd, output);
  2892. }
  2893. else {
  2894. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2895. return -1;
  2896. }
  2897. return 0;
  2898. }
  2899. // small monster spawning [Valaris]
  2900. int atcommand_monstersmall(
  2901. const int fd, struct map_session_data* sd,
  2902. const char* command, const char* message) {
  2903. char name[100] = "";
  2904. char monster[100] = "";
  2905. int mob_id = 0;
  2906. int number = 0;
  2907. int x = 0;
  2908. int y = 0;
  2909. int count;
  2910. int i;
  2911. nullpo_retr(-1, sd);
  2912. if (!message || !*message) {
  2913. clif_displaymessage(fd, "Give a monster name/id please.");
  2914. return 0;
  2915. }
  2916. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2917. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2918. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2919. clif_displaymessage(fd, "Give a monster name/id please.");
  2920. return 0;
  2921. }
  2922. // If monster identifier/name argument is a name
  2923. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2924. mob_id = atoi(monster);
  2925. if (mob_id == 0) {
  2926. clif_displaymessage(fd, "Monster name hasn't been found.");
  2927. return 0;
  2928. }
  2929. if (mob_id == 1288) {
  2930. clif_displaymessage(fd, "Cannot spawn emperium.");
  2931. return 0;
  2932. }
  2933. if (mob_id > 2000) {
  2934. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2935. return 0;
  2936. }
  2937. if (number <= 0)
  2938. number = 1;
  2939. if (strlen(name) < 1)
  2940. strcpy(name, "--ja--");
  2941. // 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
  2942. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2943. number = battle_config.atc_spawn_quantity_limit;
  2944. count = 0;
  2945. for (i = 0; i < number; i++) {
  2946. int mx, my;
  2947. if (x <= 0)
  2948. mx = sd->bl.x + (rand() % 11 - 5);
  2949. else
  2950. mx = x;
  2951. if (y <= 0)
  2952. my = sd->bl.y + (rand() % 11 - 5);
  2953. else
  2954. my = y;
  2955. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2000, 1, "") != 0) ? 1 : 0;
  2956. }
  2957. if (count != 0)
  2958. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2959. else
  2960. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2961. return 0;
  2962. }
  2963. // big monster spawning [Valaris]
  2964. int atcommand_monsterbig(
  2965. const int fd, struct map_session_data* sd,
  2966. const char* command, const char* message) {
  2967. char name[100] = "";
  2968. char monster[100] = "";
  2969. int mob_id = 0;
  2970. int number = 0;
  2971. int x = 0;
  2972. int y = 0;
  2973. int count;
  2974. int i;
  2975. nullpo_retr(-1, sd);
  2976. if (!message || !*message) {
  2977. clif_displaymessage(fd, "Give a monster name/id please.");
  2978. return 0;
  2979. }
  2980. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2981. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2982. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2983. clif_displaymessage(fd, "Give a monster name/id please.");
  2984. return 0;
  2985. }
  2986. // If monster identifier/name argument is a name
  2987. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2988. mob_id = atoi(monster);
  2989. if (mob_id == 0) {
  2990. clif_displaymessage(fd, "Monster name hasn't been found.");
  2991. return 0;
  2992. }
  2993. if (mob_id == 1288) {
  2994. clif_displaymessage(fd, "Cannot spawn emperium.");
  2995. return 0;
  2996. }
  2997. if (mob_id > 2000) {
  2998. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2999. return 0;
  3000. }
  3001. if (number <= 0)
  3002. number = 1;
  3003. if (strlen(name) < 1)
  3004. strcpy(name, "--ja--");
  3005. // 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
  3006. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3007. number = battle_config.atc_spawn_quantity_limit;
  3008. count = 0;
  3009. for (i = 0; i < number; i++) {
  3010. int mx, my;
  3011. if (x <= 0)
  3012. mx = sd->bl.x + (rand() % 11 - 5);
  3013. else
  3014. mx = x;
  3015. if (y <= 0)
  3016. my = sd->bl.y + (rand() % 11 - 5);
  3017. else
  3018. my = y;
  3019. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+4000, 1, "") != 0) ? 1 : 0;
  3020. }
  3021. if (count != 0)
  3022. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3023. else
  3024. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3025. return 0;
  3026. }
  3027. /*==========================================
  3028. *
  3029. *------------------------------------------
  3030. */
  3031. void atcommand_killmonster_sub(
  3032. const int fd, struct map_session_data* sd, const char* message,
  3033. const int drop)
  3034. {
  3035. int map_id;
  3036. char map_name[100];
  3037. if (!sd) return;
  3038. memset(map_name, '\0', sizeof(map_name));
  3039. if (!message || !*message || sscanf(message, "%99s", map_name) < 1)
  3040. map_id = sd->bl.m;
  3041. else {
  3042. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  3043. strcat(map_name, ".gat");
  3044. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3045. map_id = sd->bl.m;
  3046. }
  3047. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, drop);
  3048. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3049. return;
  3050. }
  3051. /*==========================================
  3052. *
  3053. *------------------------------------------
  3054. */
  3055. int atcommand_killmonster(
  3056. const int fd, struct map_session_data* sd,
  3057. const char* command, const char* message)
  3058. {
  3059. if (!sd) return 0;
  3060. atcommand_killmonster_sub(fd, sd, message, 1);
  3061. return 0;
  3062. }
  3063. /*==========================================
  3064. *
  3065. *------------------------------------------
  3066. */
  3067. int atcommand_killmonster2(
  3068. const int fd, struct map_session_data* sd,
  3069. const char* command, const char* message)
  3070. {
  3071. if (!sd) return 0;
  3072. atcommand_killmonster_sub(fd, sd, message, 0);
  3073. return 0;
  3074. }
  3075. /*==========================================
  3076. *
  3077. *------------------------------------------
  3078. */
  3079. int atcommand_refine(
  3080. const int fd, struct map_session_data* sd,
  3081. const char* command, const char* message)
  3082. {
  3083. int i, position = 0, refine = 0, current_position, final_refine;
  3084. int count;
  3085. char output[200];
  3086. nullpo_retr(-1, sd);
  3087. memset(output, '\0', sizeof(output));
  3088. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3089. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3090. return -1;
  3091. }
  3092. if (refine < -10)
  3093. refine = -10;
  3094. else if (refine > 10)
  3095. refine = 10;
  3096. else if (refine == 0)
  3097. refine = 1;
  3098. count = 0;
  3099. for (i = 0; i < MAX_INVENTORY; i++) {
  3100. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3101. (sd->status.inventory[i].equip & position ||
  3102. (sd->status.inventory[i].equip && !position))) {
  3103. final_refine = sd->status.inventory[i].refine + refine;
  3104. if (final_refine > 10)
  3105. final_refine = 10;
  3106. else if (final_refine < 0)
  3107. final_refine = 0;
  3108. if (sd->status.inventory[i].refine != final_refine) {
  3109. sd->status.inventory[i].refine = final_refine;
  3110. current_position = sd->status.inventory[i].equip;
  3111. pc_unequipitem(sd, i, 3);
  3112. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3113. clif_delitem(sd, i, 1);
  3114. clif_additem(sd, i, 1, 0);
  3115. pc_equipitem(sd, i, current_position);
  3116. clif_misceffect((struct block_list*)&sd->bl, 3);
  3117. count++;
  3118. }
  3119. }
  3120. }
  3121. if (count == 0)
  3122. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3123. else if (count == 1)
  3124. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3125. else {
  3126. sprintf(output, msg_table[168], count); // %d items have been refined!
  3127. clif_displaymessage(fd, output);
  3128. }
  3129. return 0;
  3130. }
  3131. /*==========================================
  3132. *
  3133. *------------------------------------------
  3134. */
  3135. int atcommand_produce(
  3136. const int fd, struct map_session_data* sd,
  3137. const char* command, const char* message)
  3138. {
  3139. char item_name[100];
  3140. int item_id, attribute = 0, star = 0;
  3141. int flag = 0;
  3142. struct item_data *item_data;
  3143. struct item tmp_item;
  3144. char output[200];
  3145. nullpo_retr(-1, sd);
  3146. memset(output, '\0', sizeof(output));
  3147. memset(item_name, '\0', sizeof(item_name));
  3148. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3149. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3150. return -1;
  3151. }
  3152. item_id = 0;
  3153. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3154. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3155. item_id = item_data->nameid;
  3156. if (itemdb_exists(item_id) &&
  3157. (item_id <= 500 || item_id > 1099) &&
  3158. (item_id < 4001 || item_id > 4148) &&
  3159. (item_id < 7001 || item_id > 10019) &&
  3160. itemdb_isequip(item_id)) {
  3161. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3162. attribute = ATTRIBUTE_NORMAL;
  3163. if (star < MIN_STAR || star > MAX_STAR)
  3164. star = 0;
  3165. memset(&tmp_item, 0, sizeof tmp_item);
  3166. tmp_item.nameid = item_id;
  3167. tmp_item.amount = 1;
  3168. tmp_item.identify = 1;
  3169. tmp_item.card[0] = 0x00ff;
  3170. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3171. *((unsigned long *)(&tmp_item.card[2])) = sd->char_id;
  3172. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3173. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3174. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3175. clif_additem(sd, 0, 0, flag);
  3176. } else {
  3177. if (battle_config.error_log)
  3178. printf("@produce NOT WEAPON [%d]\n", item_id);
  3179. if (item_id != 0 && itemdb_exists(item_id))
  3180. sprintf(output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3181. else
  3182. sprintf(output, msg_table[170]); // This item is not an equipment.
  3183. clif_displaymessage(fd, output);
  3184. return -1;
  3185. }
  3186. return 0;
  3187. }
  3188. /*==========================================
  3189. * Sub-function to display actual memo points
  3190. *------------------------------------------
  3191. */
  3192. void atcommand_memo_sub(struct map_session_data* sd) {
  3193. int i;
  3194. char output[200];
  3195. if (!sd) return;
  3196. memset(output, '\0', sizeof(output));
  3197. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3198. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3199. if (sd->status.memo_point[i].map[0])
  3200. 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);
  3201. else
  3202. sprintf(output, msg_table[171], i); // %d - void
  3203. clif_displaymessage(sd->fd, output);
  3204. }
  3205. return;
  3206. }
  3207. /*==========================================
  3208. *
  3209. *------------------------------------------
  3210. */
  3211. int atcommand_memo(
  3212. const int fd, struct map_session_data* sd,
  3213. const char* command, const char* message)
  3214. {
  3215. int position = 0;
  3216. char output[200];
  3217. nullpo_retr(-1, sd);
  3218. memset(output, '\0', sizeof(output));
  3219. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3220. atcommand_memo_sub(sd);
  3221. else {
  3222. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3223. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3224. clif_displaymessage(fd, "You are not authorised to memo this map.");
  3225. return -1;
  3226. }
  3227. if (sd->status.memo_point[position].map[0]) {
  3228. 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).
  3229. clif_displaymessage(fd, output);
  3230. }
  3231. memcpy(sd->status.memo_point[position].map, map[sd->bl.m].name, 24);
  3232. sd->status.memo_point[position].x = sd->bl.x;
  3233. sd->status.memo_point[position].y = sd->bl.y;
  3234. clif_skill_memo(sd, 0);
  3235. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3236. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3237. atcommand_memo_sub(sd);
  3238. } else {
  3239. sprintf(output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3240. clif_displaymessage(fd, output);
  3241. atcommand_memo_sub(sd);
  3242. return -1;
  3243. }
  3244. }
  3245. return 0;
  3246. }
  3247. /*==========================================
  3248. *
  3249. *------------------------------------------
  3250. */
  3251. int atcommand_gat(
  3252. const int fd, struct map_session_data* sd,
  3253. const char* command, const char* message)
  3254. {
  3255. char output[200];
  3256. int y;
  3257. nullpo_retr(-1, sd);
  3258. memset(output, '\0', sizeof(output));
  3259. for (y = 2; y >= -2; y--) {
  3260. sprintf(output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3261. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3262. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y,CELL_CHKTYPE),
  3263. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y,CELL_CHKTYPE),
  3264. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y,CELL_CHKTYPE),
  3265. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y,CELL_CHKTYPE),
  3266. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y,CELL_CHKTYPE));
  3267. clif_displaymessage(fd, output);
  3268. }
  3269. return 0;
  3270. }
  3271. /*==========================================
  3272. *
  3273. *------------------------------------------
  3274. */
  3275. int atcommand_packet(
  3276. const int fd, struct map_session_data* sd,
  3277. const char* command, const char* message)
  3278. {
  3279. int x = 0, y = 0;
  3280. nullpo_retr(-1, sd);
  3281. if (!message || !*message || sscanf(message, "%d %d", &x, &y) < 2) {
  3282. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3283. return -1;
  3284. }
  3285. clif_status_change(&sd->bl, x, y);
  3286. return 0;
  3287. }
  3288. /*==========================================
  3289. * @stpoint (Rewritten by [Yor])
  3290. *------------------------------------------
  3291. */
  3292. int atcommand_statuspoint(
  3293. const int fd, struct map_session_data* sd,
  3294. const char* command, const char* message)
  3295. {
  3296. int point, new_status_point;
  3297. if (!message || !*message || (point = atoi(message)) == 0) {
  3298. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3299. return -1;
  3300. }
  3301. new_status_point = (int)sd->status.status_point + point;
  3302. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3303. new_status_point = 0x7FFF;
  3304. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3305. new_status_point = 0;
  3306. if (new_status_point != (int)sd->status.status_point) {
  3307. sd->status.status_point = (short)new_status_point;
  3308. clif_updatestatus(sd, SP_STATUSPOINT);
  3309. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3310. } else {
  3311. if (point < 0)
  3312. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3313. else
  3314. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3315. return -1;
  3316. }
  3317. return 0;
  3318. }
  3319. /*==========================================
  3320. * @skpoint (Rewritten by [Yor])
  3321. *------------------------------------------
  3322. */
  3323. int atcommand_skillpoint(
  3324. const int fd, struct map_session_data* sd,
  3325. const char* command, const char* message)
  3326. {
  3327. int point, new_skill_point;
  3328. nullpo_retr(-1, sd);
  3329. if (!message || !*message || (point = atoi(message)) == 0) {
  3330. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3331. return -1;
  3332. }
  3333. new_skill_point = (int)sd->status.skill_point + point;
  3334. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3335. new_skill_point = 0x7FFF;
  3336. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3337. new_skill_point = 0;
  3338. if (new_skill_point != (int)sd->status.skill_point) {
  3339. sd->status.skill_point = (short)new_skill_point;
  3340. clif_updatestatus(sd, SP_SKILLPOINT);
  3341. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3342. } else {
  3343. if (point < 0)
  3344. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3345. else
  3346. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3347. return -1;
  3348. }
  3349. return 0;
  3350. }
  3351. /*==========================================
  3352. * @zeny (Rewritten by [Yor])
  3353. *------------------------------------------
  3354. */
  3355. int atcommand_zeny(
  3356. const int fd, struct map_session_data* sd,
  3357. const char* command, const char* message)
  3358. {
  3359. int zeny, new_zeny;
  3360. nullpo_retr(-1, sd);
  3361. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3362. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3363. return -1;
  3364. }
  3365. new_zeny = sd->status.zeny + zeny;
  3366. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3367. new_zeny = MAX_ZENY;
  3368. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3369. new_zeny = 0;
  3370. if (new_zeny != sd->status.zeny) {
  3371. sd->status.zeny = new_zeny;
  3372. clif_updatestatus(sd, SP_ZENY);
  3373. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3374. } else {
  3375. if (zeny < 0)
  3376. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3377. else
  3378. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3379. return -1;
  3380. }
  3381. return 0;
  3382. }
  3383. /*==========================================
  3384. *
  3385. *------------------------------------------
  3386. */
  3387. int atcommand_param(
  3388. const int fd, struct map_session_data* sd,
  3389. const char* command, const char* message)
  3390. {
  3391. int i, index, value = 0, new_value;
  3392. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3393. short* status[] = {
  3394. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3395. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3396. };
  3397. char output[200];
  3398. nullpo_retr(-1, sd);
  3399. memset(output, '\0', sizeof(output));
  3400. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3401. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3402. clif_displaymessage(fd, output);
  3403. return -1;
  3404. }
  3405. index = -1;
  3406. for (i = 0; param[i] != NULL; i++) {
  3407. if (strcmpi(command, param[i]) == 0) {
  3408. index = i;
  3409. break;
  3410. }
  3411. }
  3412. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3413. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3414. clif_displaymessage(fd, output);
  3415. return -1;
  3416. }
  3417. new_value = (int)*status[index] + value;
  3418. if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
  3419. new_value = battle_config.max_parameter;
  3420. else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3421. new_value = 1;
  3422. if (new_value != (int)*status[index]) {
  3423. *status[index] = new_value;
  3424. clif_updatestatus(sd, SP_STR + index);
  3425. clif_updatestatus(sd, SP_USTR + index);
  3426. pc_calcstatus(sd, 0);
  3427. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3428. } else {
  3429. if (value < 0)
  3430. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3431. else
  3432. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3433. return -1;
  3434. }
  3435. return 0;
  3436. }
  3437. /*==========================================
  3438. *
  3439. *------------------------------------------
  3440. */
  3441. //** Stat all by fritz (rewritten by [Yor])
  3442. int atcommand_stat_all(
  3443. const int fd, struct map_session_data* sd,
  3444. const char* command, const char* message)
  3445. {
  3446. int index, count, value = 0, new_value;
  3447. short* status[] = {
  3448. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3449. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3450. };
  3451. nullpo_retr(-1, sd);
  3452. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3453. value = battle_config.max_parameter;
  3454. count = 0;
  3455. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3456. new_value = (int)*status[index] + value;
  3457. if (value > 0 && (value > battle_config.max_parameter || new_value > battle_config.max_parameter)) // fix positiv overflow
  3458. new_value = battle_config.max_parameter;
  3459. else if (value < 0 && (value < -battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3460. new_value = 1;
  3461. if (new_value != (int)*status[index]) {
  3462. *status[index] = new_value;
  3463. clif_updatestatus(sd, SP_STR + index);
  3464. clif_updatestatus(sd, SP_USTR + index);
  3465. pc_calcstatus(sd, 0);
  3466. count++;
  3467. }
  3468. }
  3469. if (count > 0) // if at least 1 stat modified
  3470. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3471. else {
  3472. if (value < 0)
  3473. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3474. else
  3475. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3476. return -1;
  3477. }
  3478. return 0;
  3479. }
  3480. /*==========================================
  3481. *
  3482. *------------------------------------------
  3483. */
  3484. int atcommand_guildlevelup(
  3485. const int fd, struct map_session_data* sd,
  3486. const char* command, const char* message)
  3487. {
  3488. int level = 0;
  3489. short added_level;
  3490. struct guild *guild_info;
  3491. nullpo_retr(-1, sd);
  3492. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3493. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3494. return -1;
  3495. }
  3496. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3497. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3498. return -1;
  3499. }
  3500. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3501. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3502. return -1;
  3503. }
  3504. added_level = (short)level;
  3505. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3506. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3507. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3508. added_level = 1 - guild_info->guild_lv;
  3509. if (added_level != 0) {
  3510. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3511. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3512. } else {
  3513. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3514. return -1;
  3515. }
  3516. return 0;
  3517. }
  3518. /*==========================================
  3519. *
  3520. *------------------------------------------
  3521. */
  3522. int atcommand_makeegg(
  3523. const int fd, struct map_session_data* sd,
  3524. const char* command, const char* message)
  3525. {
  3526. struct item_data *item_data;
  3527. int id, pet_id;
  3528. nullpo_retr(-1, sd);
  3529. if (!message || !*message) {
  3530. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3531. return -1;
  3532. }
  3533. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3534. id = item_data->nameid;
  3535. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3536. id = atoi(message);
  3537. pet_id = search_petDB_index(id, PET_CLASS);
  3538. if (pet_id < 0)
  3539. pet_id = search_petDB_index(id, PET_EGG);
  3540. if (pet_id >= 0) {
  3541. sd->catch_target_class = pet_db[pet_id].class;
  3542. intif_create_pet(
  3543. sd->status.account_id, sd->status.char_id,
  3544. pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
  3545. pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
  3546. 100, 0, 1, pet_db[pet_id].jname);
  3547. } else {
  3548. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3549. return -1;
  3550. }
  3551. return 0;
  3552. }
  3553. /*==========================================
  3554. *
  3555. *------------------------------------------
  3556. */
  3557. int atcommand_hatch(
  3558. const int fd, struct map_session_data* sd,
  3559. const char* command, const char* message)
  3560. {
  3561. nullpo_retr(-1, sd);
  3562. if (sd->status.pet_id <= 0)
  3563. clif_sendegg(sd);
  3564. else {
  3565. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3566. return -1;
  3567. }
  3568. return 0;
  3569. }
  3570. /*==========================================
  3571. *
  3572. *------------------------------------------
  3573. */
  3574. int atcommand_petfriendly(
  3575. const int fd, struct map_session_data* sd,
  3576. const char* command, const char* message)
  3577. {
  3578. int friendly;
  3579. int t;
  3580. nullpo_retr(-1, sd);
  3581. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3582. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3583. return -1;
  3584. }
  3585. if (sd->status.pet_id > 0 && sd->pd) {
  3586. if (friendly >= 0 && friendly <= 1000) {
  3587. if (friendly != sd->pet.intimate) {
  3588. t = sd->pet.intimate;
  3589. sd->pet.intimate = friendly;
  3590. clif_send_petstatus(sd);
  3591. if (battle_config.pet_status_support) {
  3592. if ((sd->pet.intimate > 0 && t <= 0) ||
  3593. (sd->pet.intimate <= 0 && t > 0)) {
  3594. if (sd->bl.prev != NULL)
  3595. pc_calcstatus(sd, 0);
  3596. else
  3597. pc_calcstatus(sd, 2);
  3598. }
  3599. }
  3600. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3601. } else {
  3602. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3603. return -1;
  3604. }
  3605. } else {
  3606. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3607. return -1;
  3608. }
  3609. } else {
  3610. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3611. return -1;
  3612. }
  3613. return 0;
  3614. }
  3615. /*==========================================
  3616. *
  3617. *------------------------------------------
  3618. */
  3619. int atcommand_pethungry(
  3620. const int fd, struct map_session_data* sd,
  3621. const char* command, const char* message)
  3622. {
  3623. int hungry;
  3624. nullpo_retr(-1, sd);
  3625. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3626. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3627. return -1;
  3628. }
  3629. if (sd->status.pet_id > 0 && sd->pd) {
  3630. if (hungry >= 0 && hungry <= 100) {
  3631. if (hungry != sd->pet.hungry) {
  3632. sd->pet.hungry = hungry;
  3633. clif_send_petstatus(sd);
  3634. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3635. } else {
  3636. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3637. return -1;
  3638. }
  3639. } else {
  3640. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3641. return -1;
  3642. }
  3643. } else {
  3644. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3645. return -1;
  3646. }
  3647. return 0;
  3648. }
  3649. /*==========================================
  3650. *
  3651. *------------------------------------------
  3652. */
  3653. int atcommand_petrename(
  3654. const int fd, struct map_session_data* sd,
  3655. const char* command, const char* message)
  3656. {
  3657. nullpo_retr(-1, sd);
  3658. if (sd->status.pet_id > 0 && sd->pd) {
  3659. if (sd->pet.rename_flag != 0) {
  3660. sd->pet.rename_flag = 0;
  3661. intif_save_petdata(sd->status.account_id, &sd->pet);
  3662. clif_send_petstatus(sd);
  3663. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3664. } else {
  3665. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3666. return -1;
  3667. }
  3668. } else {
  3669. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3670. return -1;
  3671. }
  3672. return 0;
  3673. }
  3674. /*==========================================
  3675. *
  3676. *------------------------------------------
  3677. */
  3678. int
  3679. atcommand_recall(
  3680. const int fd, struct map_session_data* sd,
  3681. const char* command, const char* message)
  3682. {
  3683. char character[100];
  3684. char output[200];
  3685. struct map_session_data *pl_sd = NULL;
  3686. nullpo_retr(-1, sd);
  3687. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3688. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3689. return -1;
  3690. }
  3691. memset(character, '\0', sizeof character);
  3692. if(sscanf(message, "%99[^\n]", character) < 1)
  3693. return -1;
  3694. if(strncmp(sd->status.name,character,24)==0)
  3695. return -1;
  3696. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3697. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3698. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3699. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3700. return -1;
  3701. }
  3702. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3703. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  3704. return -1;
  3705. }
  3706. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  3707. sprintf(output, msg_table[46], character); // %s recalled!
  3708. clif_displaymessage(fd, output);
  3709. } else {
  3710. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3711. return -1;
  3712. }
  3713. } else {
  3714. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3715. return -1;
  3716. }
  3717. return 0;
  3718. }
  3719. /*==========================================
  3720. *
  3721. *------------------------------------------
  3722. */
  3723. int atcommand_revive(
  3724. const int fd, struct map_session_data* sd,
  3725. const char* command, const char* message)
  3726. {
  3727. char character[100];
  3728. struct map_session_data *pl_sd;
  3729. nullpo_retr(-1, sd);
  3730. memset(character, '\0', sizeof(character));
  3731. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3732. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3733. return -1;
  3734. }
  3735. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3736. if (pc_isdead(pl_sd)) {
  3737. pl_sd->status.hp = pl_sd->status.max_hp;
  3738. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3739. pc_setstand(pl_sd);
  3740. if (battle_config.pc_invincible_time > 0)
  3741. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3742. clif_updatestatus(pl_sd, SP_HP);
  3743. clif_updatestatus(pl_sd, SP_SP);
  3744. clif_resurrection(&pl_sd->bl, 1);
  3745. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3746. return 0;
  3747. }
  3748. return -1;
  3749. } else {
  3750. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3751. return -1;
  3752. }
  3753. return 0;
  3754. }
  3755. /*==========================================
  3756. * charchangesex command (usage: charchangesex <player_name>)
  3757. *------------------------------------------
  3758. */
  3759. int atcommand_char_change_sex(
  3760. const int fd, struct map_session_data* sd,
  3761. const char* command, const char* message)
  3762. {
  3763. char character[100];
  3764. nullpo_retr(-1, sd);
  3765. memset(character, '\0', sizeof(character));
  3766. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3767. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  3768. return -1;
  3769. }
  3770. // check player name
  3771. if (strlen(character) < 4) {
  3772. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3773. return -1;
  3774. } else if (strlen(character) > 23) {
  3775. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3776. return -1;
  3777. } else {
  3778. chrif_char_ask_name(sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
  3779. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3780. }
  3781. return 0;
  3782. }
  3783. /*==========================================
  3784. * charblock command (usage: charblock <player_name>)
  3785. * This command do a definitiv ban on a player
  3786. *------------------------------------------
  3787. */
  3788. int atcommand_char_block(
  3789. const int fd, struct map_session_data* sd,
  3790. const char* command, const char* message)
  3791. {
  3792. char character[100];
  3793. nullpo_retr(-1, sd);
  3794. memset(character, '\0', sizeof(character));
  3795. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3796. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3797. return -1;
  3798. }
  3799. // check player name
  3800. if (strlen(character) < 4) {
  3801. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3802. return -1;
  3803. } else if (strlen(character) > 23) {
  3804. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3805. return -1;
  3806. } else {
  3807. chrif_char_ask_name(sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3808. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3809. }
  3810. return 0;
  3811. }
  3812. /*==========================================
  3813. * charban command (usage: charban <time> <player_name>)
  3814. * This command do a limited ban on a player
  3815. * Time is done as follows:
  3816. * Adjustment value (-1, 1, +1, etc...)
  3817. * Modified element:
  3818. * a or y: year
  3819. * m: month
  3820. * j or d: day
  3821. * h: hour
  3822. * mn: minute
  3823. * s: second
  3824. * <example> @ban +1m-2mn1s-6y test_player
  3825. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3826. *------------------------------------------
  3827. */
  3828. int atcommand_char_ban(
  3829. const int fd, struct map_session_data* sd,
  3830. const char* command, const char* message)
  3831. {
  3832. char modif[100], character[100];
  3833. char * modif_p;
  3834. int year, month, day, hour, minute, second, value;
  3835. nullpo_retr(-1, sd);
  3836. memset(modif, '\0', sizeof(modif));
  3837. memset(character, '\0', sizeof(character));
  3838. if (!message || !*message || sscanf(message, "%s %99[^\n]", modif, character) < 2) {
  3839. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3840. return -1;
  3841. }
  3842. modif[sizeof(modif)-1] = '\0';
  3843. character[sizeof(character)-1] = '\0';
  3844. modif_p = modif;
  3845. year = month = day = hour = minute = second = 0;
  3846. while (modif_p[0] != '\0') {
  3847. value = atoi(modif_p);
  3848. if (value == 0)
  3849. modif_p++;
  3850. else {
  3851. if (modif_p[0] == '-' || modif_p[0] == '+')
  3852. modif_p++;
  3853. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3854. modif_p++;
  3855. if (modif_p[0] == 's') {
  3856. second = value;
  3857. modif_p++;
  3858. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3859. minute = value;
  3860. modif_p = modif_p + 2;
  3861. } else if (modif_p[0] == 'h') {
  3862. hour = value;
  3863. modif_p++;
  3864. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3865. day = value;
  3866. modif_p++;
  3867. } else if (modif_p[0] == 'm') {
  3868. month = value;
  3869. modif_p++;
  3870. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3871. year = value;
  3872. modif_p++;
  3873. } else if (modif_p[0] != '\0') {
  3874. modif_p++;
  3875. }
  3876. }
  3877. }
  3878. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3879. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  3880. return -1;
  3881. }
  3882. // check player name
  3883. if (strlen(character) < 4) {
  3884. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3885. return -1;
  3886. } else if (strlen(character) > 23) {
  3887. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3888. return -1;
  3889. } else {
  3890. chrif_char_ask_name(sd->status.account_id, character, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3891. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3892. }
  3893. return 0;
  3894. }
  3895. /*==========================================
  3896. * charunblock command (usage: charunblock <player_name>)
  3897. *------------------------------------------
  3898. */
  3899. int atcommand_char_unblock(
  3900. const int fd, struct map_session_data* sd,
  3901. const char* command, const char* message)
  3902. {
  3903. char character[100];
  3904. nullpo_retr(-1, sd);
  3905. memset(character, '\0', sizeof(character));
  3906. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3907. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3908. return -1;
  3909. }
  3910. // check player name
  3911. if (strlen(character) < 4) {
  3912. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3913. return -1;
  3914. } else if (strlen(character) > 23) {
  3915. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3916. return -1;
  3917. } else {
  3918. // send answer to login server via char-server
  3919. chrif_char_ask_name(sd->status.account_id, character, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3920. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3921. }
  3922. return 0;
  3923. }
  3924. /*==========================================
  3925. * charunban command (usage: charunban <player_name>)
  3926. *------------------------------------------
  3927. */
  3928. int atcommand_char_unban(
  3929. const int fd, struct map_session_data* sd,
  3930. const char* command, const char* message)
  3931. {
  3932. char character[100];
  3933. nullpo_retr(-1, sd);
  3934. memset(character, '\0', sizeof(character));
  3935. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3936. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3937. return -1;
  3938. }
  3939. // check player name
  3940. if (strlen(character) < 4) {
  3941. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3942. return -1;
  3943. } else if (strlen(character) > 23) {
  3944. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3945. return -1;
  3946. } else {
  3947. // send answer to login server via char-server
  3948. chrif_char_ask_name(sd->status.account_id, character, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3949. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3950. }
  3951. return 0;
  3952. }
  3953. /*==========================================
  3954. *
  3955. *------------------------------------------
  3956. */
  3957. int atcommand_night(
  3958. const int fd, struct map_session_data* sd,
  3959. const char* command, const char* message)
  3960. {
  3961. struct map_session_data *pl_sd;
  3962. int i;
  3963. nullpo_retr(-1, sd);
  3964. if (night_flag != 1) {
  3965. night_flag = 1; // 0=day, 1=night [Yor]
  3966. for(i = 0; i < fd_max; i++) {
  3967. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !map[sd->bl.m].flag.indoors) {
  3968. //pl_sd->opt2 |= STATE_BLIND;
  3969. //clif_changeoption(&pl_sd->bl);
  3970. if (battle_config.night_darkness_level > 0)
  3971. clif_specialeffect(&pl_sd->bl, 474 + battle_config.night_darkness_level, 0);
  3972. else {
  3973. //clif_specialeffect(&pl_sd->bl, 483, 0); // default darkness level
  3974. pl_sd->opt2 |= STATE_BLIND;
  3975. clif_changeoption(&pl_sd->bl);
  3976. }
  3977. clif_displaymessage(pl_sd->fd, msg_table[59]); // Night has fallen.
  3978. }
  3979. }
  3980. } else {
  3981. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  3982. return -1;
  3983. }
  3984. return 0;
  3985. }
  3986. /*==========================================
  3987. *
  3988. *------------------------------------------
  3989. */
  3990. int atcommand_day(
  3991. const int fd, struct map_session_data* sd,
  3992. const char* command, const char* message)
  3993. {
  3994. struct map_session_data *pl_sd;
  3995. int i;
  3996. nullpo_retr(-1, sd);
  3997. if (night_flag != 0) {
  3998. night_flag = 0; // 0=day, 1=night [Yor]
  3999. for(i = 0; i < fd_max; i++) {
  4000. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4001. pl_sd->opt2 &= ~STATE_BLIND;
  4002. clif_changeoption(&pl_sd->bl);
  4003. clif_displaymessage(pl_sd->fd, msg_table[60]); // Day has arrived.
  4004. }
  4005. }
  4006. } else {
  4007. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4008. return -1;
  4009. }
  4010. return 0;
  4011. }
  4012. /*==========================================
  4013. *
  4014. *------------------------------------------
  4015. */
  4016. int atcommand_doom(
  4017. const int fd, struct map_session_data* sd,
  4018. const char* command, const char* message)
  4019. {
  4020. struct map_session_data *pl_sd;
  4021. int i;
  4022. nullpo_retr(-1, sd);
  4023. clif_specialeffect(&sd->bl,450,2);
  4024. for(i = 0; i < fd_max; i++) {
  4025. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd &&
  4026. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4027. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4028. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4029. }
  4030. }
  4031. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4032. return 0;
  4033. }
  4034. /*==========================================
  4035. *
  4036. *------------------------------------------
  4037. */
  4038. int atcommand_doommap(
  4039. const int fd, struct map_session_data* sd,
  4040. const char* command, const char* message)
  4041. {
  4042. struct map_session_data *pl_sd;
  4043. int i;
  4044. nullpo_retr(-1, sd);
  4045. clif_specialeffect(&sd->bl,450,3);
  4046. for (i = 0; i < fd_max; i++) {
  4047. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd && sd->bl.m == pl_sd->bl.m &&
  4048. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4049. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4050. // clif_specialeffect(&pl_sd->bl,450,1);
  4051. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4052. }
  4053. }
  4054. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4055. return 0;
  4056. }
  4057. /*==========================================
  4058. *
  4059. *------------------------------------------
  4060. */
  4061. static void atcommand_raise_sub(struct map_session_data* sd)
  4062. {
  4063. if (sd && sd->state.auth && pc_isdead(sd)) {
  4064. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4065. sd->status.hp = sd->status.max_hp;
  4066. sd->status.sp = sd->status.max_sp;
  4067. pc_setstand(sd);
  4068. clif_updatestatus(sd, SP_HP);
  4069. clif_updatestatus(sd, SP_SP);
  4070. clif_resurrection(&sd->bl, 1);
  4071. if (battle_config.pc_invincible_time > 0)
  4072. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4073. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4074. }
  4075. }
  4076. /*==========================================
  4077. *
  4078. *------------------------------------------
  4079. */
  4080. int atcommand_raise(
  4081. const int fd, struct map_session_data* sd,
  4082. const char* command, const char* message)
  4083. {
  4084. int i;
  4085. nullpo_retr(-1, sd);
  4086. for (i = 0; i < fd_max; i++) {
  4087. if (session[i])
  4088. atcommand_raise_sub(session[i]->session_data);
  4089. }
  4090. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4091. return 0;
  4092. }
  4093. /*==========================================
  4094. *
  4095. *------------------------------------------
  4096. */
  4097. int atcommand_raisemap(
  4098. const int fd, struct map_session_data* sd,
  4099. const char* command, const char* message)
  4100. {
  4101. struct map_session_data *pl_sd;
  4102. int i;
  4103. nullpo_retr(-1, sd);
  4104. for (i = 0; i < fd_max; i++) {
  4105. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->bl.m == pl_sd->bl.m)
  4106. atcommand_raise_sub(pl_sd);
  4107. }
  4108. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4109. return 0;
  4110. }
  4111. /*==========================================
  4112. * atcommand_character_baselevel @charbaselvlで対象キャラのレベルを上げる
  4113. *------------------------------------------
  4114. */
  4115. int atcommand_character_baselevel(
  4116. const int fd, struct map_session_data* sd,
  4117. const char* command, const char* message)
  4118. {
  4119. struct map_session_data *pl_sd;
  4120. char character[100];
  4121. int level = 0, i;
  4122. nullpo_retr(-1, sd);
  4123. memset(character, '\0', sizeof(character));
  4124. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4125. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charbaselvl <#> <nickname>).");
  4126. return -1;
  4127. }
  4128. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4129. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  4130. if (level > 0) {
  4131. if (pl_sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  4132. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  4133. return 0;
  4134. } // End Addition
  4135. if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
  4136. level = battle_config.maximum_level - pl_sd->status.base_level;
  4137. for (i = 1; i <= level; i++)
  4138. pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5;
  4139. pl_sd->status.base_level += level;
  4140. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4141. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4142. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4143. pc_calcstatus(pl_sd, 0);
  4144. pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp);
  4145. clif_misceffect(&pl_sd->bl, 0);
  4146. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  4147. } else {
  4148. if (pl_sd->status.base_level == 1) {
  4149. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  4150. return -1;
  4151. }
  4152. if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) // fix negativ overflow
  4153. level = 1 - pl_sd->status.base_level;
  4154. if (pl_sd->status.status_point > 0) {
  4155. for (i = 0; i > level; i--)
  4156. pl_sd->status.status_point -= (pl_sd->status.base_level + i + 14) / 5;
  4157. if (pl_sd->status.status_point < 0)
  4158. pl_sd->status.status_point = 0;
  4159. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4160. } // to add: remove status points from stats
  4161. pl_sd->status.base_level += level;
  4162. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4163. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4164. pc_calcstatus(pl_sd, 0);
  4165. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  4166. }
  4167. } else {
  4168. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4169. return -1;
  4170. }
  4171. } else {
  4172. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4173. return -1;
  4174. }
  4175. return 0; //正常終了
  4176. }
  4177. /*==========================================
  4178. * atcommand_character_joblevel @charjoblvlで対象キャラのJobレベルを上げる
  4179. *------------------------------------------
  4180. */
  4181. int atcommand_character_joblevel(
  4182. const int fd, struct map_session_data* sd,
  4183. const char* command, const char* message)
  4184. {
  4185. struct map_session_data *pl_sd;
  4186. char character[100];
  4187. int max_level = 50, level = 0;
  4188. //転生や養子の場合の元の職業を算出する
  4189. struct pc_base_job pl_s_class;
  4190. nullpo_retr(-1, sd);
  4191. memset(character, '\0', sizeof(character));
  4192. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4193. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charjlvl <#> <nickname>).");
  4194. return -1;
  4195. }
  4196. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4197. pl_s_class = pc_calc_base_job(pl_sd->status.class);
  4198. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  4199. if (pl_s_class.job == 0)
  4200. max_level -= 40;
  4201. // super novices can go up to 99 [celest]
  4202. else if (pl_s_class.job == 23)
  4203. max_level += 49;
  4204. else if (pl_sd->status.class > 4007 && pl_sd->status.class < 4023)
  4205. max_level += 20;
  4206. if (level > 0) {
  4207. if (pl_sd->status.job_level == max_level) {
  4208. clif_displaymessage(fd, msg_table[67]); // Character's job level can't go any higher.
  4209. return -1;
  4210. }
  4211. if (pl_sd->status.job_level + level > max_level)
  4212. level = max_level - pl_sd->status.job_level;
  4213. pl_sd->status.job_level += level;
  4214. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4215. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4216. pl_sd->status.skill_point += level;
  4217. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4218. pc_calcstatus(pl_sd, 0);
  4219. clif_misceffect(&pl_sd->bl, 1);
  4220. clif_displaymessage(fd, msg_table[68]); // character's job level raised.
  4221. } else {
  4222. if (pl_sd->status.job_level == 1) {
  4223. clif_displaymessage(fd, msg_table[194]); // Character's job level can't go any lower.
  4224. return -1;
  4225. }
  4226. if (pl_sd->status.job_level + level < 1)
  4227. level = 1 - pl_sd->status.job_level;
  4228. pl_sd->status.job_level += level;
  4229. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4230. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4231. if (pl_sd->status.skill_point > 0) {
  4232. pl_sd->status.skill_point += level;
  4233. if (pl_sd->status.skill_point < 0)
  4234. pl_sd->status.skill_point = 0;
  4235. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4236. } // to add: remove status points from skills
  4237. pc_calcstatus(pl_sd, 0);
  4238. clif_displaymessage(fd, msg_table[69]); // Character's job level lowered.
  4239. }
  4240. } else {
  4241. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4242. return -1;
  4243. }
  4244. } else {
  4245. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4246. return -1;
  4247. }
  4248. return 0;
  4249. }
  4250. /*==========================================
  4251. *
  4252. *------------------------------------------
  4253. */
  4254. int atcommand_kick(
  4255. const int fd, struct map_session_data* sd,
  4256. const char* command, const char* message)
  4257. {
  4258. struct map_session_data *pl_sd;
  4259. char character[100];
  4260. nullpo_retr(-1, sd);
  4261. memset(character, '\0', sizeof(character));
  4262. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4263. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4264. return -1;
  4265. }
  4266. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4267. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4268. clif_GM_kick(sd, pl_sd, 1);
  4269. else {
  4270. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4271. return -1;
  4272. }
  4273. } else {
  4274. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4275. return -1;
  4276. }
  4277. return 0;
  4278. }
  4279. /*==========================================
  4280. *
  4281. *------------------------------------------
  4282. */
  4283. int atcommand_kickall(
  4284. const int fd, struct map_session_data* sd,
  4285. const char* command, const char* message)
  4286. {
  4287. struct map_session_data *pl_sd;
  4288. int i;
  4289. nullpo_retr(-1, sd);
  4290. for (i = 0; i < fd_max; i++) {
  4291. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4292. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4293. if (sd->status.account_id != pl_sd->status.account_id)
  4294. clif_GM_kick(sd, pl_sd, 0);
  4295. }
  4296. }
  4297. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4298. return 0;
  4299. }
  4300. /*==========================================
  4301. *
  4302. *------------------------------------------
  4303. */
  4304. int atcommand_allskill(
  4305. const int fd, struct map_session_data* sd,
  4306. const char* command, const char* message)
  4307. {
  4308. nullpo_retr(-1, sd);
  4309. pc_allskillup(sd); // all skills
  4310. sd->status.skill_point = 0; // 0 skill points
  4311. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4312. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4313. return 0;
  4314. }
  4315. /*==========================================
  4316. *
  4317. *------------------------------------------
  4318. */
  4319. int atcommand_questskill(
  4320. const int fd, struct map_session_data* sd,
  4321. const char* command, const char* message)
  4322. {
  4323. int skill_id;
  4324. nullpo_retr(-1, sd);
  4325. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4326. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4327. return -1;
  4328. }
  4329. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4330. if (skill_get_inf2(skill_id) & 0x01) {
  4331. if (pc_checkskill(sd, skill_id) == 0) {
  4332. pc_skill(sd, skill_id, 1, 0);
  4333. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4334. } else {
  4335. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4336. return -1;
  4337. }
  4338. } else {
  4339. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4340. return -1;
  4341. }
  4342. } else {
  4343. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4344. return -1;
  4345. }
  4346. return 0;
  4347. }
  4348. /*==========================================
  4349. *
  4350. *------------------------------------------
  4351. */
  4352. int atcommand_charquestskill(
  4353. const int fd, struct map_session_data* sd,
  4354. const char* command, const char* message)
  4355. {
  4356. char character[100];
  4357. struct map_session_data *pl_sd;
  4358. int skill_id = 0;
  4359. nullpo_retr(-1, sd);
  4360. memset(character, '\0', sizeof(character));
  4361. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4362. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charquestskill <#:0+> <char_name>).");
  4363. return -1;
  4364. }
  4365. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4366. if (skill_get_inf2(skill_id) & 0x01) {
  4367. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4368. if (pc_checkskill(pl_sd, skill_id) == 0) {
  4369. pc_skill(pl_sd, skill_id, 1, 0);
  4370. clif_displaymessage(fd, msg_table[199]); // This player has learned the skill.
  4371. } else {
  4372. clif_displaymessage(fd, msg_table[200]); // This player already has this quest skill.
  4373. return -1;
  4374. }
  4375. } else {
  4376. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4377. return -1;
  4378. }
  4379. } else {
  4380. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4381. return -1;
  4382. }
  4383. } else {
  4384. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4385. return -1;
  4386. }
  4387. return 0;
  4388. }
  4389. /*==========================================
  4390. *
  4391. *------------------------------------------
  4392. */
  4393. int atcommand_lostskill(
  4394. const int fd, struct map_session_data* sd,
  4395. const char* command, const char* message)
  4396. {
  4397. int skill_id;
  4398. nullpo_retr(-1, sd);
  4399. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4400. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4401. return -1;
  4402. }
  4403. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4404. if (skill_get_inf2(skill_id) & 0x01) {
  4405. if (pc_checkskill(sd, skill_id) > 0) {
  4406. sd->status.skill[skill_id].lv = 0;
  4407. sd->status.skill[skill_id].flag = 0;
  4408. clif_skillinfoblock(sd);
  4409. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4410. } else {
  4411. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4412. return -1;
  4413. }
  4414. } else {
  4415. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4416. return -1;
  4417. }
  4418. } else {
  4419. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4420. return -1;
  4421. }
  4422. return 0;
  4423. }
  4424. /*==========================================
  4425. *
  4426. *------------------------------------------
  4427. */
  4428. int atcommand_charlostskill(
  4429. const int fd, struct map_session_data* sd,
  4430. const char* command, const char* message)
  4431. {
  4432. char character[100];
  4433. struct map_session_data *pl_sd;
  4434. int skill_id = 0;
  4435. nullpo_retr(-1, sd);
  4436. memset(character, '\0', sizeof(character));
  4437. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4438. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  4439. return -1;
  4440. }
  4441. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4442. if (skill_get_inf2(skill_id) & 0x01) {
  4443. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4444. if (pc_checkskill(pl_sd, skill_id) > 0) {
  4445. pl_sd->status.skill[skill_id].lv = 0;
  4446. pl_sd->status.skill[skill_id].flag = 0;
  4447. clif_skillinfoblock(pl_sd);
  4448. clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill.
  4449. } else {
  4450. clif_displaymessage(fd, msg_table[203]); // This player doesn't have this quest skill.
  4451. return -1;
  4452. }
  4453. } else {
  4454. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4455. return -1;
  4456. }
  4457. } else {
  4458. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4459. return -1;
  4460. }
  4461. } else {
  4462. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4463. return -1;
  4464. }
  4465. return 0;
  4466. }
  4467. /*==========================================
  4468. *
  4469. *------------------------------------------
  4470. */
  4471. int atcommand_spiritball(
  4472. const int fd, struct map_session_data* sd,
  4473. const char* command, const char* message)
  4474. {
  4475. int number;
  4476. nullpo_retr(-1, sd);
  4477. if (!message || !*message || (number = atoi(message)) < 0) {
  4478. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4479. return -1;
  4480. }
  4481. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4482. if (number > 500)
  4483. number = 500;
  4484. if (number >= 0 && number <= 0x7FFF) {
  4485. if (sd->spiritball != number || number > 499) {
  4486. if (sd->spiritball > 0)
  4487. pc_delspiritball(sd, sd->spiritball, 1);
  4488. sd->spiritball = number;
  4489. clif_spiritball(sd);
  4490. // no message, player can look the difference
  4491. if (number > 1000)
  4492. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4493. } else {
  4494. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4495. return -1;
  4496. }
  4497. } else {
  4498. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4499. return -1;
  4500. }
  4501. return 0;
  4502. }
  4503. /*==========================================
  4504. *
  4505. *------------------------------------------
  4506. */
  4507. int atcommand_party(
  4508. const int fd, struct map_session_data* sd,
  4509. const char* command, const char* message)
  4510. {
  4511. char party[100];
  4512. nullpo_retr(-1, sd);
  4513. memset(party, '\0', sizeof(party));
  4514. if (!message || !*message || sscanf(message, "%99[^\n]", party) < 1) {
  4515. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4516. return -1;
  4517. }
  4518. party_create(sd, party);
  4519. return 0;
  4520. }
  4521. /*==========================================
  4522. *
  4523. *------------------------------------------
  4524. */
  4525. int atcommand_guild(
  4526. const int fd, struct map_session_data* sd,
  4527. const char* command, const char* message)
  4528. {
  4529. char guild[100];
  4530. int prev;
  4531. nullpo_retr(-1, sd);
  4532. memset(guild, '\0', sizeof(guild));
  4533. if (!message || !*message || sscanf(message, "%99[^\n]", guild) < 1) {
  4534. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4535. return -1;
  4536. }
  4537. prev = battle_config.guild_emperium_check;
  4538. battle_config.guild_emperium_check = 0;
  4539. guild_create(sd, guild);
  4540. battle_config.guild_emperium_check = prev;
  4541. return 0;
  4542. }
  4543. /*==========================================
  4544. *
  4545. *------------------------------------------
  4546. */
  4547. int atcommand_agitstart(
  4548. const int fd, struct map_session_data* sd,
  4549. const char* command, const char* message)
  4550. {
  4551. nullpo_retr(-1, sd);
  4552. if (agit_flag == 1) {
  4553. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4554. return -1;
  4555. }
  4556. agit_flag = 1;
  4557. guild_agit_start();
  4558. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4559. return 0;
  4560. }
  4561. /*==========================================
  4562. *
  4563. *------------------------------------------
  4564. */
  4565. int atcommand_agitend(
  4566. const int fd, struct map_session_data* sd,
  4567. const char* command, const char* message)
  4568. {
  4569. nullpo_retr(-1, sd);
  4570. if (agit_flag == 0) {
  4571. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4572. return -1;
  4573. }
  4574. agit_flag = 0;
  4575. guild_agit_end();
  4576. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4577. return 0;
  4578. }
  4579. /*==========================================
  4580. * @mapexitでマップサーバーを終了させる
  4581. *------------------------------------------
  4582. */
  4583. int atcommand_mapexit(
  4584. const int fd, struct map_session_data* sd,
  4585. const char* command, const char* message)
  4586. {
  4587. struct map_session_data *pl_sd;
  4588. int i;
  4589. nullpo_retr(-1, sd);
  4590. for (i = 0; i < fd_max; i++) {
  4591. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4592. if (sd->status.account_id != pl_sd->status.account_id)
  4593. clif_GM_kick(sd, pl_sd, 0);
  4594. }
  4595. }
  4596. clif_GM_kick(sd, sd, 0);
  4597. runflag = 0;
  4598. return 0;
  4599. }
  4600. /*==========================================
  4601. * idsearch <part_of_name>: revrited by [Yor]
  4602. *------------------------------------------
  4603. */
  4604. int atcommand_idsearch(
  4605. const int fd, struct map_session_data* sd,
  4606. const char* command, const char* message)
  4607. {
  4608. char item_name[100];
  4609. char output[200];
  4610. int i, match;
  4611. struct item_data *item;
  4612. nullpo_retr(-1, sd);
  4613. memset(item_name, '\0', sizeof(item_name));
  4614. memset(output, '\0', sizeof(output));
  4615. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4616. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4617. return -1;
  4618. }
  4619. sprintf(output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4620. clif_displaymessage(fd, output);
  4621. match = 0;
  4622. for(i = 0; i < 20000; i++) {
  4623. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4624. match++;
  4625. sprintf(output, msg_table[78], item->jname, item->nameid); // %s: %d
  4626. clif_displaymessage(fd, output);
  4627. }
  4628. }
  4629. sprintf(output, msg_table[79], match); // It is %d affair above.
  4630. clif_displaymessage(fd, output);
  4631. return 0;
  4632. }
  4633. /*==========================================
  4634. * Character Skill Reset
  4635. *------------------------------------------
  4636. */
  4637. int atcommand_charskreset(
  4638. const int fd, struct map_session_data* sd,
  4639. const char* command, const char* message)
  4640. {
  4641. char character[100];
  4642. char output[200];
  4643. struct map_session_data *pl_sd;
  4644. nullpo_retr(-1, sd);
  4645. memset(character, '\0', sizeof(character));
  4646. memset(output, '\0', sizeof(output));
  4647. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4648. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  4649. return -1;
  4650. }
  4651. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4652. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  4653. pc_resetskill(pl_sd);
  4654. sprintf(output, msg_table[206], character); // '%s' skill points reseted!
  4655. clif_displaymessage(fd, output);
  4656. } else {
  4657. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4658. return -1;
  4659. }
  4660. } else {
  4661. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4662. return -1;
  4663. }
  4664. return 0;
  4665. }
  4666. /*==========================================
  4667. * Character Stat Reset
  4668. *------------------------------------------
  4669. */
  4670. int atcommand_charstreset(
  4671. const int fd, struct map_session_data* sd,
  4672. const char* command, const char* message)
  4673. {
  4674. char character[100];
  4675. char output[200];
  4676. struct map_session_data *pl_sd;
  4677. nullpo_retr(-1, sd);
  4678. memset(character, '\0', sizeof(character));
  4679. memset(output, '\0', sizeof(output));
  4680. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4681. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  4682. return -1;
  4683. }
  4684. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4685. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  4686. pc_resetstate(pl_sd);
  4687. sprintf(output, msg_table[207], character); // '%s' stats points reseted!
  4688. clif_displaymessage(fd, output);
  4689. } else {
  4690. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4691. return -1;
  4692. }
  4693. } else {
  4694. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4695. return -1;
  4696. }
  4697. return 0;
  4698. }
  4699. /*==========================================
  4700. * Character Model by chbrules
  4701. *------------------------------------------
  4702. */
  4703. int atcommand_charmodel(
  4704. const int fd, struct map_session_data* sd,
  4705. const char* command, const char* message)
  4706. {
  4707. int hair_style = 0, hair_color = 0, cloth_color = 0;
  4708. struct map_session_data *pl_sd;
  4709. char character[100];
  4710. char output[200];
  4711. nullpo_retr(-1, sd);
  4712. memset(character, '\0', sizeof(character));
  4713. memset(output, '\0', sizeof(output));
  4714. 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) {
  4715. 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>).",
  4716. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  4717. clif_displaymessage(fd, output);
  4718. return -1;
  4719. }
  4720. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4721. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  4722. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  4723. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  4724. if (cloth_color != 0 &&
  4725. pl_sd->status.sex == 1 &&
  4726. (pl_sd->status.class == 12 || pl_sd->status.class == 17)) {
  4727. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  4728. return -1;
  4729. } else {
  4730. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  4731. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  4732. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  4733. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  4734. }
  4735. } else {
  4736. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4737. return -1;
  4738. }
  4739. } else {
  4740. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4741. return -1;
  4742. }
  4743. return 0;
  4744. }
  4745. /*==========================================
  4746. * Character Skill Point (Rewritten by [Yor])
  4747. *------------------------------------------
  4748. */
  4749. int atcommand_charskpoint(
  4750. const int fd, struct map_session_data* sd,
  4751. const char* command, const char* message)
  4752. {
  4753. struct map_session_data *pl_sd;
  4754. char character[100];
  4755. int new_skill_point;
  4756. int point = 0;
  4757. nullpo_retr(-1, sd);
  4758. memset(character, '\0', sizeof(character));
  4759. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4760. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  4761. return -1;
  4762. }
  4763. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4764. new_skill_point = (int)pl_sd->status.skill_point + point;
  4765. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  4766. new_skill_point = 0x7FFF;
  4767. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  4768. new_skill_point = 0;
  4769. if (new_skill_point != (int)pl_sd->status.skill_point) {
  4770. pl_sd->status.skill_point = new_skill_point;
  4771. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4772. clif_displaymessage(fd, msg_table[209]); // Character's number of skill points changed!
  4773. } else {
  4774. if (point < 0)
  4775. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4776. else
  4777. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4778. return -1;
  4779. }
  4780. } else {
  4781. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4782. return -1;
  4783. }
  4784. return 0;
  4785. }
  4786. /*==========================================
  4787. * Character Status Point (rewritten by [Yor])
  4788. *------------------------------------------
  4789. */
  4790. int atcommand_charstpoint(
  4791. const int fd, struct map_session_data* sd,
  4792. const char* command, const char* message)
  4793. {
  4794. struct map_session_data *pl_sd;
  4795. char character[100];
  4796. int new_status_point;
  4797. int point = 0;
  4798. nullpo_retr(-1, sd);
  4799. memset(character, '\0', sizeof(character));
  4800. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4801. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  4802. return -1;
  4803. }
  4804. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4805. new_status_point = (int)pl_sd->status.status_point + point;
  4806. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  4807. new_status_point = 0x7FFF;
  4808. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  4809. new_status_point = 0;
  4810. if (new_status_point != (int)pl_sd->status.status_point) {
  4811. pl_sd->status.status_point = new_status_point;
  4812. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4813. clif_displaymessage(fd, msg_table[210]); // Character's number of status points changed!
  4814. } else {
  4815. if (point < 0)
  4816. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4817. else
  4818. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4819. return -1;
  4820. }
  4821. } else {
  4822. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4823. return -1;
  4824. }
  4825. return 0;
  4826. }
  4827. /*==========================================
  4828. * Recall All Characters Online To Your Location
  4829. *------------------------------------------
  4830. */
  4831. int atcommand_recallall(
  4832. const int fd, struct map_session_data* sd,
  4833. const char* command, const char* message)
  4834. {
  4835. struct map_session_data *pl_sd;
  4836. int i;
  4837. int count;
  4838. char output[200];
  4839. nullpo_retr(-1, sd);
  4840. memset(output, '\0', sizeof(output));
  4841. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4842. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4843. return -1;
  4844. }
  4845. count = 0;
  4846. for (i = 0; i < fd_max; i++) {
  4847. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id &&
  4848. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4849. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4850. count++;
  4851. else
  4852. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4853. }
  4854. }
  4855. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4856. if (count) {
  4857. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4858. clif_displaymessage(fd, output);
  4859. }
  4860. return 0;
  4861. }
  4862. /*==========================================
  4863. * Recall online characters of a guild to your location
  4864. *------------------------------------------
  4865. */
  4866. int atcommand_guildrecall(
  4867. const int fd, struct map_session_data* sd,
  4868. const char* command, const char* message)
  4869. {
  4870. struct map_session_data *pl_sd;
  4871. int i;
  4872. char guild_name[100];
  4873. char output[200];
  4874. struct guild *g;
  4875. int count;
  4876. nullpo_retr(-1, sd);
  4877. memset(guild_name, '\0', sizeof(guild_name));
  4878. memset(output, '\0', sizeof(output));
  4879. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  4880. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4881. return -1;
  4882. }
  4883. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4884. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4885. return -1;
  4886. }
  4887. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4888. (g = guild_search(atoi(message))) != NULL) {
  4889. count = 0;
  4890. for (i = 0; i < fd_max; i++) {
  4891. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4892. sd->status.account_id != pl_sd->status.account_id &&
  4893. pl_sd->status.guild_id == g->guild_id) {
  4894. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4895. count++;
  4896. else
  4897. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4898. }
  4899. }
  4900. sprintf(output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4901. clif_displaymessage(fd, output);
  4902. if (count) {
  4903. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4904. clif_displaymessage(fd, output);
  4905. }
  4906. } else {
  4907. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4908. return -1;
  4909. }
  4910. return 0;
  4911. }
  4912. /*==========================================
  4913. * Recall online characters of a party to your location
  4914. *------------------------------------------
  4915. */
  4916. int atcommand_partyrecall(
  4917. const int fd, struct map_session_data* sd,
  4918. const char* command, const char* message)
  4919. {
  4920. int i;
  4921. struct map_session_data *pl_sd;
  4922. char party_name[100];
  4923. char output[200];
  4924. struct party *p;
  4925. int count;
  4926. nullpo_retr(-1, sd);
  4927. memset(party_name, '\0', sizeof(party_name));
  4928. memset(output, '\0', sizeof(output));
  4929. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  4930. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4931. return -1;
  4932. }
  4933. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4934. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4935. return -1;
  4936. }
  4937. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4938. (p = party_search(atoi(message))) != NULL) {
  4939. count = 0;
  4940. for (i = 0; i < fd_max; i++) {
  4941. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4942. sd->status.account_id != pl_sd->status.account_id &&
  4943. pl_sd->status.party_id == p->party_id) {
  4944. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4945. count++;
  4946. else
  4947. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4948. }
  4949. }
  4950. sprintf(output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4951. clif_displaymessage(fd, output);
  4952. if (count) {
  4953. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4954. clif_displaymessage(fd, output);
  4955. }
  4956. } else {
  4957. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4958. return -1;
  4959. }
  4960. return 0;
  4961. }
  4962. /*==========================================
  4963. *
  4964. *------------------------------------------
  4965. */
  4966. int atcommand_reloaditemdb(
  4967. const int fd, struct map_session_data* sd,
  4968. const char* command, const char* message)
  4969. {
  4970. nullpo_retr(-1, sd);
  4971. itemdb_reload();
  4972. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4973. return 0;
  4974. }
  4975. /*==========================================
  4976. *
  4977. *------------------------------------------
  4978. */
  4979. int atcommand_reloadmobdb(
  4980. const int fd, struct map_session_data* sd,
  4981. const char* command, const char* message)
  4982. {
  4983. nullpo_retr(-1, sd);
  4984. mob_reload();
  4985. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4986. return 0;
  4987. }
  4988. /*==========================================
  4989. *
  4990. *------------------------------------------
  4991. */
  4992. int atcommand_reloadskilldb(
  4993. const int fd, struct map_session_data* sd,
  4994. const char* command, const char* message)
  4995. {
  4996. nullpo_retr(-1, sd);
  4997. skill_reload();
  4998. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4999. return 0;
  5000. }
  5001. /*==========================================
  5002. *
  5003. *------------------------------------------
  5004. */
  5005. int atcommand_reloadscript(
  5006. const int fd, struct map_session_data* sd,
  5007. const char* command, const char* message)
  5008. {
  5009. nullpo_retr(-1, sd);
  5010. atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." );
  5011. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  5012. rehash( fd, sd );
  5013. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  5014. do_init_npc();
  5015. do_init_script();
  5016. npc_event_do_oninit();
  5017. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  5018. return 0;
  5019. }
  5020. /*==========================================
  5021. *
  5022. *------------------------------------------
  5023. */
  5024. int atcommand_reloadgmdb( // by [Yor]
  5025. const int fd, struct map_session_data* sd,
  5026. const char* command, const char* message)
  5027. {
  5028. nullpo_retr(-1, sd);
  5029. chrif_reloadGMdb();
  5030. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  5031. return 0;
  5032. }
  5033. /*==========================================
  5034. * @mapinfo <map name> [0-3] by MC_Cameri
  5035. * => Shows information about the map [map name]
  5036. * 0 = no additional information
  5037. * 1 = Show users in that map and their location
  5038. * 2 = Shows NPCs in that map
  5039. * 3 = Shows the shops/chats in that map (not implemented)
  5040. *------------------------------------------
  5041. */
  5042. int atcommand_mapinfo(
  5043. const int fd, struct map_session_data* sd,
  5044. const char* command, const char* message)
  5045. {
  5046. struct map_session_data *pl_sd;
  5047. struct npc_data *nd = NULL;
  5048. struct chat_data *cd = NULL;
  5049. char output[200], map_name[100];
  5050. char direction[12];
  5051. int m_id, i, chat_num, list = 0;
  5052. nullpo_retr(-1, sd);
  5053. memset(output, '\0', sizeof(output));
  5054. memset(map_name, '\0', sizeof(map_name));
  5055. memset(direction, '\0', sizeof(direction));
  5056. sscanf(message, "%d %99[^\n]", &list, map_name);
  5057. if (list < 0 || list > 3) {
  5058. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5059. return -1;
  5060. }
  5061. if (map_name[0] == '\0')
  5062. strcpy(map_name, sd->mapname);
  5063. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  5064. strcat(map_name, ".gat");
  5065. if ((m_id = map_mapname2mapid(map_name)) < 0) {
  5066. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5067. return -1;
  5068. }
  5069. clif_displaymessage(fd, "------ Map Info ------");
  5070. sprintf(output, "Map Name: %s", map_name);
  5071. clif_displaymessage(fd, output);
  5072. sprintf(output, "Players In Map: %d", map[m_id].users);
  5073. clif_displaymessage(fd, output);
  5074. sprintf(output, "NPCs In Map: %d", map[m_id].npc_num);
  5075. clif_displaymessage(fd, output);
  5076. chat_num = 0;
  5077. for (i = 0; i < fd_max; i++) {
  5078. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5079. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5080. chat_num++;
  5081. }
  5082. }
  5083. sprintf(output, "Chats In Map: %d", chat_num);
  5084. clif_displaymessage(fd, output);
  5085. clif_displaymessage(fd, "------ Map Flags ------");
  5086. sprintf(output, "Player vs Player: %s | No Guild: %s | No Party: %s",
  5087. (map[m_id].flag.pvp) ? "True" : "False",
  5088. (map[m_id].flag.pvp_noguild) ? "True" : "False",
  5089. (map[m_id].flag.pvp_noparty) ? "True" : "False");
  5090. clif_displaymessage(fd, output);
  5091. sprintf(output, "Guild vs Guild: %s | No Party: %s", (map[m_id].flag.gvg) ? "True" : "False", (map[m_id].flag.gvg_noparty) ? "True" : "False");
  5092. clif_displaymessage(fd, output);
  5093. sprintf(output, "No Dead Branch: %s", (map[m_id].flag.nobranch) ? "True" : "False");
  5094. clif_displaymessage(fd, output);
  5095. sprintf(output, "No Memo: %s", (map[m_id].flag.nomemo) ? "True" : "False");
  5096. clif_displaymessage(fd, output);
  5097. sprintf(output, "No Penalty: %s", (map[m_id].flag.nopenalty) ? "True" : "False");
  5098. clif_displaymessage(fd, output);
  5099. sprintf(output, "No Return: %s", (map[m_id].flag.noreturn) ? "True" : "False");
  5100. clif_displaymessage(fd, output);
  5101. sprintf(output, "No Save: %s", (map[m_id].flag.nosave) ? "True" : "False");
  5102. clif_displaymessage(fd, output);
  5103. sprintf(output, "No Teleport: %s", (map[m_id].flag.noteleport) ? "True" : "False");
  5104. clif_displaymessage(fd, output);
  5105. sprintf(output, "No Monster Teleport: %s", (map[m_id].flag.monster_noteleport) ? "True" : "False");
  5106. clif_displaymessage(fd, output);
  5107. sprintf(output, "No Zeny Penalty: %s", (map[m_id].flag.nozenypenalty) ? "True" : "False");
  5108. clif_displaymessage(fd, output);
  5109. switch (list) {
  5110. case 0:
  5111. // Do nothing. It's list 0, no additional display.
  5112. break;
  5113. case 1:
  5114. clif_displaymessage(fd, "----- Players in Map -----");
  5115. for (i = 0; i < fd_max; i++) {
  5116. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && strcmp(pl_sd->mapname, map_name) == 0) {
  5117. sprintf(output, "Player '%s' (session #%d) | Location: %d,%d",
  5118. pl_sd->status.name, i, pl_sd->bl.x, pl_sd->bl.y);
  5119. clif_displaymessage(fd, output);
  5120. }
  5121. }
  5122. break;
  5123. case 2:
  5124. clif_displaymessage(fd, "----- NPCs in Map -----");
  5125. for (i = 0; i < map[m_id].npc_num;) {
  5126. nd = map[m_id].npc[i];
  5127. switch(nd->dir) {
  5128. case 0: strcpy(direction, "North"); break;
  5129. case 1: strcpy(direction, "North West"); break;
  5130. case 2: strcpy(direction, "West"); break;
  5131. case 3: strcpy(direction, "South West"); break;
  5132. case 4: strcpy(direction, "South"); break;
  5133. case 5: strcpy(direction, "South East"); break;
  5134. case 6: strcpy(direction, "East"); break;
  5135. case 7: strcpy(direction, "North East"); break;
  5136. case 9: strcpy(direction, "North"); break;
  5137. default: strcpy(direction, "Unknown"); break;
  5138. }
  5139. sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5140. ++i, nd->name, direction, nd->class, nd->bl.x, nd->bl.y);
  5141. clif_displaymessage(fd, output);
  5142. }
  5143. break;
  5144. case 3:
  5145. clif_displaymessage(fd, "----- Chats in Map -----");
  5146. for (i = 0; i < fd_max; i++) {
  5147. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5148. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5149. strcmp(pl_sd->mapname, map_name) == 0 &&
  5150. cd->usersd[0] == pl_sd) {
  5151. sprintf(output, "Chat %d: %s | Player: %s | Location: %d %d",
  5152. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5153. clif_displaymessage(fd, output);
  5154. sprintf(output, " Users: %d/%d | Password: %s | Public: %s",
  5155. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5156. clif_displaymessage(fd, output);
  5157. }
  5158. }
  5159. break;
  5160. default: // normally impossible to arrive here
  5161. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5162. return -1;
  5163. break;
  5164. }
  5165. return 0;
  5166. }
  5167. /*==========================================
  5168. *
  5169. *------------------------------------------
  5170. */
  5171. int atcommand_mount_peco(
  5172. const int fd, struct map_session_data* sd,
  5173. const char* command, const char* message)
  5174. {
  5175. nullpo_retr(-1, sd);
  5176. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5177. clif_displaymessage(fd, msg_table[212]); // Cannot mount a Peco while in disguise.
  5178. return -1;
  5179. }
  5180. if (!pc_isriding(sd)) { // if actually no peco
  5181. if (sd->status.class == 7 || sd->status.class == 14 || sd->status.class == 4008 || sd->status.class == 4015) {
  5182. if (sd->status.class == 7)
  5183. sd->status.class = sd->view_class = 13;
  5184. else if (sd->status.class == 14)
  5185. sd->status.class = sd->view_class = 21;
  5186. else if (sd->status.class == 4008)
  5187. sd->status.class = sd->view_class = 4014;
  5188. else if (sd->status.class == 4015)
  5189. sd->status.class = sd->view_class = 4022;
  5190. pc_setoption(sd, sd->status.option | 0x0020);
  5191. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5192. } else {
  5193. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5194. return -1;
  5195. }
  5196. } else {
  5197. if (sd->status.class == 13)
  5198. sd->status.class = sd->view_class = 7;
  5199. else if (sd->status.class == 21)
  5200. sd->status.class = sd->view_class = 14;
  5201. else if (sd->status.class == 4014)
  5202. sd->status.class = sd->view_class = 4008;
  5203. else if (sd->status.class == 4022)
  5204. sd->status.class = sd->view_class = 4015;
  5205. pc_setoption(sd, sd->status.option & ~0x0020);
  5206. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5207. }
  5208. return 0;
  5209. }
  5210. /*==========================================
  5211. *
  5212. *------------------------------------------
  5213. */
  5214. int atcommand_char_mount_peco(
  5215. const int fd, struct map_session_data* sd,
  5216. const char* command, const char* message)
  5217. {
  5218. char character[100];
  5219. struct map_session_data *pl_sd;
  5220. nullpo_retr(-1, sd);
  5221. memset(character, '\0', sizeof(character));
  5222. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5223. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5224. return -1;
  5225. }
  5226. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5227. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5228. clif_displaymessage(fd, msg_table[215]); // This player cannot mount a Peco while in disguise.
  5229. return -1;
  5230. }
  5231. if (!pc_isriding(pl_sd)) { // if actually no peco
  5232. if (pl_sd->status.class == 7 || pl_sd->status.class == 14 || pl_sd->status.class == 4008 || pl_sd->status.class == 4015) {
  5233. if (pl_sd->status.class == 7)
  5234. pl_sd->status.class = pl_sd->view_class = 13;
  5235. else if (pl_sd->status.class == 14)
  5236. pl_sd->status.class = pl_sd->view_class = 21;
  5237. else if (pl_sd->status.class == 4008)
  5238. pl_sd->status.class = pl_sd->view_class = 4014;
  5239. else if (pl_sd->status.class == 4015)
  5240. pl_sd->status.class = pl_sd->view_class = 4022;
  5241. pc_setoption(pl_sd, pl_sd->status.option | 0x0020);
  5242. clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco.
  5243. } else {
  5244. clif_displaymessage(fd, msg_table[217]); // This player can not mount a peco with his/her job.
  5245. return -1;
  5246. }
  5247. } else {
  5248. if (pl_sd->status.class == 13)
  5249. pl_sd->status.class = pl_sd->view_class = 7;
  5250. else if (pl_sd->status.class == 21)
  5251. pl_sd->status.class = pl_sd->view_class = 14;
  5252. else if (pl_sd->status.class == 4014)
  5253. pl_sd->status.class = pl_sd->view_class = 4008;
  5254. else if (pl_sd->status.class == 4022)
  5255. pl_sd->status.class = pl_sd->view_class = 4015;
  5256. pc_setoption(pl_sd, pl_sd->status.option & ~0x0020);
  5257. clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco.
  5258. }
  5259. } else {
  5260. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5261. return -1;
  5262. }
  5263. return 0;
  5264. }
  5265. /*==========================================
  5266. *Spy Commands by Syrus22
  5267. *------------------------------------------
  5268. */
  5269. int atcommand_guildspy(
  5270. const int fd, struct map_session_data* sd,
  5271. const char* command, const char* message)
  5272. {
  5273. char guild_name[100];
  5274. char output[200];
  5275. struct guild *g;
  5276. nullpo_retr(-1, sd);
  5277. memset(guild_name, '\0', sizeof(guild_name));
  5278. memset(output, '\0', sizeof(output));
  5279. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  5280. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5281. return -1;
  5282. }
  5283. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5284. (g = guild_search(atoi(message))) != NULL) {
  5285. if (sd->guildspy == g->guild_id) {
  5286. sd->guildspy = 0;
  5287. sprintf(output, msg_table[103], g->name); // No longer spying on the %s guild.
  5288. clif_displaymessage(fd, output);
  5289. } else {
  5290. sd->guildspy = g->guild_id;
  5291. sprintf(output, msg_table[104], g->name); // Spying on the %s guild.
  5292. clif_displaymessage(fd, output);
  5293. }
  5294. } else {
  5295. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5296. return -1;
  5297. }
  5298. return 0;
  5299. }
  5300. /*==========================================
  5301. *
  5302. *------------------------------------------
  5303. */
  5304. int atcommand_partyspy(
  5305. const int fd, struct map_session_data* sd,
  5306. const char* command, const char* message)
  5307. {
  5308. char party_name[100];
  5309. char output[200];
  5310. struct party *p;
  5311. nullpo_retr(-1, sd);
  5312. memset(party_name, '\0', sizeof(party_name));
  5313. memset(output, '\0', sizeof(output));
  5314. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  5315. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5316. return -1;
  5317. }
  5318. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5319. (p = party_search(atoi(message))) != NULL) {
  5320. if (sd->partyspy == p->party_id) {
  5321. sd->partyspy = 0;
  5322. sprintf(output, msg_table[105], p->name); // No longer spying on the %s party.
  5323. clif_displaymessage(fd, output);
  5324. } else {
  5325. sd->partyspy = p->party_id;
  5326. sprintf(output, msg_table[106], p->name); // Spying on the %s party.
  5327. clif_displaymessage(fd, output);
  5328. }
  5329. } else {
  5330. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5331. return -1;
  5332. }
  5333. return 0;
  5334. }
  5335. /*==========================================
  5336. * @repairall [Valaris]
  5337. *------------------------------------------
  5338. */
  5339. int atcommand_repairall(
  5340. const int fd, struct map_session_data* sd,
  5341. const char* command, const char* message)
  5342. {
  5343. int count, i;
  5344. nullpo_retr(-1, sd);
  5345. count = 0;
  5346. for (i = 0; i < MAX_INVENTORY; i++) {
  5347. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5348. sd->status.inventory[i].attribute = 0;
  5349. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5350. count++;
  5351. }
  5352. }
  5353. if (count > 0) {
  5354. clif_misceffect(&sd->bl, 3);
  5355. clif_equiplist(sd);
  5356. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5357. } else {
  5358. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5359. return -1;
  5360. }
  5361. return 0;
  5362. }
  5363. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5364. int atcommand_nuke(
  5365. const int fd, struct map_session_data* sd,
  5366. const char* command, const char* message)
  5367. {
  5368. char character[100];
  5369. struct map_session_data *pl_sd;
  5370. nullpo_retr(-1, sd);
  5371. memset(character, '\0', sizeof(character));
  5372. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5373. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5374. return -1;
  5375. }
  5376. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5377. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5378. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5379. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5380. } else {
  5381. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5382. return -1;
  5383. }
  5384. } else {
  5385. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5386. return -1;
  5387. }
  5388. return 0;
  5389. }
  5390. /*==========================================
  5391. *
  5392. *------------------------------------------
  5393. */
  5394. int atcommand_enablenpc(const int fd, struct map_session_data* sd,
  5395. const char* command, const char* message)
  5396. {
  5397. char NPCname[100];
  5398. nullpo_retr(-1, sd);
  5399. memset(NPCname, '\0', sizeof(NPCname));
  5400. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5401. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcon <NPC_name>).");
  5402. return -1;
  5403. }
  5404. if (npc_name2id(NPCname) != NULL) {
  5405. npc_enable(NPCname, 1);
  5406. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5407. } else {
  5408. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5409. return -1;
  5410. }
  5411. return 0;
  5412. }
  5413. /*==========================================
  5414. *
  5415. *------------------------------------------
  5416. */
  5417. int atcommand_disablenpc(const int fd, struct map_session_data* sd,
  5418. const char* command, const char* message)
  5419. {
  5420. char NPCname[100];
  5421. nullpo_retr(-1, sd);
  5422. memset(NPCname, '\0', sizeof(NPCname));
  5423. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5424. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5425. return -1;
  5426. }
  5427. if (npc_name2id(NPCname) != NULL) {
  5428. npc_enable(NPCname, 0);
  5429. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5430. } else {
  5431. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5432. return -1;
  5433. }
  5434. return 0;
  5435. }
  5436. /*==========================================
  5437. * time in txt for time command (by [Yor])
  5438. *------------------------------------------
  5439. */
  5440. char * txt_time(unsigned int duration) {
  5441. int days, hours, minutes, seconds;
  5442. char temp[256];
  5443. static char temp1[256];
  5444. memset(temp, '\0', sizeof(temp));
  5445. memset(temp1, '\0', sizeof(temp1));
  5446. if (duration < 0)
  5447. duration = 0;
  5448. days = duration / (60 * 60 * 24);
  5449. duration = duration - (60 * 60 * 24 * days);
  5450. hours = duration / (60 * 60);
  5451. duration = duration - (60 * 60 * hours);
  5452. minutes = duration / 60;
  5453. seconds = duration - (60 * minutes);
  5454. if (days < 2)
  5455. sprintf(temp, msg_table[219], days); // %d day
  5456. else
  5457. sprintf(temp, msg_table[220], days); // %d days
  5458. if (hours < 2)
  5459. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5460. else
  5461. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5462. if (minutes < 2)
  5463. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5464. else
  5465. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5466. if (seconds < 2)
  5467. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5468. else
  5469. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5470. return temp1;
  5471. }
  5472. /*==========================================
  5473. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5474. * Calculation management of GM modification (@day/@night GM commands) is done
  5475. *------------------------------------------
  5476. */
  5477. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5478. const char* command, const char* message)
  5479. {
  5480. struct TimerData * timer_data;
  5481. struct TimerData * timer_data2;
  5482. time_t time_server; // variable for number of seconds (used with time() function)
  5483. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5484. char temp[256];
  5485. nullpo_retr(-1, sd);
  5486. memset(temp, '\0', sizeof(temp));
  5487. time(&time_server); // get time in seconds since 1/1/1970
  5488. datetime = localtime(&time_server); // convert seconds in structure
  5489. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5490. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5491. clif_displaymessage(fd, temp);
  5492. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5493. if (night_flag == 0)
  5494. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5495. else
  5496. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5497. } else if (battle_config.night_duration == 0)
  5498. if (night_flag == 1) { // we start with night
  5499. timer_data = get_timer(day_timer_tid);
  5500. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5501. clif_displaymessage(fd, temp);
  5502. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5503. } else
  5504. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5505. else if (battle_config.day_duration == 0)
  5506. if (night_flag == 0) { // we start with day
  5507. timer_data = get_timer(night_timer_tid);
  5508. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5509. clif_displaymessage(fd, temp);
  5510. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5511. } else
  5512. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5513. else {
  5514. if (night_flag == 0) {
  5515. timer_data = get_timer(night_timer_tid);
  5516. timer_data2 = get_timer(day_timer_tid);
  5517. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5518. clif_displaymessage(fd, temp);
  5519. if (timer_data->tick > timer_data2->tick)
  5520. 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.
  5521. else
  5522. 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.
  5523. clif_displaymessage(fd, temp);
  5524. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5525. clif_displaymessage(fd, temp);
  5526. } else {
  5527. timer_data = get_timer(day_timer_tid);
  5528. timer_data2 = get_timer(night_timer_tid);
  5529. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5530. clif_displaymessage(fd, temp);
  5531. if (timer_data->tick > timer_data2->tick)
  5532. 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.
  5533. else
  5534. 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.
  5535. clif_displaymessage(fd, temp);
  5536. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5537. clif_displaymessage(fd, temp);
  5538. }
  5539. }
  5540. return 0;
  5541. }
  5542. /*==========================================
  5543. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5544. * removes <quantity> item from a character
  5545. * item can be equiped or not.
  5546. * Inspired from a old command created by RoVeRT
  5547. *------------------------------------------
  5548. */
  5549. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5550. const char* command, const char* message)
  5551. {
  5552. struct map_session_data *pl_sd;
  5553. char character[100];
  5554. char item_name[100];
  5555. int i, number = 0, item_id, item_position, count;
  5556. char output[200];
  5557. struct item_data *item_data;
  5558. nullpo_retr(-1, sd);
  5559. memset(character, '\0', sizeof(character));
  5560. memset(item_name, '\0', sizeof(item_name));
  5561. memset(output, '\0', sizeof(output));
  5562. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, character) < 3 || number < 1) {
  5563. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5564. return -1;
  5565. }
  5566. item_id = 0;
  5567. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5568. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5569. item_id = item_data->nameid;
  5570. if (item_id > 500) {
  5571. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5572. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5573. item_position = pc_search_inventory(pl_sd, item_id);
  5574. if (item_position >= 0) {
  5575. count = 0;
  5576. for(i = 0; i < number && item_position >= 0; i++) {
  5577. pc_delitem(pl_sd, item_position, 1, 0);
  5578. count++;
  5579. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5580. }
  5581. sprintf(output, msg_table[113], count); // %d item(s) removed by a GM.
  5582. clif_displaymessage(pl_sd->fd, output);
  5583. if (number == count)
  5584. sprintf(output, msg_table[114], count); // %d item(s) removed from the player.
  5585. else
  5586. sprintf(output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5587. clif_displaymessage(fd, output);
  5588. } else {
  5589. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5590. return -1;
  5591. }
  5592. } else {
  5593. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5594. return -1;
  5595. }
  5596. } else {
  5597. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5598. return -1;
  5599. }
  5600. } else {
  5601. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5602. return -1;
  5603. }
  5604. return 0;
  5605. }
  5606. /*==========================================
  5607. * @jail <char_name> by [Yor]
  5608. * Special warp! No check with nowarp and nowarpto flag
  5609. *------------------------------------------
  5610. */
  5611. int atcommand_jail(
  5612. const int fd, struct map_session_data* sd,
  5613. const char* command, const char* message)
  5614. {
  5615. char character[100];
  5616. struct map_session_data *pl_sd;
  5617. int x, y;
  5618. nullpo_retr(-1, sd);
  5619. memset(character, '\0', sizeof(character));
  5620. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5621. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5622. return -1;
  5623. }
  5624. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5625. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5626. switch(rand() % 2) {
  5627. case 0:
  5628. x = 24;
  5629. y = 75;
  5630. break;
  5631. default:
  5632. x = 49;
  5633. y = 75;
  5634. break;
  5635. }
  5636. if (pc_setpos(pl_sd, "sec_pri.gat", x, y, 3) == 0) {
  5637. pc_setsavepoint(pl_sd, "sec_pri.gat", x, y); // Save Char Respawn Point in the jail room [Lupus]
  5638. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5639. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5640. } else {
  5641. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5642. return -1;
  5643. }
  5644. } else {
  5645. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5646. return -1;
  5647. }
  5648. } else {
  5649. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5650. return -1;
  5651. }
  5652. return 0;
  5653. }
  5654. /*==========================================
  5655. * @unjail/@discharge <char_name> by [Yor]
  5656. * Special warp! No check with nowarp and nowarpto flag
  5657. *------------------------------------------
  5658. */
  5659. int atcommand_unjail(
  5660. const int fd, struct map_session_data* sd,
  5661. const char* command, const char* message)
  5662. {
  5663. char character[100];
  5664. struct map_session_data *pl_sd;
  5665. memset(character, '\0', sizeof(character));
  5666. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5667. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5668. return -1;
  5669. }
  5670. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5671. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5672. if (pl_sd->bl.m != map_mapname2mapid("sec_pri.gat")) {
  5673. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5674. return -1;
  5675. } else if (pc_setpos(pl_sd, "prontera.gat", 156, 191, 3) == 0) {
  5676. pc_setsavepoint(pl_sd, "prontera.gat", 156, 191); // Save char respawn point in Prontera
  5677. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5678. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5679. } else {
  5680. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5681. return -1;
  5682. }
  5683. } else {
  5684. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5685. return -1;
  5686. }
  5687. } else {
  5688. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5689. return -1;
  5690. }
  5691. return 0;
  5692. }
  5693. /*==========================================
  5694. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5695. *------------------------------------------
  5696. */
  5697. int atcommand_disguise(
  5698. const int fd, struct map_session_data* sd,
  5699. const char* command, const char* message)
  5700. {
  5701. int mob_id = 0;
  5702. nullpo_retr(-1, sd);
  5703. if (!message || !*message) {
  5704. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5705. return -1;
  5706. }
  5707. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5708. mob_id = atoi(message);
  5709. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5710. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5711. (mob_id >= 813 && mob_id <= 834) || // NPC
  5712. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5713. if (pc_isriding(sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5714. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5715. return -1;
  5716. }
  5717. sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5718. sd->disguise = mob_id;
  5719. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5720. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5721. } else {
  5722. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5723. return -1;
  5724. }
  5725. return 0;
  5726. }
  5727. /*==========================================
  5728. * @undisguise by [Yor]
  5729. *------------------------------------------
  5730. */
  5731. int atcommand_undisguise(
  5732. const int fd, struct map_session_data* sd,
  5733. const char* command, const char* message)
  5734. {
  5735. nullpo_retr(-1, sd);
  5736. if (sd->disguise) {
  5737. clif_clearchar(&sd->bl, 9);
  5738. sd->disguise = 0;
  5739. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5740. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5741. } else {
  5742. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5743. return -1;
  5744. }
  5745. return 0;
  5746. }
  5747. /*==========================================
  5748. * @broadcast by [Valaris]
  5749. *------------------------------------------
  5750. */
  5751. int atcommand_broadcast(
  5752. const int fd, struct map_session_data* sd,
  5753. const char* command, const char* message)
  5754. {
  5755. char output[200];
  5756. nullpo_retr(-1, sd);
  5757. memset(output, '\0', sizeof(output));
  5758. if (!message || !*message) {
  5759. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5760. return -1;
  5761. }
  5762. sprintf(output, "%s : %s", sd->status.name, message);
  5763. intif_GMmessage(output, strlen(output) + 1, 0);
  5764. return 0;
  5765. }
  5766. /*==========================================
  5767. * @localbroadcast by [Valaris]
  5768. *------------------------------------------
  5769. */
  5770. int atcommand_localbroadcast(
  5771. const int fd, struct map_session_data* sd,
  5772. const char* command, const char* message)
  5773. {
  5774. char output[200];
  5775. nullpo_retr(-1, sd);
  5776. memset(output, '\0', sizeof(output));
  5777. if (!message || !*message) {
  5778. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5779. return -1;
  5780. }
  5781. sprintf(output, "%s : %s", sd->status.name, message);
  5782. clif_GMmessage(&sd->bl, output, strlen(output) + 1, 1); // 1: ALL_SAMEMAP
  5783. return 0;
  5784. }
  5785. /*==========================================
  5786. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5787. *------------------------------------------
  5788. */
  5789. int atcommand_chardisguise(
  5790. const int fd, struct map_session_data* sd,
  5791. const char* command, const char* message)
  5792. {
  5793. int mob_id;
  5794. char character[100];
  5795. char mob_name[100];
  5796. struct map_session_data* pl_sd;
  5797. nullpo_retr(-1, sd);
  5798. memset(character, '\0', sizeof(character));
  5799. memset(mob_name, '\0', sizeof(mob_name));
  5800. if (!message || !*message || sscanf(message, "%s %99[^\n]", mob_name, character) < 2) {
  5801. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5802. return -1;
  5803. }
  5804. if ((mob_id = mobdb_searchname(mob_name)) == 0) // check name first (to avoid possible name begining by a number)
  5805. mob_id = atoi(mob_name);
  5806. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5807. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5808. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5809. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5810. (mob_id >= 813 && mob_id <= 834) || // NPC
  5811. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5812. if (pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5813. clif_displaymessage(fd, msg_table[228]); // Character cannot wear disguise while riding a Peco.
  5814. return -1;
  5815. }
  5816. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5817. pl_sd->disguise = mob_id;
  5818. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5819. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5820. } else {
  5821. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5822. return -1;
  5823. }
  5824. } else {
  5825. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5826. return -1;
  5827. }
  5828. } else {
  5829. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5830. return -1;
  5831. }
  5832. return 0;
  5833. }
  5834. /*==========================================
  5835. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5836. *------------------------------------------
  5837. */
  5838. int atcommand_charundisguise(
  5839. const int fd, struct map_session_data* sd,
  5840. const char* command, const char* message)
  5841. {
  5842. char character[100];
  5843. struct map_session_data* pl_sd;
  5844. nullpo_retr(-1, sd);
  5845. memset(character, '\0', sizeof(character));
  5846. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5847. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5848. return -1;
  5849. }
  5850. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5851. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5852. if (pl_sd->disguise) {
  5853. clif_clearchar(&pl_sd->bl, 9);
  5854. pl_sd->disguise = 0;
  5855. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5856. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5857. } else {
  5858. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5859. return -1;
  5860. }
  5861. } else {
  5862. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5863. return -1;
  5864. }
  5865. } else {
  5866. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5867. return -1;
  5868. }
  5869. return 0;
  5870. }
  5871. /*==========================================
  5872. * @email <actual@email> <new@email> by [Yor]
  5873. *------------------------------------------
  5874. */
  5875. int atcommand_email(
  5876. const int fd, struct map_session_data* sd,
  5877. const char* command, const char* message)
  5878. {
  5879. char actual_email[100];
  5880. char new_email[100];
  5881. nullpo_retr(-1, sd);
  5882. memset(actual_email, '\0', sizeof(actual_email));
  5883. memset(new_email, '\0', sizeof(new_email));
  5884. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5885. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5886. return -1;
  5887. }
  5888. if (e_mail_check(actual_email) == 0) {
  5889. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5890. return -1;
  5891. } else if (e_mail_check(new_email) == 0) {
  5892. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5893. return -1;
  5894. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5895. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5896. return -1;
  5897. } else if (strcmpi(actual_email, new_email) == 0) {
  5898. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5899. return -1;
  5900. } else {
  5901. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5902. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5903. }
  5904. return 0;
  5905. }
  5906. /*==========================================
  5907. *@effect
  5908. *------------------------------------------
  5909. */
  5910. int atcommand_effect(
  5911. const int fd, struct map_session_data* sd,
  5912. const char* command, const char* message)
  5913. {
  5914. struct map_session_data *pl_sd;
  5915. int type = 0, flag = 0, i;
  5916. nullpo_retr(-1, sd);
  5917. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5918. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5919. return -1;
  5920. }
  5921. if(flag <=0){
  5922. clif_specialeffect(&sd->bl, type, flag);
  5923. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5924. }
  5925. else{
  5926. for (i = 0; i < fd_max; i++) {
  5927. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  5928. clif_specialeffect(&pl_sd->bl, type, flag);
  5929. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5930. }
  5931. }
  5932. }
  5933. return 0;
  5934. }
  5935. /*==========================================
  5936. * @charcartlist <character>: Displays the items list of a player's cart.
  5937. *------------------------------------------
  5938. */
  5939. int
  5940. atcommand_character_cart_list(
  5941. const int fd, struct map_session_data* sd,
  5942. const char* command, const char* message)
  5943. {
  5944. struct map_session_data *pl_sd;
  5945. struct item_data *item_data, *item_temp;
  5946. int i, j, count, counter, counter2;
  5947. char character[100], output[200], outputtmp[200];
  5948. nullpo_retr(-1, sd);
  5949. memset(character, '\0', sizeof(character));
  5950. memset(output, '\0', sizeof(output));
  5951. memset(outputtmp, '\0', sizeof(outputtmp));
  5952. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5953. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5954. return -1;
  5955. }
  5956. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5957. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5958. counter = 0;
  5959. count = 0;
  5960. for (i = 0; i < MAX_CART; i++) {
  5961. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5962. counter = counter + pl_sd->status.cart[i].amount;
  5963. count++;
  5964. if (count == 1) {
  5965. sprintf(output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  5966. clif_displaymessage(fd, output);
  5967. }
  5968. if (pl_sd->status.cart[i].refine)
  5969. 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);
  5970. else
  5971. 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);
  5972. clif_displaymessage(fd, output);
  5973. memset(output, '\0', sizeof(output));
  5974. counter2 = 0;
  5975. for (j = 0; j < item_data->slot; j++) {
  5976. if (pl_sd->status.cart[i].card[j]) {
  5977. if ((item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  5978. if (output[0] == '\0')
  5979. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  5980. else
  5981. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  5982. strcat(output, outputtmp);
  5983. }
  5984. }
  5985. }
  5986. if (output[0] != '\0') {
  5987. output[strlen(output) - 2] = ')';
  5988. output[strlen(output) - 1] = '\0';
  5989. clif_displaymessage(fd, output);
  5990. }
  5991. }
  5992. }
  5993. if (count == 0)
  5994. clif_displaymessage(fd, "No item found in the cart of this player.");
  5995. else {
  5996. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  5997. clif_displaymessage(fd, output);
  5998. }
  5999. } else {
  6000. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6001. return -1;
  6002. }
  6003. } else {
  6004. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6005. return -1;
  6006. }
  6007. return 0;
  6008. }
  6009. /*==========================================
  6010. * @killer by MouseJstr
  6011. * enable killing players even when not in pvp
  6012. *------------------------------------------
  6013. */
  6014. int
  6015. atcommand_killer(
  6016. const int fd, struct map_session_data* sd,
  6017. const char* command, const char* message)
  6018. {
  6019. nullpo_retr(-1, sd);
  6020. sd->special_state.killer = !sd->special_state.killer;
  6021. if(sd->special_state.killer)
  6022. clif_displaymessage(fd, msg_table[241]);
  6023. else
  6024. clif_displaymessage(fd, msg_table[242]);
  6025. return 0;
  6026. }
  6027. /*==========================================
  6028. * @killable by MouseJstr
  6029. * enable other people killing you
  6030. *------------------------------------------
  6031. */
  6032. int
  6033. atcommand_killable(
  6034. const int fd, struct map_session_data* sd,
  6035. const char* command, const char* message)
  6036. {
  6037. nullpo_retr(-1, sd);
  6038. sd->special_state.killable = !sd->special_state.killable;
  6039. if(sd->special_state.killable)
  6040. clif_displaymessage(fd, msg_table[242]);
  6041. else
  6042. clif_displaymessage(fd, msg_table[241]);
  6043. return 0;
  6044. }
  6045. /*==========================================
  6046. * @charkillable by MouseJstr
  6047. * enable another player to be killed
  6048. *------------------------------------------
  6049. */
  6050. int
  6051. atcommand_charkillable(
  6052. const int fd, struct map_session_data* sd,
  6053. const char* command, const char* message)
  6054. {
  6055. struct map_session_data *pl_sd = NULL;
  6056. nullpo_retr(-1, sd);
  6057. if (!message || !*message)
  6058. return -1;
  6059. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6060. return -1;
  6061. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6062. if(pl_sd->special_state.killable)
  6063. clif_displaymessage(fd, "The player is now killable");
  6064. else
  6065. clif_displaymessage(fd, "The player is no longer killable");
  6066. return 0;
  6067. }
  6068. /*==========================================
  6069. * @skillon by MouseJstr
  6070. * turn skills on for the map
  6071. *------------------------------------------
  6072. */
  6073. int
  6074. atcommand_skillon(
  6075. const int fd, struct map_session_data* sd,
  6076. const char* command, const char* message)
  6077. {
  6078. nullpo_retr(-1, sd);
  6079. map[sd->bl.m].flag.noskill = 0;
  6080. clif_displaymessage(fd, msg_table[244]);
  6081. return 0;
  6082. }
  6083. /*==========================================
  6084. * @skilloff by MouseJstr
  6085. * Turn skills off on the map
  6086. *------------------------------------------
  6087. */
  6088. int
  6089. atcommand_skilloff(
  6090. const int fd, struct map_session_data* sd,
  6091. const char* command, const char* message)
  6092. {
  6093. nullpo_retr(-1, sd);
  6094. map[sd->bl.m].flag.noskill = 1;
  6095. clif_displaymessage(fd, msg_table[243]);
  6096. return 0;
  6097. }
  6098. /*==========================================
  6099. * @npcmove by MouseJstr
  6100. *
  6101. * move a npc
  6102. *------------------------------------------
  6103. */
  6104. int
  6105. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6106. const char* command, const char* message)
  6107. {
  6108. char character[100];
  6109. int x = 0, y = 0;
  6110. struct npc_data *nd = 0;
  6111. nullpo_retr(-1, sd);
  6112. if (!message || !*message)
  6113. return -1;
  6114. memset(character, '\0', sizeof character);
  6115. if (sscanf(message, "%d %d %99[^\n]", &x, &y, character) < 3) {
  6116. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6117. return -1;
  6118. }
  6119. nullpo_retr(-1, (nd = npc_name2id(character)));
  6120. npc_enable(character, 0);
  6121. nd->bl.x = x;
  6122. nd->bl.y = y;
  6123. npc_enable(character, 1);
  6124. return 0;
  6125. }
  6126. /*==========================================
  6127. * @addwarp by MouseJstr
  6128. *
  6129. * Create a new static warp point.
  6130. *------------------------------------------
  6131. */
  6132. int
  6133. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6134. const char* command, const char* message)
  6135. {
  6136. char w1[64], w3[64], w4[64];
  6137. char map[30], output[200];
  6138. int x,y,ret;
  6139. nullpo_retr(-1, sd);
  6140. if (!message || !*message)
  6141. return -1;
  6142. if (sscanf(message, "%99s %d %d[^\n]", map, &x, &y ) < 3)
  6143. return -1;
  6144. sprintf(w1,"%s,%d,%d", sd->mapname, sd->bl.x, sd->bl.y);
  6145. sprintf(w3,"%s%d%d%d%d", map,sd->bl.x, sd->bl.y, x, y);
  6146. sprintf(w4,"1,1,%s.gat,%d,%d", map, x, y);
  6147. ret = npc_parse_warp(w1, "warp", w3, w4);
  6148. sprintf(output, "New warp NPC => %s",w3);
  6149. clif_displaymessage(fd, output);
  6150. return ret;
  6151. }
  6152. /*==========================================
  6153. * @follow by [MouseJstr]
  6154. *
  6155. * Follow a player .. staying no more then 5 spaces away
  6156. *------------------------------------------
  6157. */
  6158. int
  6159. atcommand_follow(const int fd, struct map_session_data* sd,
  6160. const char* command, const char* message)
  6161. {
  6162. struct map_session_data *pl_sd = NULL;
  6163. nullpo_retr(-1, sd);
  6164. if (!message || !*message)
  6165. return -1;
  6166. if((pl_sd=map_nick2sd((char *) message)) != NULL)
  6167. pc_follow(sd, pl_sd->bl.id);
  6168. else
  6169. return 1;
  6170. return 0;
  6171. }
  6172. /*==========================================
  6173. * @dropall by [MouseJstr]
  6174. *
  6175. * Drop all your possession on the ground
  6176. *------------------------------------------
  6177. */
  6178. int
  6179. atcommand_dropall(const int fd, struct map_session_data* sd,
  6180. const char* command, const char* message)
  6181. {
  6182. int i;
  6183. nullpo_retr(-1, sd);
  6184. for (i = 0; i < MAX_INVENTORY; i++) {
  6185. if (sd->status.inventory[i].amount) {
  6186. if(sd->status.inventory[i].equip != 0)
  6187. pc_unequipitem(sd, i, 3);
  6188. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6189. }
  6190. }
  6191. return 0;
  6192. }
  6193. /*==========================================
  6194. * @chardropall by [MouseJstr]
  6195. *
  6196. * Throw all the characters possessions on the ground. Normally
  6197. * done in response to them being disrespectful of a GM
  6198. *------------------------------------------
  6199. */
  6200. int
  6201. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6202. const char* command, const char* message)
  6203. {
  6204. int i;
  6205. struct map_session_data *pl_sd = NULL;
  6206. nullpo_retr(-1, sd);
  6207. if (!message || !*message)
  6208. return -1;
  6209. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6210. return -1;
  6211. for (i = 0; i < MAX_INVENTORY; i++) {
  6212. if (pl_sd->status.inventory[i].amount) {
  6213. if(pl_sd->status.inventory[i].equip != 0)
  6214. pc_unequipitem(pl_sd, i, 3);
  6215. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6216. }
  6217. }
  6218. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6219. clif_displaymessage(fd, "It is done");
  6220. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6221. return 0;
  6222. }
  6223. /*==========================================
  6224. * @storeall by [MouseJstr]
  6225. *
  6226. * Put everything into storage to simplify your inventory to make
  6227. * debugging easie
  6228. *------------------------------------------
  6229. */
  6230. int
  6231. atcommand_storeall(const int fd, struct map_session_data* sd,
  6232. const char* command, const char* message)
  6233. {
  6234. int i;
  6235. nullpo_retr(-1, sd);
  6236. if (storage_storageopen(sd) == 1) {
  6237. clif_displaymessage(fd, "run this command again..");
  6238. return 0;
  6239. }
  6240. for (i = 0; i < MAX_INVENTORY; i++) {
  6241. if (sd->status.inventory[i].amount) {
  6242. if(sd->status.inventory[i].equip != 0)
  6243. pc_unequipitem(sd, i, 3);
  6244. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6245. }
  6246. }
  6247. storage_storageclose(sd);
  6248. clif_displaymessage(fd, "It is done");
  6249. return 0;
  6250. }
  6251. /*==========================================
  6252. * @charstoreall by [MouseJstr]
  6253. *
  6254. * A way to screw with players who piss you off
  6255. *------------------------------------------
  6256. */
  6257. int
  6258. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6259. const char* command, const char* message)
  6260. {
  6261. int i;
  6262. struct map_session_data *pl_sd = NULL;
  6263. nullpo_retr(-1, sd);
  6264. if (!message || !*message)
  6265. return -1;
  6266. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6267. return -1;
  6268. if (storage_storageopen(pl_sd) == 1) {
  6269. clif_displaymessage(fd, "Had to open the characters storage window...");
  6270. clif_displaymessage(fd, "run this command again..");
  6271. return 0;
  6272. }
  6273. for (i = 0; i < MAX_INVENTORY; i++) {
  6274. if (pl_sd->status.inventory[i].amount) {
  6275. if(pl_sd->status.inventory[i].equip != 0)
  6276. pc_unequipitem(pl_sd, i, 3);
  6277. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6278. }
  6279. }
  6280. storage_storageclose(pl_sd);
  6281. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6282. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6283. clif_displaymessage(pl_sd->fd, " -- the management");
  6284. clif_displaymessage(fd, "It is done");
  6285. return 0;
  6286. }
  6287. /*==========================================
  6288. * @skillid by [MouseJstr]
  6289. *
  6290. * lookup a skill by name
  6291. *------------------------------------------
  6292. */
  6293. int
  6294. atcommand_skillid(const int fd, struct map_session_data* sd,
  6295. const char* command, const char* message)
  6296. {
  6297. int skillen = 0, idx = 0;
  6298. nullpo_retr(-1, sd);
  6299. if (!message || !*message)
  6300. return -1;
  6301. skillen = strlen(message);
  6302. while (skill_names[idx].id != 0) {
  6303. if ((strnicmp(skill_names[idx].name, message, skillen) == 0) ||
  6304. (strnicmp(skill_names[idx].desc, message, skillen) == 0)) {
  6305. char output[255];
  6306. sprintf(output, "skill %d: %s", skill_names[idx].id, skill_names[idx].desc);
  6307. clif_displaymessage(fd, output);
  6308. }
  6309. idx++;
  6310. }
  6311. return 0;
  6312. }
  6313. /*==========================================
  6314. * @useskill by [MouseJstr]
  6315. *
  6316. * A way of using skills without having to find them in the skills menu
  6317. *------------------------------------------
  6318. */
  6319. int
  6320. atcommand_useskill(const int fd, struct map_session_data* sd,
  6321. const char* command, const char* message)
  6322. {
  6323. struct map_session_data *pl_sd = NULL;
  6324. int skillnum;
  6325. int skilllv;
  6326. int inf;
  6327. char target[255];
  6328. nullpo_retr(-1, sd);
  6329. if (!message || !*message)
  6330. return -1;
  6331. if(sscanf(message, "%d %d %s", &skillnum, &skilllv, target) != 3) {
  6332. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6333. return -1;
  6334. }
  6335. if((pl_sd=map_nick2sd(target)) == NULL) {
  6336. return -1;
  6337. }
  6338. inf = skill_get_inf(skillnum);
  6339. if ((inf == 2) || (inf == 1))
  6340. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6341. else
  6342. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6343. return 0;
  6344. }
  6345. /*==========================================
  6346. * @skilltree by [MouseJstr]
  6347. *
  6348. * prints the skill tree for a player required to get to a skill
  6349. *------------------------------------------
  6350. */
  6351. int
  6352. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6353. const char* command, const char* message)
  6354. {
  6355. struct map_session_data *pl_sd = NULL;
  6356. int skillnum, skillidx = -1;
  6357. int meets = 1, j, c=0, s=0;
  6358. struct pc_base_job s_class;
  6359. char target[255], *tbl;
  6360. char output[255];
  6361. struct skill_tree_entry *ent;
  6362. nullpo_retr(-1, sd);
  6363. if (!message || !*message)
  6364. return -1;
  6365. if(sscanf(message, "%d %[^\r\n]", &skillnum, target) != 2) {
  6366. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6367. return -1;
  6368. }
  6369. if((pl_sd=map_nick2sd(target)) == NULL)
  6370. return -1;
  6371. s_class = pc_calc_base_job(pl_sd->status.class);
  6372. c = s_class.job;
  6373. s = s_class.upper;
  6374. c = pc_calc_skilltree_normalize_job(c, pl_sd);
  6375. tbl = job_name(c);
  6376. sprintf(output, "Player is using %s %s skill tree (%d basic points)",
  6377. s_class.upper ? "upper" : "lower",
  6378. tbl, pc_checkskill(pl_sd, 1));
  6379. clif_displaymessage(fd, output);
  6380. for (j = 0; skill_tree[s][c][j].id != 0; j++) {
  6381. if (skill_tree[s][c][j].id == skillnum) {
  6382. skillidx = j;
  6383. break;
  6384. }
  6385. }
  6386. if (skillidx == -1) {
  6387. sprintf(output, "I do not believe the player can use that skill");
  6388. clif_displaymessage(fd, output);
  6389. return 0;
  6390. }
  6391. ent = &skill_tree[s][c][skillidx];
  6392. for(j=0;j<5;j++)
  6393. if( ent->need[j].id &&
  6394. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6395. {
  6396. int idx = 0;
  6397. char *desc;
  6398. while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id)
  6399. idx++;
  6400. if (skill_names[idx].id == 0)
  6401. desc = "Unknown skill";
  6402. else
  6403. desc = skill_names[idx].desc;
  6404. sprintf(output, "player requires level %d of skill %s",
  6405. ent->need[j].lv, desc);
  6406. clif_displaymessage(fd, output);
  6407. meets = 0;
  6408. }
  6409. if (meets == 1) {
  6410. sprintf(output, "I believe the player meets all the requirements for that skill");
  6411. clif_displaymessage(fd, output);
  6412. }
  6413. return 0;
  6414. }
  6415. /*==========================================
  6416. * @marry by [MouseJstr]
  6417. *
  6418. * Marry two players
  6419. *------------------------------------------
  6420. */
  6421. int
  6422. atcommand_marry(const int fd, struct map_session_data* sd,
  6423. const char* command, const char* message)
  6424. {
  6425. struct map_session_data *pl_sd1 = NULL;
  6426. struct map_session_data *pl_sd2 = NULL;
  6427. char player1[255], player2[255];
  6428. nullpo_retr(-1, sd);
  6429. if (!message || !*message)
  6430. return -1;
  6431. if (sscanf(message, "%[^,],%[^\r\n]", player1, player2) != 2) {
  6432. clif_displaymessage(fd, "usage: @marry <player1> <player2>.");
  6433. return -1;
  6434. }
  6435. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6436. sprintf(player2, "Cannot find player %s online", player1);
  6437. clif_displaymessage(fd, player2);
  6438. return -1;
  6439. }
  6440. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6441. sprintf(player1, "Cannot find player %s online", player2);
  6442. clif_displaymessage(fd, player1);
  6443. return -1;
  6444. }
  6445. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6446. clif_displaymessage(fd, "They are married.. wish them well");
  6447. return 0;
  6448. } else
  6449. return -1;
  6450. }
  6451. /*==========================================
  6452. * @divorce by [MouseJstr]
  6453. *
  6454. * divorce two players
  6455. *------------------------------------------
  6456. */
  6457. int
  6458. atcommand_divorce(const int fd, struct map_session_data* sd,
  6459. const char* command, const char* message)
  6460. {
  6461. struct map_session_data *pl_sd = NULL;
  6462. nullpo_retr(-1, sd);
  6463. if (!message || !*message)
  6464. return -1;
  6465. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6466. return pc_divorce(pl_sd);
  6467. clif_displaymessage(fd, "They are now divorced.");
  6468. } else
  6469. clif_displaymessage(fd, "The divorce has failed.. talk to the judge..");
  6470. return 0;
  6471. }
  6472. /*==========================================
  6473. * @rings by [MouseJstr]
  6474. *
  6475. * Give two players rings
  6476. *------------------------------------------
  6477. */
  6478. int
  6479. atcommand_rings(const int fd, struct map_session_data* sd,
  6480. const char* command, const char* message)
  6481. {
  6482. struct item item_tmp;
  6483. int flag;
  6484. memset(&item_tmp, 0, sizeof(item_tmp));
  6485. item_tmp.nameid = 2634;
  6486. item_tmp.identify = 1;
  6487. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6488. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6489. item_tmp.nameid = 2635;
  6490. item_tmp.identify = 1;
  6491. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6492. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6493. clif_displaymessage(fd, "You have rings! Give them to the lovers.");
  6494. return 0;
  6495. }
  6496. /*==========================================
  6497. * @grind by [MouseJstr]
  6498. *------------------------------------------
  6499. */
  6500. int
  6501. atcommand_grind(const int fd, struct map_session_data* sd,
  6502. const char* command, const char* message)
  6503. {
  6504. struct map_session_data *pl_sd = NULL;
  6505. int skillnum;
  6506. int inf;
  6507. char target[255];
  6508. nullpo_retr(-1, sd);
  6509. if (!message || !*message)
  6510. return -1;
  6511. if(sscanf(message, "%s", target) != 1) {
  6512. clif_displaymessage(fd, "Usage: @grind <target>");
  6513. return -1;
  6514. }
  6515. if((pl_sd=map_nick2sd(target)) == NULL)
  6516. return -1;
  6517. for (skillnum = 1; skillnum < 500; skillnum++) {
  6518. sd->status.sp = sd->status.max_sp;
  6519. atcommand_alive(fd, sd, command, message);
  6520. inf = skill_get_inf(skillnum);
  6521. if ((inf == 2) || (inf == 1))
  6522. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6523. else
  6524. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6525. }
  6526. return 0;
  6527. }
  6528. /*==========================================
  6529. * @grind2 by [MouseJstr]
  6530. *------------------------------------------
  6531. */
  6532. int
  6533. atcommand_grind2(const int fd, struct map_session_data* sd,
  6534. const char* command, const char* message)
  6535. {
  6536. int i, x, y, id;
  6537. for (i = 1000; i <2000; i++) {
  6538. x = sd->bl.x + (rand() % 10 - 5);
  6539. y = sd->bl.y + (rand() % 10 - 5);
  6540. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6541. }
  6542. return 0;
  6543. }
  6544. /*==========================================
  6545. * It is made to rain.
  6546. *------------------------------------------
  6547. */
  6548. int
  6549. atcommand_rain(
  6550. const int fd, struct map_session_data* sd,
  6551. const char* command, const char* message)
  6552. {
  6553. int effno = 0;
  6554. nullpo_retr(-1, sd);
  6555. effno = 161;
  6556. if (map[sd->bl.m].flag.rain) {
  6557. map[sd->bl.m].flag.rain=0;
  6558. clif_displaymessage(fd, "The rain has stopped.");
  6559. } else {
  6560. map[sd->bl.m].flag.rain=1;
  6561. clif_specialeffect(&sd->bl,effno,2);
  6562. clif_displaymessage(fd, "It is made to rain.");
  6563. }
  6564. return 0;
  6565. }
  6566. /*==========================================
  6567. * It is made to snow.
  6568. *------------------------------------------
  6569. */
  6570. int
  6571. atcommand_snow(
  6572. const int fd, struct map_session_data* sd,
  6573. const char* command, const char* message)
  6574. {
  6575. int effno = 0;
  6576. effno = 162;
  6577. nullpo_retr(-1, sd);
  6578. if (map[sd->bl.m].flag.snow) {
  6579. map[sd->bl.m].flag.snow=0;
  6580. clif_displaymessage(fd, "Snow has stopped falling.");
  6581. } else {
  6582. map[sd->bl.m].flag.snow=1;
  6583. clif_specialeffect(&sd->bl,effno,2);
  6584. clif_displaymessage(fd, "It is made to snow.");
  6585. }
  6586. return 0;
  6587. }
  6588. /*==========================================
  6589. * Cherry tree snowstorm is made to fall. (Sakura)
  6590. *------------------------------------------
  6591. */
  6592. int
  6593. atcommand_sakura(
  6594. const int fd, struct map_session_data* sd,
  6595. const char* command, const char* message)
  6596. {
  6597. int effno = 0;
  6598. effno = 163;
  6599. nullpo_retr(-1, sd);
  6600. if (map[sd->bl.m].flag.sakura) {
  6601. map[sd->bl.m].flag.sakura=0;
  6602. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6603. } else {
  6604. map[sd->bl.m].flag.sakura=1;
  6605. clif_specialeffect(&sd->bl,effno,2);
  6606. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6607. }
  6608. return 0;
  6609. }
  6610. /*==========================================
  6611. * Fog hangs over.
  6612. *------------------------------------------
  6613. */
  6614. int
  6615. atcommand_fog(
  6616. const int fd, struct map_session_data* sd,
  6617. const char* command, const char* message)
  6618. {
  6619. int effno = 0;
  6620. effno = 233;
  6621. nullpo_retr(-1, sd);
  6622. if (map[sd->bl.m].flag.fog) {
  6623. map[sd->bl.m].flag.fog=0;
  6624. clif_displaymessage(fd, "The fog has gone.");
  6625. } else {
  6626. map[sd->bl.m].flag.fog=1;
  6627. clif_specialeffect(&sd->bl,effno,2);
  6628. clif_displaymessage(fd, "Fog hangs over.");
  6629. }
  6630. return 0;
  6631. }
  6632. /*==========================================
  6633. * Fallen leaves fall.
  6634. *------------------------------------------
  6635. */
  6636. int
  6637. atcommand_leaves(
  6638. const int fd, struct map_session_data* sd,
  6639. const char* command, const char* message)
  6640. {
  6641. int effno = 0;
  6642. effno = 333;
  6643. nullpo_retr(-1, sd);
  6644. if (map[sd->bl.m].flag.leaves) {
  6645. map[sd->bl.m].flag.leaves=0;
  6646. clif_displaymessage(fd, "Leaves no longer fall.");
  6647. } else {
  6648. map[sd->bl.m].flag.leaves=1;
  6649. clif_specialeffect(&sd->bl,effno,2);
  6650. clif_displaymessage(fd, "Fallen leaves fall.");
  6651. }
  6652. return 0;
  6653. }
  6654. /*==========================================
  6655. * Clearing Weather Effects by Dexity
  6656. *------------------------------------------
  6657. */
  6658. int
  6659. atcommand_clearweather(
  6660. const int fd, struct map_session_data* sd,
  6661. const char* command, const char* message)
  6662. {
  6663. //int effno = 0;
  6664. nullpo_retr(-1, sd);
  6665. map[sd->bl.m].flag.rain=0;
  6666. map[sd->bl.m].flag.snow=0;
  6667. map[sd->bl.m].flag.sakura=0;
  6668. map[sd->bl.m].flag.fog=0;
  6669. map[sd->bl.m].flag.leaves=0;
  6670. //clif_specialeffect(&sd->bl,effno,2); // not required. [celest]
  6671. return 0;
  6672. }
  6673. /*==========================================
  6674. * MOB Search
  6675. *------------------------------------------
  6676. */
  6677. int
  6678. atcommand_mobsearch(
  6679. const int fd, struct map_session_data* sd,
  6680. const char* command, const char* message)
  6681. {
  6682. char mob_name[100];
  6683. char output[100];
  6684. int mob_id,map_id = 0;
  6685. nullpo_retr(-1, sd);
  6686. if (sscanf(message, "%99s", mob_name) < 0)
  6687. return -1;
  6688. if ((mob_id = atoi(mob_name)) == 0)
  6689. mob_id = mobdb_searchname(mob_name);
  6690. if(mob_id !=-1 && (mob_id <= 1000 || mob_id >= 2000)){
  6691. snprintf(output, sizeof output, "Invalid mob id %s!",mob_name);
  6692. clif_displaymessage(fd, output);
  6693. return 0;
  6694. }
  6695. if(mob_id == atoi(mob_name) && mob_db[mob_id].jname)
  6696. strcpy(mob_name,mob_db[mob_id].jname); // --ja--
  6697. // strcpy(mob_name,mob_db[mob_id].name); // --en--
  6698. map_id = sd->bl.m;
  6699. snprintf(output, sizeof output, "Mob Search... %s %s",
  6700. mob_name, sd->mapname);
  6701. clif_displaymessage(fd, output);
  6702. map_foreachinarea(atmobsearch_sub, map_id, 0, 0,
  6703. map[map_id].xs, map[map_id].ys, BL_MOB, mob_id, fd);
  6704. atmobsearch_sub(&sd->bl,0); // 番号リセット
  6705. return 0;
  6706. }
  6707. /*==========================================
  6708. * ドロップアイテムの掃除
  6709. *------------------------------------------
  6710. */
  6711. int
  6712. atcommand_cleanmap(
  6713. const int fd, struct map_session_data* sd,
  6714. const char* command, const char* message)
  6715. {
  6716. int i=0;
  6717. map_foreachinarea(atcommand_cleanmap_sub,sd->bl.m,
  6718. sd->bl.x-AREA_SIZE*2,sd->bl.y-AREA_SIZE*2,
  6719. sd->bl.x+AREA_SIZE*2,sd->bl.y+AREA_SIZE*2,
  6720. BL_ITEM,sd,&i);
  6721. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  6722. return 0;
  6723. }
  6724. /*==========================================
  6725. * Give Item
  6726. * @giveitem (item_id or item_name) amount charname
  6727. *------------------------------------------
  6728. */
  6729. static void
  6730. atcommand_giveitem_sub(struct map_session_data *sd,struct item_data *item_data,int number)
  6731. {
  6732. int flag = 0;
  6733. int loop = 1, get_count = number,i;
  6734. struct item item_tmp;
  6735. if(sd && item_data){
  6736. if (item_data->type == 4 || item_data->type == 5 ||
  6737. item_data->type == 7 || item_data->type == 8) {
  6738. loop = number;
  6739. get_count = 1;
  6740. }
  6741. for (i = 0; i < loop; i++) {
  6742. memset(&item_tmp, 0, sizeof(item_tmp));
  6743. item_tmp.nameid = item_data->nameid;
  6744. item_tmp.identify = 1;
  6745. if ((flag = pc_additem((struct map_session_data*)sd,
  6746. &item_tmp, get_count)))
  6747. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6748. }
  6749. }
  6750. }
  6751. int
  6752. atcommand_giveitem(
  6753. const int fd, struct map_session_data* sd,
  6754. const char* command, const char* message)
  6755. {
  6756. struct map_session_data *pl_sd = NULL;
  6757. struct item_data *item_data;
  6758. char item_name[100];
  6759. char character[100];
  6760. char output[100];
  6761. int number,i,item_id;
  6762. if (!message || !*message)
  6763. return -1;
  6764. if (sscanf(message, "%99s %d %99[^\n]", item_name, &number, character) < 3)
  6765. return -1;
  6766. if (number <= 0)
  6767. number = 1;
  6768. if ((item_id = atoi(item_name)) > 0) {
  6769. if (battle_config.item_check) {
  6770. item_id =
  6771. (((item_data = itemdb_exists(item_id)) &&
  6772. itemdb_available(item_id)) ? item_id : 0);
  6773. } else {
  6774. item_data = itemdb_search(item_id);
  6775. }
  6776. } else if ((item_data = itemdb_searchname(item_name)) != NULL) {
  6777. item_id = (!battle_config.item_check ||
  6778. itemdb_available(item_data->nameid)) ? item_data->nameid : 0;
  6779. }
  6780. if(item_id == 0)
  6781. return -1;
  6782. if ((pl_sd = map_nick2sd(character)) != NULL) { //該当名のキャラが存在する
  6783. atcommand_giveitem_sub(pl_sd,item_data,number);
  6784. snprintf(output, sizeof output, "You got %s %d.",item_name,number);
  6785. clif_displaymessage(pl_sd->fd, output);
  6786. snprintf(output, sizeof output, "%s received %s %d.",pl_sd->status.name,item_name,number);
  6787. clif_displaymessage(fd, output);
  6788. }
  6789. else if(strcmp(character,"ALL")==0){ // 名前がALLなら、接続者全員へ
  6790. for (i = 0; i < fd_max; i++) {
  6791. if (session[i] && (pl_sd = session[i]->session_data)){
  6792. atcommand_giveitem_sub(pl_sd,item_data,number);
  6793. snprintf(output, sizeof output, "You got %s %d.", item_name,number);
  6794. clif_displaymessage(pl_sd->fd, output);
  6795. }
  6796. }
  6797. snprintf(output, sizeof output, "%s received %s %d.","Everyone",item_name,number);
  6798. clif_displaymessage(fd, output);
  6799. }
  6800. return 0;
  6801. }
  6802. /*==========================================
  6803. *
  6804. *------------------------------------------
  6805. */
  6806. int
  6807. atcommand_summon(
  6808. const int fd, struct map_session_data* sd,
  6809. const char* command, const char* message)
  6810. {
  6811. char name[100];
  6812. int mob_id = 0;
  6813. int x = 0;
  6814. int y = 0;
  6815. int id = 0;
  6816. struct mob_data *md;
  6817. unsigned int tick=gettick();
  6818. nullpo_retr(-1, sd);
  6819. if (!message || !*message)
  6820. return -1;
  6821. if (sscanf(message, "%99s", name) < 1)
  6822. return -1;
  6823. if ((mob_id = atoi(name)) == 0)
  6824. mob_id = mobdb_searchname(name);
  6825. if(mob_id == 0)
  6826. return -1;
  6827. x = sd->bl.x + (rand() % 10 - 5);
  6828. y = sd->bl.y + (rand() % 10 - 5);
  6829. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  6830. if((md=(struct mob_data *)map_id2bl(id))){
  6831. md->master_id=sd->bl.id;
  6832. md->state.special_mob_ai=1;
  6833. md->mode=mob_db[md->class].mode|0x04;
  6834. md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0);
  6835. clif_misceffect2(&md->bl,344);
  6836. }
  6837. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  6838. return 0;
  6839. }
  6840. /*==========================================
  6841. * @adjcmdlvl by [MouseJstr]
  6842. *
  6843. * Temp adjust the GM level required to use a GM command
  6844. *
  6845. * Used during beta testing to allow players to use GM commands
  6846. * for short periods of time
  6847. *------------------------------------------
  6848. */
  6849. int
  6850. atcommand_adjcmdlvl(
  6851. const int fd, struct map_session_data* sd,
  6852. const char* command, const char* message)
  6853. {
  6854. int i, newlev;
  6855. char cmd[100];
  6856. nullpo_retr(-1, sd);
  6857. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  6858. clif_displaymessage(fd, "usage: @adjcmdlvl <lvl> <command>.");
  6859. return -1;
  6860. }
  6861. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  6862. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  6863. atcommand_info[i].level = newlev;
  6864. clif_displaymessage(fd, "@command level changed.");
  6865. return 0;
  6866. }
  6867. clif_displaymessage(fd, "@command not found.");
  6868. return -1;
  6869. }
  6870. /*==========================================
  6871. * @adjgmlvl by [MouseJstr]
  6872. *
  6873. * Create a temp GM
  6874. *
  6875. * Used during beta testing to allow players to use GM commands
  6876. * for short periods of time
  6877. *------------------------------------------
  6878. */
  6879. int
  6880. atcommand_adjgmlvl(
  6881. const int fd, struct map_session_data* sd,
  6882. const char* command, const char* message)
  6883. {
  6884. int newlev;
  6885. char user[100];
  6886. struct map_session_data *pl_sd;
  6887. nullpo_retr(-1, sd);
  6888. if (!message || !*message || sscanf(message, "%d %[^\r\n]", &newlev, user) != 2) {
  6889. clif_displaymessage(fd, "usage: @adjgmlvl <lvl> <user>.");
  6890. return -1;
  6891. }
  6892. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  6893. return -1;
  6894. pc_set_gm_level(pl_sd->status.account_id, newlev);
  6895. return 0;
  6896. }
  6897. /*==========================================
  6898. * @trade by [MouseJstr]
  6899. *
  6900. * Open a trade window with a remote player
  6901. *
  6902. * If I have to jump to a remote player one more time, I am
  6903. * gonna scream!
  6904. *------------------------------------------
  6905. */
  6906. int
  6907. atcommand_trade(
  6908. const int fd, struct map_session_data* sd,
  6909. const char* command, const char* message)
  6910. {
  6911. struct map_session_data *pl_sd = NULL;
  6912. nullpo_retr(-1, sd);
  6913. if (!message || !*message)
  6914. return -1;
  6915. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6916. trade_traderequest(sd, pl_sd->bl.id);
  6917. return 0;
  6918. }
  6919. return -1;
  6920. }
  6921. /*==========================================
  6922. * @setbattleflag by [MouseJstr]
  6923. *
  6924. * set a battle_config flag without having to reboot
  6925. */
  6926. int
  6927. atcommand_setbattleflag(
  6928. const int fd, struct map_session_data* sd,
  6929. const char* command, const char* message)
  6930. {
  6931. char flag[128], value[128];
  6932. nullpo_retr(-1, sd);
  6933. if (!message || !*message || sscanf(message, "%s %s", flag, value) != 2) {
  6934. clif_displaymessage(fd, "usage: @setbattleflag <flag> <value>.");
  6935. return -1;
  6936. }
  6937. if (battle_set_value(flag, value) == 0)
  6938. clif_displaymessage(fd, "unknown battle_config flag");
  6939. else
  6940. clif_displaymessage(fd, "battle_config set as requested");
  6941. return 0;
  6942. }
  6943. /*===========================
  6944. * @unmute [Valaris]
  6945. *===========================
  6946. */
  6947. int atcommand_unmute(
  6948. const int fd, struct map_session_data* sd,
  6949. const char* command, const char* message)
  6950. {
  6951. struct map_session_data *pl_sd = NULL;
  6952. nullpo_retr(-1, sd);
  6953. if (!message || !*message)
  6954. return -1;
  6955. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6956. if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) {
  6957. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  6958. skill_status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  6959. clif_displaymessage(sd->fd,"Player unmuted");
  6960. }
  6961. else
  6962. clif_displaymessage(sd->fd,"Player is not muted");
  6963. }
  6964. return 0;
  6965. }
  6966. /*==========================================
  6967. * @uptime by MC Cameri
  6968. *------------------------------------------
  6969. */
  6970. int
  6971. atcommand_uptime(
  6972. const int fd, struct map_session_data* sd,
  6973. const char* command, const char* message)
  6974. {
  6975. char output[200];
  6976. long seconds = 0, day = 24*60*60, hour = 60*60,
  6977. minute = 60, days = 0, hours = 0, minutes = 0;
  6978. nullpo_retr(-1, sd);
  6979. seconds = (gettick()-ticks)/CLOCKS_PER_SEC;
  6980. days = seconds/day;
  6981. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6982. hours = seconds/hour;
  6983. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6984. minutes = seconds/minute;
  6985. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6986. snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds);
  6987. clif_displaymessage(fd,output);
  6988. return 0;
  6989. }
  6990. /*==========================================
  6991. * @changesex <sex>
  6992. * => Changes one's sex. Argument sex can be
  6993. * 0 or 1, m or f, male or female.
  6994. *------------------------------------------
  6995. */
  6996. int
  6997. atcommand_changesex(
  6998. const int fd, struct map_session_data* sd,
  6999. const char* command, const char* message)
  7000. {
  7001. nullpo_retr(-1, sd);
  7002. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7003. return 0;
  7004. }
  7005. /*================================================
  7006. * @mute - Mutes a player for a set amount of time
  7007. *------------------------------------------------
  7008. */
  7009. int atcommand_mute(
  7010. const int fd, struct map_session_data* sd,
  7011. const char* command, const char* message)
  7012. {
  7013. struct map_session_data *pl_sd = NULL;
  7014. char character[100];
  7015. int manner;
  7016. nullpo_retr(-1, sd);
  7017. if (!message || !*message || sscanf(message, "%d %99[^\n]", &manner, character) < 1) {
  7018. clif_displaymessage(fd, "usage: @mute <time> <character name>.");
  7019. return -1;
  7020. }
  7021. if ((pl_sd = map_nick2sd(character)) != NULL) {
  7022. pl_sd->status.manner -= manner;
  7023. if(pl_sd->status.manner < 0)
  7024. skill_status_change_start(&pl_sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  7025. }
  7026. else {
  7027. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7028. return -1;
  7029. }
  7030. return 0;
  7031. }
  7032. /*==========================================
  7033. * @refresh (like @jumpto <<yourself>>)
  7034. *------------------------------------------
  7035. */
  7036. int atcommand_refresh(
  7037. const int fd, struct map_session_data* sd,
  7038. const char* command, const char* message)
  7039. {
  7040. nullpo_retr(-1, sd);
  7041. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  7042. return 0;
  7043. }
  7044. /*==========================================
  7045. * @petid <part of pet name>
  7046. * => Displays a list of matching pets.
  7047. *------------------------------------------
  7048. */
  7049. int
  7050. atcommand_petid(const int fd, struct map_session_data* sd,
  7051. const char* command, const char* message)
  7052. {
  7053. char searchtext[100];
  7054. char temp0[100];
  7055. char temp1[100];
  7056. int cnt = 0, i = 0;
  7057. nullpo_retr(-1, sd);
  7058. if (!message || !*message)
  7059. return -1;
  7060. if (sscanf(message, "%99s", searchtext) < 1)
  7061. return -1;
  7062. estr_lower(searchtext);
  7063. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7064. clif_displaymessage(fd,temp0);
  7065. while (i < MAX_PET_DB) {
  7066. strcpy(temp1,pet_db[i].name);
  7067. strcpy(temp1, estr_lower(temp1));
  7068. strcpy(temp0,pet_db[i].jname);
  7069. strcpy(temp0, estr_lower(temp1));
  7070. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7071. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class,
  7072. pet_db[i].jname);
  7073. if (cnt >= 100) { // Only if there are custom pets
  7074. clif_displaymessage(fd, "Be more specific, can't send more than"
  7075. " 100 results.");
  7076. } else {
  7077. clif_displaymessage(fd, temp0);
  7078. }
  7079. cnt++;
  7080. }
  7081. i++;
  7082. }
  7083. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7084. clif_displaymessage(fd, temp0);
  7085. return 0;
  7086. }
  7087. /*==========================================
  7088. * @identify
  7089. * => GM's magnifier.
  7090. *------------------------------------------
  7091. */
  7092. int
  7093. atcommand_identify(
  7094. const int fd, struct map_session_data* sd,
  7095. const char* command, const char* message)
  7096. {
  7097. int i,num;
  7098. nullpo_retr(-1, sd);
  7099. for(i=num=0;i<MAX_INVENTORY;i++){
  7100. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7101. num++;
  7102. }
  7103. }
  7104. if (num > 0) {
  7105. clif_item_identify_list(sd);
  7106. } else {
  7107. clif_displaymessage(fd,"There are no items to appraise.");
  7108. }
  7109. return 0;
  7110. }
  7111. /*==========================================
  7112. * @gmotd (Global MOTD)
  7113. * by davidsiaw :P
  7114. *------------------------------------------
  7115. */
  7116. int
  7117. atcommand_gmotd(
  7118. const int fd, struct map_session_data* sd,
  7119. const char* command, const char* message)
  7120. {
  7121. char buf[256];
  7122. FILE *fp;
  7123. nullpo_retr(-1, sd);
  7124. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7125. while (fgets(buf, 250, fp) != NULL){
  7126. int i;
  7127. for( i=0; buf[i]; i++){
  7128. if( buf[i]=='\r' || buf[i]=='\n'){
  7129. buf[i]=0;
  7130. break;
  7131. }
  7132. }
  7133. intif_GMmessage(buf,strlen(buf)+1,8);
  7134. }
  7135. fclose(fp);
  7136. }
  7137. return 0;
  7138. }
  7139. int atcommand_misceffect(
  7140. const int fd, struct map_session_data* sd,
  7141. const char* command, const char* message)
  7142. {
  7143. int effect = 0;
  7144. nullpo_retr(-1, sd);
  7145. if (!message || !*message)
  7146. return -1;
  7147. if (sscanf(message, "%d", &effect) < 1)
  7148. return -1;
  7149. clif_misceffect(&sd->bl,effect);
  7150. return 0;
  7151. }
  7152. int charid2sessionid(int charid)
  7153. {
  7154. int i;
  7155. int session_id=0;
  7156. struct map_session_data *pl_sd = NULL;
  7157. for(i=0;i<fd_max;i++){
  7158. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  7159. if (pl_sd->status.char_id==charid) { session_id = i; break; }
  7160. }
  7161. }
  7162. return session_id;
  7163. }
  7164. int accountid2sessionid(int accountid)
  7165. {
  7166. int i;
  7167. int session_id=0;
  7168. struct map_session_data *pl_sd = NULL;
  7169. for(i=0;i<fd_max;i++){
  7170. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  7171. if (pl_sd->status.account_id==accountid) { session_id = i; break; }
  7172. }
  7173. }
  7174. return session_id;
  7175. }
  7176. /*==========================================
  7177. * Jump to a player by PID number
  7178. * Original by Dino9021
  7179. * Added in by nsstrunks
  7180. *------------------------------------------
  7181. */
  7182. int atcommand_jumptoid(
  7183. const int fd, struct map_session_data* sd,
  7184. const char* command, const char* message)
  7185. {
  7186. char character[100];
  7187. char output[200];
  7188. int cid=0;
  7189. int session_id=0;
  7190. struct map_session_data *pl_sd;
  7191. memset(character, '\0', sizeof(character));
  7192. memset(output, '\0', sizeof(output));
  7193. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7194. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7195. return -1;
  7196. }
  7197. cid=atoi(message);
  7198. if ((session_id=charid2sessionid(cid))!=0)
  7199. {
  7200. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7201. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7202. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7203. return -1;
  7204. }
  7205. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7206. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7207. return -1;
  7208. }
  7209. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7210. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7211. clif_displaymessage(fd, output);
  7212. } else {
  7213. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7214. return -1;
  7215. }
  7216. }
  7217. else
  7218. {
  7219. clif_displaymessage(fd,msg_table[3]);
  7220. }
  7221. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7222. return 0;
  7223. }
  7224. /*==========================================
  7225. * Jump to a player by PID number
  7226. * Original by Dino9021
  7227. * Added in by nsstrunks
  7228. *------------------------------------------
  7229. */
  7230. int atcommand_jumptoid2(
  7231. const int fd, struct map_session_data* sd,
  7232. const char* command, const char* message)
  7233. {
  7234. char character[100];
  7235. char output[200];
  7236. int aid=0;
  7237. int session_id=0;
  7238. struct map_session_data *pl_sd;
  7239. memset(character, '\0', sizeof(character));
  7240. memset(output, '\0', sizeof(output));
  7241. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7242. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7243. return -1;
  7244. }
  7245. aid=atoi(message);
  7246. if ((session_id=accountid2sessionid(aid))!=0)
  7247. {
  7248. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7249. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7250. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7251. return -1;
  7252. }
  7253. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7254. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7255. return -1;
  7256. }
  7257. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7258. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7259. clif_displaymessage(fd, output);
  7260. } else {
  7261. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7262. return -1;
  7263. }
  7264. }
  7265. else
  7266. {
  7267. clif_displaymessage(fd,msg_table[3]);
  7268. }
  7269. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7270. return 0;
  7271. }
  7272. /*==========================================
  7273. * Recall a player by PID number
  7274. * Original by Dino9021
  7275. * Added in by nsstrunks
  7276. *------------------------------------------
  7277. */
  7278. int atcommand_recallid(
  7279. const int fd, struct map_session_data* sd,
  7280. const char* command, const char* message)
  7281. {
  7282. char character[100];
  7283. char output[200];
  7284. int cid=0;
  7285. int session_id=0;
  7286. struct map_session_data *pl_sd;
  7287. memset(character, '\0', sizeof(character));
  7288. memset(output, '\0', sizeof(output));
  7289. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7290. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7291. return -1;
  7292. }
  7293. cid=atoi(message);
  7294. if ((session_id=charid2sessionid(cid))!=0)
  7295. {
  7296. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7297. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7298. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7299. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7300. return -1;
  7301. }
  7302. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7303. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7304. return -1;
  7305. }
  7306. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7307. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7308. clif_displaymessage(fd, output);
  7309. } else {
  7310. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7311. return -1;
  7312. }
  7313. } else {
  7314. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7315. return -1;
  7316. }
  7317. }
  7318. else
  7319. {
  7320. clif_displaymessage(fd,msg_table[3]);
  7321. }
  7322. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7323. return 0;
  7324. }
  7325. /*==========================================
  7326. * Recall a player by PID number
  7327. * Original by Dino9021
  7328. * Added in by nsstrunks
  7329. *------------------------------------------
  7330. */
  7331. int atcommand_recallid2(
  7332. const int fd, struct map_session_data* sd,
  7333. const char* command, const char* message)
  7334. {
  7335. char character[100];
  7336. char output[200];
  7337. int aid=0;
  7338. int session_id=0;
  7339. struct map_session_data *pl_sd;
  7340. memset(character, '\0', sizeof(character));
  7341. memset(output, '\0', sizeof(output));
  7342. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7343. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7344. return -1;
  7345. }
  7346. aid=atoi(message);
  7347. if ((session_id=accountid2sessionid(aid))!=0)
  7348. {
  7349. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7350. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7351. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7352. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7353. return -1;
  7354. }
  7355. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7356. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7357. return -1;
  7358. }
  7359. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7360. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7361. clif_displaymessage(fd, output);
  7362. } else {
  7363. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7364. return -1;
  7365. }
  7366. } else {
  7367. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7368. return -1;
  7369. }
  7370. }
  7371. else
  7372. {
  7373. clif_displaymessage(fd,msg_table[3]);
  7374. }
  7375. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7376. return 0;
  7377. }
  7378. /*==========================================
  7379. * Kick a player by PID number
  7380. * Original by Dino9021
  7381. * Added in by nsstrunks
  7382. *------------------------------------------
  7383. */
  7384. int atcommand_kickid(
  7385. const int fd, struct map_session_data* sd,
  7386. const char* command, const char* message)
  7387. {
  7388. struct map_session_data *pl_sd;
  7389. char character[100];
  7390. int cid=0;
  7391. int session_id=0;
  7392. memset(character, '\0', sizeof(character));
  7393. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7394. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7395. return -1;
  7396. }
  7397. cid=atoi(message);
  7398. if ((session_id=charid2sessionid(cid))!=0)
  7399. {
  7400. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7401. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7402. clif_GM_kick(sd, pl_sd, 1);
  7403. else {
  7404. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7405. return -1;
  7406. }
  7407. } else {
  7408. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7409. return -1;
  7410. }
  7411. }
  7412. else
  7413. {
  7414. clif_displaymessage(fd,msg_table[3]);
  7415. }
  7416. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7417. return 0;
  7418. }
  7419. /*==========================================
  7420. * Kick a player by PID number
  7421. * Original by Dino9021
  7422. * Added in by nsstrunks
  7423. *------------------------------------------
  7424. */
  7425. int atcommand_kickid2(
  7426. const int fd, struct map_session_data* sd,
  7427. const char* command, const char* message)
  7428. {
  7429. struct map_session_data *pl_sd;
  7430. char character[100];
  7431. int aid=0;
  7432. int session_id=0;
  7433. memset(character, '\0', sizeof(character));
  7434. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7435. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7436. return -1;
  7437. }
  7438. aid=atoi(message);
  7439. if ((session_id=accountid2sessionid(aid))!=0)
  7440. {
  7441. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7442. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7443. clif_GM_kick(sd, pl_sd, 1);
  7444. else {
  7445. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7446. return -1;
  7447. }
  7448. } else {
  7449. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7450. return -1;
  7451. }
  7452. }
  7453. else
  7454. {
  7455. clif_displaymessage(fd,msg_table[3]);
  7456. }
  7457. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7458. return 0;
  7459. }
  7460. /*==========================================
  7461. * Revive a player by PID number
  7462. * Original by Dino9021
  7463. * Added in by nsstrunks
  7464. *------------------------------------------
  7465. */
  7466. int atcommand_reviveid(
  7467. const int fd, struct map_session_data* sd,
  7468. const char* command, const char* message)
  7469. {
  7470. char character[100];
  7471. int cid=0;
  7472. int session_id=0;
  7473. struct map_session_data *pl_sd;
  7474. memset(character, '\0', sizeof(character));
  7475. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7476. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7477. return -1;
  7478. }
  7479. cid=atoi(message);
  7480. if ((session_id=charid2sessionid(cid))!=0)
  7481. {
  7482. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7483. pl_sd->status.hp = pl_sd->status.max_hp;
  7484. pc_setstand(pl_sd);
  7485. if (battle_config.pc_invincible_time > 0)
  7486. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7487. clif_updatestatus(pl_sd, SP_HP);
  7488. clif_updatestatus(pl_sd, SP_SP);
  7489. clif_resurrection(&pl_sd->bl, 1);
  7490. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7491. } else {
  7492. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7493. return -1;
  7494. }
  7495. }
  7496. else
  7497. {
  7498. clif_displaymessage(fd,msg_table[3]);
  7499. }
  7500. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7501. return 0;
  7502. }
  7503. /*==========================================
  7504. * Revive a player by PID number
  7505. * Original by Dino9021
  7506. * Added in by nsstrunks
  7507. *------------------------------------------
  7508. */
  7509. int atcommand_reviveid2(
  7510. const int fd, struct map_session_data* sd,
  7511. const char* command, const char* message)
  7512. {
  7513. char character[100];
  7514. int aid=0;
  7515. int session_id=0;
  7516. struct map_session_data *pl_sd;
  7517. memset(character, '\0', sizeof(character));
  7518. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7519. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7520. return -1;
  7521. }
  7522. aid=atoi(message);
  7523. if ((session_id=accountid2sessionid(aid))!=0)
  7524. {
  7525. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7526. pl_sd->status.hp = pl_sd->status.max_hp;
  7527. pc_setstand(pl_sd);
  7528. if (battle_config.pc_invincible_time > 0)
  7529. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7530. clif_updatestatus(pl_sd, SP_HP);
  7531. clif_updatestatus(pl_sd, SP_SP);
  7532. clif_resurrection(&pl_sd->bl, 1);
  7533. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7534. } else {
  7535. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7536. return -1;
  7537. }
  7538. }
  7539. else
  7540. {
  7541. clif_displaymessage(fd,msg_table[3]);
  7542. }
  7543. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7544. return 0;
  7545. }
  7546. /*==========================================
  7547. * Kill a player by PID number
  7548. * Original by Dino9021
  7549. * Added in by nsstrunks
  7550. *------------------------------------------
  7551. */
  7552. int atcommand_killid(
  7553. const int fd, struct map_session_data* sd,
  7554. const char* command, const char* message)
  7555. {
  7556. char character[100];
  7557. int cid=0;
  7558. int session_id=0;
  7559. struct map_session_data *pl_sd;
  7560. memset(character, '\0', sizeof(character));
  7561. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7562. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7563. return -1;
  7564. }
  7565. cid=atoi(message);
  7566. if ((session_id=charid2sessionid(cid))!=0)
  7567. {
  7568. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7569. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7570. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7571. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7572. } else {
  7573. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7574. return -1;
  7575. }
  7576. } else {
  7577. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7578. return -1;
  7579. }
  7580. }
  7581. else
  7582. {
  7583. clif_displaymessage(fd,msg_table[3]);
  7584. }
  7585. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7586. return 0;
  7587. }
  7588. /*==========================================
  7589. * Kill a player by PID number
  7590. * Original by Dino9021
  7591. * Added in by nsstrunks
  7592. *------------------------------------------
  7593. */
  7594. int atcommand_killid2(
  7595. const int fd, struct map_session_data* sd,
  7596. const char* command, const char* message)
  7597. {
  7598. char character[100];
  7599. int aid=0;
  7600. int session_id=0;
  7601. struct map_session_data *pl_sd;
  7602. memset(character, '\0', sizeof(character));
  7603. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7604. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7605. return -1;
  7606. }
  7607. aid=atoi(message);
  7608. if ((session_id=accountid2sessionid(aid))!=0)
  7609. {
  7610. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7611. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7612. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7613. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7614. } else {
  7615. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7616. return -1;
  7617. }
  7618. } else {
  7619. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7620. return -1;
  7621. }
  7622. }
  7623. else
  7624. {
  7625. clif_displaymessage(fd,msg_table[3]);
  7626. }
  7627. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7628. return 0;
  7629. }
  7630. /*==========================================
  7631. * Make a player killable, by PID
  7632. * Original by Dino9021
  7633. * Added in by nsstrunks
  7634. *------------------------------------------
  7635. */
  7636. int
  7637. atcommand_charkillableid(
  7638. const int fd, struct map_session_data* sd,
  7639. const char* command, const char* message)
  7640. {
  7641. struct map_session_data *pl_sd = NULL;
  7642. int cid=0;
  7643. int session_id=0;
  7644. if (!message || (cid = atoi(message)) == 0 || !*message)
  7645. return -1;
  7646. cid=atoi(message);
  7647. if ((session_id=charid2sessionid(cid))!=0)
  7648. {
  7649. if((pl_sd=session[session_id]->session_data) == NULL)
  7650. return -1;
  7651. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7652. if(pl_sd->special_state.killable)
  7653. clif_displaymessage(fd, "The player is now killable");
  7654. else
  7655. clif_displaymessage(fd, "The player is no longer killable");
  7656. }
  7657. else
  7658. {
  7659. clif_displaymessage(fd,msg_table[3]);
  7660. }
  7661. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7662. return 0;
  7663. }
  7664. /*==========================================
  7665. * Make a player killable, by PID
  7666. * Original by Dino9021
  7667. * Added in by nsstrunks
  7668. *------------------------------------------
  7669. */
  7670. int
  7671. atcommand_charkillableid2(
  7672. const int fd, struct map_session_data* sd,
  7673. const char* command, const char* message)
  7674. {
  7675. struct map_session_data *pl_sd = NULL;
  7676. int aid=0;
  7677. int session_id=0;
  7678. if (!message || (aid = atoi(message)) == 0 || !*message)
  7679. return -1;
  7680. aid=atoi(message);
  7681. if ((session_id=accountid2sessionid(aid))!=0)
  7682. {
  7683. if((pl_sd=session[session_id]->session_data) == NULL)
  7684. return -1;
  7685. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7686. if(pl_sd->special_state.killable)
  7687. clif_displaymessage(fd, "The player is now killable");
  7688. else
  7689. clif_displaymessage(fd, "The player is no longer killable");
  7690. }
  7691. else
  7692. {
  7693. clif_displaymessage(fd,msg_table[3]);
  7694. }
  7695. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7696. return 0;
  7697. }
  7698. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7699. /*==========================================
  7700. * Mail System commands by [Valaris]
  7701. *------------------------------------------
  7702. */
  7703. int atcommand_listmail(
  7704. const int fd, struct map_session_data* sd,
  7705. const char* command, const char* message)
  7706. {
  7707. if(!battle_config.mail_system)
  7708. return 0;
  7709. nullpo_retr(-1, sd);
  7710. if(strlen(command)==12)
  7711. mail_check(sd,3);
  7712. else if(strlen(command)==9)
  7713. mail_check(sd,2);
  7714. else
  7715. mail_check(sd,1);
  7716. return 0;
  7717. }
  7718. int atcommand_readmail(
  7719. const int fd, struct map_session_data* sd,
  7720. const char* command, const char* message)
  7721. {
  7722. if(!battle_config.mail_system)
  7723. return 0;
  7724. nullpo_retr(-1, sd);
  7725. if (!message || !*message) {
  7726. clif_displaymessage(sd->fd,"You must specify a message number.");
  7727. return 0;
  7728. }
  7729. if(strlen(command)==11)
  7730. mail_delete(sd,atoi(message));
  7731. else
  7732. mail_read(sd,atoi(message));
  7733. return 0;
  7734. }
  7735. int atcommand_sendmail(
  7736. const int fd, struct map_session_data* sd,
  7737. const char* command, const char* message)
  7738. {
  7739. char name[24],text[80];
  7740. if(!battle_config.mail_system)
  7741. return 0;
  7742. nullpo_retr(-1, sd);
  7743. if (!message || !*message) {
  7744. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7745. return 0;
  7746. }
  7747. if ((sscanf(message, "\"%[^\"]\" %79[^\n]", name, text) < 2) &&
  7748. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7749. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7750. return 0;
  7751. }
  7752. if(strlen(command)==17)
  7753. mail_send(sd,name,text,1);
  7754. else
  7755. mail_send(sd,name,text,0);
  7756. return 0;
  7757. }
  7758. /*==========================================
  7759. * Refresh online command for SQL [Valaris]
  7760. * Will refresh and check online column of
  7761. * players and set correctly.
  7762. *------------------------------------------
  7763. */
  7764. int atcommand_refreshonline(
  7765. const int fd, struct map_session_data* sd,
  7766. const char* command, const char* message)
  7767. {
  7768. nullpo_retr(-1, sd);
  7769. char_online_check();
  7770. return 0;
  7771. }
  7772. #endif /* end sql only */