atcommand.c 273 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/random.h"
  11. #include "../common/socket.h"
  12. #include "../common/strlib.h"
  13. #include "../common/utils.h"
  14. #include "../common/conf.h"
  15. #include "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "clif.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "intif.h"
  22. #include "itemdb.h"
  23. #include "log.h"
  24. #include "map.h"
  25. #include "pc.h"
  26. #include "pc_groups.h" // groupid2name
  27. #include "status.h"
  28. #include "skill.h"
  29. #include "mob.h"
  30. #include "npc.h"
  31. #include "pet.h"
  32. #include "homunculus.h"
  33. #include "mail.h"
  34. #include "mercenary.h"
  35. #include "elemental.h"
  36. #include "party.h"
  37. #include "guild.h"
  38. #include "script.h"
  39. #include "storage.h"
  40. #include "trade.h"
  41. #include "unit.h"
  42. #include "mapreg.h"
  43. #include "quest.h"
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <string.h>
  47. #include <math.h>
  48. #define ATCOMMAND_LENGTH 50
  49. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  50. #define MAX_MSG 1400
  51. typedef struct AtCommandInfo AtCommandInfo;
  52. typedef struct AliasInfo AliasInfo;
  53. int atcmd_binding_count = 0;
  54. struct AtCommandInfo {
  55. char command[ATCOMMAND_LENGTH];
  56. AtCommandFunc func;
  57. char* at_groups;/* quick @commands "can-use" lookup */
  58. char* char_groups;/* quick @charcommands "can-use" lookup */
  59. };
  60. struct AliasInfo {
  61. AtCommandInfo *command;
  62. char alias[ATCOMMAND_LENGTH];
  63. };
  64. char atcommand_symbol = '@'; // first char of the commands
  65. char charcommand_symbol = '#';
  66. static char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  67. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  68. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  69. static config_t atcommand_config;
  70. static char atcmd_output[CHAT_SIZE_MAX];
  71. static char atcmd_player_name[NAME_LENGTH];
  72. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  73. static const char* atcommand_checkalias(const char *aliasname); // @help
  74. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  75. // @commands (script-based)
  76. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  77. int i = 0;
  78. if( *name == atcommand_symbol || *name == charcommand_symbol )
  79. name++; // for backwards compatibility
  80. ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
  81. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  82. }
  83. //-----------------------------------------------------------
  84. // Return the message string of the specified number by [Yor]
  85. //-----------------------------------------------------------
  86. const char* msg_txt(int msg_number)
  87. {
  88. if (msg_number >= 0 && msg_number < MAX_MSG &&
  89. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  90. return msg_table[msg_number];
  91. return "??";
  92. }
  93. /*==========================================
  94. * Read Message Data
  95. *------------------------------------------*/
  96. int msg_config_read(const char* cfgName)
  97. {
  98. int msg_number;
  99. char line[1024], w1[1024], w2[1024];
  100. FILE *fp;
  101. static int called = 1;
  102. if ((fp = fopen(cfgName, "r")) == NULL) {
  103. ShowError("Messages file not found: %s\n", cfgName);
  104. return 1;
  105. }
  106. if ((--called) == 0)
  107. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  108. while(fgets(line, sizeof(line), fp))
  109. {
  110. if (line[0] == '/' && line[1] == '/')
  111. continue;
  112. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  113. continue;
  114. if (strcmpi(w1, "import") == 0)
  115. msg_config_read(w2);
  116. else
  117. {
  118. msg_number = atoi(w1);
  119. if (msg_number >= 0 && msg_number < MAX_MSG)
  120. {
  121. if (msg_table[msg_number] != NULL)
  122. aFree(msg_table[msg_number]);
  123. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  124. strcpy(msg_table[msg_number],w2);
  125. }
  126. }
  127. }
  128. fclose(fp);
  129. return 0;
  130. }
  131. /*==========================================
  132. * Cleanup Message Data
  133. *------------------------------------------*/
  134. void do_final_msg(void)
  135. {
  136. int i;
  137. for (i = 0; i < MAX_MSG; i++)
  138. aFree(msg_table[i]);
  139. }
  140. /**
  141. * retrieves the help string associated with a given command.
  142. *
  143. * @param name the name of the command to retrieve help information for
  144. * @return the string associated with the command, or NULL
  145. */
  146. static const char* atcommand_help_string(const char* command)
  147. {
  148. const char* str = NULL;
  149. config_setting_t* info;
  150. if( *command == atcommand_symbol || *command == charcommand_symbol )
  151. {// remove the prefix symbol for the raw name of the command
  152. command ++;
  153. }
  154. // convert alias to the real command name
  155. command = atcommand_checkalias(command);
  156. // attept to find the first default help command
  157. info = config_lookup(&atcommand_config, "help");
  158. if( info == NULL )
  159. {// failed to find the help property in the configuration file
  160. return NULL;
  161. }
  162. if( !config_setting_lookup_string( info, command, &str ) )
  163. {// failed to find the matching help string
  164. return NULL;
  165. }
  166. // push the result from the method
  167. return str;
  168. }
  169. /*==========================================
  170. * @send (used for testing packet sends from the client)
  171. *------------------------------------------*/
  172. ACMD_FUNC(send)
  173. {
  174. int len=0,off,end,type;
  175. long num;
  176. // read message type as hex number (without the 0x)
  177. if(!message || !*message ||
  178. !((sscanf(message, "len %x", &type)==1 && (len=1))
  179. || sscanf(message, "%x", &type)==1) )
  180. {
  181. int i;
  182. for (i = 900; i <= 903; ++i)
  183. clif_displaymessage(fd, msg_txt(i));
  184. return -1;
  185. }
  186. #define PARSE_ERROR(error,p) \
  187. {\
  188. clif_displaymessage(fd, (error));\
  189. sprintf(atcmd_output, ">%s", (p));\
  190. clif_displaymessage(fd, atcmd_output);\
  191. }
  192. //define PARSE_ERROR
  193. #define CHECK_EOS(p) \
  194. if(*(p) == 0){\
  195. clif_displaymessage(fd, "Unexpected end of string");\
  196. return -1;\
  197. }
  198. //define CHECK_EOS
  199. #define SKIP_VALUE(p) \
  200. {\
  201. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  202. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  203. }
  204. //define SKIP_VALUE
  205. #define GET_VALUE(p,num) \
  206. {\
  207. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  208. PARSE_ERROR("Invalid number in:",(p));\
  209. return -1;\
  210. }\
  211. }
  212. //define GET_VALUE
  213. if (type > 0 && type < MAX_PACKET_DB) {
  214. if(len)
  215. {// show packet length
  216. sprintf(atcmd_output, msg_txt(904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  217. clif_displaymessage(fd, atcmd_output);
  218. return 0;
  219. }
  220. len=packet_db[sd->packet_ver][type].len;
  221. off=2;
  222. if(len == 0)
  223. {// unknown packet - ERROR
  224. sprintf(atcmd_output, msg_txt(905), type); // Unknown packet: 0x%x
  225. clif_displaymessage(fd, atcmd_output);
  226. return -1;
  227. } else if(len == -1)
  228. {// dynamic packet
  229. len=SHRT_MAX-4; // maximum length
  230. off=4;
  231. }
  232. WFIFOHEAD(fd, len);
  233. WFIFOW(fd,0)=TOW(type);
  234. // parse packet contents
  235. SKIP_VALUE(message);
  236. while(*message != 0 && off < len){
  237. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  238. {// default (byte)
  239. GET_VALUE(message,num);
  240. WFIFOB(fd,off)=TOB(num);
  241. ++off;
  242. } else if(TOUPPER(*message) == 'B')
  243. {// byte
  244. ++message;
  245. GET_VALUE(message,num);
  246. WFIFOB(fd,off)=TOB(num);
  247. ++off;
  248. } else if(TOUPPER(*message) == 'W')
  249. {// word (2 bytes)
  250. ++message;
  251. GET_VALUE(message,num);
  252. WFIFOW(fd,off)=TOW(num);
  253. off+=2;
  254. } else if(TOUPPER(*message) == 'L')
  255. {// long word (4 bytes)
  256. ++message;
  257. GET_VALUE(message,num);
  258. WFIFOL(fd,off)=TOL(num);
  259. off+=4;
  260. } else if(TOUPPER(*message) == 'S')
  261. {// string - escapes are valid
  262. // get string length - num <= 0 means not fixed length (default)
  263. ++message;
  264. if(*message == '"'){
  265. num=0;
  266. } else {
  267. GET_VALUE(message,num);
  268. while(*message != '"')
  269. {// find start of string
  270. if(*message == 0 || ISSPACE(*message)){
  271. PARSE_ERROR(msg_txt(906),message); // Not a string:
  272. return -1;
  273. }
  274. ++message;
  275. }
  276. }
  277. // parse string
  278. ++message;
  279. CHECK_EOS(message);
  280. end=(num<=0? 0: min(off+((int)num),len));
  281. for(; *message != '"' && (off < end || end == 0); ++off){
  282. if(*message == '\\'){
  283. ++message;
  284. CHECK_EOS(message);
  285. switch(*message){
  286. case 'a': num=0x07; break; // Bell
  287. case 'b': num=0x08; break; // Backspace
  288. case 't': num=0x09; break; // Horizontal tab
  289. case 'n': num=0x0A; break; // Line feed
  290. case 'v': num=0x0B; break; // Vertical tab
  291. case 'f': num=0x0C; break; // Form feed
  292. case 'r': num=0x0D; break; // Carriage return
  293. case 'e': num=0x1B; break; // Escape
  294. default: num=*message; break;
  295. case 'x': // Hexadecimal
  296. {
  297. ++message;
  298. CHECK_EOS(message);
  299. if(!ISXDIGIT(*message)){
  300. PARSE_ERROR(msg_txt(907),message); // Not a hexadecimal digit:
  301. return -1;
  302. }
  303. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  304. if(ISXDIGIT(*message)){
  305. ++message;
  306. CHECK_EOS(message);
  307. num<<=8;
  308. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  309. }
  310. WFIFOB(fd,off)=TOB(num);
  311. ++message;
  312. CHECK_EOS(message);
  313. continue;
  314. }
  315. case '0':
  316. case '1':
  317. case '2':
  318. case '3':
  319. case '4':
  320. case '5':
  321. case '6':
  322. case '7': // Octal
  323. {
  324. num=*message-'0'; // 1st octal digit
  325. ++message;
  326. CHECK_EOS(message);
  327. if(ISDIGIT(*message) && *message < '8'){
  328. num<<=3;
  329. num+=*message-'0'; // 2nd octal digit
  330. ++message;
  331. CHECK_EOS(message);
  332. if(ISDIGIT(*message) && *message < '8'){
  333. num<<=3;
  334. num+=*message-'0'; // 3rd octal digit
  335. ++message;
  336. CHECK_EOS(message);
  337. }
  338. }
  339. WFIFOB(fd,off)=TOB(num);
  340. continue;
  341. }
  342. }
  343. } else
  344. num=*message;
  345. WFIFOB(fd,off)=TOB(num);
  346. ++message;
  347. CHECK_EOS(message);
  348. }//for
  349. while(*message != '"')
  350. {// ignore extra characters
  351. ++message;
  352. CHECK_EOS(message);
  353. }
  354. // terminate the string
  355. if(off < end)
  356. {// fill the rest with 0's
  357. memset(WFIFOP(fd,off),0,end-off);
  358. off=end;
  359. }
  360. } else
  361. {// unknown
  362. PARSE_ERROR(msg_txt(908),message); // Unknown type of value in:
  363. return -1;
  364. }
  365. SKIP_VALUE(message);
  366. }
  367. if(packet_db[sd->packet_ver][type].len == -1)
  368. {// send dynamic packet
  369. WFIFOW(fd,2)=TOW(off);
  370. WFIFOSET(fd,off);
  371. } else
  372. {// send static packet
  373. if(off < len)
  374. memset(WFIFOP(fd,off),0,len-off);
  375. WFIFOSET(fd,len);
  376. }
  377. } else {
  378. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  379. return -1;
  380. }
  381. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  382. clif_displaymessage(fd, atcmd_output);
  383. return 0;
  384. #undef PARSE_ERROR
  385. #undef CHECK_EOS
  386. #undef SKIP_VALUE
  387. #undef GET_VALUE
  388. }
  389. /*==========================================
  390. * @rura, @warp, @mapmove
  391. *------------------------------------------*/
  392. ACMD_FUNC(mapmove)
  393. {
  394. char map_name[MAP_NAME_LENGTH_EXT];
  395. unsigned short mapindex;
  396. short x = 0, y = 0;
  397. int m = -1;
  398. nullpo_retr(-1, sd);
  399. memset(map_name, '\0', sizeof(map_name));
  400. if (!message || !*message ||
  401. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  402. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  403. clif_displaymessage(fd, msg_txt(909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  404. return -1;
  405. }
  406. mapindex = mapindex_name2id(map_name);
  407. if (mapindex)
  408. m = map_mapindex2mapid(mapindex);
  409. if (!mapindex) { // m < 0 means on different server! [Kevin]
  410. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  411. return -1;
  412. }
  413. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  414. { //This is to prevent the pc_setpos call from printing an error.
  415. clif_displaymessage(fd, msg_txt(2));
  416. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  417. x = y = 0; //Invalid cell, use random spot.
  418. }
  419. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  420. clif_displaymessage(fd, msg_txt(247));
  421. return -1;
  422. }
  423. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  424. clif_displaymessage(fd, msg_txt(248));
  425. return -1;
  426. }
  427. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  428. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  429. return -1;
  430. }
  431. clif_displaymessage(fd, msg_txt(0)); // Warped.
  432. return 0;
  433. }
  434. /*==========================================
  435. * Displays where a character is. Corrected version by Silent. [Skotlex]
  436. *------------------------------------------*/
  437. ACMD_FUNC(where)
  438. {
  439. struct map_session_data* pl_sd;
  440. nullpo_retr(-1, sd);
  441. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  442. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  443. clif_displaymessage(fd, msg_txt(910)); // Please enter a player name (usage: @where <char name>).
  444. return -1;
  445. }
  446. pl_sd = map_nick2sd(atcmd_player_name);
  447. if (pl_sd == NULL ||
  448. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  449. (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  450. ) {
  451. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  452. return -1;
  453. }
  454. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  455. clif_displaymessage(fd, atcmd_output);
  456. return 0;
  457. }
  458. /*==========================================
  459. *
  460. *------------------------------------------*/
  461. ACMD_FUNC(jumpto)
  462. {
  463. struct map_session_data *pl_sd = NULL;
  464. nullpo_retr(-1, sd);
  465. if (!message || !*message) {
  466. clif_displaymessage(fd, msg_txt(911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  467. return -1;
  468. }
  469. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  470. {
  471. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  472. return -1;
  473. }
  474. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  475. {
  476. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  477. return -1;
  478. }
  479. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  480. {
  481. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  482. return -1;
  483. }
  484. if( pc_isdead(sd) )
  485. {
  486. clif_displaymessage(fd, msg_txt(664));
  487. return -1;
  488. }
  489. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  490. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  491. clif_displaymessage(fd, atcmd_output);
  492. return 0;
  493. }
  494. /*==========================================
  495. *
  496. *------------------------------------------*/
  497. ACMD_FUNC(jump)
  498. {
  499. short x = 0, y = 0;
  500. nullpo_retr(-1, sd);
  501. memset(atcmd_output, '\0', sizeof(atcmd_output));
  502. sscanf(message, "%hd %hd", &x, &y);
  503. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  504. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  505. return -1;
  506. }
  507. if( pc_isdead(sd) )
  508. {
  509. clif_displaymessage(fd, msg_txt(664));
  510. return -1;
  511. }
  512. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  513. { //This is to prevent the pc_setpos call from printing an error.
  514. clif_displaymessage(fd, msg_txt(2));
  515. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  516. x = y = 0; //Invalid cell, use random spot.
  517. }
  518. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  519. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  520. clif_displaymessage(fd, atcmd_output);
  521. return 0;
  522. }
  523. /*==========================================
  524. * Display list of online characters with
  525. * various info.
  526. *------------------------------------------*/
  527. ACMD_FUNC(who)
  528. {
  529. struct map_session_data *pl_sd = NULL;
  530. struct s_mapiterator *iter = NULL;
  531. char map_name[MAP_NAME_LENGTH_EXT] = "";
  532. char player_name[NAME_LENGTH] = "";
  533. int count = 0;
  534. int level = 0;
  535. StringBuf buf;
  536. /**
  537. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  538. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  539. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  540. */
  541. int display_type = 1;
  542. int map_id = -1;
  543. nullpo_retr(-1, sd);
  544. if (strstr(command, "map") != NULL) {
  545. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  546. map_id = sd->bl.m;
  547. } else {
  548. sscanf(message, "%23s", player_name);
  549. }
  550. if (strstr(command, "2") != NULL)
  551. display_type = 2;
  552. else if (strstr(command, "3") != NULL)
  553. display_type = 3;
  554. level = pc_get_group_level(sd);
  555. StringBuf_Init(&buf);
  556. iter = mapit_getallusers();
  557. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  558. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  559. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  560. || (map_id >= 0 && pl_sd->bl.m != map_id))
  561. continue;
  562. switch (display_type) {
  563. case 2: {
  564. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  565. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  566. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  567. StringBuf_Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level,
  568. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  569. break;
  570. }
  571. case 3: {
  572. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  573. StringBuf_Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  574. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  575. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  576. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  577. StringBuf_Printf(&buf, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  578. break;
  579. }
  580. default: {
  581. struct party_data *p = party_search(pl_sd->status.party_id);
  582. struct guild *g = guild_search(pl_sd->status.guild_id);
  583. StringBuf_Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
  584. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  585. StringBuf_Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  586. if (p != NULL)
  587. StringBuf_Printf(&buf, msg_txt(345), p->party.name); // " | Party: '%s'"
  588. if (g != NULL)
  589. StringBuf_Printf(&buf, msg_txt(346), g->name); // " | Guild: '%s'"
  590. break;
  591. }
  592. }
  593. clif_displaymessage(fd, StringBuf_Value(&buf));
  594. StringBuf_Clear(&buf);
  595. count++;
  596. }
  597. }
  598. mapit_free(iter);
  599. if (map_id < 0) {
  600. if (count == 0)
  601. StringBuf_Printf(&buf, msg_txt(28)); // No player found.
  602. else if (count == 1)
  603. StringBuf_Printf(&buf, msg_txt(29)); // 1 player found.
  604. else
  605. StringBuf_Printf(&buf, msg_txt(30), count); // %d players found.
  606. } else {
  607. if (count == 0)
  608. StringBuf_Printf(&buf, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  609. else if (count == 1)
  610. StringBuf_Printf(&buf, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  611. else
  612. StringBuf_Printf(&buf, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  613. }
  614. clif_displaymessage(fd, StringBuf_Value(&buf));
  615. StringBuf_Destroy(&buf);
  616. return 0;
  617. }
  618. /*==========================================
  619. *
  620. *------------------------------------------*/
  621. ACMD_FUNC(whogm)
  622. {
  623. struct map_session_data* pl_sd;
  624. struct s_mapiterator* iter;
  625. int j, count;
  626. int pl_level, level;
  627. char match_text[CHAT_SIZE_MAX];
  628. char player_name[NAME_LENGTH];
  629. struct guild *g;
  630. struct party_data *p;
  631. nullpo_retr(-1, sd);
  632. memset(atcmd_output, '\0', sizeof(atcmd_output));
  633. memset(match_text, '\0', sizeof(match_text));
  634. memset(player_name, '\0', sizeof(player_name));
  635. if (sscanf(message, "%199[^\n]", match_text) < 1)
  636. strcpy(match_text, "");
  637. for (j = 0; match_text[j]; j++)
  638. match_text[j] = TOLOWER(match_text[j]);
  639. count = 0;
  640. level = pc_get_group_level(sd);
  641. iter = mapit_getallusers();
  642. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  643. {
  644. pl_level = pc_get_group_level(pl_sd);
  645. if (!pl_level)
  646. continue;
  647. if (match_text[0])
  648. {
  649. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  650. for (j = 0; player_name[j]; j++)
  651. player_name[j] = TOLOWER(player_name[j]);
  652. // search with no case sensitive
  653. if (strstr(player_name, match_text) == NULL)
  654. continue;
  655. }
  656. if (pl_level > level) {
  657. if (pl_sd->sc.option & OPTION_INVISIBLE)
  658. continue;
  659. sprintf(atcmd_output, msg_txt(913), pl_sd->status.name); // Name: %s (GM)
  660. clif_displaymessage(fd, atcmd_output);
  661. count++;
  662. continue;
  663. }
  664. sprintf(atcmd_output, msg_txt(914), // Name: %s (GM:%d) | Location: %s %d %d
  665. pl_sd->status.name, pl_level,
  666. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  667. clif_displaymessage(fd, atcmd_output);
  668. sprintf(atcmd_output, msg_txt(915), // BLvl: %d | Job: %s (Lvl: %d)
  669. pl_sd->status.base_level,
  670. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  671. clif_displaymessage(fd, atcmd_output);
  672. p = party_search(pl_sd->status.party_id);
  673. g = guild_search(pl_sd->status.guild_id);
  674. sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s'
  675. p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None.
  676. clif_displaymessage(fd, atcmd_output);
  677. count++;
  678. }
  679. mapit_free(iter);
  680. if (count == 0)
  681. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  682. else if (count == 1)
  683. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  684. else {
  685. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  686. clif_displaymessage(fd, atcmd_output);
  687. }
  688. return 0;
  689. }
  690. /*==========================================
  691. *
  692. *------------------------------------------*/
  693. ACMD_FUNC(save)
  694. {
  695. nullpo_retr(-1, sd);
  696. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  697. if (sd->status.pet_id > 0 && sd->pd)
  698. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  699. chrif_save(sd,0);
  700. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  701. return 0;
  702. }
  703. /*==========================================
  704. *
  705. *------------------------------------------*/
  706. ACMD_FUNC(load)
  707. {
  708. int m;
  709. nullpo_retr(-1, sd);
  710. m = map_mapindex2mapid(sd->status.save_point.map);
  711. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  712. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  713. return -1;
  714. }
  715. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  716. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  717. return -1;
  718. }
  719. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  720. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  721. return 0;
  722. }
  723. /*==========================================
  724. *
  725. *------------------------------------------*/
  726. ACMD_FUNC(speed)
  727. {
  728. int speed;
  729. nullpo_retr(-1, sd);
  730. memset(atcmd_output, '\0', sizeof(atcmd_output));
  731. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  732. sprintf(atcmd_output, msg_txt(918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  733. clif_displaymessage(fd, atcmd_output);
  734. return -1;
  735. }
  736. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  737. status_calc_bl(&sd->bl, SCB_SPEED);
  738. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  739. return 0;
  740. }
  741. /*==========================================
  742. *
  743. *------------------------------------------*/
  744. ACMD_FUNC(storage)
  745. {
  746. nullpo_retr(-1, sd);
  747. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  748. return -1;
  749. if (storage_storageopen(sd) == 1)
  750. { //Already open.
  751. clif_displaymessage(fd, msg_txt(250));
  752. return -1;
  753. }
  754. clif_displaymessage(fd, msg_txt(919)); // Storage opened.
  755. return 0;
  756. }
  757. /*==========================================
  758. *
  759. *------------------------------------------*/
  760. ACMD_FUNC(guildstorage)
  761. {
  762. nullpo_retr(-1, sd);
  763. if (!sd->status.guild_id) {
  764. clif_displaymessage(fd, msg_txt(252));
  765. return -1;
  766. }
  767. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  768. return -1;
  769. if (sd->state.storage_flag == 1) {
  770. clif_displaymessage(fd, msg_txt(250));
  771. return -1;
  772. }
  773. if (sd->state.storage_flag == 2) {
  774. clif_displaymessage(fd, msg_txt(251));
  775. return -1;
  776. }
  777. storage_guild_storageopen(sd);
  778. clif_displaymessage(fd, msg_txt(920)); // Guild storage opened.
  779. return 0;
  780. }
  781. /*==========================================
  782. *
  783. *------------------------------------------*/
  784. ACMD_FUNC(option)
  785. {
  786. int param1 = 0, param2 = 0, param3 = 0;
  787. nullpo_retr(-1, sd);
  788. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  789. {// failed to match the parameters so inform the user of the options
  790. const char* text = NULL;
  791. // attempt to find the setting information for this command
  792. text = atcommand_help_string( command );
  793. // notify the user of the requirement to enter an option
  794. clif_displaymessage(fd, msg_txt(921)); // Please enter at least one option.
  795. if( text )
  796. {// send the help text associated with this command
  797. clif_displaymessage( fd, text );
  798. }
  799. return -1;
  800. }
  801. sd->sc.opt1 = param1;
  802. sd->sc.opt2 = param2;
  803. pc_setoption(sd, param3);
  804. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  805. return 0;
  806. }
  807. /*==========================================
  808. *
  809. *------------------------------------------*/
  810. ACMD_FUNC(hide)
  811. {
  812. nullpo_retr(-1, sd);
  813. if (sd->sc.option & OPTION_INVISIBLE) {
  814. sd->sc.option &= ~OPTION_INVISIBLE;
  815. if (sd->disguise)
  816. status_set_viewdata(&sd->bl, sd->disguise);
  817. else
  818. status_set_viewdata(&sd->bl, sd->status.class_);
  819. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  820. // increment the number of pvp players on the map
  821. map[sd->bl.m].users_pvp++;
  822. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  823. {// register the player for ranking calculations
  824. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  825. }
  826. //bugreport:2266
  827. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  828. } else {
  829. sd->sc.option |= OPTION_INVISIBLE;
  830. sd->vd.class_ = INVISIBLE_CLASS;
  831. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  832. // decrement the number of pvp players on the map
  833. map[sd->bl.m].users_pvp--;
  834. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  835. {// unregister the player for ranking
  836. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  837. sd->pvp_timer = INVALID_TIMER;
  838. }
  839. }
  840. clif_changeoption(&sd->bl);
  841. return 0;
  842. }
  843. /*==========================================
  844. * Changes a character's class
  845. *------------------------------------------*/
  846. ACMD_FUNC(jobchange)
  847. {
  848. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  849. int job = 0, upper = 0;
  850. const char* text;
  851. nullpo_retr(-1, sd);
  852. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  853. {
  854. int i, found = 0;
  855. const struct { char name[24]; int id; } jobs[] = {
  856. { "novice", 0 },
  857. { "swordman", 1 },
  858. { "swordsman", 1 },
  859. { "magician", 2 },
  860. { "mage", 2 },
  861. { "archer", 3 },
  862. { "acolyte", 4 },
  863. { "merchant", 5 },
  864. { "thief", 6 },
  865. { "knight", 7 },
  866. { "priest", 8 },
  867. { "priestess", 8 },
  868. { "wizard", 9 },
  869. { "blacksmith", 10 },
  870. { "hunter", 11 },
  871. { "assassin", 12 },
  872. { "crusader", 14 },
  873. { "monk", 15 },
  874. { "sage", 16 },
  875. { "rogue", 17 },
  876. { "alchemist", 18 },
  877. { "bard", 19 },
  878. { "dancer", 20 },
  879. { "super novice", 23 },
  880. { "supernovice", 23 },
  881. { "gunslinger", 24 },
  882. { "gunner", 24 },
  883. { "ninja", 25 },
  884. { "novice high", 4001 },
  885. { "high novice", 4001 },
  886. { "swordman high", 4002 },
  887. { "swordsman high", 4002 },
  888. { "magician high", 4003 },
  889. { "mage high", 4003 },
  890. { "archer high", 4004 },
  891. { "acolyte high", 4005 },
  892. { "merchant high", 4006 },
  893. { "thief high", 4007 },
  894. { "lord knight", 4008 },
  895. { "high priest", 4009 },
  896. { "high priestess", 4009 },
  897. { "high wizard", 4010 },
  898. { "whitesmith", 4011 },
  899. { "sniper", 4012 },
  900. { "assassin cross", 4013 },
  901. { "paladin", 4015 },
  902. { "champion", 4016 },
  903. { "professor", 4017 },
  904. { "stalker", 4018 },
  905. { "creator", 4019 },
  906. { "clown", 4020 },
  907. { "gypsy", 4021 },
  908. { "baby novice", 4023 },
  909. { "baby swordman", 4024 },
  910. { "baby swordsman", 4024 },
  911. { "baby magician", 4025 },
  912. { "baby mage", 4025 },
  913. { "baby archer", 4026 },
  914. { "baby acolyte", 4027 },
  915. { "baby merchant", 4028 },
  916. { "baby thief", 4029 },
  917. { "baby knight", 4030 },
  918. { "baby priest", 4031 },
  919. { "baby priestess", 4031 },
  920. { "baby wizard", 4032 },
  921. { "baby blacksmith",4033 },
  922. { "baby hunter", 4034 },
  923. { "baby assassin", 4035 },
  924. { "baby crusader", 4037 },
  925. { "baby monk", 4038 },
  926. { "baby sage", 4039 },
  927. { "baby rogue", 4040 },
  928. { "baby alchemist", 4041 },
  929. { "baby bard", 4042 },
  930. { "baby dancer", 4043 },
  931. { "super baby", 4045 },
  932. { "taekwon", 4046 },
  933. { "taekwon boy", 4046 },
  934. { "taekwon girl", 4046 },
  935. { "star gladiator", 4047 },
  936. { "soul linker", 4049 },
  937. { "gangsi", 4050 },
  938. { "bongun", 4050 },
  939. { "munak", 4050 },
  940. { "death knight", 4051 },
  941. { "dark collector", 4052 },
  942. { "rune knight", 4054 },
  943. { "warlock", 4055 },
  944. { "ranger", 4056 },
  945. { "arch bishop", 4057 },
  946. { "mechanic", 4058 },
  947. { "guillotine", 4059 },
  948. { "rune knight2", 4060 },
  949. { "warlock2", 4061 },
  950. { "ranger2", 4062 },
  951. { "arch bishop2", 4063 },
  952. { "mechanic2", 4064 },
  953. { "guillotine2", 4065 },
  954. { "royal guard", 4066 },
  955. { "sorcerer", 4067 },
  956. { "minstrel", 4068 },
  957. { "wanderer", 4069 },
  958. { "sura", 4070 },
  959. { "genetic", 4071 },
  960. { "shadow chaser", 4072 },
  961. { "royal guard2", 4073 },
  962. { "sorcerer2", 4074 },
  963. { "minstrel2", 4075 },
  964. { "wanderer2", 4076 },
  965. { "sura2", 4077 },
  966. { "genetic2", 4078 },
  967. { "shadow chaser2", 4079 },
  968. { "baby rune", 4096 },
  969. { "baby warlock", 4097 },
  970. { "baby ranger", 4098 },
  971. { "baby bishop", 4099 },
  972. { "baby mechanic", 4100 },
  973. { "baby cross", 4101 },
  974. { "baby guard", 4102 },
  975. { "baby sorcerer", 4103 },
  976. { "baby minstrel", 4104 },
  977. { "baby wanderer", 4105 },
  978. { "baby sura", 4106 },
  979. { "baby genetic", 4107 },
  980. { "baby chaser", 4108 },
  981. { "super novice e", 4190 },
  982. { "super baby e", 4191 },
  983. { "kagerou", 4211 },
  984. { "oboro", 4212 },
  985. };
  986. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  987. if (strncmpi(message, jobs[i].name, 16) == 0) {
  988. job = jobs[i].id;
  989. upper = 0;
  990. found = 1;
  991. break;
  992. }
  993. }
  994. if (!found) {
  995. text = atcommand_help_string(command);
  996. if (text) clif_displaymessage(fd, text);
  997. return -1;
  998. }
  999. }
  1000. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27 || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1001. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  1002. ) // Deny direct transformation into dummy jobs
  1003. {clif_displaymessage(fd, msg_txt(923)); //"You can not change to this job by command."
  1004. return 0;}
  1005. if (pcdb_checkid(job))
  1006. {
  1007. if (pc_jobchange(sd, job, upper) == 0)
  1008. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1009. else {
  1010. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1011. return -1;
  1012. }
  1013. } else {
  1014. text = atcommand_help_string(command);
  1015. if (text) clif_displaymessage(fd, text);
  1016. return -1;
  1017. }
  1018. return 0;
  1019. }
  1020. /*==========================================
  1021. *
  1022. *------------------------------------------*/
  1023. ACMD_FUNC(kill)
  1024. {
  1025. nullpo_retr(-1, sd);
  1026. status_kill(&sd->bl);
  1027. clif_displaymessage(sd->fd, msg_txt(13)); // A pity! You've died.
  1028. if (fd != sd->fd)
  1029. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1030. return 0;
  1031. }
  1032. /*==========================================
  1033. *
  1034. *------------------------------------------*/
  1035. ACMD_FUNC(alive)
  1036. {
  1037. nullpo_retr(-1, sd);
  1038. if (!status_revive(&sd->bl, 100, 100))
  1039. {
  1040. clif_displaymessage(fd, msg_txt(667));
  1041. return -1;
  1042. }
  1043. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1044. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1045. return 0;
  1046. }
  1047. /*==========================================
  1048. * +kamic [LuzZza]
  1049. *------------------------------------------*/
  1050. ACMD_FUNC(kami)
  1051. {
  1052. unsigned long color=0;
  1053. nullpo_retr(-1, sd);
  1054. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1055. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1056. if (!message || !*message) {
  1057. clif_displaymessage(fd, msg_txt(980)); // Please enter a message (usage: @kami <message>).
  1058. return -1;
  1059. }
  1060. sscanf(message, "%199[^\n]", atcmd_output);
  1061. if (strstr(command, "l") != NULL)
  1062. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  1063. else
  1064. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1065. } else {
  1066. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1067. clif_displaymessage(fd, msg_txt(981)); // Please enter color and message (usage: @kamic <color> <message>).
  1068. return -1;
  1069. }
  1070. if(color > 0xFFFFFF) {
  1071. clif_displaymessage(fd, msg_txt(982)); // Invalid color.
  1072. return -1;
  1073. }
  1074. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1075. }
  1076. return 0;
  1077. }
  1078. /*==========================================
  1079. *
  1080. *------------------------------------------*/
  1081. ACMD_FUNC(heal)
  1082. {
  1083. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1084. nullpo_retr(-1, sd);
  1085. sscanf(message, "%d %d", &hp, &sp);
  1086. // some overflow checks
  1087. if( hp == INT_MIN ) hp++;
  1088. if( sp == INT_MIN ) sp++;
  1089. if ( hp == 0 && sp == 0 ) {
  1090. if (!status_percent_heal(&sd->bl, 100, 100))
  1091. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1092. else
  1093. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1094. return 0;
  1095. }
  1096. if ( hp > 0 && sp >= 0 ) {
  1097. if(!status_heal(&sd->bl, hp, sp, 0))
  1098. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1099. else
  1100. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1101. return 0;
  1102. }
  1103. if ( hp < 0 && sp <= 0 ) {
  1104. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1105. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1106. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1107. return 0;
  1108. }
  1109. //Opposing signs.
  1110. if ( hp ) {
  1111. if (hp > 0)
  1112. status_heal(&sd->bl, hp, 0, 0);
  1113. else {
  1114. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1115. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1116. }
  1117. }
  1118. if ( sp ) {
  1119. if (sp > 0)
  1120. status_heal(&sd->bl, 0, sp, 0);
  1121. else
  1122. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1123. }
  1124. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1125. return 0;
  1126. }
  1127. /*==========================================
  1128. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1129. *------------------------------------------*/
  1130. ACMD_FUNC(item)
  1131. {
  1132. char item_name[100];
  1133. int number = 0, item_id, flag = 0;
  1134. struct item item_tmp;
  1135. struct item_data *item_data;
  1136. int get_count, i;
  1137. nullpo_retr(-1, sd);
  1138. memset(item_name, '\0', sizeof(item_name));
  1139. if (!message || !*message || (
  1140. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1141. sscanf(message, "%99s %d", item_name, &number) < 1
  1142. )) {
  1143. clif_displaymessage(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1144. return -1;
  1145. }
  1146. if (number <= 0)
  1147. number = 1;
  1148. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1149. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1150. {
  1151. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1152. return -1;
  1153. }
  1154. item_id = item_data->nameid;
  1155. get_count = number;
  1156. //Check if it's stackable.
  1157. if (!itemdb_isstackable2(item_data))
  1158. get_count = 1;
  1159. for (i = 0; i < number; i += get_count) {
  1160. // if not pet egg
  1161. if (!pet_create_egg(sd, item_id)) {
  1162. memset(&item_tmp, 0, sizeof(item_tmp));
  1163. item_tmp.nameid = item_id;
  1164. item_tmp.identify = 1;
  1165. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1166. clif_additem(sd, 0, 0, flag);
  1167. }
  1168. }
  1169. if (flag == 0)
  1170. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1171. return 0;
  1172. }
  1173. /*==========================================
  1174. *
  1175. *------------------------------------------*/
  1176. ACMD_FUNC(item2)
  1177. {
  1178. struct item item_tmp;
  1179. struct item_data *item_data;
  1180. char item_name[100];
  1181. int item_id, number = 0;
  1182. int identify = 0, refine = 0, attr = 0;
  1183. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1184. int flag = 0;
  1185. int loop, get_count, i;
  1186. nullpo_retr(-1, sd);
  1187. memset(item_name, '\0', sizeof(item_name));
  1188. if (!message || !*message || (
  1189. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1190. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1191. )) {
  1192. clif_displaymessage(fd, msg_txt(984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1193. clif_displaymessage(fd, msg_txt(985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1194. return -1;
  1195. }
  1196. if (number <= 0)
  1197. number = 1;
  1198. item_id = 0;
  1199. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1200. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1201. item_id = item_data->nameid;
  1202. if (item_id > 500) {
  1203. loop = 1;
  1204. get_count = number;
  1205. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1206. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1207. loop = number;
  1208. get_count = 1;
  1209. if (item_data->type == IT_PETEGG) {
  1210. identify = 1;
  1211. refine = 0;
  1212. }
  1213. if (item_data->type == IT_PETARMOR)
  1214. refine = 0;
  1215. if (refine > MAX_REFINE)
  1216. refine = MAX_REFINE;
  1217. } else {
  1218. identify = 1;
  1219. refine = attr = 0;
  1220. }
  1221. for (i = 0; i < loop; i++) {
  1222. memset(&item_tmp, 0, sizeof(item_tmp));
  1223. item_tmp.nameid = item_id;
  1224. item_tmp.identify = identify;
  1225. item_tmp.refine = refine;
  1226. item_tmp.attribute = attr;
  1227. item_tmp.card[0] = c1;
  1228. item_tmp.card[1] = c2;
  1229. item_tmp.card[2] = c3;
  1230. item_tmp.card[3] = c4;
  1231. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1232. clif_additem(sd, 0, 0, flag);
  1233. }
  1234. if (flag == 0)
  1235. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1236. } else {
  1237. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1238. return -1;
  1239. }
  1240. return 0;
  1241. }
  1242. /*==========================================
  1243. *
  1244. *------------------------------------------*/
  1245. ACMD_FUNC(itemreset)
  1246. {
  1247. int i;
  1248. nullpo_retr(-1, sd);
  1249. for (i = 0; i < MAX_INVENTORY; i++) {
  1250. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1251. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1252. }
  1253. }
  1254. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1255. return 0;
  1256. }
  1257. /*==========================================
  1258. * Atcommand @lvlup
  1259. *------------------------------------------*/
  1260. ACMD_FUNC(baselevelup)
  1261. {
  1262. int level=0, i=0, status_point=0;
  1263. nullpo_retr(-1, sd);
  1264. level = atoi(message);
  1265. if (!message || !*message || !level) {
  1266. clif_displaymessage(fd, msg_txt(986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1267. return -1;
  1268. }
  1269. if (level > 0) {
  1270. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1271. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1272. return -1;
  1273. } // End Addition
  1274. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1275. level = pc_maxbaselv(sd) - sd->status.base_level;
  1276. for (i = 0; i < level; i++)
  1277. status_point += pc_gets_status_point(sd->status.base_level + i);
  1278. sd->status.status_point += status_point;
  1279. sd->status.base_level += (unsigned int)level;
  1280. status_percent_heal(&sd->bl, 100, 100);
  1281. clif_misceffect(&sd->bl, 0);
  1282. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1283. } else {
  1284. if (sd->status.base_level == 1) {
  1285. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1286. return -1;
  1287. }
  1288. level*=-1;
  1289. if ((unsigned int)level >= sd->status.base_level)
  1290. level = sd->status.base_level-1;
  1291. for (i = 0; i > -level; i--)
  1292. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1293. if (sd->status.status_point < status_point)
  1294. pc_resetstate(sd);
  1295. if (sd->status.status_point < status_point)
  1296. sd->status.status_point = 0;
  1297. else
  1298. sd->status.status_point -= status_point;
  1299. sd->status.base_level -= (unsigned int)level;
  1300. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1301. }
  1302. sd->status.base_exp = 0;
  1303. clif_updatestatus(sd, SP_STATUSPOINT);
  1304. clif_updatestatus(sd, SP_BASELEVEL);
  1305. clif_updatestatus(sd, SP_BASEEXP);
  1306. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1307. status_calc_pc(sd, 0);
  1308. pc_baselevelchanged(sd);
  1309. if(sd->status.party_id)
  1310. party_send_levelup(sd);
  1311. return 0;
  1312. }
  1313. /*==========================================
  1314. *
  1315. *------------------------------------------*/
  1316. ACMD_FUNC(joblevelup)
  1317. {
  1318. int level=0;
  1319. nullpo_retr(-1, sd);
  1320. level = atoi(message);
  1321. if (!message || !*message || !level) {
  1322. clif_displaymessage(fd, msg_txt(987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1323. return -1;
  1324. }
  1325. if (level > 0) {
  1326. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1327. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1328. return -1;
  1329. }
  1330. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1331. level = pc_maxjoblv(sd) - sd->status.job_level;
  1332. sd->status.job_level += (unsigned int)level;
  1333. sd->status.skill_point += level;
  1334. clif_misceffect(&sd->bl, 1);
  1335. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1336. } else {
  1337. if (sd->status.job_level == 1) {
  1338. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1339. return -1;
  1340. }
  1341. level *=-1;
  1342. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1343. level = sd->status.job_level-1;
  1344. sd->status.job_level -= (unsigned int)level;
  1345. if (sd->status.skill_point < level)
  1346. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1347. if (sd->status.skill_point < level)
  1348. sd->status.skill_point = 0;
  1349. else
  1350. sd->status.skill_point -= level;
  1351. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1352. }
  1353. sd->status.job_exp = 0;
  1354. clif_updatestatus(sd, SP_JOBLEVEL);
  1355. clif_updatestatus(sd, SP_JOBEXP);
  1356. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1357. clif_updatestatus(sd, SP_SKILLPOINT);
  1358. status_calc_pc(sd, 0);
  1359. return 0;
  1360. }
  1361. /*==========================================
  1362. * @help
  1363. *------------------------------------------*/
  1364. ACMD_FUNC(help)
  1365. {
  1366. config_setting_t *help;
  1367. const char *text = NULL;
  1368. const char *command_name = NULL;
  1369. char *default_command = "help";
  1370. nullpo_retr(-1, sd);
  1371. help = config_lookup(&atcommand_config, "help");
  1372. if (help == NULL) {
  1373. clif_displaymessage(fd, msg_txt(27)); // "Commands help is not available."
  1374. return -1;
  1375. }
  1376. if (!message || !*message) {
  1377. command_name = default_command; // If no command_name specified, display help for @help.
  1378. } else {
  1379. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1380. ++message;
  1381. command_name = atcommand_checkalias(message);
  1382. }
  1383. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1384. sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command"
  1385. clif_displaymessage(fd, atcmd_output);
  1386. atcommand_get_suggestions(sd, command_name, true);
  1387. return -1;
  1388. }
  1389. if (!config_setting_lookup_string(help, command_name, &text)) {
  1390. sprintf(atcmd_output, msg_txt(988), atcommand_symbol, command_name); // There is no help for %c%s.
  1391. clif_displaymessage(fd, atcmd_output);
  1392. atcommand_get_suggestions(sd, command_name, true);
  1393. return -1;
  1394. }
  1395. sprintf(atcmd_output, msg_txt(989), atcommand_symbol, command_name); // Help for command %c%s:
  1396. clif_displaymessage(fd, atcmd_output);
  1397. { // Display aliases
  1398. DBIterator* iter;
  1399. AtCommandInfo *command_info;
  1400. AliasInfo *alias_info = NULL;
  1401. StringBuf buf;
  1402. bool has_aliases = false;
  1403. StringBuf_Init(&buf);
  1404. StringBuf_AppendStr(&buf, msg_txt(990)); // Available aliases:
  1405. command_info = get_atcommandinfo_byname(command_name);
  1406. iter = db_iterator(atcommand_alias_db);
  1407. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1408. if (alias_info->command == command_info) {
  1409. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1410. has_aliases = true;
  1411. }
  1412. }
  1413. dbi_destroy(iter);
  1414. if (has_aliases)
  1415. clif_displaymessage(fd, StringBuf_Value(&buf));
  1416. StringBuf_Destroy(&buf);
  1417. }
  1418. // Display help contents
  1419. clif_displaymessage(fd, text);
  1420. return 0;
  1421. }
  1422. // helper function, used in foreach calls to stop auto-attack timers
  1423. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1424. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1425. {
  1426. struct unit_data *ud = unit_bl2ud(bl);
  1427. int id = va_arg(ap, int);
  1428. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1429. {
  1430. unit_stop_attack(bl);
  1431. return 1;
  1432. }
  1433. return 0;
  1434. }
  1435. /*==========================================
  1436. *
  1437. *------------------------------------------*/
  1438. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1439. {
  1440. TBL_PC* sd = (TBL_PC*)bl;
  1441. clif_pvpset(sd, 0, 0, 2);
  1442. if (sd->pvp_timer != INVALID_TIMER) {
  1443. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1444. sd->pvp_timer = INVALID_TIMER;
  1445. }
  1446. return 0;
  1447. }
  1448. ACMD_FUNC(pvpoff)
  1449. {
  1450. nullpo_retr(-1, sd);
  1451. if (!map[sd->bl.m].flag.pvp) {
  1452. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1453. return -1;
  1454. }
  1455. map[sd->bl.m].flag.pvp = 0;
  1456. if (!battle_config.pk_mode)
  1457. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1458. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1459. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1460. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1461. return 0;
  1462. }
  1463. /*==========================================
  1464. *
  1465. *------------------------------------------*/
  1466. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1467. {
  1468. TBL_PC* sd = (TBL_PC*)bl;
  1469. if (sd->pvp_timer == INVALID_TIMER) {
  1470. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1471. sd->pvp_rank = 0;
  1472. sd->pvp_lastusers = 0;
  1473. sd->pvp_point = 5;
  1474. sd->pvp_won = 0;
  1475. sd->pvp_lost = 0;
  1476. }
  1477. return 0;
  1478. }
  1479. ACMD_FUNC(pvpon)
  1480. {
  1481. nullpo_retr(-1, sd);
  1482. if (map[sd->bl.m].flag.pvp) {
  1483. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1484. return -1;
  1485. }
  1486. map[sd->bl.m].flag.pvp = 1;
  1487. if (!battle_config.pk_mode)
  1488. {// display pvp circle and rank
  1489. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1490. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1491. }
  1492. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1493. return 0;
  1494. }
  1495. /*==========================================
  1496. *
  1497. *------------------------------------------*/
  1498. ACMD_FUNC(gvgoff)
  1499. {
  1500. nullpo_retr(-1, sd);
  1501. if (!map[sd->bl.m].flag.gvg) {
  1502. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1503. return -1;
  1504. }
  1505. map[sd->bl.m].flag.gvg = 0;
  1506. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1507. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1508. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1509. return 0;
  1510. }
  1511. /*==========================================
  1512. *
  1513. *------------------------------------------*/
  1514. ACMD_FUNC(gvgon)
  1515. {
  1516. nullpo_retr(-1, sd);
  1517. if (map[sd->bl.m].flag.gvg) {
  1518. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1519. return -1;
  1520. }
  1521. map[sd->bl.m].flag.gvg = 1;
  1522. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1523. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1524. return 0;
  1525. }
  1526. /*==========================================
  1527. *
  1528. *------------------------------------------*/
  1529. ACMD_FUNC(model)
  1530. {
  1531. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1532. nullpo_retr(-1, sd);
  1533. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1534. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1535. sprintf(atcmd_output, msg_txt(991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1536. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1537. clif_displaymessage(fd, atcmd_output);
  1538. return -1;
  1539. }
  1540. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1541. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1542. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1543. pc_changelook(sd, LOOK_HAIR, hair_style);
  1544. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1545. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1546. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1547. } else {
  1548. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1549. return -1;
  1550. }
  1551. return 0;
  1552. }
  1553. /*==========================================
  1554. * @dye && @ccolor
  1555. *------------------------------------------*/
  1556. ACMD_FUNC(dye)
  1557. {
  1558. int cloth_color = 0;
  1559. nullpo_retr(-1, sd);
  1560. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1561. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1562. sprintf(atcmd_output, msg_txt(992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1563. clif_displaymessage(fd, atcmd_output);
  1564. return -1;
  1565. }
  1566. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1567. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1568. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1569. } else {
  1570. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1571. return -1;
  1572. }
  1573. return 0;
  1574. }
  1575. /*==========================================
  1576. * @hairstyle && @hstyle
  1577. *------------------------------------------*/
  1578. ACMD_FUNC(hair_style)
  1579. {
  1580. int hair_style = 0;
  1581. nullpo_retr(-1, sd);
  1582. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1583. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1584. sprintf(atcmd_output, msg_txt(993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1585. clif_displaymessage(fd, atcmd_output);
  1586. return -1;
  1587. }
  1588. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1589. pc_changelook(sd, LOOK_HAIR, hair_style);
  1590. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1591. } else {
  1592. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1593. return -1;
  1594. }
  1595. return 0;
  1596. }
  1597. /*==========================================
  1598. * @haircolor && @hcolor
  1599. *------------------------------------------*/
  1600. ACMD_FUNC(hair_color)
  1601. {
  1602. int hair_color = 0;
  1603. nullpo_retr(-1, sd);
  1604. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1605. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1606. sprintf(atcmd_output, msg_txt(994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1607. clif_displaymessage(fd, atcmd_output);
  1608. return -1;
  1609. }
  1610. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1611. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1612. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1613. } else {
  1614. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1615. return -1;
  1616. }
  1617. return 0;
  1618. }
  1619. /*==========================================
  1620. * @go [city_number or city_name] - Updated by Harbin
  1621. *------------------------------------------*/
  1622. ACMD_FUNC(go)
  1623. {
  1624. int i;
  1625. int town;
  1626. char map_name[MAP_NAME_LENGTH];
  1627. int m;
  1628. const struct {
  1629. char map[MAP_NAME_LENGTH];
  1630. int x, y;
  1631. } data[] = {
  1632. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1633. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1634. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1635. { MAP_PAYON, 162, 233 }, // 3=Payon
  1636. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1637. #ifdef RENEWAL
  1638. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1639. #else
  1640. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1641. #endif
  1642. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1643. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1644. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1645. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1646. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1647. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1648. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1649. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1650. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1651. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1652. { MAP_JAIL, 23, 61 }, // 16=Prison
  1653. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1654. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1655. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1656. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1657. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1658. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1659. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1660. { MAP_VEINS, 216, 123 }, // 24=Veins
  1661. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1662. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1663. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1664. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  1665. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1666. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1667. { MAP_MORA, 44, 151 }, // 31=Mora
  1668. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1669. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1670. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1671. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1672. };
  1673. nullpo_retr(-1, sd);
  1674. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1675. clif_displaymessage(sd->fd,msg_txt(995)); // You cannot use @go on this map.
  1676. return 0;
  1677. }
  1678. memset(map_name, '\0', sizeof(map_name));
  1679. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1680. // get the number
  1681. town = atoi(message);
  1682. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1683. {// no value matched so send the list of locations
  1684. const char* text;
  1685. // attempt to find the text help string
  1686. text = atcommand_help_string( command );
  1687. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  1688. if( text )
  1689. {// send the text to the client
  1690. clif_displaymessage( fd, text );
  1691. }
  1692. return -1;
  1693. }
  1694. // get possible name of the city
  1695. map_name[MAP_NAME_LENGTH-1] = '\0';
  1696. for (i = 0; map_name[i]; i++)
  1697. map_name[i] = TOLOWER(map_name[i]);
  1698. // try to identify the map name
  1699. if (strncmp(map_name, "prontera", 3) == 0) {
  1700. town = 0;
  1701. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1702. strncmp(map_name, "morroc", 4) == 0) {
  1703. town = 1;
  1704. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1705. town = 2;
  1706. } else if (strncmp(map_name, "payon", 3) == 0) {
  1707. town = 3;
  1708. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1709. town = 4;
  1710. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1711. town = 5;
  1712. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1713. town = 6;
  1714. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1715. strcmp(map_name, "christmas") == 0 ||
  1716. strncmp(map_name, "xmas", 3) == 0 ||
  1717. strncmp(map_name, "x-mas", 3) == 0) {
  1718. town = 7;
  1719. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1720. town = 8;
  1721. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1722. strncmp(map_name, "yuno", 3) == 0) {
  1723. town = 9;
  1724. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1725. town = 10;
  1726. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1727. strncmp(map_name, "gonryun", 3) == 0) {
  1728. town = 11;
  1729. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1730. town = 12;
  1731. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1732. town = 13;
  1733. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1734. town = 14;
  1735. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1736. strncmp(map_name, "startpoint", 3) == 0 ||
  1737. strncmp(map_name, "beginning", 3) == 0) {
  1738. town = 15;
  1739. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1740. strncmp(map_name, "prison", 3) == 0 ||
  1741. strncmp(map_name, "jail", 3) == 0) {
  1742. town = 16;
  1743. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1744. town = 17;
  1745. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1746. town = 18;
  1747. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1748. town = 19;
  1749. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1750. town = 20;
  1751. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1752. town = 21;
  1753. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1754. town = 22;
  1755. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1756. town = 23;
  1757. } else if (strncmp(map_name, "veins", 3) == 0) {
  1758. town = 24;
  1759. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1760. town = 25;
  1761. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1762. town = 26;
  1763. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1764. town = 27;
  1765. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1766. town = 28;
  1767. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1768. town = 29;
  1769. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1770. town = 30;
  1771. } else if (strcmp(map_name, "mora") == 0) {
  1772. town = 31;
  1773. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1774. town = 32;
  1775. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1776. town = 33;
  1777. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1778. town = 34;
  1779. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1780. town = 35;
  1781. }
  1782. if (town >= 0 && town < ARRAYLENGTH(data))
  1783. {
  1784. m = map_mapname2mapid(data[town].map);
  1785. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1786. clif_displaymessage(fd, msg_txt(247));
  1787. return -1;
  1788. }
  1789. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1790. clif_displaymessage(fd, msg_txt(248));
  1791. return -1;
  1792. }
  1793. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1794. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1795. } else {
  1796. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1797. return -1;
  1798. }
  1799. } else { // if you arrive here, you have an error in town variable when reading of names
  1800. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  1801. return -1;
  1802. }
  1803. return 0;
  1804. }
  1805. /*==========================================
  1806. *
  1807. *------------------------------------------*/
  1808. ACMD_FUNC(monster)
  1809. {
  1810. char name[NAME_LENGTH];
  1811. char monster[NAME_LENGTH];
  1812. char eventname[EVENT_NAME_LENGTH] = "";
  1813. int mob_id;
  1814. int number = 0;
  1815. int count;
  1816. int i, k, range;
  1817. short mx, my;
  1818. nullpo_retr(-1, sd);
  1819. memset(name, '\0', sizeof(name));
  1820. memset(monster, '\0', sizeof(monster));
  1821. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1822. if (!message || !*message) {
  1823. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  1824. return -1;
  1825. }
  1826. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1827. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1828. //All data can be left as it is.
  1829. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1830. //Here, it is possible name was not given and we are using monster for it.
  1831. if (count < 3) //Blank mob's name.
  1832. name[0] = '\0';
  1833. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1834. //All data can be left as it is.
  1835. } else if (sscanf(message, "%23s", monster) > 0) {
  1836. //As before, name may be already filled.
  1837. name[0] = '\0';
  1838. } else {
  1839. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  1840. return -1;
  1841. }
  1842. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1843. mob_id = mobdb_checkid(atoi(monster));
  1844. if (mob_id == 0) {
  1845. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1846. return -1;
  1847. }
  1848. if (mob_id == MOBID_EMPERIUM) {
  1849. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  1850. return -1;
  1851. }
  1852. if (number <= 0)
  1853. number = 1;
  1854. if( !name[0] )
  1855. strcpy(name, "--ja--");
  1856. // 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
  1857. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1858. number = battle_config.atc_spawn_quantity_limit;
  1859. if (strcmp(command+1, "monstersmall") == 0)
  1860. strcpy(eventname, "2");
  1861. else if (strcmp(command+1, "monsterbig") == 0)
  1862. strcpy(eventname, "4");
  1863. if (battle_config.etc_log)
  1864. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
  1865. count = 0;
  1866. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1867. for (i = 0; i < number; i++) {
  1868. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1869. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname);
  1870. count += (k != 0) ? 1 : 0;
  1871. }
  1872. if (count != 0)
  1873. if (number == count)
  1874. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  1875. else {
  1876. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  1877. clif_displaymessage(fd, atcmd_output);
  1878. }
  1879. else {
  1880. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1881. return -1;
  1882. }
  1883. return 0;
  1884. }
  1885. /*==========================================
  1886. *
  1887. *------------------------------------------*/
  1888. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1889. {
  1890. struct mob_data *md;
  1891. int flag;
  1892. nullpo_ret(md=(struct mob_data *)bl);
  1893. flag = va_arg(ap, int);
  1894. if (md->guardian_data)
  1895. return 0; //Do not touch WoE mobs!
  1896. if (flag)
  1897. status_zap(bl,md->status.hp, 0);
  1898. else
  1899. status_kill(bl);
  1900. return 1;
  1901. }
  1902. ACMD_FUNC(killmonster)
  1903. {
  1904. int map_id, drop_flag;
  1905. char map_name[MAP_NAME_LENGTH_EXT];
  1906. nullpo_retr(-1, sd);
  1907. memset(map_name, '\0', sizeof(map_name));
  1908. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1909. map_id = sd->bl.m;
  1910. else {
  1911. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1912. map_id = sd->bl.m;
  1913. }
  1914. drop_flag = strcmp(command+1, "killmonster2");
  1915. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1916. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  1917. return 0;
  1918. }
  1919. /*==========================================
  1920. *
  1921. *------------------------------------------*/
  1922. ACMD_FUNC(refine)
  1923. {
  1924. int i,j, position = 0, refine = 0, current_position, final_refine;
  1925. int count;
  1926. nullpo_retr(-1, sd);
  1927. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1928. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1929. clif_displaymessage(fd, msg_txt(996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1930. sprintf(atcmd_output, msg_txt(997), EQP_HEAD_LOW); // %d: Lower Headgear
  1931. clif_displaymessage(fd, atcmd_output);
  1932. sprintf(atcmd_output, msg_txt(998), EQP_HAND_R); // %d: Right Hand
  1933. clif_displaymessage(fd, atcmd_output);
  1934. sprintf(atcmd_output, msg_txt(999), EQP_GARMENT); // %d: Garment
  1935. clif_displaymessage(fd, atcmd_output);
  1936. sprintf(atcmd_output, msg_txt(1000), EQP_ACC_L); // %d: Left Accessory
  1937. clif_displaymessage(fd, atcmd_output);
  1938. sprintf(atcmd_output, msg_txt(1001), EQP_ARMOR); // %d: Body Armor
  1939. clif_displaymessage(fd, atcmd_output);
  1940. sprintf(atcmd_output, msg_txt(1002), EQP_HAND_L); // %d: Left Hand
  1941. clif_displaymessage(fd, atcmd_output);
  1942. sprintf(atcmd_output, msg_txt(1003), EQP_SHOES); // %d: Shoes
  1943. clif_displaymessage(fd, atcmd_output);
  1944. sprintf(atcmd_output, msg_txt(1004), EQP_ACC_R); // %d: Right Accessory
  1945. clif_displaymessage(fd, atcmd_output);
  1946. sprintf(atcmd_output, msg_txt(1005), EQP_HEAD_TOP); // %d: Top Headgear
  1947. clif_displaymessage(fd, atcmd_output);
  1948. sprintf(atcmd_output, msg_txt(1006), EQP_HEAD_MID); // %d: Mid Headgear
  1949. clif_displaymessage(fd, atcmd_output);
  1950. return -1;
  1951. }
  1952. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1953. count = 0;
  1954. for (j = 0; j < EQI_MAX-1; j++) {
  1955. if ((i = sd->equip_index[j]) < 0)
  1956. continue;
  1957. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1958. continue;
  1959. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1960. continue;
  1961. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1962. continue;
  1963. if(position && !(sd->status.inventory[i].equip & position))
  1964. continue;
  1965. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1966. if (sd->status.inventory[i].refine != final_refine) {
  1967. sd->status.inventory[i].refine = final_refine;
  1968. current_position = sd->status.inventory[i].equip;
  1969. pc_unequipitem(sd, i, 3);
  1970. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1971. clif_delitem(sd, i, 1, 3);
  1972. clif_additem(sd, i, 1, 0);
  1973. pc_equipitem(sd, i, current_position);
  1974. clif_misceffect(&sd->bl, 3);
  1975. count++;
  1976. }
  1977. }
  1978. if (count == 0)
  1979. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  1980. else if (count == 1)
  1981. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  1982. else {
  1983. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  1984. clif_displaymessage(fd, atcmd_output);
  1985. }
  1986. return 0;
  1987. }
  1988. /*==========================================
  1989. *
  1990. *------------------------------------------*/
  1991. ACMD_FUNC(produce)
  1992. {
  1993. char item_name[100];
  1994. int item_id, attribute = 0, star = 0;
  1995. int flag = 0;
  1996. struct item_data *item_data;
  1997. struct item tmp_item;
  1998. nullpo_retr(-1, sd);
  1999. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2000. memset(item_name, '\0', sizeof(item_name));
  2001. if (!message || !*message || (
  2002. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2003. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2004. )) {
  2005. clif_displaymessage(fd, msg_txt(1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2006. return -1;
  2007. }
  2008. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  2009. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  2010. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2011. return -1;
  2012. }
  2013. item_id = item_data->nameid;
  2014. if (itemdb_isequip2(item_data)) {
  2015. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2016. attribute = ATTRIBUTE_NORMAL;
  2017. if (star < MIN_STAR || star > MAX_STAR)
  2018. star = 0;
  2019. memset(&tmp_item, 0, sizeof tmp_item);
  2020. tmp_item.nameid = item_id;
  2021. tmp_item.amount = 1;
  2022. tmp_item.identify = 1;
  2023. tmp_item.card[0] = CARD0_FORGE;
  2024. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2025. ((star*5) << 8) + attribute:0;
  2026. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2027. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2028. clif_produceeffect(sd, 0, item_id);
  2029. clif_misceffect(&sd->bl, 3);
  2030. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2031. clif_additem(sd, 0, 0, flag);
  2032. } else {
  2033. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2034. clif_displaymessage(fd, atcmd_output);
  2035. return -1;
  2036. }
  2037. return 0;
  2038. }
  2039. /*==========================================
  2040. *
  2041. *------------------------------------------*/
  2042. ACMD_FUNC(memo)
  2043. {
  2044. int position = 0;
  2045. nullpo_retr(-1, sd);
  2046. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2047. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2048. {
  2049. int i;
  2050. clif_displaymessage(sd->fd, msg_txt(668));
  2051. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2052. {
  2053. if( sd->status.memo_point[i].map )
  2054. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  2055. else
  2056. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2057. clif_displaymessage(sd->fd, atcmd_output);
  2058. }
  2059. return 0;
  2060. }
  2061. if( position < 0 || position >= MAX_MEMOPOINTS )
  2062. {
  2063. sprintf(atcmd_output, msg_txt(1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2064. clif_displaymessage(fd, atcmd_output);
  2065. return -1;
  2066. }
  2067. pc_memo(sd, position);
  2068. return 0;
  2069. }
  2070. /*==========================================
  2071. *
  2072. *------------------------------------------*/
  2073. ACMD_FUNC(gat)
  2074. {
  2075. int y;
  2076. nullpo_retr(-1, sd);
  2077. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2078. for (y = 2; y >= -2; y--) {
  2079. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2080. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2081. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2082. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2083. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2084. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2085. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2086. clif_displaymessage(fd, atcmd_output);
  2087. }
  2088. return 0;
  2089. }
  2090. /*==========================================
  2091. *
  2092. *------------------------------------------*/
  2093. ACMD_FUNC(displaystatus)
  2094. {
  2095. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2096. nullpo_retr(-1, sd);
  2097. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2098. clif_displaymessage(fd, msg_txt(1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2099. return -1;
  2100. }
  2101. if (i < 2) flag = 1;
  2102. if (i < 3) tick = 0;
  2103. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2104. return 0;
  2105. }
  2106. /*==========================================
  2107. * @stpoint (Rewritten by [Yor])
  2108. *------------------------------------------*/
  2109. ACMD_FUNC(statuspoint)
  2110. {
  2111. int point;
  2112. unsigned int new_status_point;
  2113. if (!message || !*message || (point = atoi(message)) == 0) {
  2114. clif_displaymessage(fd, msg_txt(1010)); // Please enter a number (usage: @stpoint <number of points>).
  2115. return -1;
  2116. }
  2117. if(point < 0)
  2118. {
  2119. if(sd->status.status_point < (unsigned int)(-point))
  2120. {
  2121. new_status_point = 0;
  2122. }
  2123. else
  2124. {
  2125. new_status_point = sd->status.status_point + point;
  2126. }
  2127. }
  2128. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2129. {
  2130. new_status_point = UINT_MAX;
  2131. }
  2132. else
  2133. {
  2134. new_status_point = sd->status.status_point + point;
  2135. }
  2136. if (new_status_point != sd->status.status_point) {
  2137. sd->status.status_point = new_status_point;
  2138. clif_updatestatus(sd, SP_STATUSPOINT);
  2139. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2140. } else {
  2141. if (point < 0)
  2142. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2143. else
  2144. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2145. return -1;
  2146. }
  2147. return 0;
  2148. }
  2149. /*==========================================
  2150. * @skpoint (Rewritten by [Yor])
  2151. *------------------------------------------*/
  2152. ACMD_FUNC(skillpoint)
  2153. {
  2154. int point;
  2155. unsigned int new_skill_point;
  2156. nullpo_retr(-1, sd);
  2157. if (!message || !*message || (point = atoi(message)) == 0) {
  2158. clif_displaymessage(fd, msg_txt(1011)); // Please enter a number (usage: @skpoint <number of points>).
  2159. return -1;
  2160. }
  2161. if(point < 0)
  2162. {
  2163. if(sd->status.skill_point < (unsigned int)(-point))
  2164. {
  2165. new_skill_point = 0;
  2166. }
  2167. else
  2168. {
  2169. new_skill_point = sd->status.skill_point + point;
  2170. }
  2171. }
  2172. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2173. {
  2174. new_skill_point = UINT_MAX;
  2175. }
  2176. else
  2177. {
  2178. new_skill_point = sd->status.skill_point + point;
  2179. }
  2180. if (new_skill_point != sd->status.skill_point) {
  2181. sd->status.skill_point = new_skill_point;
  2182. clif_updatestatus(sd, SP_SKILLPOINT);
  2183. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2184. } else {
  2185. if (point < 0)
  2186. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2187. else
  2188. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2189. return -1;
  2190. }
  2191. return 0;
  2192. }
  2193. /*==========================================
  2194. * @zeny (Rewritten by [Yor])
  2195. *------------------------------------------*/
  2196. ACMD_FUNC(zeny)
  2197. {
  2198. int zeny, new_zeny;
  2199. nullpo_retr(-1, sd);
  2200. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2201. clif_displaymessage(fd, msg_txt(1012)); // Please enter an amount (usage: @zeny <amount>).
  2202. return -1;
  2203. }
  2204. new_zeny = sd->status.zeny + zeny;
  2205. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2206. new_zeny = MAX_ZENY;
  2207. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2208. new_zeny = 0;
  2209. if (new_zeny != sd->status.zeny) {
  2210. sd->status.zeny = new_zeny;
  2211. clif_updatestatus(sd, SP_ZENY);
  2212. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2213. } else {
  2214. if (zeny < 0)
  2215. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2216. else
  2217. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2218. return -1;
  2219. }
  2220. return 0;
  2221. }
  2222. /*==========================================
  2223. *
  2224. *------------------------------------------*/
  2225. ACMD_FUNC(param)
  2226. {
  2227. int i, value = 0, new_value, max;
  2228. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2229. short* status[6];
  2230. //we don't use direct initialization because it isn't part of the c standard.
  2231. nullpo_retr(-1, sd);
  2232. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2233. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2234. clif_displaymessage(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2235. return -1;
  2236. }
  2237. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2238. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2239. clif_displaymessage(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2240. return -1;
  2241. }
  2242. status[0] = &sd->status.str;
  2243. status[1] = &sd->status.agi;
  2244. status[2] = &sd->status.vit;
  2245. status[3] = &sd->status.int_;
  2246. status[4] = &sd->status.dex;
  2247. status[5] = &sd->status.luk;
  2248. if( battle_config.atcommand_max_stat_bypass )
  2249. max = SHRT_MAX;
  2250. else
  2251. max = pc_maxparameter(sd);
  2252. if(value < 0 && *status[i] <= -value) {
  2253. new_value = 1;
  2254. } else if(max - *status[i] < value) {
  2255. new_value = max;
  2256. } else {
  2257. new_value = *status[i] + value;
  2258. }
  2259. if (new_value != *status[i]) {
  2260. *status[i] = new_value;
  2261. clif_updatestatus(sd, SP_STR + i);
  2262. clif_updatestatus(sd, SP_USTR + i);
  2263. status_calc_pc(sd, 0);
  2264. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2265. } else {
  2266. if (value < 0)
  2267. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2268. else
  2269. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2270. return -1;
  2271. }
  2272. return 0;
  2273. }
  2274. /*==========================================
  2275. * Stat all by fritz (rewritten by [Yor])
  2276. *------------------------------------------*/
  2277. ACMD_FUNC(stat_all)
  2278. {
  2279. int index, count, value, max, new_value;
  2280. short* status[6];
  2281. //we don't use direct initialization because it isn't part of the c standard.
  2282. nullpo_retr(-1, sd);
  2283. status[0] = &sd->status.str;
  2284. status[1] = &sd->status.agi;
  2285. status[2] = &sd->status.vit;
  2286. status[3] = &sd->status.int_;
  2287. status[4] = &sd->status.dex;
  2288. status[5] = &sd->status.luk;
  2289. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2290. value = pc_maxparameter(sd);
  2291. max = pc_maxparameter(sd);
  2292. } else {
  2293. if( battle_config.atcommand_max_stat_bypass )
  2294. max = SHRT_MAX;
  2295. else
  2296. max = pc_maxparameter(sd);
  2297. }
  2298. count = 0;
  2299. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2300. if (value > 0 && *status[index] > max - value)
  2301. new_value = max;
  2302. else if (value < 0 && *status[index] <= -value)
  2303. new_value = 1;
  2304. else
  2305. new_value = *status[index] +value;
  2306. if (new_value != (int)*status[index]) {
  2307. *status[index] = new_value;
  2308. clif_updatestatus(sd, SP_STR + index);
  2309. clif_updatestatus(sd, SP_USTR + index);
  2310. count++;
  2311. }
  2312. }
  2313. if (count > 0) { // if at least 1 stat modified
  2314. status_calc_pc(sd, 0);
  2315. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2316. } else {
  2317. if (value < 0)
  2318. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2319. else
  2320. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2321. return -1;
  2322. }
  2323. return 0;
  2324. }
  2325. /*==========================================
  2326. *
  2327. *------------------------------------------*/
  2328. ACMD_FUNC(guildlevelup)
  2329. {
  2330. int level = 0;
  2331. short added_level;
  2332. struct guild *guild_info;
  2333. nullpo_retr(-1, sd);
  2334. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2335. clif_displaymessage(fd, msg_txt(1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2336. return -1;
  2337. }
  2338. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2339. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2340. return -1;
  2341. }
  2342. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2343. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2344. // return -1;
  2345. //}
  2346. added_level = (short)level;
  2347. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2348. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2349. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2350. added_level = 1 - guild_info->guild_lv;
  2351. if (added_level != 0) {
  2352. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2353. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2354. } else {
  2355. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2356. return -1;
  2357. }
  2358. return 0;
  2359. }
  2360. /*==========================================
  2361. *
  2362. *------------------------------------------*/
  2363. ACMD_FUNC(makeegg)
  2364. {
  2365. struct item_data *item_data;
  2366. int id, pet_id;
  2367. nullpo_retr(-1, sd);
  2368. if (!message || !*message) {
  2369. clif_displaymessage(fd, msg_txt(1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2370. return -1;
  2371. }
  2372. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2373. id = item_data->nameid;
  2374. else
  2375. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2376. ;
  2377. else
  2378. id = atoi(message);
  2379. pet_id = search_petDB_index(id, PET_CLASS);
  2380. if (pet_id < 0)
  2381. pet_id = search_petDB_index(id, PET_EGG);
  2382. if (pet_id >= 0) {
  2383. sd->catch_target_class = pet_db[pet_id].class_;
  2384. intif_create_pet(
  2385. sd->status.account_id, sd->status.char_id,
  2386. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2387. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2388. 100, 0, 1, pet_db[pet_id].jname);
  2389. } else {
  2390. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2391. return -1;
  2392. }
  2393. return 0;
  2394. }
  2395. /*==========================================
  2396. *
  2397. *------------------------------------------*/
  2398. ACMD_FUNC(hatch)
  2399. {
  2400. nullpo_retr(-1, sd);
  2401. if (sd->status.pet_id <= 0)
  2402. clif_sendegg(sd);
  2403. else {
  2404. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2405. return -1;
  2406. }
  2407. return 0;
  2408. }
  2409. /*==========================================
  2410. *
  2411. *------------------------------------------*/
  2412. ACMD_FUNC(petfriendly)
  2413. {
  2414. int friendly;
  2415. struct pet_data *pd;
  2416. nullpo_retr(-1, sd);
  2417. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2418. clif_displaymessage(fd, msg_txt(1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2419. return -1;
  2420. }
  2421. pd = sd->pd;
  2422. if (!pd) {
  2423. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2424. return -1;
  2425. }
  2426. if (friendly < 0 || friendly > 1000)
  2427. {
  2428. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2429. return -1;
  2430. }
  2431. if (friendly == pd->pet.intimate) {
  2432. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2433. return -1;
  2434. }
  2435. pet_set_intimate(pd, friendly);
  2436. clif_send_petstatus(sd);
  2437. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2438. return 0;
  2439. }
  2440. /*==========================================
  2441. *
  2442. *------------------------------------------*/
  2443. ACMD_FUNC(pethungry)
  2444. {
  2445. int hungry;
  2446. struct pet_data *pd;
  2447. nullpo_retr(-1, sd);
  2448. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2449. clif_displaymessage(fd, msg_txt(1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2450. return -1;
  2451. }
  2452. pd = sd->pd;
  2453. if (!sd->status.pet_id || !pd) {
  2454. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2455. return -1;
  2456. }
  2457. if (hungry < 0 || hungry > 100) {
  2458. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2459. return -1;
  2460. }
  2461. if (hungry == pd->pet.hungry) {
  2462. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2463. return -1;
  2464. }
  2465. pd->pet.hungry = hungry;
  2466. clif_send_petstatus(sd);
  2467. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2468. return 0;
  2469. }
  2470. /*==========================================
  2471. *
  2472. *------------------------------------------*/
  2473. ACMD_FUNC(petrename)
  2474. {
  2475. struct pet_data *pd;
  2476. nullpo_retr(-1, sd);
  2477. if (!sd->status.pet_id || !sd->pd) {
  2478. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2479. return -1;
  2480. }
  2481. pd = sd->pd;
  2482. if (!pd->pet.rename_flag) {
  2483. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2484. return -1;
  2485. }
  2486. pd->pet.rename_flag = 0;
  2487. intif_save_petdata(sd->status.account_id, &pd->pet);
  2488. clif_send_petstatus(sd);
  2489. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2490. return 0;
  2491. }
  2492. /*==========================================
  2493. *
  2494. *------------------------------------------*/
  2495. ACMD_FUNC(recall) {
  2496. struct map_session_data *pl_sd = NULL;
  2497. nullpo_retr(-1, sd);
  2498. if (!message || !*message) {
  2499. clif_displaymessage(fd, msg_txt(1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2500. return -1;
  2501. }
  2502. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2503. {
  2504. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2505. return -1;
  2506. }
  2507. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2508. {
  2509. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2510. return -1;
  2511. }
  2512. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2513. clif_displaymessage(fd, msg_txt(1019)); // You are not authorized to warp someone to this map.
  2514. return -1;
  2515. }
  2516. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2517. clif_displaymessage(fd, msg_txt(1020)); // You are not authorized to warp this player from their map.
  2518. return -1;
  2519. }
  2520. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2521. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2522. clif_displaymessage(fd, atcmd_output);
  2523. return 0;
  2524. }
  2525. /*==========================================
  2526. * charblock command (usage: charblock <player_name>)
  2527. * This command do a definitiv ban on a player
  2528. *------------------------------------------*/
  2529. ACMD_FUNC(char_block)
  2530. {
  2531. nullpo_retr(-1, sd);
  2532. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2533. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2534. clif_displaymessage(fd, msg_txt(1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2535. return -1;
  2536. }
  2537. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2538. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2539. return 0;
  2540. }
  2541. /*==========================================
  2542. * charban command (usage: charban <time> <player_name>)
  2543. * This command do a limited ban on a player
  2544. * Time is done as follows:
  2545. * Adjustment value (-1, 1, +1, etc...)
  2546. * Modified element:
  2547. * a or y: year
  2548. * m: month
  2549. * j or d: day
  2550. * h: hour
  2551. * mn: minute
  2552. * s: second
  2553. * <example> @ban +1m-2mn1s-6y test_player
  2554. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2555. *------------------------------------------*/
  2556. ACMD_FUNC(char_ban)
  2557. {
  2558. char * modif_p;
  2559. int year, month, day, hour, minute, second, value;
  2560. time_t timestamp;
  2561. struct tm *tmtime;
  2562. nullpo_retr(-1, sd);
  2563. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2564. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2565. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2566. clif_displaymessage(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2567. return -1;
  2568. }
  2569. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2570. modif_p = atcmd_output;
  2571. year = month = day = hour = minute = second = 0;
  2572. while (modif_p[0] != '\0') {
  2573. value = atoi(modif_p);
  2574. if (value == 0)
  2575. modif_p++;
  2576. else {
  2577. if (modif_p[0] == '-' || modif_p[0] == '+')
  2578. modif_p++;
  2579. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2580. modif_p++;
  2581. if (modif_p[0] == 's') {
  2582. second = value;
  2583. modif_p++;
  2584. } else if (modif_p[0] == 'n') {
  2585. minute = value;
  2586. modif_p++;
  2587. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2588. minute = value;
  2589. modif_p = modif_p + 2;
  2590. } else if (modif_p[0] == 'h') {
  2591. hour = value;
  2592. modif_p++;
  2593. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2594. day = value;
  2595. modif_p++;
  2596. } else if (modif_p[0] == 'm') {
  2597. month = value;
  2598. modif_p++;
  2599. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2600. year = value;
  2601. modif_p++;
  2602. } else if (modif_p[0] != '\0') {
  2603. modif_p++;
  2604. }
  2605. }
  2606. }
  2607. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2608. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2609. return -1;
  2610. }
  2611. /**
  2612. * We now check if you can adjust the ban to negative (and if this is the case)
  2613. **/
  2614. timestamp = time(NULL);
  2615. tmtime = localtime(&timestamp);
  2616. tmtime->tm_year = tmtime->tm_year + year;
  2617. tmtime->tm_mon = tmtime->tm_mon + month;
  2618. tmtime->tm_mday = tmtime->tm_mday + day;
  2619. tmtime->tm_hour = tmtime->tm_hour + hour;
  2620. tmtime->tm_min = tmtime->tm_min + minute;
  2621. tmtime->tm_sec = tmtime->tm_sec + second;
  2622. timestamp = mktime(tmtime);
  2623. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2624. clif_displaymessage(fd,msg_txt(1023)); // You are not allowed to reduce the length of a ban.
  2625. return -1;
  2626. }
  2627. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2628. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2629. return 0;
  2630. }
  2631. /*==========================================
  2632. * charunblock command (usage: charunblock <player_name>)
  2633. *------------------------------------------*/
  2634. ACMD_FUNC(char_unblock)
  2635. {
  2636. nullpo_retr(-1, sd);
  2637. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2638. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2639. clif_displaymessage(fd, msg_txt(1024)); // Please enter a player name (usage: @charunblock <char name>).
  2640. return -1;
  2641. }
  2642. // send answer to login server via char-server
  2643. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2644. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2645. return 0;
  2646. }
  2647. /*==========================================
  2648. * charunban command (usage: charunban <player_name>)
  2649. *------------------------------------------*/
  2650. ACMD_FUNC(char_unban)
  2651. {
  2652. nullpo_retr(-1, sd);
  2653. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2654. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2655. clif_displaymessage(fd, msg_txt(1025)); // Please enter a player name (usage: @charunban <char name>).
  2656. return -1;
  2657. }
  2658. // send answer to login server via char-server
  2659. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2660. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2661. return 0;
  2662. }
  2663. /*==========================================
  2664. *
  2665. *------------------------------------------*/
  2666. ACMD_FUNC(night)
  2667. {
  2668. nullpo_retr(-1, sd);
  2669. if (night_flag != 1) {
  2670. map_night_timer(night_timer_tid, 0, 0, 1);
  2671. } else {
  2672. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  2673. return -1;
  2674. }
  2675. return 0;
  2676. }
  2677. /*==========================================
  2678. *
  2679. *------------------------------------------*/
  2680. ACMD_FUNC(day)
  2681. {
  2682. nullpo_retr(-1, sd);
  2683. if (night_flag != 0) {
  2684. map_day_timer(day_timer_tid, 0, 0, 1);
  2685. } else {
  2686. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  2687. return -1;
  2688. }
  2689. return 0;
  2690. }
  2691. /*==========================================
  2692. *
  2693. *------------------------------------------*/
  2694. ACMD_FUNC(doom)
  2695. {
  2696. struct map_session_data* pl_sd;
  2697. struct s_mapiterator* iter;
  2698. nullpo_retr(-1, sd);
  2699. iter = mapit_getallusers();
  2700. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2701. {
  2702. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2703. {
  2704. status_kill(&pl_sd->bl);
  2705. clif_specialeffect(&pl_sd->bl,450,AREA);
  2706. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2707. }
  2708. }
  2709. mapit_free(iter);
  2710. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2711. return 0;
  2712. }
  2713. /*==========================================
  2714. *
  2715. *------------------------------------------*/
  2716. ACMD_FUNC(doommap)
  2717. {
  2718. struct map_session_data* pl_sd;
  2719. struct s_mapiterator* iter;
  2720. nullpo_retr(-1, sd);
  2721. iter = mapit_getallusers();
  2722. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2723. {
  2724. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2725. {
  2726. status_kill(&pl_sd->bl);
  2727. clif_specialeffect(&pl_sd->bl,450,AREA);
  2728. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2729. }
  2730. }
  2731. mapit_free(iter);
  2732. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2733. return 0;
  2734. }
  2735. /*==========================================
  2736. *
  2737. *------------------------------------------*/
  2738. static void atcommand_raise_sub(struct map_session_data* sd) {
  2739. status_revive(&sd->bl, 100, 100);
  2740. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2741. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  2742. }
  2743. /*==========================================
  2744. *
  2745. *------------------------------------------*/
  2746. ACMD_FUNC(raise)
  2747. {
  2748. struct map_session_data* pl_sd;
  2749. struct s_mapiterator* iter;
  2750. nullpo_retr(-1, sd);
  2751. iter = mapit_getallusers();
  2752. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2753. if( pc_isdead(pl_sd) )
  2754. atcommand_raise_sub(pl_sd);
  2755. mapit_free(iter);
  2756. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2757. return 0;
  2758. }
  2759. /*==========================================
  2760. *
  2761. *------------------------------------------*/
  2762. ACMD_FUNC(raisemap)
  2763. {
  2764. struct map_session_data* pl_sd;
  2765. struct s_mapiterator* iter;
  2766. nullpo_retr(-1, sd);
  2767. iter = mapit_getallusers();
  2768. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2769. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2770. atcommand_raise_sub(pl_sd);
  2771. mapit_free(iter);
  2772. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2773. return 0;
  2774. }
  2775. /*==========================================
  2776. *
  2777. *------------------------------------------*/
  2778. ACMD_FUNC(kick)
  2779. {
  2780. struct map_session_data *pl_sd;
  2781. nullpo_retr(-1, sd);
  2782. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2783. if (!message || !*message) {
  2784. clif_displaymessage(fd, msg_txt(1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2785. return -1;
  2786. }
  2787. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2788. {
  2789. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2790. return -1;
  2791. }
  2792. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2793. {
  2794. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2795. return -1;
  2796. }
  2797. clif_GM_kick(sd, pl_sd);
  2798. return 0;
  2799. }
  2800. /*==========================================
  2801. *
  2802. *------------------------------------------*/
  2803. ACMD_FUNC(kickall)
  2804. {
  2805. struct map_session_data* pl_sd;
  2806. struct s_mapiterator* iter;
  2807. nullpo_retr(-1, sd);
  2808. iter = mapit_getallusers();
  2809. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2810. {
  2811. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2812. if (sd->status.account_id != pl_sd->status.account_id)
  2813. clif_GM_kick(NULL, pl_sd);
  2814. }
  2815. }
  2816. mapit_free(iter);
  2817. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  2818. return 0;
  2819. }
  2820. /*==========================================
  2821. *
  2822. *------------------------------------------*/
  2823. ACMD_FUNC(allskill)
  2824. {
  2825. nullpo_retr(-1, sd);
  2826. pc_allskillup(sd); // all skills
  2827. sd->status.skill_point = 0; // 0 skill points
  2828. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2829. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  2830. return 0;
  2831. }
  2832. /*==========================================
  2833. *
  2834. *------------------------------------------*/
  2835. ACMD_FUNC(questskill)
  2836. {
  2837. int skill_id;
  2838. nullpo_retr(-1, sd);
  2839. if (!message || !*message || (skill_id = atoi(message)) < 0)
  2840. {// also send a list of skills applicable to this command
  2841. const char* text;
  2842. // attempt to find the text corresponding to this command
  2843. text = atcommand_help_string( command );
  2844. // send the error message as always
  2845. clif_displaymessage(fd, msg_txt(1027)); // Please enter a quest skill number.
  2846. if( text )
  2847. {// send the skill ID list associated with this command
  2848. clif_displaymessage( fd, text );
  2849. }
  2850. return -1;
  2851. }
  2852. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  2853. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2854. return -1;
  2855. }
  2856. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2857. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2858. return -1;
  2859. }
  2860. if (pc_checkskill(sd, skill_id) > 0) {
  2861. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  2862. return -1;
  2863. }
  2864. pc_skill(sd, skill_id, 1, 0);
  2865. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  2866. return 0;
  2867. }
  2868. /*==========================================
  2869. *
  2870. *------------------------------------------*/
  2871. ACMD_FUNC(lostskill)
  2872. {
  2873. int skill_id;
  2874. nullpo_retr(-1, sd);
  2875. if (!message || !*message || (skill_id = atoi(message)) < 0)
  2876. {// also send a list of skills applicable to this command
  2877. const char* text;
  2878. // attempt to find the text corresponding to this command
  2879. text = atcommand_help_string( command );
  2880. // send the error message as always
  2881. clif_displaymessage(fd, msg_txt(1027)); // Please enter a quest skill number.
  2882. if( text )
  2883. {// send the skill ID list associated with this command
  2884. clif_displaymessage( fd, text );
  2885. }
  2886. return -1;
  2887. }
  2888. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  2889. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2890. return -1;
  2891. }
  2892. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2893. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2894. return -1;
  2895. }
  2896. if (pc_checkskill(sd, skill_id) == 0) {
  2897. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  2898. return -1;
  2899. }
  2900. sd->status.skill[skill_id].lv = 0;
  2901. sd->status.skill[skill_id].flag = 0;
  2902. clif_deleteskill(sd,skill_id);
  2903. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  2904. return 0;
  2905. }
  2906. /*==========================================
  2907. *
  2908. *------------------------------------------*/
  2909. ACMD_FUNC(spiritball)
  2910. {
  2911. int max_spiritballs;
  2912. int number;
  2913. nullpo_retr(-1, sd);
  2914. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2915. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2916. {
  2917. char msg[CHAT_SIZE_MAX];
  2918. safesnprintf(msg, sizeof(msg), msg_txt(1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2919. clif_displaymessage(fd, msg);
  2920. return -1;
  2921. }
  2922. if( sd->spiritball > 0 )
  2923. pc_delspiritball(sd, sd->spiritball, 1);
  2924. sd->spiritball = number;
  2925. clif_spiritball(sd);
  2926. // no message, player can look the difference
  2927. return 0;
  2928. }
  2929. /*==========================================
  2930. *
  2931. *------------------------------------------*/
  2932. ACMD_FUNC(party)
  2933. {
  2934. char party[NAME_LENGTH];
  2935. nullpo_retr(-1, sd);
  2936. memset(party, '\0', sizeof(party));
  2937. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2938. clif_displaymessage(fd, msg_txt(1029)); // Please enter a party name (usage: @party <party_name>).
  2939. return -1;
  2940. }
  2941. party_create(sd, party, 0, 0);
  2942. return 0;
  2943. }
  2944. /*==========================================
  2945. *
  2946. *------------------------------------------*/
  2947. ACMD_FUNC(guild)
  2948. {
  2949. char guild[NAME_LENGTH];
  2950. int prev;
  2951. nullpo_retr(-1, sd);
  2952. memset(guild, '\0', sizeof(guild));
  2953. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2954. clif_displaymessage(fd, msg_txt(1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2955. return -1;
  2956. }
  2957. prev = battle_config.guild_emperium_check;
  2958. battle_config.guild_emperium_check = 0;
  2959. guild_create(sd, guild);
  2960. battle_config.guild_emperium_check = prev;
  2961. return 0;
  2962. }
  2963. /*==========================================
  2964. *
  2965. *------------------------------------------*/
  2966. ACMD_FUNC(agitstart)
  2967. {
  2968. nullpo_retr(-1, sd);
  2969. if (agit_flag == 1) {
  2970. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  2971. return -1;
  2972. }
  2973. agit_flag = 1;
  2974. guild_agit_start();
  2975. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  2976. return 0;
  2977. }
  2978. /*==========================================
  2979. *
  2980. *------------------------------------------*/
  2981. ACMD_FUNC(agitstart2)
  2982. {
  2983. nullpo_retr(-1, sd);
  2984. if (agit2_flag == 1) {
  2985. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  2986. return -1;
  2987. }
  2988. agit2_flag = 1;
  2989. guild_agit2_start();
  2990. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  2991. return 0;
  2992. }
  2993. /*==========================================
  2994. *
  2995. *------------------------------------------*/
  2996. ACMD_FUNC(agitend)
  2997. {
  2998. nullpo_retr(-1, sd);
  2999. if (agit_flag == 0) {
  3000. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3001. return -1;
  3002. }
  3003. agit_flag = 0;
  3004. guild_agit_end();
  3005. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3006. return 0;
  3007. }
  3008. /*==========================================
  3009. *
  3010. *------------------------------------------*/
  3011. ACMD_FUNC(agitend2)
  3012. {
  3013. nullpo_retr(-1, sd);
  3014. if (agit2_flag == 0) {
  3015. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3016. return -1;
  3017. }
  3018. agit2_flag = 0;
  3019. guild_agit2_end();
  3020. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3021. return 0;
  3022. }
  3023. /*==========================================
  3024. * @mapexit - shuts down the map server
  3025. *------------------------------------------*/
  3026. ACMD_FUNC(mapexit)
  3027. {
  3028. nullpo_retr(-1, sd);
  3029. do_shutdown();
  3030. return 0;
  3031. }
  3032. /*==========================================
  3033. * idsearch <part_of_name>: revrited by [Yor]
  3034. *------------------------------------------*/
  3035. ACMD_FUNC(idsearch)
  3036. {
  3037. char item_name[100];
  3038. unsigned int i, match;
  3039. struct item_data *item_array[MAX_SEARCH];
  3040. nullpo_retr(-1, sd);
  3041. memset(item_name, '\0', sizeof(item_name));
  3042. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3043. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3044. clif_displaymessage(fd, msg_txt(1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3045. return -1;
  3046. }
  3047. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3048. clif_displaymessage(fd, atcmd_output);
  3049. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3050. if (match > MAX_SEARCH) {
  3051. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3052. clif_displaymessage(fd, atcmd_output);
  3053. match = MAX_SEARCH;
  3054. }
  3055. for(i = 0; i < match; i++) {
  3056. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3057. clif_displaymessage(fd, atcmd_output);
  3058. }
  3059. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3060. clif_displaymessage(fd, atcmd_output);
  3061. return 0;
  3062. }
  3063. /*==========================================
  3064. * Recall All Characters Online To Your Location
  3065. *------------------------------------------*/
  3066. ACMD_FUNC(recallall)
  3067. {
  3068. struct map_session_data* pl_sd;
  3069. struct s_mapiterator* iter;
  3070. int count;
  3071. nullpo_retr(-1, sd);
  3072. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3073. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3074. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3075. return -1;
  3076. }
  3077. count = 0;
  3078. iter = mapit_getallusers();
  3079. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3080. {
  3081. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3082. {
  3083. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3084. count++;
  3085. else {
  3086. if (pc_isdead(pl_sd)) { //Wake them up
  3087. pc_setstand(pl_sd);
  3088. pc_setrestartvalue(pl_sd,1);
  3089. }
  3090. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3091. }
  3092. }
  3093. }
  3094. mapit_free(iter);
  3095. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3096. if (count) {
  3097. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3098. clif_displaymessage(fd, atcmd_output);
  3099. }
  3100. return 0;
  3101. }
  3102. /*==========================================
  3103. * Recall online characters of a guild to your location
  3104. *------------------------------------------*/
  3105. ACMD_FUNC(guildrecall)
  3106. {
  3107. struct map_session_data* pl_sd;
  3108. struct s_mapiterator* iter;
  3109. int count;
  3110. char guild_name[NAME_LENGTH];
  3111. struct guild *g;
  3112. nullpo_retr(-1, sd);
  3113. memset(guild_name, '\0', sizeof(guild_name));
  3114. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3115. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3116. clif_displaymessage(fd, msg_txt(1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3117. return -1;
  3118. }
  3119. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3120. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3121. return -1;
  3122. }
  3123. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3124. (g = guild_search(atoi(message))) == NULL)
  3125. {
  3126. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3127. return -1;
  3128. }
  3129. count = 0;
  3130. iter = mapit_getallusers();
  3131. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3132. {
  3133. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3134. {
  3135. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3136. continue; //Skip GMs greater than you.
  3137. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3138. count++;
  3139. else
  3140. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3141. }
  3142. }
  3143. mapit_free(iter);
  3144. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3145. clif_displaymessage(fd, atcmd_output);
  3146. if (count) {
  3147. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3148. clif_displaymessage(fd, atcmd_output);
  3149. }
  3150. return 0;
  3151. }
  3152. /*==========================================
  3153. * Recall online characters of a party to your location
  3154. *------------------------------------------*/
  3155. ACMD_FUNC(partyrecall)
  3156. {
  3157. struct map_session_data* pl_sd;
  3158. struct s_mapiterator* iter;
  3159. char party_name[NAME_LENGTH];
  3160. struct party_data *p;
  3161. int count;
  3162. nullpo_retr(-1, sd);
  3163. memset(party_name, '\0', sizeof(party_name));
  3164. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3165. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3166. clif_displaymessage(fd, msg_txt(1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3167. return -1;
  3168. }
  3169. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3170. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3171. return -1;
  3172. }
  3173. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3174. (p = party_search(atoi(message))) == NULL)
  3175. {
  3176. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3177. return -1;
  3178. }
  3179. count = 0;
  3180. iter = mapit_getallusers();
  3181. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3182. {
  3183. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3184. {
  3185. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3186. continue; //Skip GMs greater than you.
  3187. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3188. count++;
  3189. else
  3190. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3191. }
  3192. }
  3193. mapit_free(iter);
  3194. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3195. clif_displaymessage(fd, atcmd_output);
  3196. if (count) {
  3197. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3198. clif_displaymessage(fd, atcmd_output);
  3199. }
  3200. return 0;
  3201. }
  3202. /*==========================================
  3203. *
  3204. *------------------------------------------*/
  3205. ACMD_FUNC(reloaditemdb)
  3206. {
  3207. nullpo_retr(-1, sd);
  3208. itemdb_reload();
  3209. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3210. return 0;
  3211. }
  3212. /*==========================================
  3213. *
  3214. *------------------------------------------*/
  3215. ACMD_FUNC(reloadmobdb)
  3216. {
  3217. nullpo_retr(-1, sd);
  3218. mob_reload();
  3219. read_petdb();
  3220. merc_reload();
  3221. read_mercenarydb();
  3222. read_mercenary_skilldb();
  3223. reload_elementaldb();
  3224. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3225. return 0;
  3226. }
  3227. /*==========================================
  3228. *
  3229. *------------------------------------------*/
  3230. ACMD_FUNC(reloadskilldb)
  3231. {
  3232. nullpo_retr(-1, sd);
  3233. skill_reload();
  3234. merc_skill_reload();
  3235. reload_elemental_skilldb();
  3236. read_mercenary_skilldb();
  3237. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3238. return 0;
  3239. }
  3240. /*==========================================
  3241. * @reloadatcommand - reloads atcommand_athena.conf groups.conf
  3242. *------------------------------------------*/
  3243. void atcommand_doload();
  3244. ACMD_FUNC(reloadatcommand) {
  3245. config_t run_test;
  3246. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3247. clif_displaymessage(fd, msg_txt(1036)); // Error reading groups.conf, reload failed.
  3248. return -1;
  3249. }
  3250. config_destroy(&run_test);
  3251. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3252. clif_displaymessage(fd, msg_txt(1037)); // Error reading atcommand_athena.conf, reload failed.
  3253. return -1;
  3254. }
  3255. config_destroy(&run_test);
  3256. atcommand_doload();
  3257. pc_groups_reload();
  3258. clif_displaymessage(fd, msg_txt(254));
  3259. return 0;
  3260. }
  3261. /*==========================================
  3262. * @reloadbattleconf - reloads battle_athena.conf
  3263. *------------------------------------------*/
  3264. ACMD_FUNC(reloadbattleconf)
  3265. {
  3266. struct Battle_Config prev_config;
  3267. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3268. battle_config_read(BATTLE_CONF_FILENAME);
  3269. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3270. || prev_config.item_rate_common != battle_config.item_rate_common
  3271. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3272. || prev_config.item_rate_card != battle_config.item_rate_card
  3273. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3274. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3275. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3276. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3277. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3278. || prev_config.item_rate_use != battle_config.item_rate_use
  3279. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3280. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3281. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3282. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3283. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3284. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3285. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3286. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3287. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3288. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3289. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3290. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3291. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3292. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3293. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3294. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3295. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3296. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3297. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3298. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3299. )
  3300. { // Exp or Drop rates changed.
  3301. mob_reload(); //Needed as well so rate changes take effect.
  3302. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3303. }
  3304. clif_displaymessage(fd, msg_txt(255));
  3305. return 0;
  3306. }
  3307. /*==========================================
  3308. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3309. *------------------------------------------*/
  3310. ACMD_FUNC(reloadstatusdb)
  3311. {
  3312. status_readdb();
  3313. clif_displaymessage(fd, msg_txt(256));
  3314. return 0;
  3315. }
  3316. /*==========================================
  3317. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3318. *------------------------------------------*/
  3319. ACMD_FUNC(reloadpcdb)
  3320. {
  3321. pc_readdb();
  3322. clif_displaymessage(fd, msg_txt(257));
  3323. return 0;
  3324. }
  3325. /*==========================================
  3326. * @reloadmotd - reloads motd.txt
  3327. *------------------------------------------*/
  3328. ACMD_FUNC(reloadmotd)
  3329. {
  3330. pc_read_motd();
  3331. clif_displaymessage(fd, msg_txt(268));
  3332. return 0;
  3333. }
  3334. /*==========================================
  3335. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3336. *------------------------------------------*/
  3337. ACMD_FUNC(reloadscript)
  3338. {
  3339. nullpo_retr(-1, sd);
  3340. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3341. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3342. flush_fifos();
  3343. map_reloadnpc(true); // reload config files seeking for npcs
  3344. script_reload();
  3345. npc_reload();
  3346. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3347. return 0;
  3348. }
  3349. /*==========================================
  3350. * @mapinfo [0-3] <map name> by MC_Cameri
  3351. * => Shows information about the map [map name]
  3352. * 0 = no additional information
  3353. * 1 = Show users in that map and their location
  3354. * 2 = Shows NPCs in that map
  3355. * 3 = Shows the shops/chats in that map (not implemented)
  3356. *------------------------------------------*/
  3357. ACMD_FUNC(mapinfo)
  3358. {
  3359. struct map_session_data* pl_sd;
  3360. struct s_mapiterator* iter;
  3361. struct npc_data *nd = NULL;
  3362. struct chat_data *cd = NULL;
  3363. char direction[12];
  3364. int i, m_id, chat_num, list = 0;
  3365. unsigned short m_index;
  3366. char mapname[24];
  3367. nullpo_retr(-1, sd);
  3368. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3369. memset(mapname, '\0', sizeof(mapname));
  3370. memset(direction, '\0', sizeof(direction));
  3371. sscanf(message, "%d %23[^\n]", &list, mapname);
  3372. if (list < 0 || list > 3) {
  3373. clif_displaymessage(fd, msg_txt(1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3374. return -1;
  3375. }
  3376. if (mapname[0] == '\0') {
  3377. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3378. m_id = map_mapindex2mapid(sd->mapindex);
  3379. } else {
  3380. m_id = map_mapname2mapid(mapname);
  3381. }
  3382. if (m_id < 0) {
  3383. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3384. return -1;
  3385. }
  3386. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3387. clif_displaymessage(fd, msg_txt(1039)); // ------ Map Info ------
  3388. // count chats (for initial message)
  3389. chat_num = 0;
  3390. iter = mapit_getallusers();
  3391. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3392. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3393. chat_num++;
  3394. mapit_free(iter);
  3395. sprintf(atcmd_output, msg_txt(1040), mapname, map[m_id].users, map[m_id].npc_num, chat_num); // Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d
  3396. clif_displaymessage(fd, atcmd_output);
  3397. clif_displaymessage(fd, msg_txt(1041)); // ------ Map Flags ------
  3398. if (map[m_id].flag.town)
  3399. clif_displaymessage(fd, msg_txt(1042)); // Town Map
  3400. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3401. clif_displaymessage(fd, msg_txt(1043)); // Autotrade Enabled
  3402. else
  3403. clif_displaymessage(fd, msg_txt(1044)); // Autotrade Disabled
  3404. if (map[m_id].flag.battleground)
  3405. clif_displaymessage(fd, msg_txt(1045)); // Battlegrounds ON
  3406. strcpy(atcmd_output,msg_txt(1046)); // PvP Flags:
  3407. if (map[m_id].flag.pvp)
  3408. strcat(atcmd_output, msg_txt(1047)); // Pvp ON |
  3409. if (map[m_id].flag.pvp_noguild)
  3410. strcat(atcmd_output, msg_txt(1048)); // NoGuild |
  3411. if (map[m_id].flag.pvp_noparty)
  3412. strcat(atcmd_output, msg_txt(1049)); // NoParty |
  3413. if (map[m_id].flag.pvp_nightmaredrop)
  3414. strcat(atcmd_output, msg_txt(1050)); // NightmareDrop |
  3415. if (map[m_id].flag.pvp_nocalcrank)
  3416. strcat(atcmd_output, msg_txt(1051)); // NoCalcRank |
  3417. clif_displaymessage(fd, atcmd_output);
  3418. strcpy(atcmd_output,msg_txt(1052)); // GvG Flags:
  3419. if (map[m_id].flag.gvg)
  3420. strcat(atcmd_output, msg_txt(1053)); // GvG ON |
  3421. if (map[m_id].flag.gvg_dungeon)
  3422. strcat(atcmd_output, msg_txt(1054)); // GvG Dungeon |
  3423. if (map[m_id].flag.gvg_castle)
  3424. strcat(atcmd_output, msg_txt(1055)); // GvG Castle |
  3425. if (map[m_id].flag.gvg_noparty)
  3426. strcat(atcmd_output, msg_txt(1056)); // NoParty |
  3427. clif_displaymessage(fd, atcmd_output);
  3428. strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags:
  3429. if (map[m_id].flag.noteleport)
  3430. strcat(atcmd_output, msg_txt(1058)); // NoTeleport |
  3431. if (map[m_id].flag.monster_noteleport)
  3432. strcat(atcmd_output, msg_txt(1059)); // Monster NoTeleport |
  3433. if (map[m_id].flag.nowarp)
  3434. strcat(atcmd_output, msg_txt(1060)); // NoWarp |
  3435. if (map[m_id].flag.nowarpto)
  3436. strcat(atcmd_output, msg_txt(1061)); // NoWarpTo |
  3437. if (map[m_id].flag.noreturn)
  3438. strcat(atcmd_output, msg_txt(1062)); // NoReturn |
  3439. if (map[m_id].flag.nogo)
  3440. strcat(atcmd_output, msg_txt(1063)); // NoGo |
  3441. if (map[m_id].flag.nomemo)
  3442. strcat(atcmd_output, msg_txt(1064)); // NoMemo |
  3443. clif_displaymessage(fd, atcmd_output);
  3444. sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3445. (map[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off
  3446. clif_displaymessage(fd, atcmd_output);
  3447. if (map[m_id].flag.nosave) {
  3448. if (!map[m_id].save.map)
  3449. clif_displaymessage(fd, msg_txt(1068)); // No Save (Return to last Save Point)
  3450. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3451. sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3452. clif_displaymessage(fd, atcmd_output);
  3453. }
  3454. else {
  3455. sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d
  3456. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3457. clif_displaymessage(fd, atcmd_output);
  3458. }
  3459. }
  3460. strcpy(atcmd_output,msg_txt(1071)); // Weather Flags:
  3461. if (map[m_id].flag.snow)
  3462. strcat(atcmd_output, msg_txt(1072)); // Snow |
  3463. if (map[m_id].flag.fog)
  3464. strcat(atcmd_output, msg_txt(1073)); // Fog |
  3465. if (map[m_id].flag.sakura)
  3466. strcat(atcmd_output, msg_txt(1074)); // Sakura |
  3467. if (map[m_id].flag.clouds)
  3468. strcat(atcmd_output, msg_txt(1075)); // Clouds |
  3469. if (map[m_id].flag.clouds2)
  3470. strcat(atcmd_output, msg_txt(1076)); // Clouds2 |
  3471. if (map[m_id].flag.fireworks)
  3472. strcat(atcmd_output, msg_txt(1077)); // Fireworks |
  3473. if (map[m_id].flag.leaves)
  3474. strcat(atcmd_output, msg_txt(1078)); // Leaves |
  3475. /**
  3476. * No longer available, keeping here just in case it's back someday. [Ind]
  3477. **/
  3478. //if (map[m_id].flag.rain)
  3479. // strcat(atcmd_output, msg_txt(1079)); // Rain |
  3480. if (map[m_id].flag.nightenabled)
  3481. strcat(atcmd_output, msg_txt(1080)); // Displays Night |
  3482. clif_displaymessage(fd, atcmd_output);
  3483. strcpy(atcmd_output,msg_txt(1081)); // Other Flags:
  3484. if (map[m_id].flag.nobranch)
  3485. strcat(atcmd_output, msg_txt(1082)); // NoBranch |
  3486. if (map[m_id].flag.notrade)
  3487. strcat(atcmd_output, msg_txt(1083)); // NoTrade |
  3488. if (map[m_id].flag.novending)
  3489. strcat(atcmd_output, msg_txt(1084)); // NoVending |
  3490. if (map[m_id].flag.nodrop)
  3491. strcat(atcmd_output, msg_txt(1085)); // NoDrop |
  3492. if (map[m_id].flag.noskill)
  3493. strcat(atcmd_output, msg_txt(1086)); // NoSkill |
  3494. if (map[m_id].flag.noicewall)
  3495. strcat(atcmd_output, msg_txt(1087)); // NoIcewall |
  3496. if (map[m_id].flag.allowks)
  3497. strcat(atcmd_output, msg_txt(1088)); // AllowKS |
  3498. if (map[m_id].flag.reset)
  3499. strcat(atcmd_output, msg_txt(1089)); // Reset |
  3500. clif_displaymessage(fd, atcmd_output);
  3501. strcpy(atcmd_output,msg_txt(1090)); // Other Flags:
  3502. if (map[m_id].nocommand)
  3503. strcat(atcmd_output, msg_txt(1091)); // NoCommand |
  3504. if (map[m_id].flag.nobaseexp)
  3505. strcat(atcmd_output, msg_txt(1092)); // NoBaseEXP |
  3506. if (map[m_id].flag.nojobexp)
  3507. strcat(atcmd_output, msg_txt(1093)); // NoJobEXP |
  3508. if (map[m_id].flag.nomobloot)
  3509. strcat(atcmd_output, msg_txt(1094)); // NoMobLoot |
  3510. if (map[m_id].flag.nomvploot)
  3511. strcat(atcmd_output, msg_txt(1095)); // NoMVPLoot |
  3512. if (map[m_id].flag.partylock)
  3513. strcat(atcmd_output, msg_txt(1096)); // PartyLock |
  3514. if (map[m_id].flag.guildlock)
  3515. strcat(atcmd_output, msg_txt(1097)); // GuildLock |
  3516. clif_displaymessage(fd, atcmd_output);
  3517. switch (list) {
  3518. case 0:
  3519. // Do nothing. It's list 0, no additional display.
  3520. break;
  3521. case 1:
  3522. clif_displaymessage(fd, msg_txt(1098)); // ----- Players in Map -----
  3523. iter = mapit_getallusers();
  3524. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3525. {
  3526. if (pl_sd->mapindex == m_index) {
  3527. sprintf(atcmd_output, msg_txt(1099), // Player '%s' (session #%d) | Location: %d,%d
  3528. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3529. clif_displaymessage(fd, atcmd_output);
  3530. }
  3531. }
  3532. mapit_free(iter);
  3533. break;
  3534. case 2:
  3535. clif_displaymessage(fd, msg_txt(1100)); // ----- NPCs in Map -----
  3536. for (i = 0; i < map[m_id].npc_num;)
  3537. {
  3538. nd = map[m_id].npc[i];
  3539. switch(nd->ud.dir) {
  3540. case 0: strcpy(direction, msg_txt(1101)); break; // North
  3541. case 1: strcpy(direction, msg_txt(1102)); break; // North West
  3542. case 2: strcpy(direction, msg_txt(1103)); break; // West
  3543. case 3: strcpy(direction, msg_txt(1104)); break; // South West
  3544. case 4: strcpy(direction, msg_txt(1105)); break; // South
  3545. case 5: strcpy(direction, msg_txt(1106)); break; // South East
  3546. case 6: strcpy(direction, msg_txt(1107)); break; // East
  3547. case 7: strcpy(direction, msg_txt(1108)); break; // North East
  3548. case 9: strcpy(direction, msg_txt(1109)); break; // North
  3549. default: strcpy(direction, msg_txt(1110)); break; // Unknown
  3550. }
  3551. if(strcmp(nd->name,nd->exname) == 0)
  3552. sprintf(atcmd_output, msg_txt(1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3553. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3554. else
  3555. sprintf(atcmd_output, msg_txt(1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3556. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3557. clif_displaymessage(fd, atcmd_output);
  3558. }
  3559. break;
  3560. case 3:
  3561. clif_displaymessage(fd, msg_txt(1113)); // ----- Chats in Map -----
  3562. iter = mapit_getallusers();
  3563. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3564. {
  3565. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3566. pl_sd->mapindex == m_index &&
  3567. cd->usersd[0] == pl_sd)
  3568. {
  3569. sprintf(atcmd_output, msg_txt(1114), // Chat: %s | Player: %s | Location: %d %d
  3570. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3571. clif_displaymessage(fd, atcmd_output);
  3572. sprintf(atcmd_output, msg_txt(1115), // Users: %d/%d | Password: %s | Public: %s
  3573. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(1116) : msg_txt(1117)); // Yes / No
  3574. clif_displaymessage(fd, atcmd_output);
  3575. }
  3576. }
  3577. mapit_free(iter);
  3578. break;
  3579. default: // normally impossible to arrive here
  3580. clif_displaymessage(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3581. return -1;
  3582. break;
  3583. }
  3584. return 0;
  3585. }
  3586. /*==========================================
  3587. *
  3588. *------------------------------------------*/
  3589. ACMD_FUNC(mount_peco)
  3590. {
  3591. nullpo_retr(-1, sd);
  3592. if (sd->disguise) {
  3593. clif_displaymessage(fd, msg_txt(212)); // Cannot mount while in disguise.
  3594. return -1;
  3595. }
  3596. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3597. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3598. clif_displaymessage(sd->fd,msg_txt(1119)); // You have mounted your Dragon.
  3599. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3600. } else {
  3601. clif_displaymessage(sd->fd,msg_txt(1120)); // You have released your Dragon.
  3602. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3603. }
  3604. return 0;
  3605. }
  3606. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  3607. if( !pc_isridingwug(sd) ) {
  3608. clif_displaymessage(sd->fd,msg_txt(1121)); // You have mounted your Warg.
  3609. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3610. } else {
  3611. clif_displaymessage(sd->fd,msg_txt(1122)); // You have released your Warg.
  3612. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3613. }
  3614. return 0;
  3615. }
  3616. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3617. if( !pc_ismadogear(sd) ) {
  3618. clif_displaymessage(sd->fd,msg_txt(1123)); // You have mounted your Mado Gear.
  3619. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3620. } else {
  3621. clif_displaymessage(sd->fd,msg_txt(1124)); // You have released your Mado Gear.
  3622. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3623. }
  3624. return 0;
  3625. }
  3626. if (!pc_isriding(sd)) { // if actually no peco
  3627. if (!pc_checkskill(sd, KN_RIDING)) {
  3628. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  3629. return -1;
  3630. }
  3631. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3632. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  3633. } else {//Dismount
  3634. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3635. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  3636. }
  3637. return 0;
  3638. }
  3639. /*==========================================
  3640. *Spy Commands by Syrus22
  3641. *------------------------------------------*/
  3642. ACMD_FUNC(guildspy)
  3643. {
  3644. char guild_name[NAME_LENGTH];
  3645. struct guild *g;
  3646. nullpo_retr(-1, sd);
  3647. memset(guild_name, '\0', sizeof(guild_name));
  3648. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3649. if (!enable_spy)
  3650. {
  3651. clif_displaymessage(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
  3652. return -1;
  3653. }
  3654. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3655. clif_displaymessage(fd, msg_txt(1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3656. return -1;
  3657. }
  3658. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3659. (g = guild_search(atoi(message))) != NULL) {
  3660. if (sd->guildspy == g->guild_id) {
  3661. sd->guildspy = 0;
  3662. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3663. clif_displaymessage(fd, atcmd_output);
  3664. } else {
  3665. sd->guildspy = g->guild_id;
  3666. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3667. clif_displaymessage(fd, atcmd_output);
  3668. }
  3669. } else {
  3670. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  3671. return -1;
  3672. }
  3673. return 0;
  3674. }
  3675. /*==========================================
  3676. *
  3677. *------------------------------------------*/
  3678. ACMD_FUNC(partyspy)
  3679. {
  3680. char party_name[NAME_LENGTH];
  3681. struct party_data *p;
  3682. nullpo_retr(-1, sd);
  3683. memset(party_name, '\0', sizeof(party_name));
  3684. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3685. if (!enable_spy)
  3686. {
  3687. clif_displaymessage(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
  3688. return -1;
  3689. }
  3690. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3691. clif_displaymessage(fd, msg_txt(1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3692. return -1;
  3693. }
  3694. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3695. (p = party_search(atoi(message))) != NULL) {
  3696. if (sd->partyspy == p->party.party_id) {
  3697. sd->partyspy = 0;
  3698. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3699. clif_displaymessage(fd, atcmd_output);
  3700. } else {
  3701. sd->partyspy = p->party.party_id;
  3702. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3703. clif_displaymessage(fd, atcmd_output);
  3704. }
  3705. } else {
  3706. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  3707. return -1;
  3708. }
  3709. return 0;
  3710. }
  3711. /*==========================================
  3712. * @repairall [Valaris]
  3713. *------------------------------------------*/
  3714. ACMD_FUNC(repairall)
  3715. {
  3716. int count, i;
  3717. nullpo_retr(-1, sd);
  3718. count = 0;
  3719. for (i = 0; i < MAX_INVENTORY; i++) {
  3720. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3721. sd->status.inventory[i].attribute = 0;
  3722. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3723. count++;
  3724. }
  3725. }
  3726. if (count > 0) {
  3727. clif_misceffect(&sd->bl, 3);
  3728. clif_equiplist(sd);
  3729. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3730. } else {
  3731. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3732. return -1;
  3733. }
  3734. return 0;
  3735. }
  3736. /*==========================================
  3737. * @nuke [Valaris]
  3738. *------------------------------------------*/
  3739. ACMD_FUNC(nuke)
  3740. {
  3741. struct map_session_data *pl_sd;
  3742. nullpo_retr(-1, sd);
  3743. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3744. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3745. clif_displaymessage(fd, msg_txt(1128)); // Please enter a player name (usage: @nuke <char name>).
  3746. return -1;
  3747. }
  3748. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3749. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3750. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3751. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3752. } else {
  3753. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3754. return -1;
  3755. }
  3756. } else {
  3757. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3758. return -1;
  3759. }
  3760. return 0;
  3761. }
  3762. /*==========================================
  3763. * @tonpc
  3764. *------------------------------------------*/
  3765. ACMD_FUNC(tonpc)
  3766. {
  3767. char npcname[NAME_LENGTH+1];
  3768. struct npc_data *nd;
  3769. nullpo_retr(-1, sd);
  3770. memset(npcname, 0, sizeof(npcname));
  3771. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3772. clif_displaymessage(fd, msg_txt(1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3773. return -1;
  3774. }
  3775. if ((nd = npc_name2id(npcname)) != NULL) {
  3776. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3777. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3778. else
  3779. return -1;
  3780. } else {
  3781. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3782. return -1;
  3783. }
  3784. return 0;
  3785. }
  3786. /*==========================================
  3787. *
  3788. *------------------------------------------*/
  3789. ACMD_FUNC(shownpc)
  3790. {
  3791. char NPCname[NAME_LENGTH+1];
  3792. nullpo_retr(-1, sd);
  3793. memset(NPCname, '\0', sizeof(NPCname));
  3794. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3795. clif_displaymessage(fd, msg_txt(1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3796. return -1;
  3797. }
  3798. if (npc_name2id(NPCname) != NULL) {
  3799. npc_enable(NPCname, 1);
  3800. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  3801. } else {
  3802. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3803. return -1;
  3804. }
  3805. return 0;
  3806. }
  3807. /*==========================================
  3808. *
  3809. *------------------------------------------*/
  3810. ACMD_FUNC(hidenpc)
  3811. {
  3812. char NPCname[NAME_LENGTH+1];
  3813. nullpo_retr(-1, sd);
  3814. memset(NPCname, '\0', sizeof(NPCname));
  3815. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3816. clif_displaymessage(fd, msg_txt(1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3817. return -1;
  3818. }
  3819. if (npc_name2id(NPCname) == NULL) {
  3820. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3821. return -1;
  3822. }
  3823. npc_enable(NPCname, 0);
  3824. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3825. return 0;
  3826. }
  3827. ACMD_FUNC(loadnpc)
  3828. {
  3829. FILE *fp;
  3830. if (!message || !*message) {
  3831. clif_displaymessage(fd, msg_txt(1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3832. return -1;
  3833. }
  3834. // check if script file exists
  3835. if ((fp = fopen(message, "r")) == NULL) {
  3836. clif_displaymessage(fd, msg_txt(261));
  3837. return -1;
  3838. }
  3839. fclose(fp);
  3840. // add to list of script sources and run it
  3841. npc_addsrcfile(message);
  3842. npc_parsesrcfile(message,true);
  3843. npc_read_event_script();
  3844. clif_displaymessage(fd, msg_txt(262));
  3845. return 0;
  3846. }
  3847. ACMD_FUNC(unloadnpc)
  3848. {
  3849. struct npc_data *nd;
  3850. char NPCname[NAME_LENGTH+1];
  3851. nullpo_retr(-1, sd);
  3852. memset(NPCname, '\0', sizeof(NPCname));
  3853. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3854. clif_displaymessage(fd, msg_txt(1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
  3855. return -1;
  3856. }
  3857. if ((nd = npc_name2id(NPCname)) == NULL) {
  3858. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3859. return -1;
  3860. }
  3861. npc_unload_duplicates(nd);
  3862. npc_unload(nd,true);
  3863. npc_read_event_script();
  3864. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3865. return 0;
  3866. }
  3867. /*==========================================
  3868. * time in txt for time command (by [Yor])
  3869. *------------------------------------------*/
  3870. char* txt_time(unsigned int duration)
  3871. {
  3872. int days, hours, minutes, seconds;
  3873. char temp[CHAT_SIZE_MAX];
  3874. static char temp1[CHAT_SIZE_MAX];
  3875. memset(temp, '\0', sizeof(temp));
  3876. memset(temp1, '\0', sizeof(temp1));
  3877. days = duration / (60 * 60 * 24);
  3878. duration = duration - (60 * 60 * 24 * days);
  3879. hours = duration / (60 * 60);
  3880. duration = duration - (60 * 60 * hours);
  3881. minutes = duration / 60;
  3882. seconds = duration - (60 * minutes);
  3883. if (days == 1)
  3884. sprintf(temp, msg_txt(219), days); // %d day
  3885. else if (days > 1)
  3886. sprintf(temp, msg_txt(220), days); // %d days
  3887. if (hours == 1)
  3888. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  3889. else if (hours > 1)
  3890. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  3891. if (minutes < 2)
  3892. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  3893. else
  3894. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  3895. if (seconds == 1)
  3896. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  3897. else if (seconds > 1)
  3898. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  3899. return temp1;
  3900. }
  3901. /*==========================================
  3902. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3903. * Calculation management of GM modification (@day/@night GM commands) is done
  3904. *------------------------------------------*/
  3905. ACMD_FUNC(servertime)
  3906. {
  3907. const struct TimerData * timer_data;
  3908. const struct TimerData * timer_data2;
  3909. time_t time_server; // variable for number of seconds (used with time() function)
  3910. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3911. char temp[CHAT_SIZE_MAX];
  3912. nullpo_retr(-1, sd);
  3913. memset(temp, '\0', sizeof(temp));
  3914. time(&time_server); // get time in seconds since 1/1/1970
  3915. datetime = localtime(&time_server); // convert seconds in structure
  3916. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3917. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3918. clif_displaymessage(fd, temp);
  3919. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3920. if (night_flag == 0)
  3921. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3922. else
  3923. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3924. } else if (battle_config.night_duration == 0)
  3925. if (night_flag == 1) { // we start with night
  3926. timer_data = get_timer(day_timer_tid);
  3927. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  3928. clif_displaymessage(fd, temp);
  3929. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  3930. } else
  3931. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3932. else if (battle_config.day_duration == 0)
  3933. if (night_flag == 0) { // we start with day
  3934. timer_data = get_timer(night_timer_tid);
  3935. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3936. clif_displaymessage(fd, temp);
  3937. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  3938. } else
  3939. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3940. else {
  3941. if (night_flag == 0) {
  3942. timer_data = get_timer(night_timer_tid);
  3943. timer_data2 = get_timer(day_timer_tid);
  3944. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3945. clif_displaymessage(fd, temp);
  3946. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3947. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  3948. else
  3949. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  3950. clif_displaymessage(fd, temp);
  3951. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3952. clif_displaymessage(fd, temp);
  3953. } else {
  3954. timer_data = get_timer(day_timer_tid);
  3955. timer_data2 = get_timer(night_timer_tid);
  3956. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  3957. clif_displaymessage(fd, temp);
  3958. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3959. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  3960. else
  3961. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  3962. clif_displaymessage(fd, temp);
  3963. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3964. clif_displaymessage(fd, temp);
  3965. }
  3966. }
  3967. return 0;
  3968. }
  3969. //Added by Coltaro
  3970. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  3971. //Well, using time_t could still work but for some reason that looks like more coding x_x
  3972. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  3973. {
  3974. const int factor_year = 518400; //12*30*24*60 = 518400
  3975. const int factor_month = 43200; //30*24*60 = 43200
  3976. const int factor_day = 1440; //24*60 = 1440
  3977. const int factor_hour = 60;
  3978. *year = jailtime/factor_year;
  3979. jailtime -= *year*factor_year;
  3980. *month = jailtime/factor_month;
  3981. jailtime -= *month*factor_month;
  3982. *day = jailtime/factor_day;
  3983. jailtime -= *day*factor_day;
  3984. *hour = jailtime/factor_hour;
  3985. jailtime -= *hour*factor_hour;
  3986. *minute = jailtime;
  3987. *year = *year > 0? *year : 0;
  3988. *month = *month > 0? *month : 0;
  3989. *day = *day > 0? *day : 0;
  3990. *hour = *hour > 0? *hour : 0;
  3991. *minute = *minute > 0? *minute : 0;
  3992. return;
  3993. }
  3994. /*==========================================
  3995. * @jail <char_name> by [Yor]
  3996. * Special warp! No check with nowarp and nowarpto flag
  3997. *------------------------------------------*/
  3998. ACMD_FUNC(jail)
  3999. {
  4000. struct map_session_data *pl_sd;
  4001. int x, y;
  4002. unsigned short m_index;
  4003. nullpo_retr(-1, sd);
  4004. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4005. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4006. clif_displaymessage(fd, msg_txt(1134)); // Please enter a player name (usage: @jail <char_name>).
  4007. return -1;
  4008. }
  4009. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4010. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4011. return -1;
  4012. }
  4013. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  4014. { // you can jail only lower or same GM
  4015. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4016. return -1;
  4017. }
  4018. if (pl_sd->sc.data[SC_JAILED])
  4019. {
  4020. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4021. return -1;
  4022. }
  4023. switch(rnd() % 2) { //Jail Locations
  4024. case 0:
  4025. m_index = mapindex_name2id(MAP_JAIL);
  4026. x = 24;
  4027. y = 75;
  4028. break;
  4029. default:
  4030. m_index = mapindex_name2id(MAP_JAIL);
  4031. x = 49;
  4032. y = 75;
  4033. break;
  4034. }
  4035. //Duration of INT_MAX to specify infinity.
  4036. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4037. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4038. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4039. return 0;
  4040. }
  4041. /*==========================================
  4042. * @unjail/@discharge <char_name> by [Yor]
  4043. * Special warp! No check with nowarp and nowarpto flag
  4044. *------------------------------------------*/
  4045. ACMD_FUNC(unjail)
  4046. {
  4047. struct map_session_data *pl_sd;
  4048. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4049. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4050. clif_displaymessage(fd, msg_txt(1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4051. return -1;
  4052. }
  4053. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4054. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4055. return -1;
  4056. }
  4057. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4058. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4059. return -1;
  4060. }
  4061. if (!pl_sd->sc.data[SC_JAILED])
  4062. {
  4063. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4064. return -1;
  4065. }
  4066. //Reset jail time to 1 sec.
  4067. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4068. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4069. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4070. return 0;
  4071. }
  4072. ACMD_FUNC(jailfor)
  4073. {
  4074. struct map_session_data *pl_sd = NULL;
  4075. int year, month, day, hour, minute, value;
  4076. char * modif_p;
  4077. int jailtime = 0,x,y;
  4078. short m_index = 0;
  4079. nullpo_retr(-1, sd);
  4080. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4081. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4082. return -1;
  4083. }
  4084. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4085. modif_p = atcmd_output;
  4086. year = month = day = hour = minute = 0;
  4087. while (modif_p[0] != '\0') {
  4088. value = atoi(modif_p);
  4089. if (value == 0)
  4090. modif_p++;
  4091. else {
  4092. if (modif_p[0] == '-' || modif_p[0] == '+')
  4093. modif_p++;
  4094. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4095. modif_p++;
  4096. if (modif_p[0] == 'n') {
  4097. minute = value;
  4098. modif_p++;
  4099. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4100. minute = value;
  4101. modif_p = modif_p + 2;
  4102. } else if (modif_p[0] == 'h') {
  4103. hour = value;
  4104. modif_p++;
  4105. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4106. day = value;
  4107. modif_p++;
  4108. } else if (modif_p[0] == 'm') {
  4109. month = value;
  4110. modif_p++;
  4111. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4112. year = value;
  4113. modif_p++;
  4114. } else if (modif_p[0] != '\0') {
  4115. modif_p++;
  4116. }
  4117. }
  4118. }
  4119. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4120. clif_displaymessage(fd, msg_txt(1136)); // Invalid time for jail command.
  4121. return -1;
  4122. }
  4123. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4124. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4125. return -1;
  4126. }
  4127. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4128. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4129. return -1;
  4130. }
  4131. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4132. if(jailtime==0) {
  4133. clif_displaymessage(fd, msg_txt(1136)); // Invalid time for jail command.
  4134. return -1;
  4135. }
  4136. //Added by Coltaro
  4137. if(pl_sd->sc.data[SC_JAILED] &&
  4138. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4139. { //Update the player's jail time
  4140. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4141. if (jailtime <= 0) {
  4142. jailtime = 0;
  4143. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4144. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4145. } else {
  4146. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4147. sprintf(atcmd_output,msg_txt(402),msg_txt(1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4148. clif_displaymessage(pl_sd->fd, atcmd_output);
  4149. sprintf(atcmd_output,msg_txt(402),msg_txt(1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4150. clif_displaymessage(fd, atcmd_output);
  4151. }
  4152. } else if (jailtime < 0) {
  4153. clif_displaymessage(fd, msg_txt(1136));
  4154. return -1;
  4155. }
  4156. //Jail locations, add more as you wish.
  4157. switch(rnd()%2)
  4158. {
  4159. case 1: //Jail #1
  4160. m_index = mapindex_name2id(MAP_JAIL);
  4161. x = 49; y = 75;
  4162. break;
  4163. default: //Default Jail
  4164. m_index = mapindex_name2id(MAP_JAIL);
  4165. x = 24; y = 75;
  4166. break;
  4167. }
  4168. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  4169. return 0;
  4170. }
  4171. //By Coltaro
  4172. ACMD_FUNC(jailtime)
  4173. {
  4174. int year, month, day, hour, minute;
  4175. nullpo_retr(-1, sd);
  4176. if (!sd->sc.data[SC_JAILED]) {
  4177. clif_displaymessage(fd, msg_txt(1139)); // You are not in jail.
  4178. return -1;
  4179. }
  4180. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4181. clif_displaymessage(fd, msg_txt(1140)); // You have been jailed indefinitely.
  4182. return 0;
  4183. }
  4184. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4185. clif_displaymessage(fd, msg_txt(1141)); // You have been jailed for an unknown amount of time.
  4186. return -1;
  4187. }
  4188. //Get remaining jail time
  4189. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4190. sprintf(atcmd_output,msg_txt(402),msg_txt(1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4191. clif_displaymessage(fd, atcmd_output);
  4192. return 0;
  4193. }
  4194. /*==========================================
  4195. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4196. *------------------------------------------*/
  4197. ACMD_FUNC(disguise)
  4198. {
  4199. int id = 0;
  4200. nullpo_retr(-1, sd);
  4201. if (!message || !*message) {
  4202. clif_displaymessage(fd, msg_txt(1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4203. return -1;
  4204. }
  4205. if ((id = atoi(message)) > 0)
  4206. { //Acquired an ID
  4207. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4208. id = 0; //Invalid id for either mobs or npcs.
  4209. } else { //Acquired a Name
  4210. if ((id = mobdb_searchname(message)) == 0)
  4211. {
  4212. struct npc_data* nd = npc_name2id(message);
  4213. if (nd != NULL)
  4214. id = nd->class_;
  4215. }
  4216. }
  4217. if (id == 0)
  4218. {
  4219. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4220. return -1;
  4221. }
  4222. if(pc_isriding(sd))
  4223. {
  4224. clif_displaymessage(fd, msg_txt(1144)); // Character cannot be disguised while mounted.
  4225. return -1;
  4226. }
  4227. pc_disguise(sd, id);
  4228. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4229. return 0;
  4230. }
  4231. /*==========================================
  4232. * DisguiseAll
  4233. *------------------------------------------*/
  4234. ACMD_FUNC(disguiseall)
  4235. {
  4236. int mob_id=0;
  4237. struct map_session_data *pl_sd;
  4238. struct s_mapiterator* iter;
  4239. nullpo_retr(-1, sd);
  4240. if (!message || !*message) {
  4241. clif_displaymessage(fd, msg_txt(1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4242. return -1;
  4243. }
  4244. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4245. mob_id = atoi(message);
  4246. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4247. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4248. return -1;
  4249. }
  4250. iter = mapit_getallusers();
  4251. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4252. pc_disguise(pl_sd, mob_id);
  4253. mapit_free(iter);
  4254. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4255. return 0;
  4256. }
  4257. /*==========================================
  4258. * DisguiseGuild
  4259. *------------------------------------------*/
  4260. ACMD_FUNC(disguiseguild)
  4261. {
  4262. int id = 0, i;
  4263. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4264. struct map_session_data *pl_sd;
  4265. struct guild *g;
  4266. memset(monster, '\0', sizeof(monster));
  4267. memset(guild, '\0', sizeof(guild));
  4268. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4269. clif_displaymessage(fd, msg_txt(1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4270. return -1;
  4271. }
  4272. if( (id = atoi(monster)) > 0 ) {
  4273. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4274. id = 0;
  4275. } else {
  4276. if( (id = mobdb_searchname(monster)) == 0 ) {
  4277. struct npc_data* nd = npc_name2id(monster);
  4278. if( nd != NULL )
  4279. id = nd->class_;
  4280. }
  4281. }
  4282. if( id == 0 ) {
  4283. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4284. return -1;
  4285. }
  4286. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4287. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4288. return -1;
  4289. }
  4290. for( i = 0; i < g->max_member; i++ )
  4291. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4292. pc_disguise(pl_sd, id);
  4293. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4294. return 0;
  4295. }
  4296. /*==========================================
  4297. * @undisguise by [Yor]
  4298. *------------------------------------------*/
  4299. ACMD_FUNC(undisguise)
  4300. {
  4301. nullpo_retr(-1, sd);
  4302. if (sd->disguise) {
  4303. pc_disguise(sd, 0);
  4304. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4305. } else {
  4306. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4307. return -1;
  4308. }
  4309. return 0;
  4310. }
  4311. /*==========================================
  4312. * UndisguiseAll
  4313. *------------------------------------------*/
  4314. ACMD_FUNC(undisguiseall)
  4315. {
  4316. struct map_session_data *pl_sd;
  4317. struct s_mapiterator* iter;
  4318. nullpo_retr(-1, sd);
  4319. iter = mapit_getallusers();
  4320. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4321. if( pl_sd->disguise )
  4322. pc_disguise(pl_sd, 0);
  4323. mapit_free(iter);
  4324. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4325. return 0;
  4326. }
  4327. /*==========================================
  4328. * UndisguiseGuild
  4329. *------------------------------------------*/
  4330. ACMD_FUNC(undisguiseguild)
  4331. {
  4332. char guild_name[NAME_LENGTH];
  4333. struct map_session_data *pl_sd;
  4334. struct guild *g;
  4335. int i;
  4336. nullpo_retr(-1, sd);
  4337. memset(guild_name, '\0', sizeof(guild_name));
  4338. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4339. clif_displaymessage(fd, msg_txt(1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4340. return -1;
  4341. }
  4342. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4343. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4344. return -1;
  4345. }
  4346. for(i = 0; i < g->max_member; i++)
  4347. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4348. pc_disguise(pl_sd, 0);
  4349. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4350. return 0;
  4351. }
  4352. /*==========================================
  4353. * @exp by [Skotlex]
  4354. *------------------------------------------*/
  4355. ACMD_FUNC(exp)
  4356. {
  4357. char output[CHAT_SIZE_MAX];
  4358. double nextb, nextj;
  4359. nullpo_retr(-1, sd);
  4360. memset(output, '\0', sizeof(output));
  4361. nextb = pc_nextbaseexp(sd);
  4362. if (nextb)
  4363. nextb = sd->status.base_exp*100.0/nextb;
  4364. nextj = pc_nextjobexp(sd);
  4365. if (nextj)
  4366. nextj = sd->status.job_exp*100.0/nextj;
  4367. sprintf(output, msg_txt(1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4368. clif_displaymessage(fd, output);
  4369. return 0;
  4370. }
  4371. /*==========================================
  4372. * @broadcast by [Valaris]
  4373. *------------------------------------------*/
  4374. ACMD_FUNC(broadcast)
  4375. {
  4376. nullpo_retr(-1, sd);
  4377. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4378. if (!message || !*message) {
  4379. clif_displaymessage(fd, msg_txt(1149)); // Please enter a message (usage: @broadcast <message>).
  4380. return -1;
  4381. }
  4382. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4383. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4384. return 0;
  4385. }
  4386. /*==========================================
  4387. * @localbroadcast by [Valaris]
  4388. *------------------------------------------*/
  4389. ACMD_FUNC(localbroadcast)
  4390. {
  4391. nullpo_retr(-1, sd);
  4392. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4393. if (!message || !*message) {
  4394. clif_displaymessage(fd, msg_txt(1150)); // Please enter a message (usage: @localbroadcast <message>).
  4395. return -1;
  4396. }
  4397. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4398. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4399. return 0;
  4400. }
  4401. /*==========================================
  4402. * @email <actual@email> <new@email> by [Yor]
  4403. *------------------------------------------*/
  4404. ACMD_FUNC(email)
  4405. {
  4406. char actual_email[100];
  4407. char new_email[100];
  4408. nullpo_retr(-1, sd);
  4409. memset(actual_email, '\0', sizeof(actual_email));
  4410. memset(new_email, '\0', sizeof(new_email));
  4411. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4412. clif_displaymessage(fd, msg_txt(1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4413. return -1;
  4414. }
  4415. if (e_mail_check(actual_email) == 0) {
  4416. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4417. return -1;
  4418. } else if (e_mail_check(new_email) == 0) {
  4419. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4420. return -1;
  4421. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4422. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4423. return -1;
  4424. } else if (strcmpi(actual_email, new_email) == 0) {
  4425. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4426. return -1;
  4427. }
  4428. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4429. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4430. return 0;
  4431. }
  4432. /*==========================================
  4433. *@effect
  4434. *------------------------------------------*/
  4435. ACMD_FUNC(effect)
  4436. {
  4437. int type = 0, flag = 0;
  4438. nullpo_retr(-1, sd);
  4439. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4440. clif_displaymessage(fd, msg_txt(1152)); // Please enter an effect number (usage: @effect <effect number>).
  4441. return -1;
  4442. }
  4443. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4444. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4445. return 0;
  4446. }
  4447. /*==========================================
  4448. * @killer by MouseJstr
  4449. * enable killing players even when not in pvp
  4450. *------------------------------------------*/
  4451. ACMD_FUNC(killer)
  4452. {
  4453. nullpo_retr(-1, sd);
  4454. sd->state.killer = !sd->state.killer;
  4455. if(sd->state.killer)
  4456. clif_displaymessage(fd, msg_txt(241));
  4457. else {
  4458. clif_displaymessage(fd, msg_txt(292));
  4459. pc_stop_attack(sd);
  4460. }
  4461. return 0;
  4462. }
  4463. /*==========================================
  4464. * @killable by MouseJstr
  4465. * enable other people killing you
  4466. *------------------------------------------*/
  4467. ACMD_FUNC(killable)
  4468. {
  4469. nullpo_retr(-1, sd);
  4470. sd->state.killable = !sd->state.killable;
  4471. if(sd->state.killable)
  4472. clif_displaymessage(fd, msg_txt(242));
  4473. else {
  4474. clif_displaymessage(fd, msg_txt(288));
  4475. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4476. }
  4477. return 0;
  4478. }
  4479. /*==========================================
  4480. * @skillon by MouseJstr
  4481. * turn skills on for the map
  4482. *------------------------------------------*/
  4483. ACMD_FUNC(skillon)
  4484. {
  4485. nullpo_retr(-1, sd);
  4486. map[sd->bl.m].flag.noskill = 0;
  4487. clif_displaymessage(fd, msg_txt(244));
  4488. return 0;
  4489. }
  4490. /*==========================================
  4491. * @skilloff by MouseJstr
  4492. * Turn skills off on the map
  4493. *------------------------------------------*/
  4494. ACMD_FUNC(skilloff)
  4495. {
  4496. nullpo_retr(-1, sd);
  4497. map[sd->bl.m].flag.noskill = 1;
  4498. clif_displaymessage(fd, msg_txt(243));
  4499. return 0;
  4500. }
  4501. /*==========================================
  4502. * @npcmove by MouseJstr
  4503. * move a npc
  4504. *------------------------------------------*/
  4505. ACMD_FUNC(npcmove)
  4506. {
  4507. int x = 0, y = 0, m;
  4508. struct npc_data *nd = 0;
  4509. nullpo_retr(-1, sd);
  4510. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4511. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4512. clif_displaymessage(fd, msg_txt(1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4513. return -1;
  4514. }
  4515. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4516. {
  4517. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4518. return -1;
  4519. }
  4520. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4521. {
  4522. clif_displaymessage(fd, msg_txt(1154)); // NPC is not on this map.
  4523. return -1; //Not on a map.
  4524. }
  4525. x = cap_value(x, 0, map[m].xs-1);
  4526. y = cap_value(y, 0, map[m].ys-1);
  4527. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4528. map_moveblock(&nd->bl, x, y, gettick());
  4529. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4530. clif_displaymessage(fd, msg_txt(1155)); // NPC moved.
  4531. return 0;
  4532. }
  4533. /*==========================================
  4534. * @addwarp by MouseJstr
  4535. * Create a new static warp point.
  4536. *------------------------------------------*/
  4537. ACMD_FUNC(addwarp)
  4538. {
  4539. char mapname[32];
  4540. int x,y;
  4541. unsigned short m;
  4542. struct npc_data* nd;
  4543. nullpo_retr(-1, sd);
  4544. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4545. clif_displaymessage(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y>
  4546. return -1;
  4547. }
  4548. m = mapindex_name2id(mapname);
  4549. if( m == 0 )
  4550. {
  4551. sprintf(atcmd_output, msg_txt(1157), mapname); // Unknown map '%s'.
  4552. clif_displaymessage(fd, atcmd_output);
  4553. return -1;
  4554. }
  4555. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4556. if( nd == NULL )
  4557. return -1;
  4558. sprintf(atcmd_output, msg_txt(1158), nd->exname); // New warp NPC '%s' created.
  4559. clif_displaymessage(fd, atcmd_output);
  4560. return 0;
  4561. }
  4562. /*==========================================
  4563. * @follow by [MouseJstr]
  4564. * Follow a player .. staying no more then 5 spaces away
  4565. *------------------------------------------*/
  4566. ACMD_FUNC(follow)
  4567. {
  4568. struct map_session_data *pl_sd = NULL;
  4569. nullpo_retr(-1, sd);
  4570. if (!message || !*message) {
  4571. if (sd->followtarget == -1)
  4572. return -1;
  4573. pc_stop_following (sd);
  4574. clif_displaymessage(fd, msg_txt(1159)); // Follow mode OFF.
  4575. return 0;
  4576. }
  4577. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4578. {
  4579. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4580. return -1;
  4581. }
  4582. if (sd->followtarget == pl_sd->bl.id) {
  4583. pc_stop_following (sd);
  4584. clif_displaymessage(fd, msg_txt(1159)); // Follow mode OFF.
  4585. } else {
  4586. pc_follow(sd, pl_sd->bl.id);
  4587. clif_displaymessage(fd, msg_txt(1160)); // Follow mode ON.
  4588. }
  4589. return 0;
  4590. }
  4591. /*==========================================
  4592. * @dropall by [MouseJstr]
  4593. * Drop all your possession on the ground
  4594. *------------------------------------------*/
  4595. ACMD_FUNC(dropall)
  4596. {
  4597. int i;
  4598. nullpo_retr(-1, sd);
  4599. for (i = 0; i < MAX_INVENTORY; i++) {
  4600. if (sd->status.inventory[i].amount) {
  4601. if(sd->status.inventory[i].equip != 0)
  4602. pc_unequipitem(sd, i, 3);
  4603. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4604. }
  4605. }
  4606. return 0;
  4607. }
  4608. /*==========================================
  4609. * @storeall by [MouseJstr]
  4610. * Put everything into storage
  4611. *------------------------------------------*/
  4612. ACMD_FUNC(storeall)
  4613. {
  4614. int i;
  4615. nullpo_retr(-1, sd);
  4616. if (sd->state.storage_flag != 1)
  4617. { //Open storage.
  4618. if( storage_storageopen(sd) == 1 ) {
  4619. clif_displaymessage(fd, msg_txt(1161)); // You currently cannot open your storage.
  4620. return -1;
  4621. }
  4622. }
  4623. for (i = 0; i < MAX_INVENTORY; i++) {
  4624. if (sd->status.inventory[i].amount) {
  4625. if(sd->status.inventory[i].equip != 0)
  4626. pc_unequipitem(sd, i, 3);
  4627. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4628. }
  4629. }
  4630. storage_storageclose(sd);
  4631. clif_displaymessage(fd, msg_txt(1162)); // All items stored.
  4632. return 0;
  4633. }
  4634. /*==========================================
  4635. * @skillid by [MouseJstr]
  4636. * lookup a skill by name
  4637. *------------------------------------------*/
  4638. ACMD_FUNC(skillid)
  4639. {
  4640. int skillen, idx;
  4641. nullpo_retr(-1, sd);
  4642. if (!message || !*message)
  4643. {
  4644. clif_displaymessage(fd, msg_txt(1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4645. return -1;
  4646. }
  4647. skillen = strlen(message);
  4648. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4649. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4650. {
  4651. sprintf(atcmd_output, msg_txt(1164), idx, skill_db[idx].desc); // skill %d: %s
  4652. clif_displaymessage(fd, atcmd_output);
  4653. }
  4654. }
  4655. return 0;
  4656. }
  4657. /*==========================================
  4658. * @useskill by [MouseJstr]
  4659. * A way of using skills without having to find them in the skills menu
  4660. *------------------------------------------*/
  4661. ACMD_FUNC(useskill)
  4662. {
  4663. struct map_session_data *pl_sd = NULL;
  4664. struct block_list *bl;
  4665. int skillnum;
  4666. int skilllv;
  4667. char target[100];
  4668. nullpo_retr(-1, sd);
  4669. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4670. clif_displaymessage(fd, msg_txt(1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4671. return -1;
  4672. }
  4673. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4674. {
  4675. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4676. return -1;
  4677. }
  4678. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4679. {
  4680. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4681. return -1;
  4682. }
  4683. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4684. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4685. bl = &sd->hd->bl;
  4686. else
  4687. bl = &sd->bl;
  4688. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4689. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4690. else
  4691. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4692. return 0;
  4693. }
  4694. /*==========================================
  4695. * @displayskill by [Skotlex]
  4696. * Debug command to locate new skill IDs. It sends the
  4697. * three possible skill-effect packets to the area.
  4698. *------------------------------------------*/
  4699. ACMD_FUNC(displayskill)
  4700. {
  4701. struct status_data * status;
  4702. unsigned int tick;
  4703. int skillnum;
  4704. int skilllv = 1;
  4705. nullpo_retr(-1, sd);
  4706. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4707. {
  4708. clif_displaymessage(fd, msg_txt(1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4709. return -1;
  4710. }
  4711. status = status_get_status_data(&sd->bl);
  4712. tick = gettick();
  4713. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4714. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4715. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4716. return 0;
  4717. }
  4718. /*==========================================
  4719. * @skilltree by [MouseJstr]
  4720. * prints the skill tree for a player required to get to a skill
  4721. *------------------------------------------*/
  4722. ACMD_FUNC(skilltree)
  4723. {
  4724. struct map_session_data *pl_sd = NULL;
  4725. int skillnum;
  4726. int meets, j, c=0;
  4727. char target[NAME_LENGTH];
  4728. struct skill_tree_entry *ent;
  4729. nullpo_retr(-1, sd);
  4730. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4731. clif_displaymessage(fd, msg_txt(1167)); // Usage: @skilltree <skill ID> <target>
  4732. return -1;
  4733. }
  4734. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4735. {
  4736. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4737. return -1;
  4738. }
  4739. c = pc_calc_skilltree_normalize_job(pl_sd);
  4740. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4741. sprintf(atcmd_output, msg_txt(1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  4742. clif_displaymessage(fd, atcmd_output);
  4743. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  4744. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4745. {
  4746. clif_displaymessage(fd, msg_txt(1169)); // The player cannot use that skill.
  4747. return 0;
  4748. }
  4749. ent = &skill_tree[c][j];
  4750. meets = 1;
  4751. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4752. {
  4753. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4754. {
  4755. sprintf(atcmd_output, msg_txt(1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  4756. clif_displaymessage(fd, atcmd_output);
  4757. meets = 0;
  4758. }
  4759. }
  4760. if (meets == 1) {
  4761. clif_displaymessage(fd, msg_txt(1171)); // The player meets all the requirements for that skill.
  4762. }
  4763. return 0;
  4764. }
  4765. // Hand a ring with partners name on it to this char
  4766. void getring (struct map_session_data* sd)
  4767. {
  4768. int flag, item_id;
  4769. struct item item_tmp;
  4770. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4771. memset(&item_tmp, 0, sizeof(item_tmp));
  4772. item_tmp.nameid = item_id;
  4773. item_tmp.identify = 1;
  4774. item_tmp.card[0] = 255;
  4775. item_tmp.card[2] = sd->status.partner_id;
  4776. item_tmp.card[3] = sd->status.partner_id >> 16;
  4777. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4778. clif_additem(sd,0,0,flag);
  4779. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4780. }
  4781. }
  4782. /*==========================================
  4783. * @marry by [MouseJstr], fixed by Lupus
  4784. * Marry two players
  4785. *------------------------------------------*/
  4786. ACMD_FUNC(marry)
  4787. {
  4788. struct map_session_data *pl_sd = NULL;
  4789. char player_name[NAME_LENGTH] = "";
  4790. nullpo_retr(-1, sd);
  4791. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4792. clif_displaymessage(fd, msg_txt(1172)); // Usage: @marry <char name>
  4793. return -1;
  4794. }
  4795. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4796. clif_displaymessage(fd, msg_txt(3));
  4797. return -1;
  4798. }
  4799. if (pc_marriage(sd, pl_sd) == 0) {
  4800. clif_displaymessage(fd, msg_txt(1173)); // They are married... wish them well.
  4801. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4802. getring(sd); // Auto-give named rings (Aru)
  4803. getring(pl_sd);
  4804. return 0;
  4805. }
  4806. clif_displaymessage(fd, msg_txt(1174)); // The two cannot wed because one is either a baby or already married.
  4807. return -1;
  4808. }
  4809. /*==========================================
  4810. * @divorce by [MouseJstr], fixed by [Lupus]
  4811. * divorce two players
  4812. *------------------------------------------*/
  4813. ACMD_FUNC(divorce)
  4814. {
  4815. nullpo_retr(-1, sd);
  4816. if (pc_divorce(sd) != 0) {
  4817. sprintf(atcmd_output, msg_txt(1175), sd->status.name); // '%s' is not married.
  4818. clif_displaymessage(fd, atcmd_output);
  4819. return -1;
  4820. }
  4821. sprintf(atcmd_output, msg_txt(1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4822. clif_displaymessage(fd, atcmd_output);
  4823. return 0;
  4824. }
  4825. /*==========================================
  4826. * @changelook by [Celest]
  4827. *------------------------------------------*/
  4828. ACMD_FUNC(changelook)
  4829. {
  4830. int i, j = 0, k = 0;
  4831. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4832. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4833. clif_displaymessage(fd, msg_txt(1177)); // Usage: @changelook {<position>} <view id>
  4834. clif_displaymessage(fd, msg_txt(1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4835. return -1;
  4836. } else if ( i == 2 ) {
  4837. if (j < 1 || j > 7)
  4838. j = 1;
  4839. j = pos[j - 1];
  4840. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4841. k = j; // swap
  4842. j = LOOK_HEAD_TOP;
  4843. }
  4844. clif_changelook(&sd->bl,j,k);
  4845. return 0;
  4846. }
  4847. /*==========================================
  4848. * @autotrade by durf [Lupus] [Paradox924X]
  4849. * Turns on/off Autotrade for a specific player
  4850. *------------------------------------------*/
  4851. ACMD_FUNC(autotrade)
  4852. {
  4853. nullpo_retr(-1, sd);
  4854. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4855. clif_displaymessage(fd, msg_txt(1179)); // Autotrade is not allowed on this map.
  4856. return -1;
  4857. }
  4858. if( pc_isdead(sd) ) {
  4859. clif_displaymessage(fd, msg_txt(1180)); // You cannot autotrade when dead.
  4860. return -1;
  4861. }
  4862. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4863. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  4864. return -1;
  4865. }
  4866. sd->state.autotrade = 1;
  4867. if( battle_config.at_timeout )
  4868. {
  4869. int timeout = atoi(message);
  4870. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  4871. }
  4872. clif_authfail_fd(fd, 15);
  4873. return 0;
  4874. }
  4875. /*==========================================
  4876. * @changegm by durf (changed by Lupus)
  4877. * Changes Master of your Guild to a specified guild member
  4878. *------------------------------------------*/
  4879. ACMD_FUNC(changegm)
  4880. {
  4881. struct guild *g;
  4882. struct map_session_data *pl_sd;
  4883. nullpo_retr(-1, sd);
  4884. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name)) {
  4885. clif_displaymessage(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
  4886. return -1;
  4887. }
  4888. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4889. clif_displaymessage(fd, msg_txt(1182)); // You cannot change guild leaders on this map.
  4890. return -1;
  4891. }
  4892. if( !message[0] ) {
  4893. clif_displaymessage(fd, msg_txt(1183)); // Usage: @changegm <guild_member_name>
  4894. return -1;
  4895. }
  4896. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4897. clif_displaymessage(fd, msg_txt(1184)); // Target character must be online and be a guild member.
  4898. return -1;
  4899. }
  4900. guild_gm_change(sd->status.guild_id, pl_sd);
  4901. return 0;
  4902. }
  4903. /*==========================================
  4904. * @changeleader by Skotlex
  4905. * Changes the leader of a party.
  4906. *------------------------------------------*/
  4907. ACMD_FUNC(changeleader)
  4908. {
  4909. nullpo_retr(-1, sd);
  4910. if( !message[0] )
  4911. {
  4912. clif_displaymessage(fd, msg_txt(1185)); // Usage: @changeleader <party_member_name>
  4913. return -1;
  4914. }
  4915. if (party_changeleader(sd, map_nick2sd((char *) message)))
  4916. return 0;
  4917. return -1;
  4918. }
  4919. /*==========================================
  4920. * @partyoption by Skotlex
  4921. * Used to change the item share setting of a party.
  4922. *------------------------------------------*/
  4923. ACMD_FUNC(partyoption)
  4924. {
  4925. struct party_data *p;
  4926. int mi, option;
  4927. char w1[16], w2[16];
  4928. nullpo_retr(-1, sd);
  4929. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4930. {
  4931. clif_displaymessage(fd, msg_txt(282));
  4932. return -1;
  4933. }
  4934. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4935. if (mi == MAX_PARTY)
  4936. return -1; //Shouldn't happen
  4937. if (!p->party.member[mi].leader)
  4938. {
  4939. clif_displaymessage(fd, msg_txt(282));
  4940. return -1;
  4941. }
  4942. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4943. {
  4944. clif_displaymessage(fd, msg_txt(1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  4945. return -1;
  4946. }
  4947. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4948. //Change item share type.
  4949. if (option != p->party.item)
  4950. party_changeoption(sd, p->party.exp, option);
  4951. else
  4952. clif_displaymessage(fd, msg_txt(286));
  4953. return 0;
  4954. }
  4955. /*==========================================
  4956. * @autoloot by Upa-Kun
  4957. * Turns on/off AutoLoot for a specific player
  4958. *------------------------------------------*/
  4959. ACMD_FUNC(autoloot)
  4960. {
  4961. int rate;
  4962. double drate;
  4963. nullpo_retr(-1, sd);
  4964. // autoloot command without value
  4965. if(!message || !*message)
  4966. {
  4967. if (sd->state.autoloot)
  4968. rate = 0;
  4969. else
  4970. rate = 10000;
  4971. } else {
  4972. drate = atof(message);
  4973. rate = (int)(drate*100);
  4974. }
  4975. if (rate < 0) rate = 0;
  4976. if (rate > 10000) rate = 10000;
  4977. sd->state.autoloot = rate;
  4978. if (sd->state.autoloot) {
  4979. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  4980. clif_displaymessage(fd, atcmd_output);
  4981. }else
  4982. clif_displaymessage(fd, msg_txt(1188)); // Autoloot is now off.
  4983. return 0;
  4984. }
  4985. /*==========================================
  4986. * @alootid
  4987. *------------------------------------------*/
  4988. ACMD_FUNC(autolootitem)
  4989. {
  4990. struct item_data *item_data = NULL;
  4991. int i;
  4992. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4993. if (message && *message) {
  4994. if (message[0] == '+') {
  4995. message++;
  4996. action = 1;
  4997. }
  4998. else if (message[0] == '-') {
  4999. message++;
  5000. action = 2;
  5001. }
  5002. else if (!strcmp(message,"reset"))
  5003. action = 4;
  5004. }
  5005. if (action < 3) // add or remove
  5006. {
  5007. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5008. item_data = itemdb_searchname(message);
  5009. if (!item_data) {
  5010. // No items founds in the DB with Id or Name
  5011. clif_displaymessage(fd, msg_txt(1189)); // Item not found.
  5012. return -1;
  5013. }
  5014. }
  5015. switch(action) {
  5016. case 1:
  5017. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5018. if (i != AUTOLOOTITEM_SIZE) {
  5019. clif_displaymessage(fd, msg_txt(1190)); // You're already autolooting this item.
  5020. return -1;
  5021. }
  5022. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5023. if (i == AUTOLOOTITEM_SIZE) {
  5024. clif_displaymessage(fd, msg_txt(1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5025. return -1;
  5026. }
  5027. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5028. sprintf(atcmd_output, msg_txt(1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5029. clif_displaymessage(fd, atcmd_output);
  5030. sd->state.autolooting = 1;
  5031. break;
  5032. case 2:
  5033. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5034. if (i == AUTOLOOTITEM_SIZE) {
  5035. clif_displaymessage(fd, msg_txt(1193)); // You're currently not autolooting this item.
  5036. return -1;
  5037. }
  5038. sd->state.autolootid[i] = 0;
  5039. sprintf(atcmd_output, msg_txt(1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5040. clif_displaymessage(fd, atcmd_output);
  5041. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5042. if (i == AUTOLOOTITEM_SIZE) {
  5043. sd->state.autolooting = 0;
  5044. }
  5045. break;
  5046. case 3:
  5047. sprintf(atcmd_output, msg_txt(1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5048. clif_displaymessage(fd, atcmd_output);
  5049. clif_displaymessage(fd, msg_txt(1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  5050. clif_displaymessage(fd, msg_txt(1197)); // "@alootid reset" will clear your autolootitem list.
  5051. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5052. if (i == AUTOLOOTITEM_SIZE) {
  5053. clif_displaymessage(fd, msg_txt(1198)); // Your autolootitem list is empty.
  5054. } else {
  5055. clif_displaymessage(fd, msg_txt(1199)); // Items on your autolootitem list:
  5056. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5057. {
  5058. if (sd->state.autolootid[i] == 0)
  5059. continue;
  5060. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5061. ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
  5062. continue;
  5063. }
  5064. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5065. clif_displaymessage(fd, atcmd_output);
  5066. }
  5067. }
  5068. break;
  5069. case 4:
  5070. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5071. clif_displaymessage(fd, msg_txt(1200)); // Your autolootitem list has been reset.
  5072. sd->state.autolooting = 0;
  5073. break;
  5074. }
  5075. return 0;
  5076. }
  5077. /**
  5078. * No longer available, keeping here just in case it's back someday. [Ind]
  5079. **/
  5080. /*==========================================
  5081. * It is made to rain.
  5082. *------------------------------------------*/
  5083. //ACMD_FUNC(rain)
  5084. //{
  5085. // nullpo_retr(-1, sd);
  5086. // if (map[sd->bl.m].flag.rain) {
  5087. // map[sd->bl.m].flag.rain=0;
  5088. // clif_weather(sd->bl.m);
  5089. // clif_displaymessage(fd, msg_txt(1201)); // The rain has stopped.
  5090. // } else {
  5091. // map[sd->bl.m].flag.rain=1;
  5092. // clif_weather(sd->bl.m);
  5093. // clif_displaymessage(fd, msg_txt(1202)); // It has started to rain.
  5094. // }
  5095. // return 0;
  5096. //}
  5097. /*==========================================
  5098. * It is made to snow.
  5099. *------------------------------------------*/
  5100. ACMD_FUNC(snow)
  5101. {
  5102. nullpo_retr(-1, sd);
  5103. if (map[sd->bl.m].flag.snow) {
  5104. map[sd->bl.m].flag.snow=0;
  5105. clif_weather(sd->bl.m);
  5106. clif_displaymessage(fd, msg_txt(1203)); // Snow has stopped falling.
  5107. } else {
  5108. map[sd->bl.m].flag.snow=1;
  5109. clif_weather(sd->bl.m);
  5110. clif_displaymessage(fd, msg_txt(1204)); // It has started to snow.
  5111. }
  5112. return 0;
  5113. }
  5114. /*==========================================
  5115. * Cherry tree snowstorm is made to fall. (Sakura)
  5116. *------------------------------------------*/
  5117. ACMD_FUNC(sakura)
  5118. {
  5119. nullpo_retr(-1, sd);
  5120. if (map[sd->bl.m].flag.sakura) {
  5121. map[sd->bl.m].flag.sakura=0;
  5122. clif_weather(sd->bl.m);
  5123. clif_displaymessage(fd, msg_txt(1205)); // Cherry tree leaves no longer fall.
  5124. } else {
  5125. map[sd->bl.m].flag.sakura=1;
  5126. clif_weather(sd->bl.m);
  5127. clif_displaymessage(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall.
  5128. }
  5129. return 0;
  5130. }
  5131. /*==========================================
  5132. * Clouds appear.
  5133. *------------------------------------------*/
  5134. ACMD_FUNC(clouds)
  5135. {
  5136. nullpo_retr(-1, sd);
  5137. if (map[sd->bl.m].flag.clouds) {
  5138. map[sd->bl.m].flag.clouds=0;
  5139. clif_weather(sd->bl.m);
  5140. clif_displaymessage(fd, msg_txt(1207)); // The clouds has disappear.
  5141. } else {
  5142. map[sd->bl.m].flag.clouds=1;
  5143. clif_weather(sd->bl.m);
  5144. clif_displaymessage(fd, msg_txt(1208)); // Clouds appear.
  5145. }
  5146. return 0;
  5147. }
  5148. /*==========================================
  5149. * Different type of clouds using effect 516
  5150. *------------------------------------------*/
  5151. ACMD_FUNC(clouds2)
  5152. {
  5153. nullpo_retr(-1, sd);
  5154. if (map[sd->bl.m].flag.clouds2) {
  5155. map[sd->bl.m].flag.clouds2=0;
  5156. clif_weather(sd->bl.m);
  5157. clif_displaymessage(fd, msg_txt(1209)); // The alternative clouds disappear.
  5158. } else {
  5159. map[sd->bl.m].flag.clouds2=1;
  5160. clif_weather(sd->bl.m);
  5161. clif_displaymessage(fd, msg_txt(1210)); // Alternative clouds appear.
  5162. }
  5163. return 0;
  5164. }
  5165. /*==========================================
  5166. * Fog hangs over.
  5167. *------------------------------------------*/
  5168. ACMD_FUNC(fog)
  5169. {
  5170. nullpo_retr(-1, sd);
  5171. if (map[sd->bl.m].flag.fog) {
  5172. map[sd->bl.m].flag.fog=0;
  5173. clif_weather(sd->bl.m);
  5174. clif_displaymessage(fd, msg_txt(1211)); // The fog has gone.
  5175. } else {
  5176. map[sd->bl.m].flag.fog=1;
  5177. clif_weather(sd->bl.m);
  5178. clif_displaymessage(fd, msg_txt(1212)); // Fog hangs over.
  5179. }
  5180. return 0;
  5181. }
  5182. /*==========================================
  5183. * Fallen leaves fall.
  5184. *------------------------------------------*/
  5185. ACMD_FUNC(leaves)
  5186. {
  5187. nullpo_retr(-1, sd);
  5188. if (map[sd->bl.m].flag.leaves) {
  5189. map[sd->bl.m].flag.leaves=0;
  5190. clif_weather(sd->bl.m);
  5191. clif_displaymessage(fd, msg_txt(1213)); // Leaves no longer fall.
  5192. } else {
  5193. map[sd->bl.m].flag.leaves=1;
  5194. clif_weather(sd->bl.m);
  5195. clif_displaymessage(fd, msg_txt(1214)); // Fallen leaves fall.
  5196. }
  5197. return 0;
  5198. }
  5199. /*==========================================
  5200. * Fireworks appear.
  5201. *------------------------------------------*/
  5202. ACMD_FUNC(fireworks)
  5203. {
  5204. nullpo_retr(-1, sd);
  5205. if (map[sd->bl.m].flag.fireworks) {
  5206. map[sd->bl.m].flag.fireworks=0;
  5207. clif_weather(sd->bl.m);
  5208. clif_displaymessage(fd, msg_txt(1215)); // Fireworks have ended.
  5209. } else {
  5210. map[sd->bl.m].flag.fireworks=1;
  5211. clif_weather(sd->bl.m);
  5212. clif_displaymessage(fd, msg_txt(1216)); // Fireworks have launched.
  5213. }
  5214. return 0;
  5215. }
  5216. /*==========================================
  5217. * Clearing Weather Effects by Dexity
  5218. *------------------------------------------*/
  5219. ACMD_FUNC(clearweather)
  5220. {
  5221. nullpo_retr(-1, sd);
  5222. /**
  5223. * No longer available, keeping here just in case it's back someday. [Ind]
  5224. **/
  5225. //map[sd->bl.m].flag.rain=0;
  5226. map[sd->bl.m].flag.snow=0;
  5227. map[sd->bl.m].flag.sakura=0;
  5228. map[sd->bl.m].flag.clouds=0;
  5229. map[sd->bl.m].flag.clouds2=0;
  5230. map[sd->bl.m].flag.fog=0;
  5231. map[sd->bl.m].flag.fireworks=0;
  5232. map[sd->bl.m].flag.leaves=0;
  5233. clif_weather(sd->bl.m);
  5234. clif_displaymessage(fd, msg_txt(291));
  5235. return 0;
  5236. }
  5237. /*===============================================================
  5238. * Sound Command - plays a sound for everyone around! [Codemaster]
  5239. *---------------------------------------------------------------*/
  5240. ACMD_FUNC(sound)
  5241. {
  5242. char sound_file[100];
  5243. memset(sound_file, '\0', sizeof(sound_file));
  5244. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5245. clif_displaymessage(fd, msg_txt(1217)); // Please enter a sound filename (usage: @sound <filename>).
  5246. return -1;
  5247. }
  5248. if(strstr(sound_file, ".wav") == NULL)
  5249. strcat(sound_file, ".wav");
  5250. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5251. return 0;
  5252. }
  5253. /*==========================================
  5254. * MOB Search
  5255. *------------------------------------------*/
  5256. ACMD_FUNC(mobsearch)
  5257. {
  5258. char mob_name[100];
  5259. int mob_id;
  5260. int number = 0;
  5261. struct s_mapiterator* it;
  5262. nullpo_retr(-1, sd);
  5263. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5264. clif_displaymessage(fd, msg_txt(1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5265. return -1;
  5266. }
  5267. if ((mob_id = atoi(mob_name)) == 0)
  5268. mob_id = mobdb_searchname(mob_name);
  5269. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5270. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1219),mob_name); // Invalid mob ID %s!
  5271. clif_displaymessage(fd, atcmd_output);
  5272. return -1;
  5273. }
  5274. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5275. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5276. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5277. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5278. clif_displaymessage(fd, atcmd_output);
  5279. it = mapit_geteachmob();
  5280. for(;;)
  5281. {
  5282. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5283. if( md == NULL )
  5284. break;// no more mobs
  5285. if( md->bl.m != sd->bl.m )
  5286. continue;
  5287. if( mob_id != -1 && md->class_ != mob_id )
  5288. continue;
  5289. ++number;
  5290. if( md->spawn_timer == INVALID_TIMER )
  5291. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5292. else
  5293. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5294. clif_displaymessage(fd, atcmd_output);
  5295. }
  5296. mapit_free(it);
  5297. return 0;
  5298. }
  5299. /*==========================================
  5300. * @cleanmap - cleans items on the ground
  5301. *------------------------------------------*/
  5302. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5303. {
  5304. nullpo_ret(bl);
  5305. map_clearflooritem(bl);
  5306. return 0;
  5307. }
  5308. ACMD_FUNC(cleanmap)
  5309. {
  5310. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5311. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5312. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5313. BL_ITEM);
  5314. clif_displaymessage(fd, msg_txt(1221)); // All dropped items have been cleaned up.
  5315. return 0;
  5316. }
  5317. /*==========================================
  5318. * make a NPC/PET talk
  5319. * @npctalkc [SnakeDrak]
  5320. *------------------------------------------*/
  5321. ACMD_FUNC(npctalk)
  5322. {
  5323. char name[NAME_LENGTH],mes[100],temp[100];
  5324. struct npc_data *nd;
  5325. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5326. unsigned long color=0;
  5327. if (sd->sc.count && //no "chatting" while muted.
  5328. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5329. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5330. return -1;
  5331. if(!ifcolor) {
  5332. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5333. clif_displaymessage(fd, msg_txt(1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5334. return -1;
  5335. }
  5336. }
  5337. else {
  5338. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5339. clif_displaymessage(fd, msg_txt(1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5340. return -1;
  5341. }
  5342. }
  5343. if (!(nd = npc_name2id(name))) {
  5344. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5345. return -1;
  5346. }
  5347. strtok(name, "#"); // discard extra name identifier if present
  5348. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5349. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5350. else clif_message(&nd->bl, temp);
  5351. return 0;
  5352. }
  5353. ACMD_FUNC(pettalk)
  5354. {
  5355. char mes[100],temp[100];
  5356. struct pet_data *pd;
  5357. nullpo_retr(-1, sd);
  5358. if ( battle_config.min_chat_delay ) {
  5359. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5360. return 0;
  5361. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5362. }
  5363. if(!sd->status.pet_id || !(pd=sd->pd))
  5364. {
  5365. clif_displaymessage(fd, msg_txt(184));
  5366. return -1;
  5367. }
  5368. if (sd->sc.count && //no "chatting" while muted.
  5369. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5370. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5371. return -1;
  5372. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5373. clif_displaymessage(fd, msg_txt(1224)); // Please enter a message (usage: @pettalk <message>).
  5374. return -1;
  5375. }
  5376. if (message[0] == '/')
  5377. {// pet emotion processing
  5378. const char* emo[] = {
  5379. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5380. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5381. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5382. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5383. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5384. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5385. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5386. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5387. "/whisp"
  5388. };
  5389. int i;
  5390. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5391. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5392. if( i < ARRAYLENGTH(emo) )
  5393. {
  5394. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5395. sd->emotionlasttime = time(NULL);
  5396. return 0;
  5397. }
  5398. sd->emotionlasttime = time(NULL);
  5399. clif_emotion(&pd->bl, i);
  5400. return 0;
  5401. }
  5402. }
  5403. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5404. clif_message(&pd->bl, temp);
  5405. return 0;
  5406. }
  5407. /// @users - displays the number of players present on each map (and percentage)
  5408. /// #users displays on the target user instead of self
  5409. ACMD_FUNC(users)
  5410. {
  5411. char buf[CHAT_SIZE_MAX];
  5412. int i;
  5413. int users[MAX_MAPINDEX];
  5414. int users_all;
  5415. struct s_mapiterator* iter;
  5416. memset(users, 0, sizeof(users));
  5417. users_all = 0;
  5418. // count users on each map
  5419. iter = mapit_getallusers();
  5420. for(;;)
  5421. {
  5422. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5423. if( sd2 == NULL )
  5424. break;// no more users
  5425. if( sd2->mapindex >= MAX_MAPINDEX )
  5426. continue;// invalid mapindex
  5427. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5428. if( users_all < INT_MAX ) ++users_all;
  5429. }
  5430. mapit_free(iter);
  5431. // display results for each map
  5432. for( i = 0; i < MAX_MAPINDEX; ++i )
  5433. {
  5434. if( users[i] == 0 )
  5435. continue;// empty
  5436. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5437. clif_displaymessage(sd->fd, buf);
  5438. }
  5439. // display overall count
  5440. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5441. clif_displaymessage(sd->fd, buf);
  5442. return 0;
  5443. }
  5444. /*==========================================
  5445. *
  5446. *------------------------------------------*/
  5447. ACMD_FUNC(reset)
  5448. {
  5449. pc_resetstate(sd);
  5450. pc_resetskill(sd,1);
  5451. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5452. clif_displaymessage(fd, atcmd_output);
  5453. return 0;
  5454. }
  5455. /*==========================================
  5456. *
  5457. *------------------------------------------*/
  5458. ACMD_FUNC(summon)
  5459. {
  5460. char name[NAME_LENGTH];
  5461. int mob_id = 0;
  5462. int duration = 0;
  5463. struct mob_data *md;
  5464. unsigned int tick=gettick();
  5465. nullpo_retr(-1, sd);
  5466. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5467. {
  5468. clif_displaymessage(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5469. return -1;
  5470. }
  5471. if (duration < 1)
  5472. duration =1;
  5473. else if (duration > 60)
  5474. duration =60;
  5475. if ((mob_id = atoi(name)) == 0)
  5476. mob_id = mobdb_searchname(name);
  5477. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5478. {
  5479. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5480. return -1;
  5481. }
  5482. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5483. if(!md)
  5484. return -1;
  5485. md->master_id=sd->bl.id;
  5486. md->special_state.ai=1;
  5487. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5488. clif_specialeffect(&md->bl,344,AREA);
  5489. mob_spawn(md);
  5490. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5491. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5492. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5493. return 0;
  5494. }
  5495. /*==========================================
  5496. * @adjgroup
  5497. * Temporarily move player to another group
  5498. * Useful during beta testing to allow players to use GM commands for short periods of time
  5499. *------------------------------------------*/
  5500. ACMD_FUNC(adjgroup)
  5501. {
  5502. int new_group = 0;
  5503. nullpo_retr(-1, sd);
  5504. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5505. clif_displaymessage(fd, msg_txt(1226)); // Usage: @adjgroup <group_id>
  5506. return -1;
  5507. }
  5508. if (!pc_group_exists(new_group)) {
  5509. clif_displaymessage(fd, msg_txt(1227)); // Specified group does not exist.
  5510. return -1;
  5511. }
  5512. sd->group_id = new_group;
  5513. pc_group_pc_load(sd);/* update cache */
  5514. clif_displaymessage(fd, msg_txt(1228)); // Group changed successfully.
  5515. clif_displaymessage(sd->fd, msg_txt(1229)); // Your group has changed.
  5516. return 0;
  5517. }
  5518. /*==========================================
  5519. * @trade by [MouseJstr]
  5520. * Open a trade window with a remote player
  5521. *------------------------------------------*/
  5522. ACMD_FUNC(trade)
  5523. {
  5524. struct map_session_data *pl_sd = NULL;
  5525. nullpo_retr(-1, sd);
  5526. if (!message || !*message) {
  5527. clif_displaymessage(fd, msg_txt(1230)); // Please enter a player name (usage: @trade <char name>).
  5528. return -1;
  5529. }
  5530. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5531. {
  5532. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5533. return -1;
  5534. }
  5535. trade_traderequest(sd, pl_sd);
  5536. return 0;
  5537. }
  5538. /*==========================================
  5539. * @setbattleflag by [MouseJstr]
  5540. * set a battle_config flag without having to reboot
  5541. *------------------------------------------*/
  5542. ACMD_FUNC(setbattleflag)
  5543. {
  5544. char flag[128], value[128];
  5545. nullpo_retr(-1, sd);
  5546. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5547. clif_displaymessage(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value>
  5548. return -1;
  5549. }
  5550. if (battle_set_value(flag, value) == 0)
  5551. {
  5552. clif_displaymessage(fd, msg_txt(1232)); // Unknown battle_config flag.
  5553. return -1;
  5554. }
  5555. clif_displaymessage(fd, msg_txt(1233)); // Set battle_config as requested.
  5556. return 0;
  5557. }
  5558. /*==========================================
  5559. * @unmute [Valaris]
  5560. *------------------------------------------*/
  5561. ACMD_FUNC(unmute)
  5562. {
  5563. struct map_session_data *pl_sd = NULL;
  5564. nullpo_retr(-1, sd);
  5565. if (!message || !*message) {
  5566. clif_displaymessage(fd, msg_txt(1234)); // Please enter a player name (usage: @unmute <char name>).
  5567. return -1;
  5568. }
  5569. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5570. {
  5571. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5572. return -1;
  5573. }
  5574. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5575. clif_displaymessage(sd->fd,msg_txt(1235)); // Player is not muted.
  5576. return -1;
  5577. }
  5578. pl_sd->status.manner = 0;
  5579. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5580. clif_displaymessage(sd->fd,msg_txt(1236)); // Player unmuted.
  5581. return 0;
  5582. }
  5583. /*==========================================
  5584. * @uptime by MC Cameri
  5585. *------------------------------------------*/
  5586. ACMD_FUNC(uptime)
  5587. {
  5588. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5589. minute = 60, days = 0, hours = 0, minutes = 0;
  5590. nullpo_retr(-1, sd);
  5591. seconds = get_uptime();
  5592. days = seconds/day;
  5593. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5594. hours = seconds/hour;
  5595. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5596. minutes = seconds/minute;
  5597. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5598. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5599. clif_displaymessage(fd, atcmd_output);
  5600. return 0;
  5601. }
  5602. /*==========================================
  5603. * @changesex <sex>
  5604. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5605. *------------------------------------------*/
  5606. ACMD_FUNC(changesex)
  5607. {
  5608. int i;
  5609. nullpo_retr(-1, sd);
  5610. pc_resetskill(sd,4);
  5611. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5612. for( i=0; i<EQI_MAX; i++ )
  5613. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5614. chrif_changesex(sd);
  5615. return 0;
  5616. }
  5617. /*================================================
  5618. * @mute - Mutes a player for a set amount of time
  5619. *------------------------------------------------*/
  5620. ACMD_FUNC(mute)
  5621. {
  5622. struct map_session_data *pl_sd = NULL;
  5623. int manner;
  5624. nullpo_retr(-1, sd);
  5625. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5626. clif_displaymessage(fd, msg_txt(1237)); // Usage: @mute <time> <char name>
  5627. return -1;
  5628. }
  5629. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5630. {
  5631. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5632. return -1;
  5633. }
  5634. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5635. {
  5636. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5637. return -1;
  5638. }
  5639. clif_manner_message(sd, 0);
  5640. clif_manner_message(pl_sd, 5);
  5641. if( pl_sd->status.manner < manner ) {
  5642. pl_sd->status.manner -= manner;
  5643. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5644. } else {
  5645. pl_sd->status.manner = 0;
  5646. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5647. }
  5648. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5649. return 0;
  5650. }
  5651. /*==========================================
  5652. * @refresh (like @jumpto <<yourself>>)
  5653. *------------------------------------------*/
  5654. ACMD_FUNC(refresh)
  5655. {
  5656. nullpo_retr(-1, sd);
  5657. clif_refresh(sd);
  5658. return 0;
  5659. }
  5660. /*==========================================
  5661. * @identify
  5662. * => GM's magnifier.
  5663. *------------------------------------------*/
  5664. ACMD_FUNC(identify)
  5665. {
  5666. int i,num;
  5667. nullpo_retr(-1, sd);
  5668. for(i=num=0;i<MAX_INVENTORY;i++){
  5669. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5670. num++;
  5671. }
  5672. }
  5673. if (num > 0) {
  5674. clif_item_identify_list(sd);
  5675. } else {
  5676. clif_displaymessage(fd,msg_txt(1238)); // There are no items to appraise.
  5677. }
  5678. return 0;
  5679. }
  5680. /*==========================================
  5681. * @gmotd (Global MOTD)
  5682. * by davidsiaw :P
  5683. *------------------------------------------*/
  5684. ACMD_FUNC(gmotd)
  5685. {
  5686. char buf[CHAT_SIZE_MAX];
  5687. size_t len;
  5688. FILE* fp;
  5689. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5690. {
  5691. while( fgets(buf, sizeof(buf), fp) )
  5692. {
  5693. if( buf[0] == '/' && buf[1] == '/' )
  5694. {
  5695. continue;
  5696. }
  5697. len = strlen(buf);
  5698. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5699. {// strip trailing EOL characters
  5700. len--;
  5701. }
  5702. if( len )
  5703. {
  5704. buf[len] = 0;
  5705. intif_broadcast(buf, len+1, 0);
  5706. }
  5707. }
  5708. fclose(fp);
  5709. }
  5710. return 0;
  5711. }
  5712. ACMD_FUNC(misceffect)
  5713. {
  5714. int effect = 0;
  5715. nullpo_retr(-1, sd);
  5716. if (!message || !*message)
  5717. return -1;
  5718. if (sscanf(message, "%d", &effect) < 1)
  5719. return -1;
  5720. clif_misceffect(&sd->bl,effect);
  5721. return 0;
  5722. }
  5723. /*==========================================
  5724. * MAIL SYSTEM
  5725. *------------------------------------------*/
  5726. ACMD_FUNC(mail)
  5727. {
  5728. nullpo_ret(sd);
  5729. mail_openmail(sd);
  5730. return 0;
  5731. }
  5732. /*==========================================
  5733. * Show Monster DB Info v 1.0
  5734. * originally by [Lupus]
  5735. *------------------------------------------*/
  5736. ACMD_FUNC(mobinfo)
  5737. {
  5738. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5739. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5740. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5741. char atcmd_output2[CHAT_SIZE_MAX];
  5742. struct item_data *item_data;
  5743. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5744. int count;
  5745. int i, j, k;
  5746. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5747. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5748. if (!message || !*message) {
  5749. clif_displaymessage(fd, msg_txt(1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5750. return -1;
  5751. }
  5752. // If monster identifier/name argument is a name
  5753. if ((i = mobdb_checkid(atoi(message))))
  5754. {
  5755. mob_array[0] = mob_db(i);
  5756. count = 1;
  5757. } else
  5758. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5759. if (!count) {
  5760. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5761. return -1;
  5762. }
  5763. if (count > MAX_SEARCH) {
  5764. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5765. clif_displaymessage(fd, atcmd_output);
  5766. count = MAX_SEARCH;
  5767. }
  5768. for (k = 0; k < count; k++) {
  5769. mob = mob_array[k];
  5770. // stats
  5771. if (mob->mexp)
  5772. sprintf(atcmd_output, msg_txt(1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5773. else
  5774. sprintf(atcmd_output, msg_txt(1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5775. clif_displaymessage(fd, atcmd_output);
  5776. sprintf(atcmd_output, msg_txt(1242), mob->lv, mob->status.max_hp, mob->base_exp, mob->job_exp,MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
  5777. clif_displaymessage(fd, atcmd_output);
  5778. sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5779. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  5780. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5781. clif_displaymessage(fd, atcmd_output);
  5782. sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5783. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5784. mob->range2 , mob->range3, msize[mob->status.size],
  5785. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5786. clif_displaymessage(fd, atcmd_output);
  5787. // drops
  5788. clif_displaymessage(fd, msg_txt(1245)); // Drops:
  5789. strcpy(atcmd_output, " ");
  5790. j = 0;
  5791. for (i = 0; i < MAX_MOB_DROP; i++) {
  5792. int droprate;
  5793. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5794. continue;
  5795. droprate = mob->dropitem[i].p;
  5796. if (item_data->slot)
  5797. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  5798. else
  5799. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  5800. strcat(atcmd_output, atcmd_output2);
  5801. if (++j % 3 == 0) {
  5802. clif_displaymessage(fd, atcmd_output);
  5803. strcpy(atcmd_output, " ");
  5804. }
  5805. }
  5806. if (j == 0)
  5807. clif_displaymessage(fd, msg_txt(1246)); // This monster has no drops.
  5808. else if (j % 3 != 0)
  5809. clif_displaymessage(fd, atcmd_output);
  5810. // mvp
  5811. if (mob->mexp) {
  5812. sprintf(atcmd_output, msg_txt(1247), mob->mexp); // MVP Bonus EXP:%u
  5813. clif_displaymessage(fd, atcmd_output);
  5814. strcpy(atcmd_output, msg_txt(1248)); // MVP Items:
  5815. j = 0;
  5816. for (i = 0; i < MAX_MVP_DROP; i++) {
  5817. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5818. continue;
  5819. if (mob->mvpitem[i].p > 0) {
  5820. j++;
  5821. if (j == 1)
  5822. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5823. else
  5824. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5825. strcat(atcmd_output, atcmd_output2);
  5826. }
  5827. }
  5828. if (j == 0)
  5829. clif_displaymessage(fd, msg_txt(1249)); // This monster has no MVP prizes.
  5830. else
  5831. clif_displaymessage(fd, atcmd_output);
  5832. }
  5833. }
  5834. return 0;
  5835. }
  5836. /*=========================================
  5837. * @showmobs by KarLaeda
  5838. * => For 15 sec displays the mobs on minimap
  5839. *------------------------------------------*/
  5840. ACMD_FUNC(showmobs)
  5841. {
  5842. char mob_name[100];
  5843. int mob_id;
  5844. int number = 0;
  5845. struct s_mapiterator* it;
  5846. nullpo_retr(-1, sd);
  5847. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5848. return -1;
  5849. if((mob_id = atoi(mob_name)) == 0)
  5850. mob_id = mobdb_searchname(mob_name);
  5851. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5852. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1250),mob_name); // Invalid mob id %s!
  5853. clif_displaymessage(fd, atcmd_output);
  5854. return 0;
  5855. }
  5856. if(mob_db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  5857. clif_displaymessage(fd, msg_txt(1251)); // Can't show boss mobs!
  5858. return 0;
  5859. }
  5860. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5861. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5862. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5863. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s
  5864. mob_name, mapindex_id2name(sd->mapindex));
  5865. clif_displaymessage(fd, atcmd_output);
  5866. it = mapit_geteachmob();
  5867. for(;;)
  5868. {
  5869. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5870. if( md == NULL )
  5871. break;// no more mobs
  5872. if( md->bl.m != sd->bl.m )
  5873. continue;
  5874. if( mob_id != -1 && md->class_ != mob_id )
  5875. continue;
  5876. if( md->special_state.ai || md->master_id )
  5877. continue; // hide slaves and player summoned mobs
  5878. if( md->spawn_timer != INVALID_TIMER )
  5879. continue; // hide mobs waiting for respawn
  5880. ++number;
  5881. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5882. }
  5883. mapit_free(it);
  5884. return 0;
  5885. }
  5886. /*==========================================
  5887. * homunculus level up [orn]
  5888. *------------------------------------------*/
  5889. ACMD_FUNC(homlevel)
  5890. {
  5891. TBL_HOM * hd;
  5892. int level = 0, i = 0;
  5893. nullpo_retr(-1, sd);
  5894. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  5895. clif_displaymessage(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  5896. return -1;
  5897. }
  5898. if ( !merc_is_hom_active(sd->hd) ) {
  5899. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5900. return -1;
  5901. }
  5902. hd = sd->hd;
  5903. for (i = 1; i <= level && hd->exp_next; i++){
  5904. hd->homunculus.exp += hd->exp_next;
  5905. merc_hom_levelup(hd);
  5906. }
  5907. status_calc_homunculus(hd,0);
  5908. status_percent_heal(&hd->bl, 100, 100);
  5909. clif_specialeffect(&hd->bl,568,AREA);
  5910. return 0;
  5911. }
  5912. /*==========================================
  5913. * homunculus evolution H [orn]
  5914. *------------------------------------------*/
  5915. ACMD_FUNC(homevolution)
  5916. {
  5917. nullpo_retr(-1, sd);
  5918. if ( !merc_is_hom_active(sd->hd) ) {
  5919. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5920. return -1;
  5921. }
  5922. if ( !merc_hom_evolution(sd->hd) ) {
  5923. clif_displaymessage(fd, msg_txt(1255)); // Your homunculus doesn't evolve.
  5924. return -1;
  5925. }
  5926. clif_homskillinfoblock(sd);
  5927. return 0;
  5928. }
  5929. /*==========================================
  5930. * call choosen homunculus [orn]
  5931. *------------------------------------------*/
  5932. ACMD_FUNC(makehomun)
  5933. {
  5934. int homunid;
  5935. nullpo_retr(-1, sd);
  5936. if ( sd->status.hom_id ) {
  5937. clif_displaymessage(fd, msg_txt(450));
  5938. return -1;
  5939. }
  5940. if (!message || !*message) {
  5941. clif_displaymessage(fd, msg_txt(1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  5942. return -1;
  5943. }
  5944. homunid = atoi(message);
  5945. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  5946. {
  5947. clif_displaymessage(fd, msg_txt(1257)); // Invalid Homunculus ID.
  5948. return -1;
  5949. }
  5950. merc_create_homunculus_request(sd,homunid);
  5951. return 0;
  5952. }
  5953. /*==========================================
  5954. * modify homunculus intimacy [orn]
  5955. *------------------------------------------*/
  5956. ACMD_FUNC(homfriendly)
  5957. {
  5958. int friendly = 0;
  5959. nullpo_retr(-1, sd);
  5960. if ( !merc_is_hom_active(sd->hd) ) {
  5961. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5962. return -1;
  5963. }
  5964. if (!message || !*message) {
  5965. clif_displaymessage(fd, msg_txt(1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  5966. return -1;
  5967. }
  5968. friendly = atoi(message);
  5969. friendly = cap_value(friendly, 0, 1000);
  5970. sd->hd->homunculus.intimacy = friendly * 100 ;
  5971. clif_send_homdata(sd,SP_INTIMATE,friendly);
  5972. return 0;
  5973. }
  5974. /*==========================================
  5975. * modify homunculus hunger [orn]
  5976. *------------------------------------------*/
  5977. ACMD_FUNC(homhungry)
  5978. {
  5979. int hungry = 0;
  5980. nullpo_retr(-1, sd);
  5981. if ( !merc_is_hom_active(sd->hd) ) {
  5982. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5983. return -1;
  5984. }
  5985. if (!message || !*message) {
  5986. clif_displaymessage(fd, msg_txt(1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  5987. return -1;
  5988. }
  5989. hungry = atoi(message);
  5990. hungry = cap_value(hungry, 0, 100);
  5991. sd->hd->homunculus.hunger = hungry;
  5992. clif_send_homdata(sd,SP_HUNGRY,hungry);
  5993. return 0;
  5994. }
  5995. /*==========================================
  5996. * make the homunculus speak [orn]
  5997. *------------------------------------------*/
  5998. ACMD_FUNC(homtalk)
  5999. {
  6000. char mes[100],temp[100];
  6001. nullpo_retr(-1, sd);
  6002. if ( battle_config.min_chat_delay ) {
  6003. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6004. return 0;
  6005. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6006. }
  6007. if (sd->sc.count && //no "chatting" while muted.
  6008. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6009. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6010. return -1;
  6011. if ( !merc_is_hom_active(sd->hd) ) {
  6012. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6013. return -1;
  6014. }
  6015. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6016. clif_displaymessage(fd, msg_txt(1260)); // Please enter a message (usage: @homtalk <message>).
  6017. return -1;
  6018. }
  6019. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6020. clif_message(&sd->hd->bl, temp);
  6021. return 0;
  6022. }
  6023. /*==========================================
  6024. * Show homunculus stats
  6025. *------------------------------------------*/
  6026. ACMD_FUNC(hominfo)
  6027. {
  6028. struct homun_data *hd;
  6029. struct status_data *status;
  6030. nullpo_retr(-1, sd);
  6031. if ( !merc_is_hom_active(sd->hd) ) {
  6032. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6033. return -1;
  6034. }
  6035. hd = sd->hd;
  6036. status = status_get_status_data(&hd->bl);
  6037. clif_displaymessage(fd, msg_txt(1261)); // Homunculus stats:
  6038. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1262), // HP: %d/%d - SP: %d/%d
  6039. status->hp, status->max_hp, status->sp, status->max_sp);
  6040. clif_displaymessage(fd, atcmd_output);
  6041. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1263), // ATK: %d - MATK: %d~%d
  6042. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6043. clif_displaymessage(fd, atcmd_output);
  6044. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1264), // Hungry: %d - Intimacy: %u
  6045. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6046. clif_displaymessage(fd, atcmd_output);
  6047. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6048. msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6049. status->str, status->agi, status->vit,
  6050. status->int_, status->dex, status->luk);
  6051. clif_displaymessage(fd, atcmd_output);
  6052. return 0;
  6053. }
  6054. ACMD_FUNC(homstats)
  6055. {
  6056. struct homun_data *hd;
  6057. struct s_homunculus_db *db;
  6058. struct s_homunculus *hom;
  6059. int lv, min, max, evo;
  6060. nullpo_retr(-1, sd);
  6061. if ( !merc_is_hom_active(sd->hd) ) {
  6062. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6063. return -1;
  6064. }
  6065. hd = sd->hd;
  6066. hom = &hd->homunculus;
  6067. db = hd->homunculusDB;
  6068. lv = hom->level;
  6069. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6070. msg_txt(1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6071. clif_displaymessage(fd, atcmd_output);
  6072. lv--; //Since the first increase is at level 2.
  6073. evo = (hom->class_ == db->evo_class);
  6074. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6075. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6076. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6077. clif_displaymessage(fd, atcmd_output);
  6078. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6079. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6080. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6081. clif_displaymessage(fd, atcmd_output);
  6082. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6083. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6084. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6085. clif_displaymessage(fd, atcmd_output);
  6086. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6087. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6088. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6089. clif_displaymessage(fd, atcmd_output);
  6090. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6091. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6092. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6093. clif_displaymessage(fd, atcmd_output);
  6094. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6095. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6096. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6097. clif_displaymessage(fd, atcmd_output);
  6098. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6099. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6100. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6101. clif_displaymessage(fd, atcmd_output);
  6102. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6103. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6104. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6105. clif_displaymessage(fd, atcmd_output);
  6106. return 0;
  6107. }
  6108. ACMD_FUNC(homshuffle)
  6109. {
  6110. nullpo_retr(-1, sd);
  6111. if(!sd->hd)
  6112. return -1; // nothing to do
  6113. if(!merc_hom_shuffle(sd->hd))
  6114. return -1;
  6115. clif_displaymessage(sd->fd, msg_txt(1275)); // Homunculus stats altered.
  6116. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6117. return 0;
  6118. }
  6119. /*==========================================
  6120. * Show Items DB Info v 1.0
  6121. * originally by [Lupus]
  6122. *------------------------------------------*/
  6123. ACMD_FUNC(iteminfo)
  6124. {
  6125. struct item_data *item_data, *item_array[MAX_SEARCH];
  6126. int i, count = 1;
  6127. if (!message || !*message) {
  6128. clif_displaymessage(fd, msg_txt(1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6129. return -1;
  6130. }
  6131. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6132. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6133. if (!count) {
  6134. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6135. return -1;
  6136. }
  6137. if (count > MAX_SEARCH) {
  6138. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6139. clif_displaymessage(fd, atcmd_output);
  6140. count = MAX_SEARCH;
  6141. }
  6142. for (i = 0; i < count; i++) {
  6143. item_data = item_array[i];
  6144. sprintf(atcmd_output, msg_txt(1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6145. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6146. itemdb_typename(item_data->type),
  6147. (item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script
  6148. );
  6149. clif_displaymessage(fd, atcmd_output);
  6150. sprintf(atcmd_output, msg_txt(1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  6151. clif_displaymessage(fd, atcmd_output);
  6152. if (item_data->maxchance == -1)
  6153. strcpy(atcmd_output, msg_txt(1281)); // - Available in the shops only.
  6154. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6155. sprintf(atcmd_output, msg_txt(1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6156. else
  6157. strcpy(atcmd_output, msg_txt(1283)); // - Monsters don't drop this item.
  6158. clif_displaymessage(fd, atcmd_output);
  6159. }
  6160. return 0;
  6161. }
  6162. /*==========================================
  6163. * Show who drops the item.
  6164. *------------------------------------------*/
  6165. ACMD_FUNC(whodrops)
  6166. {
  6167. struct item_data *item_data, *item_array[MAX_SEARCH];
  6168. int i,j, count = 1;
  6169. if (!message || !*message) {
  6170. clif_displaymessage(fd, msg_txt(1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6171. return -1;
  6172. }
  6173. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6174. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6175. if (!count) {
  6176. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6177. return -1;
  6178. }
  6179. if (count > MAX_SEARCH) {
  6180. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6181. clif_displaymessage(fd, atcmd_output);
  6182. count = MAX_SEARCH;
  6183. }
  6184. for (i = 0; i < count; i++) {
  6185. item_data = item_array[i];
  6186. sprintf(atcmd_output, msg_txt(1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
  6187. clif_displaymessage(fd, atcmd_output);
  6188. if (item_data->mob[0].chance == 0) {
  6189. strcpy(atcmd_output, msg_txt(1286)); // - Item is not dropped by mobs.
  6190. clif_displaymessage(fd, atcmd_output);
  6191. } else {
  6192. sprintf(atcmd_output, msg_txt(1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6193. clif_displaymessage(fd, atcmd_output);
  6194. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6195. {
  6196. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6197. clif_displaymessage(fd, atcmd_output);
  6198. }
  6199. }
  6200. }
  6201. return 0;
  6202. }
  6203. ACMD_FUNC(whereis)
  6204. {
  6205. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6206. int count;
  6207. int i, j, k;
  6208. if (!message || !*message) {
  6209. clif_displaymessage(fd, msg_txt(1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6210. return -1;
  6211. }
  6212. // If monster identifier/name argument is a name
  6213. if ((i = mobdb_checkid(atoi(message))))
  6214. {
  6215. mob_array[0] = mob_db(i);
  6216. count = 1;
  6217. } else
  6218. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6219. if (!count) {
  6220. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6221. return -1;
  6222. }
  6223. if (count > MAX_SEARCH) {
  6224. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6225. clif_displaymessage(fd, atcmd_output);
  6226. count = MAX_SEARCH;
  6227. }
  6228. for (k = 0; k < count; k++) {
  6229. mob = mob_array[k];
  6230. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), mob->jname); // %s spawns in:
  6231. clif_displaymessage(fd, atcmd_output);
  6232. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6233. {
  6234. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6235. if (j < 0) continue;
  6236. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6237. clif_displaymessage(fd, atcmd_output);
  6238. }
  6239. if (i == 0)
  6240. clif_displaymessage(fd, msg_txt(1290)); // This monster does not spawn normally.
  6241. }
  6242. return 0;
  6243. }
  6244. /*==========================================
  6245. * @adopt by [Veider]
  6246. * adopt a novice
  6247. *------------------------------------------*/
  6248. ACMD_FUNC(adopt)
  6249. {
  6250. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6251. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6252. char output[CHAT_SIZE_MAX];
  6253. nullpo_retr(-1, sd);
  6254. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6255. clif_displaymessage(fd, msg_txt(1291)); // Usage: @adopt <father>,<mother>,<child>
  6256. return -1;
  6257. }
  6258. if (battle_config.etc_log)
  6259. ShowInfo(msg_txt(1292),player1,player2,player3); // Adopting: --%s--%s--%s--\n
  6260. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6261. sprintf(output, msg_txt(1293), player1); // Cannot find player %s online.
  6262. clif_displaymessage(fd, output);
  6263. return -1;
  6264. }
  6265. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6266. sprintf(output, msg_txt(1293), player2); // Cannot find player %s online.
  6267. clif_displaymessage(fd, output);
  6268. return -1;
  6269. }
  6270. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6271. sprintf(output, msg_txt(1293), player3); // Cannot find player %s online.
  6272. clif_displaymessage(fd, output);
  6273. return -1;
  6274. }
  6275. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6276. return -1;
  6277. }
  6278. clif_displaymessage(fd, msg_txt(1294)); // They are family... wish them luck.
  6279. return 0;
  6280. }
  6281. ACMD_FUNC(version)
  6282. {
  6283. const char * revision;
  6284. if ((revision = get_svn_revision()) != 0) {
  6285. sprintf(atcmd_output,msg_txt(1295),revision); // rAthena Version SVN r%s
  6286. clif_displaymessage(fd,atcmd_output);
  6287. } else
  6288. clif_displaymessage(fd,msg_txt(1296)); // Cannot determine SVN revision.
  6289. return 0;
  6290. }
  6291. /*==========================================
  6292. * @mutearea by MouseJstr
  6293. *------------------------------------------*/
  6294. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6295. {
  6296. int time, id;
  6297. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6298. if (pl_sd == NULL)
  6299. return 0;
  6300. id = va_arg(ap, int);
  6301. time = va_arg(ap, int);
  6302. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6303. pl_sd->status.manner -= time;
  6304. if (pl_sd->status.manner < 0)
  6305. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6306. else
  6307. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6308. }
  6309. return 0;
  6310. }
  6311. ACMD_FUNC(mutearea)
  6312. {
  6313. int time;
  6314. nullpo_ret(sd);
  6315. if (!message || !*message) {
  6316. clif_displaymessage(fd, msg_txt(1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6317. return -1;
  6318. }
  6319. time = atoi(message);
  6320. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6321. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6322. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6323. return 0;
  6324. }
  6325. ACMD_FUNC(rates)
  6326. {
  6327. char buf[CHAT_SIZE_MAX];
  6328. nullpo_ret(sd);
  6329. memset(buf, '\0', sizeof(buf));
  6330. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1298), // Experience rates: Base %.2fx / Job %.2fx
  6331. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6332. clif_displaymessage(fd, buf);
  6333. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6334. battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
  6335. clif_displaymessage(fd, buf);
  6336. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6337. battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
  6338. clif_displaymessage(fd, buf);
  6339. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6340. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6341. clif_displaymessage(fd, buf);
  6342. return 0;
  6343. }
  6344. /*==========================================
  6345. * @me by lordalfa
  6346. * => Displays the OUTPUT string on top of the Visible players Heads.
  6347. *------------------------------------------*/
  6348. ACMD_FUNC(me)
  6349. {
  6350. char tempmes[CHAT_SIZE_MAX];
  6351. nullpo_retr(-1, sd);
  6352. memset(tempmes, '\0', sizeof(tempmes));
  6353. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6354. if (sd->sc.count && //no "chatting" while muted.
  6355. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6356. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6357. return -1;
  6358. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6359. clif_displaymessage(fd, msg_txt(1302)); // Please enter a message (usage: @me <message>).
  6360. return -1;
  6361. }
  6362. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6363. clif_disp_overhead(sd, atcmd_output);
  6364. return 0;
  6365. }
  6366. /*==========================================
  6367. * @size
  6368. * => Resize your character sprite. [Valaris]
  6369. *------------------------------------------*/
  6370. ACMD_FUNC(size)
  6371. {
  6372. int size = 0;
  6373. nullpo_retr(-1, sd);
  6374. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6375. if(sd->state.size) {
  6376. sd->state.size = SZ_SMALL;
  6377. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6378. }
  6379. sd->state.size = size;
  6380. if( size == SZ_MEDIUM )
  6381. clif_specialeffect(&sd->bl,420,AREA);
  6382. else if( size == SZ_BIG )
  6383. clif_specialeffect(&sd->bl,422,AREA);
  6384. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6385. return 0;
  6386. }
  6387. ACMD_FUNC(sizeall)
  6388. {
  6389. int size;
  6390. struct map_session_data *pl_sd;
  6391. struct s_mapiterator* iter;
  6392. size = atoi(message);
  6393. size = cap_value(size,0,2);
  6394. iter = mapit_getallusers();
  6395. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6396. if( pl_sd->state.size != size ) {
  6397. if( pl_sd->state.size ) {
  6398. pl_sd->state.size = SZ_SMALL;
  6399. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6400. }
  6401. pl_sd->state.size = size;
  6402. if( size == SZ_MEDIUM )
  6403. clif_specialeffect(&pl_sd->bl,420,AREA);
  6404. else if( size == SZ_BIG )
  6405. clif_specialeffect(&pl_sd->bl,422,AREA);
  6406. }
  6407. }
  6408. mapit_free(iter);
  6409. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6410. return 0;
  6411. }
  6412. ACMD_FUNC(sizeguild)
  6413. {
  6414. int size = 0, i;
  6415. char guild[NAME_LENGTH];
  6416. struct map_session_data *pl_sd;
  6417. struct guild *g;
  6418. nullpo_retr(-1, sd);
  6419. memset(guild, '\0', sizeof(guild));
  6420. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6421. clif_displaymessage(fd, msg_txt(1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6422. return -1;
  6423. }
  6424. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6425. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  6426. return -1;
  6427. }
  6428. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6429. for( i = 0; i < g->max_member; i++ ) {
  6430. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6431. if( pl_sd->state.size ) {
  6432. pl_sd->state.size = SZ_SMALL;
  6433. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6434. }
  6435. pl_sd->state.size = size;
  6436. if( size == SZ_MEDIUM )
  6437. clif_specialeffect(&pl_sd->bl,420,AREA);
  6438. else if( size == SZ_BIG )
  6439. clif_specialeffect(&pl_sd->bl,422,AREA);
  6440. }
  6441. }
  6442. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6443. return 0;
  6444. }
  6445. /*==========================================
  6446. * @monsterignore
  6447. * => Makes monsters ignore you. [Valaris]
  6448. *------------------------------------------*/
  6449. ACMD_FUNC(monsterignore)
  6450. {
  6451. nullpo_retr(-1, sd);
  6452. if (!sd->state.monster_ignore) {
  6453. sd->state.monster_ignore = 1;
  6454. clif_displaymessage(sd->fd, msg_txt(1305)); // You are now immune to attacks.
  6455. } else {
  6456. sd->state.monster_ignore = 0;
  6457. clif_displaymessage(sd->fd, msg_txt(1306)); // Returned to normal state.
  6458. }
  6459. return 0;
  6460. }
  6461. /*==========================================
  6462. * @fakename
  6463. * => Gives your character a fake name. [Valaris]
  6464. *------------------------------------------*/
  6465. ACMD_FUNC(fakename)
  6466. {
  6467. nullpo_retr(-1, sd);
  6468. if( !message || !*message )
  6469. {
  6470. if( sd->fakename[0] )
  6471. {
  6472. sd->fakename[0] = '\0';
  6473. clif_charnameack(0, &sd->bl);
  6474. clif_displaymessage(sd->fd, msg_txt(1307)); // Returned to real name.
  6475. return 0;
  6476. }
  6477. clif_displaymessage(sd->fd, msg_txt(1308)); // You must enter a name.
  6478. return -1;
  6479. }
  6480. if( strlen(message) < 2 )
  6481. {
  6482. clif_displaymessage(sd->fd, msg_txt(1309)); // Fake name must be at least two characters.
  6483. return -1;
  6484. }
  6485. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6486. clif_charnameack(0, &sd->bl);
  6487. clif_displaymessage(sd->fd, msg_txt(1310)); // Fake name enabled.
  6488. return 0;
  6489. }
  6490. /*==========================================
  6491. * Ragnarok Resources
  6492. *------------------------------------------*/
  6493. ACMD_FUNC(mapflag) {
  6494. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6495. #define setflag( cmd ) \
  6496. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6497. map[ sd->bl.m ].flag.cmd = flag;\
  6498. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6499. clif_displaymessage(sd->fd,atcmd_output);\
  6500. return 0;\
  6501. }
  6502. unsigned char flag_name[100];
  6503. int flag=9,i;
  6504. nullpo_retr(-1, sd);
  6505. memset(flag_name, '\0', sizeof(flag_name));
  6506. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6507. clif_displaymessage(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map:
  6508. clif_displaymessage(sd->fd,"----------------------------------");
  6509. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6510. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6511. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6512. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6513. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6514. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6515. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6516. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6517. checkflag(nogo); checkflag(nobaseexp);
  6518. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6519. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6520. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6521. clif_displaymessage(sd->fd," ");
  6522. clif_displaymessage(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6523. clif_displaymessage(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags.
  6524. return 1;
  6525. }
  6526. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6527. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6528. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6529. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6530. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6531. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6532. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6533. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6534. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6535. setflag(nogo); setflag(nobaseexp);
  6536. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6537. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6538. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6539. clif_displaymessage(sd->fd,msg_txt(1314)); // Invalid flag name or flag.
  6540. clif_displaymessage(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6541. clif_displaymessage(sd->fd,msg_txt(1315)); // Available Flags:
  6542. clif_displaymessage(sd->fd,"----------------------------------");
  6543. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6544. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6545. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6546. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6547. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6548. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6549. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6550. #undef checkflag
  6551. #undef setflag
  6552. return 0;
  6553. }
  6554. /*===================================
  6555. * Remove some messages
  6556. *-----------------------------------*/
  6557. ACMD_FUNC(showexp)
  6558. {
  6559. if (sd->state.showexp) {
  6560. sd->state.showexp = 0;
  6561. clif_displaymessage(fd, msg_txt(1316)); // Gained exp will not be shown.
  6562. return 0;
  6563. }
  6564. sd->state.showexp = 1;
  6565. clif_displaymessage(fd, msg_txt(1317)); // Gained exp is now shown.
  6566. return 0;
  6567. }
  6568. ACMD_FUNC(showzeny)
  6569. {
  6570. if (sd->state.showzeny) {
  6571. sd->state.showzeny = 0;
  6572. clif_displaymessage(fd, msg_txt(1318)); // Gained zeny will not be shown.
  6573. return 0;
  6574. }
  6575. sd->state.showzeny = 1;
  6576. clif_displaymessage(fd, msg_txt(1319)); // Gained zeny is now shown.
  6577. return 0;
  6578. }
  6579. ACMD_FUNC(showdelay)
  6580. {
  6581. if (sd->state.showdelay) {
  6582. sd->state.showdelay = 0;
  6583. clif_displaymessage(fd, msg_txt(1320)); // Skill delay failures will not be shown.
  6584. return 0;
  6585. }
  6586. sd->state.showdelay = 1;
  6587. clif_displaymessage(fd, msg_txt(1321)); // Skill delay failures are now shown.
  6588. return 0;
  6589. }
  6590. /*==========================================
  6591. * Duel organizing functions [LuzZza]
  6592. *
  6593. * @duel [limit|nick] - create a duel
  6594. * @invite <nick> - invite player
  6595. * @accept - accept invitation
  6596. * @reject - reject invitation
  6597. * @leave - leave duel
  6598. *------------------------------------------*/
  6599. ACMD_FUNC(invite)
  6600. {
  6601. unsigned int did = sd->duel_group;
  6602. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6603. if(did <= 0) {
  6604. // "Duel: @invite without @duel."
  6605. clif_displaymessage(fd, msg_txt(350));
  6606. return 0;
  6607. }
  6608. if(duel_list[did].max_players_limit > 0 &&
  6609. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6610. // "Duel: Limit of players is reached."
  6611. clif_displaymessage(fd, msg_txt(351));
  6612. return 0;
  6613. }
  6614. if(target_sd == NULL) {
  6615. // "Duel: Player not found."
  6616. clif_displaymessage(fd, msg_txt(352));
  6617. return 0;
  6618. }
  6619. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6620. // "Duel: Player already in duel."
  6621. clif_displaymessage(fd, msg_txt(353));
  6622. return 0;
  6623. }
  6624. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6625. {
  6626. sprintf(atcmd_output, msg_txt(364), message);
  6627. clif_displaymessage(fd, atcmd_output);
  6628. return 0;
  6629. }
  6630. duel_invite(did, sd, target_sd);
  6631. // "Duel: Invitation has been sent."
  6632. clif_displaymessage(fd, msg_txt(354));
  6633. return 0;
  6634. }
  6635. ACMD_FUNC(duel)
  6636. {
  6637. char output[CHAT_SIZE_MAX];
  6638. unsigned int maxpl=0, newduel;
  6639. struct map_session_data *target_sd;
  6640. if(sd->duel_group > 0) {
  6641. duel_showinfo(sd->duel_group, sd);
  6642. return 0;
  6643. }
  6644. if(sd->duel_invite > 0) {
  6645. // "Duel: @duel without @reject."
  6646. clif_displaymessage(fd, msg_txt(355));
  6647. return 0;
  6648. }
  6649. if(!duel_checktime(sd)) {
  6650. // "Duel: You can take part in duel only one time per %d minutes."
  6651. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6652. clif_displaymessage(fd, output);
  6653. return 0;
  6654. }
  6655. if( message[0] ) {
  6656. if(sscanf(message, "%d", &maxpl) >= 1) {
  6657. if(maxpl < 2 || maxpl > 65535) {
  6658. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6659. return 0;
  6660. }
  6661. duel_create(sd, maxpl);
  6662. } else {
  6663. target_sd = map_nick2sd((char *)message);
  6664. if(target_sd != NULL) {
  6665. if((newduel = duel_create(sd, 2)) != -1) {
  6666. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6667. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6668. return 0;
  6669. }
  6670. duel_invite(newduel, sd, target_sd);
  6671. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6672. }
  6673. } else {
  6674. // "Duel: Player not found."
  6675. clif_displaymessage(fd, msg_txt(352));
  6676. return 0;
  6677. }
  6678. }
  6679. } else
  6680. duel_create(sd, 0);
  6681. return 0;
  6682. }
  6683. ACMD_FUNC(leave)
  6684. {
  6685. if(sd->duel_group <= 0) {
  6686. // "Duel: @leave without @duel."
  6687. clif_displaymessage(fd, msg_txt(358));
  6688. return 0;
  6689. }
  6690. duel_leave(sd->duel_group, sd);
  6691. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6692. return 0;
  6693. }
  6694. ACMD_FUNC(accept)
  6695. {
  6696. char output[CHAT_SIZE_MAX];
  6697. if(!duel_checktime(sd)) {
  6698. // "Duel: You can take part in duel only one time per %d minutes."
  6699. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6700. clif_displaymessage(fd, output);
  6701. return 0;
  6702. }
  6703. if(sd->duel_invite <= 0) {
  6704. // "Duel: @accept without invititation."
  6705. clif_displaymessage(fd, msg_txt(360));
  6706. return 0;
  6707. }
  6708. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  6709. {
  6710. // "Duel: Limit of players is reached."
  6711. clif_displaymessage(fd, msg_txt(351));
  6712. return 0;
  6713. }
  6714. duel_accept(sd->duel_invite, sd);
  6715. // "Duel: Invitation has been accepted."
  6716. clif_displaymessage(fd, msg_txt(361));
  6717. return 0;
  6718. }
  6719. ACMD_FUNC(reject)
  6720. {
  6721. if(sd->duel_invite <= 0) {
  6722. // "Duel: @reject without invititation."
  6723. clif_displaymessage(fd, msg_txt(362));
  6724. return 0;
  6725. }
  6726. duel_reject(sd->duel_invite, sd);
  6727. // "Duel: Invitation has been rejected."
  6728. clif_displaymessage(fd, msg_txt(363));
  6729. return 0;
  6730. }
  6731. /*===================================
  6732. * Cash Points
  6733. *-----------------------------------*/
  6734. ACMD_FUNC(cash)
  6735. {
  6736. char output[128];
  6737. int value;
  6738. nullpo_retr(-1, sd);
  6739. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6740. clif_displaymessage(fd, msg_txt(1322)); // Please enter an amount.
  6741. return -1;
  6742. }
  6743. if( !strcmpi(command+1,"cash") )
  6744. {
  6745. if( value > 0 ) {
  6746. pc_getcash(sd, value, 0);
  6747. sprintf(output, msg_txt(505), value, sd->cashPoints);
  6748. clif_disp_onlyself(sd, output, strlen(output));
  6749. } else {
  6750. pc_paycash(sd, -value, 0);
  6751. sprintf(output, msg_txt(410), value, sd->cashPoints);
  6752. clif_disp_onlyself(sd, output, strlen(output));
  6753. }
  6754. }
  6755. else
  6756. { // @points
  6757. if( value > 0 ) {
  6758. pc_getcash(sd, 0, value);
  6759. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  6760. clif_disp_onlyself(sd, output, strlen(output));
  6761. } else {
  6762. pc_paycash(sd, -value, -value);
  6763. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  6764. clif_disp_onlyself(sd, output, strlen(output));
  6765. }
  6766. }
  6767. return 0;
  6768. }
  6769. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6770. ACMD_FUNC(clone)
  6771. {
  6772. int x=0,y=0,flag=0,master=0,i=0;
  6773. struct map_session_data *pl_sd=NULL;
  6774. if (!message || !*message) {
  6775. clif_displaymessage(sd->fd,msg_txt(1323)); // You must enter a player name or ID.
  6776. return 0;
  6777. }
  6778. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6779. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6780. return 0;
  6781. }
  6782. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6783. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6784. return 0;
  6785. }
  6786. if (strcmpi(command+1, "clone") == 0)
  6787. flag = 1;
  6788. else if (strcmpi(command+1, "slaveclone") == 0) {
  6789. flag = 2;
  6790. master = sd->bl.id;
  6791. if (battle_config.atc_slave_clone_limit
  6792. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6793. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6794. return 0;
  6795. }
  6796. }
  6797. do {
  6798. x = sd->bl.x + (rnd() % 10 - 5);
  6799. y = sd->bl.y + (rnd() % 10 - 5);
  6800. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6801. if (i >= 10) {
  6802. x = sd->bl.x;
  6803. y = sd->bl.y;
  6804. }
  6805. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6806. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6807. return 0;
  6808. }
  6809. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6810. return 0;
  6811. }
  6812. /*===================================
  6813. * Main chat [LuzZza]
  6814. * Usage: @main <on|off|message>
  6815. *-----------------------------------*/
  6816. ACMD_FUNC(main)
  6817. {
  6818. if( message[0] ) {
  6819. if(strcmpi(message, "on") == 0) {
  6820. if(!sd->state.mainchat) {
  6821. sd->state.mainchat = 1;
  6822. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6823. } else {
  6824. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6825. }
  6826. } else if(strcmpi(message, "off") == 0) {
  6827. if(sd->state.mainchat) {
  6828. sd->state.mainchat = 0;
  6829. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6830. } else {
  6831. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6832. }
  6833. } else {
  6834. if(!sd->state.mainchat) {
  6835. sd->state.mainchat = 1;
  6836. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6837. }
  6838. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6839. clif_displaymessage(fd, msg_txt(387));
  6840. return -1;
  6841. }
  6842. if ( battle_config.min_chat_delay ) {
  6843. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6844. return 0;
  6845. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6846. }
  6847. // send the message using inter-server system
  6848. intif_main_message( sd, message );
  6849. }
  6850. } else {
  6851. if(sd->state.mainchat)
  6852. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6853. else
  6854. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6855. }
  6856. return 0;
  6857. }
  6858. /*=====================================
  6859. * Autorejecting Invites/Deals [LuzZza]
  6860. * Usage: @noask
  6861. *-------------------------------------*/
  6862. ACMD_FUNC(noask)
  6863. {
  6864. if(sd->state.noask) {
  6865. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6866. sd->state.noask = 0;
  6867. } else {
  6868. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6869. sd->state.noask = 1;
  6870. }
  6871. return 0;
  6872. }
  6873. /*=====================================
  6874. * Send a @request message to all GMs of lowest_gm_level.
  6875. * Usage: @request <petition>
  6876. *-------------------------------------*/
  6877. ACMD_FUNC(request)
  6878. {
  6879. if (!message || !*message) {
  6880. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6881. return -1;
  6882. }
  6883. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6884. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6885. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6886. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6887. return 0;
  6888. }
  6889. /*==========================================
  6890. * Feel (SG save map) Reset [HiddenDragon]
  6891. *------------------------------------------*/
  6892. ACMD_FUNC(feelreset)
  6893. {
  6894. pc_resetfeel(sd);
  6895. clif_displaymessage(fd, msg_txt(1324)); // Reset 'Feeling' maps.
  6896. return 0;
  6897. }
  6898. /*==========================================
  6899. * AUCTION SYSTEM
  6900. *------------------------------------------*/
  6901. ACMD_FUNC(auction)
  6902. {
  6903. nullpo_ret(sd);
  6904. clif_Auction_openwindow(sd);
  6905. return 0;
  6906. }
  6907. /*==========================================
  6908. * Kill Steal Protection
  6909. *------------------------------------------*/
  6910. ACMD_FUNC(ksprotection)
  6911. {
  6912. nullpo_retr(-1,sd);
  6913. if( sd->state.noks ) {
  6914. sd->state.noks = 0;
  6915. clif_displaymessage(fd, msg_txt(1325)); // [ K.S Protection Inactive ]
  6916. }
  6917. else
  6918. {
  6919. if( !message || !*message || !strcmpi(message, "party") )
  6920. { // Default is Party
  6921. sd->state.noks = 2;
  6922. clif_displaymessage(fd, msg_txt(1326)); // [ K.S Protection Active - Option: Party ]
  6923. }
  6924. else if( !strcmpi(message, "self") )
  6925. {
  6926. sd->state.noks = 1;
  6927. clif_displaymessage(fd, msg_txt(1327)); // [ K.S Protection Active - Option: Self ]
  6928. }
  6929. else if( !strcmpi(message, "guild") )
  6930. {
  6931. sd->state.noks = 3;
  6932. clif_displaymessage(fd, msg_txt(1328)); // [ K.S Protection Active - Option: Guild ]
  6933. }
  6934. else
  6935. clif_displaymessage(fd, msg_txt(1329)); // Usage: @noks <self|party|guild>
  6936. }
  6937. return 0;
  6938. }
  6939. /*==========================================
  6940. * Map Kill Steal Protection Setting
  6941. *------------------------------------------*/
  6942. ACMD_FUNC(allowks)
  6943. {
  6944. nullpo_retr(-1,sd);
  6945. if( map[sd->bl.m].flag.allowks ) {
  6946. map[sd->bl.m].flag.allowks = 0;
  6947. clif_displaymessage(fd, msg_txt(1330)); // [ Map K.S Protection Active ]
  6948. } else {
  6949. map[sd->bl.m].flag.allowks = 1;
  6950. clif_displaymessage(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ]
  6951. }
  6952. return 0;
  6953. }
  6954. ACMD_FUNC(resetstat)
  6955. {
  6956. nullpo_retr(-1, sd);
  6957. pc_resetstate(sd);
  6958. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  6959. clif_displaymessage(fd, atcmd_output);
  6960. return 0;
  6961. }
  6962. ACMD_FUNC(resetskill)
  6963. {
  6964. nullpo_retr(-1,sd);
  6965. pc_resetskill(sd,1);
  6966. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  6967. clif_displaymessage(fd, atcmd_output);
  6968. return 0;
  6969. }
  6970. /*==========================================
  6971. * #storagelist: Displays the items list of a player's storage.
  6972. * #cartlist: Displays contents of target's cart.
  6973. * #itemlist: Displays contents of target's inventory.
  6974. *------------------------------------------*/
  6975. ACMD_FUNC(itemlist)
  6976. {
  6977. int i, j, count, counter;
  6978. const char* location;
  6979. const struct item* items;
  6980. int size;
  6981. StringBuf buf;
  6982. nullpo_retr(-1, sd);
  6983. if( strcmp(command+1, "storagelist") == 0 )
  6984. {
  6985. location = "storage";
  6986. items = sd->status.storage.items;
  6987. size = MAX_STORAGE;
  6988. }
  6989. else
  6990. if( strcmp(command+1, "cartlist") == 0 )
  6991. {
  6992. location = "cart";
  6993. items = sd->status.cart;
  6994. size = MAX_CART;
  6995. }
  6996. else
  6997. if( strcmp(command+1, "itemlist") == 0 )
  6998. {
  6999. location = "inventory";
  7000. items = sd->status.inventory;
  7001. size = MAX_INVENTORY;
  7002. }
  7003. else
  7004. return 1;
  7005. StringBuf_Init(&buf);
  7006. count = 0; // total slots occupied
  7007. counter = 0; // total items found
  7008. for( i = 0; i < size; ++i )
  7009. {
  7010. const struct item* it = &items[i];
  7011. struct item_data* itd;
  7012. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7013. continue;
  7014. counter += it->amount;
  7015. count++;
  7016. if( count == 1 )
  7017. {
  7018. StringBuf_Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7019. clif_displaymessage(fd, StringBuf_Value(&buf));
  7020. StringBuf_Clear(&buf);
  7021. }
  7022. if( it->refine )
  7023. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7024. else
  7025. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7026. if( it->equip )
  7027. {
  7028. char equipstr[CHAT_SIZE_MAX];
  7029. strcpy(equipstr, msg_txt(1333)); // | equipped:
  7030. if( it->equip & EQP_GARMENT )
  7031. strcat(equipstr, msg_txt(1334)); // garment,
  7032. if( it->equip & EQP_ACC_L )
  7033. strcat(equipstr, msg_txt(1335)); // left accessory,
  7034. if( it->equip & EQP_ARMOR )
  7035. strcat(equipstr, msg_txt(1336)); // body/armor,
  7036. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7037. strcat(equipstr, msg_txt(1337)); // right hand,
  7038. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7039. strcat(equipstr, msg_txt(1338)); // left hand,
  7040. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7041. strcat(equipstr, msg_txt(1339)); // both hands,
  7042. if( it->equip & EQP_SHOES )
  7043. strcat(equipstr, msg_txt(1340)); // feet,
  7044. if( it->equip & EQP_ACC_R )
  7045. strcat(equipstr, msg_txt(1341)); // right accessory,
  7046. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7047. strcat(equipstr, msg_txt(1342)); // lower head,
  7048. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7049. strcat(equipstr, msg_txt(1343)); // top head,
  7050. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7051. strcat(equipstr, msg_txt(1344)); // lower/top head,
  7052. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7053. strcat(equipstr, msg_txt(1345)); // mid head,
  7054. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7055. strcat(equipstr, msg_txt(1346)); // lower/mid head,
  7056. if( (it->equip & EQP_HELM) == EQP_HELM )
  7057. strcat(equipstr, msg_txt(1347)); // lower/mid/top head,
  7058. // remove final ', '
  7059. equipstr[strlen(equipstr) - 2] = '\0';
  7060. StringBuf_AppendStr(&buf, equipstr);
  7061. }
  7062. clif_displaymessage(fd, StringBuf_Value(&buf));
  7063. StringBuf_Clear(&buf);
  7064. if( it->card[0] == CARD0_PET )
  7065. {// pet egg
  7066. if (it->card[3])
  7067. StringBuf_Printf(&buf, msg_txt(1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7068. else
  7069. StringBuf_Printf(&buf, msg_txt(1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7070. }
  7071. else
  7072. if(it->card[0] == CARD0_FORGE)
  7073. {// forged item
  7074. StringBuf_Printf(&buf, msg_txt(1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
  7075. }
  7076. else
  7077. if(it->card[0] == CARD0_CREATE)
  7078. {// created item
  7079. StringBuf_Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7080. }
  7081. else
  7082. {// normal item
  7083. int counter2 = 0;
  7084. for( j = 0; j < itd->slot; ++j )
  7085. {
  7086. struct item_data* card;
  7087. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7088. continue;
  7089. counter2++;
  7090. if( counter2 == 1 )
  7091. StringBuf_AppendStr(&buf, msg_txt(1352)); // -> (card(s):
  7092. if( counter2 != 1 )
  7093. StringBuf_AppendStr(&buf, ", ");
  7094. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7095. }
  7096. if( counter2 > 0 )
  7097. StringBuf_AppendStr(&buf, ")");
  7098. }
  7099. if( StringBuf_Length(&buf) > 0 )
  7100. clif_displaymessage(fd, StringBuf_Value(&buf));
  7101. StringBuf_Clear(&buf);
  7102. }
  7103. if( count == 0 )
  7104. StringBuf_Printf(&buf, msg_txt(1353), location); // No item found in this player's %s.
  7105. else
  7106. StringBuf_Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots.
  7107. clif_displaymessage(fd, StringBuf_Value(&buf));
  7108. StringBuf_Destroy(&buf);
  7109. return 0;
  7110. }
  7111. ACMD_FUNC(stats)
  7112. {
  7113. char job_jobname[100];
  7114. char output[CHAT_SIZE_MAX];
  7115. int i;
  7116. struct {
  7117. const char* format;
  7118. int value;
  7119. } output_table[] = {
  7120. { "Base Level - %d", 0 },
  7121. { NULL, 0 },
  7122. { "Hp - %d", 0 },
  7123. { "MaxHp - %d", 0 },
  7124. { "Sp - %d", 0 },
  7125. { "MaxSp - %d", 0 },
  7126. { "Str - %3d", 0 },
  7127. { "Agi - %3d", 0 },
  7128. { "Vit - %3d", 0 },
  7129. { "Int - %3d", 0 },
  7130. { "Dex - %3d", 0 },
  7131. { "Luk - %3d", 0 },
  7132. { "Zeny - %d", 0 },
  7133. { "Free SK Points - %d", 0 },
  7134. { "JobChangeLvl (2nd) - %d", 0 },
  7135. { "JobChangeLvl (3rd) - %d", 0 },
  7136. { NULL, 0 }
  7137. };
  7138. memset(job_jobname, '\0', sizeof(job_jobname));
  7139. memset(output, '\0', sizeof(output));
  7140. //direct array initialization with variables is not standard C compliant.
  7141. output_table[0].value = sd->status.base_level;
  7142. output_table[1].format = job_jobname;
  7143. output_table[1].value = sd->status.job_level;
  7144. output_table[2].value = sd->status.hp;
  7145. output_table[3].value = sd->status.max_hp;
  7146. output_table[4].value = sd->status.sp;
  7147. output_table[5].value = sd->status.max_sp;
  7148. output_table[6].value = sd->status.str;
  7149. output_table[7].value = sd->status.agi;
  7150. output_table[8].value = sd->status.vit;
  7151. output_table[9].value = sd->status.int_;
  7152. output_table[10].value = sd->status.dex;
  7153. output_table[11].value = sd->status.luk;
  7154. output_table[12].value = sd->status.zeny;
  7155. output_table[13].value = sd->status.skill_point;
  7156. output_table[14].value = sd->change_level_2nd;
  7157. output_table[15].value = sd->change_level_3rd;
  7158. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7159. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7160. clif_displaymessage(fd, output);
  7161. for (i = 0; output_table[i].format != NULL; i++) {
  7162. sprintf(output, output_table[i].format, output_table[i].value);
  7163. clif_displaymessage(fd, output);
  7164. }
  7165. return 0;
  7166. }
  7167. ACMD_FUNC(delitem)
  7168. {
  7169. char item_name[100];
  7170. int nameid, amount = 0, total, idx;
  7171. struct item_data* id;
  7172. nullpo_retr(-1, sd);
  7173. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7174. {
  7175. clif_displaymessage(fd, msg_txt(1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  7176. return -1;
  7177. }
  7178. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7179. {
  7180. nameid = id->nameid;
  7181. }
  7182. else
  7183. {
  7184. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7185. return -1;
  7186. }
  7187. total = amount;
  7188. // delete items
  7189. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7190. {
  7191. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7192. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7193. {// delete pet
  7194. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7195. }
  7196. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7197. amount-= delamount;
  7198. }
  7199. // notify target
  7200. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7201. clif_displaymessage(sd->fd, atcmd_output);
  7202. // notify source
  7203. if( amount == total )
  7204. {
  7205. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7206. }
  7207. else if( amount )
  7208. {
  7209. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7210. clif_displaymessage(fd, atcmd_output);
  7211. }
  7212. else
  7213. {
  7214. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7215. clif_displaymessage(fd, atcmd_output);
  7216. }
  7217. return 0;
  7218. }
  7219. /*==========================================
  7220. * Custom Fonts
  7221. *------------------------------------------*/
  7222. ACMD_FUNC(font)
  7223. {
  7224. int font_id;
  7225. nullpo_retr(-1,sd);
  7226. font_id = atoi(message);
  7227. if( font_id == 0 )
  7228. {
  7229. if( sd->user_font )
  7230. {
  7231. sd->user_font = 0;
  7232. clif_displaymessage(fd, msg_txt(1356)); // Returning to normal font.
  7233. clif_font(sd);
  7234. }
  7235. else
  7236. {
  7237. clif_displaymessage(fd, msg_txt(1357)); // Use @font <1-9> to change your message font.
  7238. clif_displaymessage(fd, msg_txt(1358)); // Use 0 or no parameter to return to normal font.
  7239. }
  7240. }
  7241. else if( font_id < 0 || font_id > 9 )
  7242. clif_displaymessage(fd, msg_txt(1359)); // Invalid font. Use a value from 0 to 9.
  7243. else if( font_id != sd->user_font )
  7244. {
  7245. sd->user_font = font_id;
  7246. clif_font(sd);
  7247. clif_displaymessage(fd, msg_txt(1360)); // Font changed.
  7248. }
  7249. else
  7250. clif_displaymessage(fd, msg_txt(1361)); // Already using this font.
  7251. return 0;
  7252. }
  7253. /*==========================================
  7254. * type: 1 = commands (@), 2 = charcommands (#)
  7255. *------------------------------------------*/
  7256. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7257. {
  7258. char line_buff[CHATBOX_SIZE];
  7259. char* cur = line_buff;
  7260. AtCommandInfo* cmd;
  7261. DBIterator *iter = db_iterator(atcommand_db);
  7262. int count = 0;
  7263. memset(line_buff,' ',CHATBOX_SIZE);
  7264. line_buff[CHATBOX_SIZE-1] = 0;
  7265. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7266. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7267. unsigned int slen = 0;
  7268. switch( type ) {
  7269. case COMMAND_CHARCOMMAND:
  7270. if( cmd->char_groups[sd->group_pos] == 0 )
  7271. continue;
  7272. break;
  7273. case COMMAND_ATCOMMAND:
  7274. if( cmd->at_groups[sd->group_pos] == 0 )
  7275. continue;
  7276. break;
  7277. default:
  7278. continue;
  7279. }
  7280. slen = strlen(cmd->command);
  7281. // flush the text buffer if this command won't fit into it
  7282. if ( slen + cur - line_buff >= CHATBOX_SIZE )
  7283. {
  7284. clif_displaymessage(fd,line_buff);
  7285. cur = line_buff;
  7286. memset(line_buff,' ',CHATBOX_SIZE);
  7287. line_buff[CHATBOX_SIZE-1] = 0;
  7288. }
  7289. memcpy(cur,cmd->command,slen);
  7290. cur += slen+(10-slen%10);
  7291. count++;
  7292. }
  7293. dbi_destroy(iter);
  7294. clif_displaymessage(fd,line_buff);
  7295. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7296. clif_displaymessage(fd, atcmd_output);
  7297. return;
  7298. }
  7299. /*==========================================
  7300. * @commands Lists available @ commands to you
  7301. *------------------------------------------*/
  7302. ACMD_FUNC(commands)
  7303. {
  7304. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7305. return 0;
  7306. }
  7307. /*==========================================
  7308. * @charcommands Lists available # commands to you
  7309. *------------------------------------------*/
  7310. ACMD_FUNC(charcommands)
  7311. {
  7312. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7313. return 0;
  7314. }
  7315. /* for new mounts */
  7316. ACMD_FUNC(mount2) {
  7317. clif_displaymessage(sd->fd,msg_txt(1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7318. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7319. clif_displaymessage(sd->fd,msg_txt(1363)); // You have mounted.
  7320. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7321. } else {
  7322. clif_displaymessage(sd->fd,msg_txt(1364)); // You have released your mount.
  7323. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7324. }
  7325. return 0;
  7326. }
  7327. ACMD_FUNC(accinfo) {
  7328. char query[NAME_LENGTH];
  7329. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7330. clif_displaymessage(fd, msg_txt(1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7331. clif_displaymessage(fd, msg_txt(1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  7332. return -1;
  7333. }
  7334. //remove const type
  7335. safestrncpy(query, message, NAME_LENGTH);
  7336. intif_request_accinfo( sd->fd, sd->bl.id, sd->group_id, query );
  7337. return 0;
  7338. }
  7339. /* [Ind] */
  7340. ACMD_FUNC(set) {
  7341. char reg[32], val[128];
  7342. struct script_data* data;
  7343. int toset = 0;
  7344. bool is_str = false;
  7345. if( !message || !*message || (toset = sscanf(message, "%32s %128[^\n]s", reg, val)) < 1 ) {
  7346. clif_displaymessage(fd, msg_txt(1367)); // Usage: @set <variable name> <value>
  7347. clif_displaymessage(fd, msg_txt(1368)); // Usage: ex. "@set PoringCharVar 50"
  7348. clif_displaymessage(fd, msg_txt(1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7349. clif_displaymessage(fd, msg_txt(1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7350. return -1;
  7351. }
  7352. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7353. if( reg[0] == '.' ) {
  7354. clif_displaymessage(fd, msg_txt(1371)); // NPC variables may not be used with @set.
  7355. return -1;
  7356. } else if( reg[0] == '\'' ) {
  7357. clif_displaymessage(fd, msg_txt(1372)); // Instance variables may not be used with @set.
  7358. return -1;
  7359. }
  7360. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7361. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7362. if( is_str )
  7363. set_var(sd, reg, (void*) val);
  7364. else
  7365. set_var(sd, reg, (void*)__64BPRTSIZE((int)(atoi(val))));
  7366. }
  7367. CREATE(data, struct script_data,1);
  7368. if( is_str ) {// string variable
  7369. switch( reg[0] ) {
  7370. case '@':
  7371. data->u.str = pc_readregstr(sd, add_str(reg));
  7372. break;
  7373. case '$':
  7374. data->u.str = mapreg_readregstr(add_str(reg));
  7375. break;
  7376. case '#':
  7377. if( reg[1] == '#' )
  7378. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7379. else
  7380. data->u.str = pc_readaccountregstr(sd, reg);// local
  7381. break;
  7382. default:
  7383. data->u.str = pc_readglobalreg_str(sd, reg);
  7384. break;
  7385. }
  7386. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7387. data->type = C_CONSTSTR;
  7388. data->u.str = "";
  7389. } else {// duplicate string
  7390. data->type = C_STR;
  7391. data->u.str = aStrdup(data->u.str);
  7392. }
  7393. } else {// integer variable
  7394. data->type = C_INT;
  7395. switch( reg[0] ) {
  7396. case '@':
  7397. data->u.num = pc_readreg(sd, add_str(reg));
  7398. break;
  7399. case '$':
  7400. data->u.num = mapreg_readreg(add_str(reg));
  7401. break;
  7402. case '#':
  7403. if( reg[1] == '#' )
  7404. data->u.num = pc_readaccountreg2(sd, reg);// global
  7405. else
  7406. data->u.num = pc_readaccountreg(sd, reg);// local
  7407. break;
  7408. default:
  7409. data->u.num = pc_readglobalreg(sd, reg);
  7410. break;
  7411. }
  7412. }
  7413. switch( data->type ) {
  7414. case C_INT:
  7415. sprintf(atcmd_output,msg_txt(1373),reg,data->u.num); // %s value is now :%d
  7416. break;
  7417. case C_STR:
  7418. sprintf(atcmd_output,msg_txt(1374),reg,data->u.str); // %s value is now :%s
  7419. break;
  7420. case C_CONSTSTR:
  7421. sprintf(atcmd_output,msg_txt(1375),reg); // %s is empty
  7422. break;
  7423. default:
  7424. sprintf(atcmd_output,msg_txt(1376),reg,data->type); // %s data type is not supported :%u
  7425. break;
  7426. }
  7427. clif_displaymessage(fd, atcmd_output);
  7428. aFree(data);
  7429. return 0;
  7430. }
  7431. ACMD_FUNC(reloadquestdb) {
  7432. do_reload_quest();
  7433. clif_displaymessage(fd, msg_txt(1377)); // Quest database has been reloaded.
  7434. return 0;
  7435. }
  7436. ACMD_FUNC(addperm) {
  7437. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7438. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7439. int i;
  7440. if( !message || !*message ) {
  7441. sprintf(atcmd_output, msg_txt(1378),command); // Usage: %s <permission_name>
  7442. clif_displaymessage(fd, atcmd_output);
  7443. clif_displaymessage(fd, msg_txt(1379)); // -- Permission List
  7444. for( i = 0; i < perm_size; i++ ) {
  7445. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7446. clif_displaymessage(fd, atcmd_output);
  7447. }
  7448. return -1;
  7449. }
  7450. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7451. if( i == perm_size ) {
  7452. sprintf(atcmd_output,msg_txt(1380),message); // '%s' is not a known permission.
  7453. clif_displaymessage(fd, atcmd_output);
  7454. clif_displaymessage(fd, msg_txt(1379)); // -- Permission List
  7455. for( i = 0; i < perm_size; i++ ) {
  7456. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7457. clif_displaymessage(fd, atcmd_output);
  7458. }
  7459. return -1;
  7460. }
  7461. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7462. sprintf(atcmd_output, msg_txt(1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7463. clif_displaymessage(fd, atcmd_output);
  7464. return -1;
  7465. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7466. sprintf(atcmd_output, msg_txt(1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7467. clif_displaymessage(fd, atcmd_output);
  7468. sprintf(atcmd_output,msg_txt(1383),sd->status.name); // -- User '%s' Permissions
  7469. clif_displaymessage(fd, atcmd_output);
  7470. for( i = 0; i < perm_size; i++ ) {
  7471. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7472. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7473. clif_displaymessage(fd, atcmd_output);
  7474. }
  7475. }
  7476. return -1;
  7477. }
  7478. if( add )
  7479. sd->permissions |= pc_g_permission_name[i].permission;
  7480. else
  7481. sd->permissions &=~ pc_g_permission_name[i].permission;
  7482. sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7483. clif_displaymessage(fd, atcmd_output);
  7484. return 0;
  7485. }
  7486. ACMD_FUNC(unloadnpcfile) {
  7487. if( !message || !*message ) {
  7488. clif_displaymessage(fd, msg_txt(1385)); // Usage: @unloadnpcfile <file name>
  7489. return -1;
  7490. }
  7491. if( npc_unloadfile(message) )
  7492. clif_displaymessage(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7493. else {
  7494. clif_displaymessage(fd, msg_txt(1387)); // File not found.
  7495. return -1;
  7496. }
  7497. return 0;
  7498. }
  7499. ACMD_FUNC(cart) {
  7500. #define MC_CART_MDFY(x) \
  7501. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7502. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7503. sd->status.skill[MC_PUSHCART].flag = x?1:0;
  7504. int val = atoi(message);
  7505. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7506. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7507. sprintf(atcmd_output, msg_txt(1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7508. clif_displaymessage(fd, atcmd_output);
  7509. return -1;
  7510. }
  7511. if( val == 0 && !pc_iscarton(sd) ) {
  7512. clif_displaymessage(fd, msg_txt(1391)); // You do not possess a cart to be removed
  7513. return -1;
  7514. }
  7515. if( need_skill ) {
  7516. MC_CART_MDFY(1);
  7517. }
  7518. if( pc_setcart(sd, val) ) {
  7519. if( need_skill ) {
  7520. MC_CART_MDFY(0);
  7521. }
  7522. return -1;/* @cart failed */
  7523. }
  7524. if( need_skill ) {
  7525. MC_CART_MDFY(0);
  7526. }
  7527. clif_displaymessage(fd, msg_txt(1392)); // Cart Added
  7528. return 0;
  7529. #undef MC_CART_MDFY
  7530. }
  7531. /**
  7532. * Fills the reference of available commands in atcommand DBMap
  7533. **/
  7534. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL }
  7535. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL }
  7536. void atcommand_basecommands(void) {
  7537. /**
  7538. * Command reference list, place the base of your commands here
  7539. **/
  7540. AtCommandInfo atcommand_base[] = {
  7541. ACMD_DEF2("warp", mapmove),
  7542. ACMD_DEF(where),
  7543. ACMD_DEF(jumpto),
  7544. ACMD_DEF(jump),
  7545. ACMD_DEF(who),
  7546. ACMD_DEF2("who2", who),
  7547. ACMD_DEF2("who3", who),
  7548. ACMD_DEF2("whomap", who),
  7549. ACMD_DEF2("whomap2", who),
  7550. ACMD_DEF2("whomap3", who),
  7551. ACMD_DEF(whogm),
  7552. ACMD_DEF(save),
  7553. ACMD_DEF(load),
  7554. ACMD_DEF(speed),
  7555. ACMD_DEF(storage),
  7556. ACMD_DEF(guildstorage),
  7557. ACMD_DEF(option),
  7558. ACMD_DEF(hide), // + /hide
  7559. ACMD_DEF(jobchange),
  7560. ACMD_DEF(kill),
  7561. ACMD_DEF(alive),
  7562. ACMD_DEF(kami),
  7563. ACMD_DEF2("kamib", kami),
  7564. ACMD_DEF2("kamic", kami),
  7565. ACMD_DEF2("lkami", kami),
  7566. ACMD_DEF(heal),
  7567. ACMD_DEF(item),
  7568. ACMD_DEF(item2),
  7569. ACMD_DEF(itemreset),
  7570. ACMD_DEF2("blvl", baselevelup),
  7571. ACMD_DEF2("jlvl", joblevelup),
  7572. ACMD_DEF(help),
  7573. ACMD_DEF(pvpoff),
  7574. ACMD_DEF(pvpon),
  7575. ACMD_DEF(gvgoff),
  7576. ACMD_DEF(gvgon),
  7577. ACMD_DEF(model),
  7578. ACMD_DEF(go),
  7579. ACMD_DEF(monster),
  7580. ACMD_DEF2("monstersmall", monster),
  7581. ACMD_DEF2("monsterbig", monster),
  7582. ACMD_DEF(killmonster),
  7583. ACMD_DEF2("killmonster2", killmonster),
  7584. ACMD_DEF(refine),
  7585. ACMD_DEF(produce),
  7586. ACMD_DEF(memo),
  7587. ACMD_DEF(gat),
  7588. ACMD_DEF(displaystatus),
  7589. ACMD_DEF2("stpoint", statuspoint),
  7590. ACMD_DEF2("skpoint", skillpoint),
  7591. ACMD_DEF(zeny),
  7592. ACMD_DEF2("str", param),
  7593. ACMD_DEF2("agi", param),
  7594. ACMD_DEF2("vit", param),
  7595. ACMD_DEF2("int", param),
  7596. ACMD_DEF2("dex", param),
  7597. ACMD_DEF2("luk", param),
  7598. ACMD_DEF2("glvl", guildlevelup),
  7599. ACMD_DEF(makeegg),
  7600. ACMD_DEF(hatch),
  7601. ACMD_DEF(petfriendly),
  7602. ACMD_DEF(pethungry),
  7603. ACMD_DEF(petrename),
  7604. ACMD_DEF(recall), // + /recall
  7605. ACMD_DEF(night),
  7606. ACMD_DEF(day),
  7607. ACMD_DEF(doom),
  7608. ACMD_DEF(doommap),
  7609. ACMD_DEF(raise),
  7610. ACMD_DEF(raisemap),
  7611. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  7612. ACMD_DEF(kickall),
  7613. ACMD_DEF(allskill),
  7614. ACMD_DEF(questskill),
  7615. ACMD_DEF(lostskill),
  7616. ACMD_DEF(spiritball),
  7617. ACMD_DEF(party),
  7618. ACMD_DEF(guild),
  7619. ACMD_DEF(agitstart),
  7620. ACMD_DEF(agitend),
  7621. ACMD_DEF(mapexit),
  7622. ACMD_DEF(idsearch),
  7623. ACMD_DEF(broadcast), // + /b and /nb
  7624. ACMD_DEF(localbroadcast), // + /lb and /nlb
  7625. ACMD_DEF(recallall),
  7626. ACMD_DEF(reloaditemdb),
  7627. ACMD_DEF(reloadmobdb),
  7628. ACMD_DEF(reloadskilldb),
  7629. ACMD_DEF(reloadscript),
  7630. ACMD_DEF(reloadatcommand),
  7631. ACMD_DEF(reloadbattleconf),
  7632. ACMD_DEF(reloadstatusdb),
  7633. ACMD_DEF(reloadpcdb),
  7634. ACMD_DEF(reloadmotd),
  7635. ACMD_DEF(mapinfo),
  7636. ACMD_DEF(dye),
  7637. ACMD_DEF2("hairstyle", hair_style),
  7638. ACMD_DEF2("haircolor", hair_color),
  7639. ACMD_DEF2("allstats", stat_all),
  7640. ACMD_DEF2("block", char_block),
  7641. ACMD_DEF2("ban", char_ban),
  7642. ACMD_DEF2("unblock", char_unblock),
  7643. ACMD_DEF2("unban", char_unban),
  7644. ACMD_DEF2("mount", mount_peco),
  7645. ACMD_DEF(guildspy),
  7646. ACMD_DEF(partyspy),
  7647. ACMD_DEF(repairall),
  7648. ACMD_DEF(guildrecall),
  7649. ACMD_DEF(partyrecall),
  7650. ACMD_DEF(nuke),
  7651. ACMD_DEF(shownpc),
  7652. ACMD_DEF(hidenpc),
  7653. ACMD_DEF(loadnpc),
  7654. ACMD_DEF(unloadnpc),
  7655. ACMD_DEF2("time", servertime),
  7656. ACMD_DEF(jail),
  7657. ACMD_DEF(unjail),
  7658. ACMD_DEF(jailfor),
  7659. ACMD_DEF(jailtime),
  7660. ACMD_DEF(disguise),
  7661. ACMD_DEF(undisguise),
  7662. ACMD_DEF(email),
  7663. ACMD_DEF(effect),
  7664. ACMD_DEF(follow),
  7665. ACMD_DEF(addwarp),
  7666. ACMD_DEF(skillon),
  7667. ACMD_DEF(skilloff),
  7668. ACMD_DEF(killer),
  7669. ACMD_DEF(npcmove),
  7670. ACMD_DEF(killable),
  7671. ACMD_DEF(dropall),
  7672. ACMD_DEF(storeall),
  7673. ACMD_DEF(skillid),
  7674. ACMD_DEF(useskill),
  7675. ACMD_DEF(displayskill),
  7676. ACMD_DEF(snow),
  7677. ACMD_DEF(sakura),
  7678. ACMD_DEF(clouds),
  7679. ACMD_DEF(clouds2),
  7680. ACMD_DEF(fog),
  7681. ACMD_DEF(fireworks),
  7682. ACMD_DEF(leaves),
  7683. ACMD_DEF(summon),
  7684. ACMD_DEF(adjgroup),
  7685. ACMD_DEF(trade),
  7686. ACMD_DEF(send),
  7687. ACMD_DEF(setbattleflag),
  7688. ACMD_DEF(unmute),
  7689. ACMD_DEF(clearweather),
  7690. ACMD_DEF(uptime),
  7691. ACMD_DEF(changesex),
  7692. ACMD_DEF(mute),
  7693. ACMD_DEF(refresh),
  7694. ACMD_DEF(identify),
  7695. ACMD_DEF(gmotd),
  7696. ACMD_DEF(misceffect),
  7697. ACMD_DEF(mobsearch),
  7698. ACMD_DEF(cleanmap),
  7699. ACMD_DEF(npctalk),
  7700. ACMD_DEF(pettalk),
  7701. ACMD_DEF(users),
  7702. ACMD_DEF(reset),
  7703. ACMD_DEF(skilltree),
  7704. ACMD_DEF(marry),
  7705. ACMD_DEF(divorce),
  7706. ACMD_DEF(sound),
  7707. ACMD_DEF(undisguiseall),
  7708. ACMD_DEF(disguiseall),
  7709. ACMD_DEF(changelook),
  7710. ACMD_DEF(autoloot),
  7711. ACMD_DEF2("alootid", autolootitem),
  7712. ACMD_DEF(mobinfo),
  7713. ACMD_DEF(exp),
  7714. ACMD_DEF(adopt),
  7715. ACMD_DEF(version),
  7716. ACMD_DEF(mutearea),
  7717. ACMD_DEF(rates),
  7718. ACMD_DEF(iteminfo),
  7719. ACMD_DEF(whodrops),
  7720. ACMD_DEF(whereis),
  7721. ACMD_DEF(mapflag),
  7722. ACMD_DEF(me),
  7723. ACMD_DEF(monsterignore),
  7724. ACMD_DEF(fakename),
  7725. ACMD_DEF(size),
  7726. ACMD_DEF(showexp),
  7727. ACMD_DEF(showzeny),
  7728. ACMD_DEF(showdelay),
  7729. ACMD_DEF(autotrade),
  7730. ACMD_DEF(changegm),
  7731. ACMD_DEF(changeleader),
  7732. ACMD_DEF(partyoption),
  7733. ACMD_DEF(invite),
  7734. ACMD_DEF(duel),
  7735. ACMD_DEF(leave),
  7736. ACMD_DEF(accept),
  7737. ACMD_DEF(reject),
  7738. ACMD_DEF(main),
  7739. ACMD_DEF(clone),
  7740. ACMD_DEF2("slaveclone", clone),
  7741. ACMD_DEF2("evilclone", clone),
  7742. ACMD_DEF(tonpc),
  7743. ACMD_DEF(commands),
  7744. ACMD_DEF(noask),
  7745. ACMD_DEF(request),
  7746. ACMD_DEF(homlevel),
  7747. ACMD_DEF(homevolution),
  7748. ACMD_DEF(makehomun),
  7749. ACMD_DEF(homfriendly),
  7750. ACMD_DEF(homhungry),
  7751. ACMD_DEF(homtalk),
  7752. ACMD_DEF(hominfo),
  7753. ACMD_DEF(homstats),
  7754. ACMD_DEF(homshuffle),
  7755. ACMD_DEF(showmobs),
  7756. ACMD_DEF(feelreset),
  7757. ACMD_DEF(auction),
  7758. ACMD_DEF(mail),
  7759. ACMD_DEF2("noks", ksprotection),
  7760. ACMD_DEF(allowks),
  7761. ACMD_DEF(cash),
  7762. ACMD_DEF2("points", cash),
  7763. ACMD_DEF(agitstart2),
  7764. ACMD_DEF(agitend2),
  7765. ACMD_DEF2("skreset", resetskill),
  7766. ACMD_DEF2("streset", resetstat),
  7767. ACMD_DEF2("storagelist", itemlist),
  7768. ACMD_DEF2("cartlist", itemlist),
  7769. ACMD_DEF2("itemlist", itemlist),
  7770. ACMD_DEF(stats),
  7771. ACMD_DEF(delitem),
  7772. ACMD_DEF(charcommands),
  7773. ACMD_DEF(font),
  7774. ACMD_DEF(accinfo),
  7775. ACMD_DEF(set),
  7776. ACMD_DEF(reloadquestdb),
  7777. ACMD_DEF(undisguiseguild),
  7778. ACMD_DEF(disguiseguild),
  7779. ACMD_DEF(sizeall),
  7780. ACMD_DEF(sizeguild),
  7781. ACMD_DEF(addperm),
  7782. ACMD_DEF2("rmvperm", addperm),
  7783. ACMD_DEF(unloadnpcfile),
  7784. ACMD_DEF(cart),
  7785. ACMD_DEF(mount2)
  7786. };
  7787. AtCommandInfo* atcommand;
  7788. int i;
  7789. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7790. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  7791. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  7792. continue;
  7793. }
  7794. CREATE(atcommand, AtCommandInfo, 1);
  7795. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  7796. atcommand->func = atcommand_base[i].func;
  7797. strdb_put(atcommand_db, atcommand->command, atcommand);
  7798. }
  7799. return;
  7800. }
  7801. /*==========================================
  7802. * Command lookup functions
  7803. *------------------------------------------*/
  7804. bool atcommand_exists(const char* name)
  7805. {
  7806. return strdb_exists(atcommand_db, name);
  7807. }
  7808. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  7809. {
  7810. if (strdb_exists(atcommand_db, name))
  7811. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7812. return NULL;
  7813. }
  7814. static const char* atcommand_checkalias(const char *aliasname)
  7815. {
  7816. AliasInfo *alias_info = NULL;
  7817. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  7818. return alias_info->command->command;
  7819. return aliasname;
  7820. }
  7821. /// AtCommand suggestion
  7822. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  7823. DBIterator* atcommand_iter;
  7824. DBIterator* alias_iter;
  7825. AtCommandInfo* command_info = NULL;
  7826. AliasInfo* alias_info = NULL;
  7827. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  7828. char* full_match[MAX_SUGGESTIONS];
  7829. char* suggestions[MAX_SUGGESTIONS];
  7830. char* match;
  7831. int prefix_count = 0, full_count = 0;
  7832. bool can_use;
  7833. if (!battle_config.atcommand_suggestions_enabled)
  7834. return;
  7835. atcommand_iter = db_iterator(atcommand_db);
  7836. alias_iter = db_iterator(atcommand_alias_db);
  7837. // Build the matches
  7838. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  7839. match = strstr(command_info->command, name);
  7840. can_use = pc_can_use_command(sd, command_info->command, type);
  7841. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  7842. suggestions[prefix_count] = command_info->command;
  7843. ++prefix_count;
  7844. }
  7845. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  7846. full_match[full_count] = command_info->command;
  7847. ++full_count;
  7848. }
  7849. }
  7850. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  7851. match = strstr(alias_info->alias, name);
  7852. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  7853. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  7854. suggestions[prefix_count] = alias_info->alias;
  7855. ++prefix_count;
  7856. }
  7857. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  7858. full_match[full_count] = alias_info->alias;
  7859. ++full_count;
  7860. }
  7861. }
  7862. if ((full_count+prefix_count) > 0) {
  7863. char buffer[512];
  7864. int i;
  7865. // Merge full match and prefix match results
  7866. if (prefix_count < MAX_SUGGESTIONS) {
  7867. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  7868. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  7869. }
  7870. // Build the suggestion string
  7871. strcpy(buffer, msg_txt(205));
  7872. strcat(buffer,"\n");
  7873. for(i=0; i < prefix_count; ++i) {
  7874. strcat(buffer,suggestions[i]);
  7875. strcat(buffer," ");
  7876. }
  7877. clif_displaymessage(sd->fd, buffer);
  7878. }
  7879. dbi_destroy(atcommand_iter);
  7880. dbi_destroy(alias_iter);
  7881. }
  7882. /// Executes an at-command.
  7883. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7884. {
  7885. char charname[NAME_LENGTH], params[100];
  7886. char charname2[NAME_LENGTH], params2[100];
  7887. char command[100];
  7888. char output[CHAT_SIZE_MAX];
  7889. //Reconstructed message
  7890. char atcmd_msg[CHAT_SIZE_MAX];
  7891. TBL_PC * ssd = NULL; //sd for target
  7892. AtCommandInfo * info;
  7893. nullpo_retr(false, sd);
  7894. //Shouldn't happen
  7895. if ( !message || !*message )
  7896. return false;
  7897. //Block NOCHAT but do not display it as a normal message
  7898. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7899. return true;
  7900. // skip 10/11-langtype's codepage indicator, if detected
  7901. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7902. message += 3;
  7903. //Should display as a normal message
  7904. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7905. return false;
  7906. // type value 0 = server invoked: bypass restrictions
  7907. // 1 = player invoked
  7908. if ( type == 1) {
  7909. //Commands are disabled on maps flagged as 'nocommand'
  7910. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  7911. clif_displaymessage(fd, msg_txt(143));
  7912. return false;
  7913. }
  7914. }
  7915. if (*message == charcommand_symbol) {
  7916. do {
  7917. int x, y, z;
  7918. //Checks to see if #command has a name or a name + parameters.
  7919. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7920. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7921. //z always has the value of the scan that was successful
  7922. z = ( x > 1 ) ? x : y;
  7923. //#command + name means the sufficient target was used and anything else after
  7924. //can be looked at by the actual command function since most scan to see if the
  7925. //right parameters are used.
  7926. if ( x > 2 ) {
  7927. sprintf(atcmd_msg, "%s %s", command, params);
  7928. break;
  7929. }
  7930. else if ( y > 2 ) {
  7931. sprintf(atcmd_msg, "%s %s", command, params2);
  7932. break;
  7933. }
  7934. //Regardless of what style the #command is used, if it's correct, it will always have
  7935. //this value if there is no parameter. Send it as just the #command
  7936. else if ( z == 2 ) {
  7937. sprintf(atcmd_msg, "%s", command);
  7938. break;
  7939. }
  7940. if( !pc_get_group_level(sd) ) {
  7941. if( x >= 1 || y >= 1 ) { /* we have command */
  7942. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  7943. if( !info || info->char_groups[sd->group_pos] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */
  7944. return false;
  7945. } else
  7946. return false;/* display as normal message */
  7947. }
  7948. sprintf(output, msg_txt(1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  7949. clif_displaymessage(fd, output);
  7950. return true;
  7951. } while(0);
  7952. }
  7953. else if (*message == atcommand_symbol) {
  7954. //atcmd_msg is constructed above differently for charcommands
  7955. //it's copied from message if not a charcommand so it can
  7956. //pass through the rest of the code compatible with both symbols
  7957. sprintf(atcmd_msg, "%s", message);
  7958. }
  7959. //Clearing these to be used once more.
  7960. memset(command, '\0', sizeof(command));
  7961. memset(params, '\0', sizeof(params));
  7962. //check to see if any params exist within this command
  7963. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7964. params[0] = '\0';
  7965. // @commands (script based)
  7966. if(type == 1 && atcmd_binding_count > 0) {
  7967. struct atcmd_binding_data * binding;
  7968. // Check if the command initiated is a character command
  7969. if (*message == charcommand_symbol &&
  7970. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  7971. sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
  7972. clif_displaymessage(fd, output);
  7973. return true;
  7974. }
  7975. // Get atcommand binding
  7976. binding = get_atcommandbind_byname(command);
  7977. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  7978. if( binding != NULL && binding->npc_event[0] &&
  7979. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  7980. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  7981. {
  7982. // Check if self or character invoking; if self == character invoked, then self invoke.
  7983. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  7984. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  7985. return true;
  7986. }
  7987. }
  7988. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7989. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  7990. if (info == NULL) {
  7991. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  7992. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7993. clif_displaymessage(fd, output);
  7994. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  7995. return true;
  7996. } else
  7997. return false;
  7998. }
  7999. // type == 1 : player invoked
  8000. if (type == 1) {
  8001. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8002. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8003. return false;
  8004. }
  8005. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8006. clif_displaymessage(fd, msg_txt(1393)); // You can't use commands while dead
  8007. return true;
  8008. }
  8009. }
  8010. // Check if target is valid only if confirmed that player can use command.
  8011. if (*message == charcommand_symbol &&
  8012. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8013. sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
  8014. clif_displaymessage(fd, output);
  8015. return true;
  8016. }
  8017. //Attempt to use the command
  8018. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8019. {
  8020. sprintf(output,msg_txt(154), command); // %s failed.
  8021. clif_displaymessage(fd, output);
  8022. return true;
  8023. }
  8024. //Log only if successful.
  8025. if ( *atcmd_msg == atcommand_symbol )
  8026. log_atcommand(sd, atcmd_msg);
  8027. else if ( *atcmd_msg == charcommand_symbol )
  8028. log_atcommand(sd, message);
  8029. return true;
  8030. }
  8031. /*==========================================
  8032. *
  8033. *------------------------------------------*/
  8034. static void atcommand_config_read(const char* config_filename)
  8035. {
  8036. config_setting_t *aliases = NULL, *help = NULL;
  8037. const char *symbol = NULL;
  8038. int num_aliases = 0;
  8039. if (conf_read_file(&atcommand_config, config_filename))
  8040. return;
  8041. // Command symbols
  8042. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8043. if (ISPRINT(*symbol) && // no control characters
  8044. *symbol != '/' && // symbol of client commands
  8045. *symbol != '%' && // symbol of party chat
  8046. *symbol != '$' && // symbol of guild chat
  8047. *symbol != charcommand_symbol)
  8048. atcommand_symbol = *symbol;
  8049. }
  8050. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8051. if (ISPRINT(*symbol) && // no control characters
  8052. *symbol != '/' && // symbol of client commands
  8053. *symbol != '%' && // symbol of party chat
  8054. *symbol != '$' && // symbol of guild chat
  8055. *symbol != atcommand_symbol)
  8056. charcommand_symbol = *symbol;
  8057. }
  8058. // Command aliases
  8059. aliases = config_lookup(&atcommand_config, "aliases");
  8060. if (aliases != NULL) {
  8061. int i = 0;
  8062. int count = config_setting_length(aliases);
  8063. for (i = 0; i < count; ++i) {
  8064. config_setting_t *command = NULL;
  8065. const char *commandname = NULL;
  8066. int j = 0, alias_count = 0;
  8067. AtCommandInfo *commandinfo = NULL;
  8068. command = config_setting_get_elem(aliases, i);
  8069. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8070. continue;
  8071. commandname = config_setting_name(command);
  8072. if (!atcommand_exists(commandname)) {
  8073. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8074. continue;
  8075. }
  8076. commandinfo = get_atcommandinfo_byname(commandname);
  8077. alias_count = config_setting_length(command);
  8078. for (j = 0; j < alias_count; ++j) {
  8079. const char *alias = config_setting_get_string_elem(command, j);
  8080. if (alias != NULL) {
  8081. AliasInfo *alias_info;
  8082. if (strdb_exists(atcommand_alias_db, alias)) {
  8083. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8084. continue;
  8085. }
  8086. CREATE(alias_info, AliasInfo, 1);
  8087. alias_info->command = commandinfo;
  8088. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8089. strdb_put(atcommand_alias_db, alias, alias_info);
  8090. ++num_aliases;
  8091. }
  8092. }
  8093. }
  8094. }
  8095. // Commands help
  8096. // We only check if all commands exist
  8097. help = config_lookup(&atcommand_config, "help");
  8098. if (help != NULL) {
  8099. int count = config_setting_length(help);
  8100. int i;
  8101. for (i = 0; i < count; ++i) {
  8102. config_setting_t *command = NULL;
  8103. const char *commandname = NULL;
  8104. command = config_setting_get_elem(help, i);
  8105. commandname = config_setting_name(command);
  8106. if (!atcommand_exists(commandname))
  8107. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8108. }
  8109. }
  8110. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8111. return;
  8112. }
  8113. void atcommand_db_load_groups(int* group_ids) {
  8114. DBIterator *iter = db_iterator(atcommand_db);
  8115. AtCommandInfo* cmd;
  8116. int i;
  8117. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8118. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8119. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8120. for(i = 0; i < pc_group_max; i++) {
  8121. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8122. cmd->at_groups[i] = 1;
  8123. else
  8124. cmd->at_groups[i] = 0;
  8125. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8126. cmd->char_groups[i] = 1;
  8127. else
  8128. cmd->char_groups[i] = 0;
  8129. }
  8130. }
  8131. dbi_destroy(iter);
  8132. return;
  8133. }
  8134. void atcommand_db_clear(void) {
  8135. if (atcommand_db != NULL) {
  8136. DBIterator *iter = db_iterator(atcommand_db);
  8137. AtCommandInfo* cmd;
  8138. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8139. aFree(cmd->at_groups);
  8140. aFree(cmd->char_groups);
  8141. }
  8142. dbi_destroy(iter);
  8143. db_destroy(atcommand_db);
  8144. }
  8145. if (atcommand_alias_db != NULL)
  8146. db_destroy(atcommand_alias_db);
  8147. config_destroy(&atcommand_config);
  8148. }
  8149. void atcommand_doload(void) {
  8150. atcommand_db_clear();
  8151. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8152. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8153. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8154. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8155. }
  8156. void do_init_atcommand(void) {
  8157. atcommand_doload();
  8158. }
  8159. void do_final_atcommand(void) {
  8160. atcommand_db_clear();
  8161. }