atcommand.c 272 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482
  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. unsigned int size;
  1819. nullpo_retr(-1, sd);
  1820. memset(name, '\0', sizeof(name));
  1821. memset(monster, '\0', sizeof(monster));
  1822. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1823. if (!message || !*message) {
  1824. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  1825. return -1;
  1826. }
  1827. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1828. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1829. //All data can be left as it is.
  1830. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1831. //Here, it is possible name was not given and we are using monster for it.
  1832. if (count < 3) //Blank mob's name.
  1833. name[0] = '\0';
  1834. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1835. //All data can be left as it is.
  1836. } else if (sscanf(message, "%23s", monster) > 0) {
  1837. //As before, name may be already filled.
  1838. name[0] = '\0';
  1839. } else {
  1840. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  1841. return -1;
  1842. }
  1843. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1844. mob_id = mobdb_checkid(atoi(monster));
  1845. if (mob_id == 0) {
  1846. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1847. return -1;
  1848. }
  1849. if (mob_id == MOBID_EMPERIUM) {
  1850. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  1851. return -1;
  1852. }
  1853. if (number <= 0)
  1854. number = 1;
  1855. if( !name[0] )
  1856. strcpy(name, "--ja--");
  1857. // 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
  1858. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1859. number = battle_config.atc_spawn_quantity_limit;
  1860. if (strcmp(command+1, "monstersmall") == 0)
  1861. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1862. else if (strcmp(command+1, "monsterbig") == 0)
  1863. size = SZ_BIG;
  1864. else
  1865. size = SZ_SMALL;
  1866. if (battle_config.etc_log)
  1867. 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);
  1868. count = 0;
  1869. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1870. for (i = 0; i < number; i++) {
  1871. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1872. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1873. count += (k != 0) ? 1 : 0;
  1874. }
  1875. if (count != 0)
  1876. if (number == count)
  1877. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  1878. else {
  1879. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  1880. clif_displaymessage(fd, atcmd_output);
  1881. }
  1882. else {
  1883. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  1884. return -1;
  1885. }
  1886. return 0;
  1887. }
  1888. /*==========================================
  1889. *
  1890. *------------------------------------------*/
  1891. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1892. {
  1893. struct mob_data *md;
  1894. int flag;
  1895. nullpo_ret(md=(struct mob_data *)bl);
  1896. flag = va_arg(ap, int);
  1897. if (md->guardian_data)
  1898. return 0; //Do not touch WoE mobs!
  1899. if (flag)
  1900. status_zap(bl,md->status.hp, 0);
  1901. else
  1902. status_kill(bl);
  1903. return 1;
  1904. }
  1905. ACMD_FUNC(killmonster)
  1906. {
  1907. int map_id, drop_flag;
  1908. char map_name[MAP_NAME_LENGTH_EXT];
  1909. nullpo_retr(-1, sd);
  1910. memset(map_name, '\0', sizeof(map_name));
  1911. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1912. map_id = sd->bl.m;
  1913. else {
  1914. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1915. map_id = sd->bl.m;
  1916. }
  1917. drop_flag = strcmp(command+1, "killmonster2");
  1918. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1919. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  1920. return 0;
  1921. }
  1922. /*==========================================
  1923. *
  1924. *------------------------------------------*/
  1925. ACMD_FUNC(refine)
  1926. {
  1927. int i,j, position = 0, refine = 0, current_position, final_refine;
  1928. int count;
  1929. nullpo_retr(-1, sd);
  1930. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1931. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1932. clif_displaymessage(fd, msg_txt(996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1933. sprintf(atcmd_output, msg_txt(997), EQP_HEAD_LOW); // %d: Lower Headgear
  1934. clif_displaymessage(fd, atcmd_output);
  1935. sprintf(atcmd_output, msg_txt(998), EQP_HAND_R); // %d: Right Hand
  1936. clif_displaymessage(fd, atcmd_output);
  1937. sprintf(atcmd_output, msg_txt(999), EQP_GARMENT); // %d: Garment
  1938. clif_displaymessage(fd, atcmd_output);
  1939. sprintf(atcmd_output, msg_txt(1000), EQP_ACC_L); // %d: Left Accessory
  1940. clif_displaymessage(fd, atcmd_output);
  1941. sprintf(atcmd_output, msg_txt(1001), EQP_ARMOR); // %d: Body Armor
  1942. clif_displaymessage(fd, atcmd_output);
  1943. sprintf(atcmd_output, msg_txt(1002), EQP_HAND_L); // %d: Left Hand
  1944. clif_displaymessage(fd, atcmd_output);
  1945. sprintf(atcmd_output, msg_txt(1003), EQP_SHOES); // %d: Shoes
  1946. clif_displaymessage(fd, atcmd_output);
  1947. sprintf(atcmd_output, msg_txt(1004), EQP_ACC_R); // %d: Right Accessory
  1948. clif_displaymessage(fd, atcmd_output);
  1949. sprintf(atcmd_output, msg_txt(1005), EQP_HEAD_TOP); // %d: Top Headgear
  1950. clif_displaymessage(fd, atcmd_output);
  1951. sprintf(atcmd_output, msg_txt(1006), EQP_HEAD_MID); // %d: Mid Headgear
  1952. clif_displaymessage(fd, atcmd_output);
  1953. return -1;
  1954. }
  1955. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1956. count = 0;
  1957. for (j = 0; j < EQI_MAX-1; j++) {
  1958. if ((i = sd->equip_index[j]) < 0)
  1959. continue;
  1960. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1961. continue;
  1962. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1963. continue;
  1964. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1965. continue;
  1966. if(position && !(sd->status.inventory[i].equip & position))
  1967. continue;
  1968. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1969. if (sd->status.inventory[i].refine != final_refine) {
  1970. sd->status.inventory[i].refine = final_refine;
  1971. current_position = sd->status.inventory[i].equip;
  1972. pc_unequipitem(sd, i, 3);
  1973. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1974. clif_delitem(sd, i, 1, 3);
  1975. clif_additem(sd, i, 1, 0);
  1976. pc_equipitem(sd, i, current_position);
  1977. clif_misceffect(&sd->bl, 3);
  1978. count++;
  1979. }
  1980. }
  1981. if (count == 0)
  1982. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  1983. else if (count == 1)
  1984. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  1985. else {
  1986. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  1987. clif_displaymessage(fd, atcmd_output);
  1988. }
  1989. return 0;
  1990. }
  1991. /*==========================================
  1992. *
  1993. *------------------------------------------*/
  1994. ACMD_FUNC(produce)
  1995. {
  1996. char item_name[100];
  1997. int item_id, attribute = 0, star = 0;
  1998. int flag = 0;
  1999. struct item_data *item_data;
  2000. struct item tmp_item;
  2001. nullpo_retr(-1, sd);
  2002. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2003. memset(item_name, '\0', sizeof(item_name));
  2004. if (!message || !*message || (
  2005. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2006. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2007. )) {
  2008. clif_displaymessage(fd, msg_txt(1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2009. return -1;
  2010. }
  2011. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  2012. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  2013. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2014. return -1;
  2015. }
  2016. item_id = item_data->nameid;
  2017. if (itemdb_isequip2(item_data)) {
  2018. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2019. attribute = ATTRIBUTE_NORMAL;
  2020. if (star < MIN_STAR || star > MAX_STAR)
  2021. star = 0;
  2022. memset(&tmp_item, 0, sizeof tmp_item);
  2023. tmp_item.nameid = item_id;
  2024. tmp_item.amount = 1;
  2025. tmp_item.identify = 1;
  2026. tmp_item.card[0] = CARD0_FORGE;
  2027. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2028. ((star*5) << 8) + attribute:0;
  2029. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2030. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2031. clif_produceeffect(sd, 0, item_id);
  2032. clif_misceffect(&sd->bl, 3);
  2033. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2034. clif_additem(sd, 0, 0, flag);
  2035. } else {
  2036. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2037. clif_displaymessage(fd, atcmd_output);
  2038. return -1;
  2039. }
  2040. return 0;
  2041. }
  2042. /*==========================================
  2043. *
  2044. *------------------------------------------*/
  2045. ACMD_FUNC(memo)
  2046. {
  2047. int position = 0;
  2048. nullpo_retr(-1, sd);
  2049. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2050. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2051. {
  2052. int i;
  2053. clif_displaymessage(sd->fd, msg_txt(668));
  2054. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2055. {
  2056. if( sd->status.memo_point[i].map )
  2057. 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);
  2058. else
  2059. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2060. clif_displaymessage(sd->fd, atcmd_output);
  2061. }
  2062. return 0;
  2063. }
  2064. if( position < 0 || position >= MAX_MEMOPOINTS )
  2065. {
  2066. sprintf(atcmd_output, msg_txt(1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2067. clif_displaymessage(fd, atcmd_output);
  2068. return -1;
  2069. }
  2070. pc_memo(sd, position);
  2071. return 0;
  2072. }
  2073. /*==========================================
  2074. *
  2075. *------------------------------------------*/
  2076. ACMD_FUNC(gat)
  2077. {
  2078. int y;
  2079. nullpo_retr(-1, sd);
  2080. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2081. for (y = 2; y >= -2; y--) {
  2082. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2083. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2084. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2085. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2086. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2087. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2088. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2089. clif_displaymessage(fd, atcmd_output);
  2090. }
  2091. return 0;
  2092. }
  2093. /*==========================================
  2094. *
  2095. *------------------------------------------*/
  2096. ACMD_FUNC(displaystatus)
  2097. {
  2098. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2099. nullpo_retr(-1, sd);
  2100. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2101. clif_displaymessage(fd, msg_txt(1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2102. return -1;
  2103. }
  2104. if (i < 2) flag = 1;
  2105. if (i < 3) tick = 0;
  2106. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2107. return 0;
  2108. }
  2109. /*==========================================
  2110. * @stpoint (Rewritten by [Yor])
  2111. *------------------------------------------*/
  2112. ACMD_FUNC(statuspoint)
  2113. {
  2114. int point;
  2115. unsigned int new_status_point;
  2116. if (!message || !*message || (point = atoi(message)) == 0) {
  2117. clif_displaymessage(fd, msg_txt(1010)); // Please enter a number (usage: @stpoint <number of points>).
  2118. return -1;
  2119. }
  2120. if(point < 0)
  2121. {
  2122. if(sd->status.status_point < (unsigned int)(-point))
  2123. {
  2124. new_status_point = 0;
  2125. }
  2126. else
  2127. {
  2128. new_status_point = sd->status.status_point + point;
  2129. }
  2130. }
  2131. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2132. {
  2133. new_status_point = UINT_MAX;
  2134. }
  2135. else
  2136. {
  2137. new_status_point = sd->status.status_point + point;
  2138. }
  2139. if (new_status_point != sd->status.status_point) {
  2140. sd->status.status_point = new_status_point;
  2141. clif_updatestatus(sd, SP_STATUSPOINT);
  2142. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2143. } else {
  2144. if (point < 0)
  2145. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2146. else
  2147. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2148. return -1;
  2149. }
  2150. return 0;
  2151. }
  2152. /*==========================================
  2153. * @skpoint (Rewritten by [Yor])
  2154. *------------------------------------------*/
  2155. ACMD_FUNC(skillpoint)
  2156. {
  2157. int point;
  2158. unsigned int new_skill_point;
  2159. nullpo_retr(-1, sd);
  2160. if (!message || !*message || (point = atoi(message)) == 0) {
  2161. clif_displaymessage(fd, msg_txt(1011)); // Please enter a number (usage: @skpoint <number of points>).
  2162. return -1;
  2163. }
  2164. if(point < 0)
  2165. {
  2166. if(sd->status.skill_point < (unsigned int)(-point))
  2167. {
  2168. new_skill_point = 0;
  2169. }
  2170. else
  2171. {
  2172. new_skill_point = sd->status.skill_point + point;
  2173. }
  2174. }
  2175. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2176. {
  2177. new_skill_point = UINT_MAX;
  2178. }
  2179. else
  2180. {
  2181. new_skill_point = sd->status.skill_point + point;
  2182. }
  2183. if (new_skill_point != sd->status.skill_point) {
  2184. sd->status.skill_point = new_skill_point;
  2185. clif_updatestatus(sd, SP_SKILLPOINT);
  2186. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2187. } else {
  2188. if (point < 0)
  2189. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2190. else
  2191. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2192. return -1;
  2193. }
  2194. return 0;
  2195. }
  2196. /*==========================================
  2197. * @zeny (Rewritten by [Yor])
  2198. *------------------------------------------*/
  2199. ACMD_FUNC(zeny)
  2200. {
  2201. int zeny, new_zeny;
  2202. nullpo_retr(-1, sd);
  2203. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2204. clif_displaymessage(fd, msg_txt(1012)); // Please enter an amount (usage: @zeny <amount>).
  2205. return -1;
  2206. }
  2207. pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL);
  2208. return 0;
  2209. }
  2210. /*==========================================
  2211. *
  2212. *------------------------------------------*/
  2213. ACMD_FUNC(param)
  2214. {
  2215. int i, value = 0, new_value, max;
  2216. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2217. short* status[6];
  2218. //we don't use direct initialization because it isn't part of the c standard.
  2219. nullpo_retr(-1, sd);
  2220. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2221. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2222. clif_displaymessage(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2223. return -1;
  2224. }
  2225. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2226. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2227. clif_displaymessage(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2228. return -1;
  2229. }
  2230. status[0] = &sd->status.str;
  2231. status[1] = &sd->status.agi;
  2232. status[2] = &sd->status.vit;
  2233. status[3] = &sd->status.int_;
  2234. status[4] = &sd->status.dex;
  2235. status[5] = &sd->status.luk;
  2236. if( battle_config.atcommand_max_stat_bypass )
  2237. max = SHRT_MAX;
  2238. else
  2239. max = pc_maxparameter(sd);
  2240. if(value < 0 && *status[i] <= -value) {
  2241. new_value = 1;
  2242. } else if(max - *status[i] < value) {
  2243. new_value = max;
  2244. } else {
  2245. new_value = *status[i] + value;
  2246. }
  2247. if (new_value != *status[i]) {
  2248. *status[i] = new_value;
  2249. clif_updatestatus(sd, SP_STR + i);
  2250. clif_updatestatus(sd, SP_USTR + i);
  2251. status_calc_pc(sd, 0);
  2252. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2253. } else {
  2254. if (value < 0)
  2255. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2256. else
  2257. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2258. return -1;
  2259. }
  2260. return 0;
  2261. }
  2262. /*==========================================
  2263. * Stat all by fritz (rewritten by [Yor])
  2264. *------------------------------------------*/
  2265. ACMD_FUNC(stat_all)
  2266. {
  2267. int index, count, value, max, new_value;
  2268. short* status[6];
  2269. //we don't use direct initialization because it isn't part of the c standard.
  2270. nullpo_retr(-1, sd);
  2271. status[0] = &sd->status.str;
  2272. status[1] = &sd->status.agi;
  2273. status[2] = &sd->status.vit;
  2274. status[3] = &sd->status.int_;
  2275. status[4] = &sd->status.dex;
  2276. status[5] = &sd->status.luk;
  2277. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2278. value = pc_maxparameter(sd);
  2279. max = pc_maxparameter(sd);
  2280. } else {
  2281. if( battle_config.atcommand_max_stat_bypass )
  2282. max = SHRT_MAX;
  2283. else
  2284. max = pc_maxparameter(sd);
  2285. }
  2286. count = 0;
  2287. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2288. if (value > 0 && *status[index] > max - value)
  2289. new_value = max;
  2290. else if (value < 0 && *status[index] <= -value)
  2291. new_value = 1;
  2292. else
  2293. new_value = *status[index] +value;
  2294. if (new_value != (int)*status[index]) {
  2295. *status[index] = new_value;
  2296. clif_updatestatus(sd, SP_STR + index);
  2297. clif_updatestatus(sd, SP_USTR + index);
  2298. count++;
  2299. }
  2300. }
  2301. if (count > 0) { // if at least 1 stat modified
  2302. status_calc_pc(sd, 0);
  2303. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2304. } else {
  2305. if (value < 0)
  2306. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2307. else
  2308. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2309. return -1;
  2310. }
  2311. return 0;
  2312. }
  2313. /*==========================================
  2314. *
  2315. *------------------------------------------*/
  2316. ACMD_FUNC(guildlevelup)
  2317. {
  2318. int level = 0;
  2319. short added_level;
  2320. struct guild *guild_info;
  2321. nullpo_retr(-1, sd);
  2322. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2323. clif_displaymessage(fd, msg_txt(1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2324. return -1;
  2325. }
  2326. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2327. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2328. return -1;
  2329. }
  2330. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2331. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2332. // return -1;
  2333. //}
  2334. added_level = (short)level;
  2335. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2336. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2337. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2338. added_level = 1 - guild_info->guild_lv;
  2339. if (added_level != 0) {
  2340. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2341. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2342. } else {
  2343. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2344. return -1;
  2345. }
  2346. return 0;
  2347. }
  2348. /*==========================================
  2349. *
  2350. *------------------------------------------*/
  2351. ACMD_FUNC(makeegg)
  2352. {
  2353. struct item_data *item_data;
  2354. int id, pet_id;
  2355. nullpo_retr(-1, sd);
  2356. if (!message || !*message) {
  2357. clif_displaymessage(fd, msg_txt(1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2358. return -1;
  2359. }
  2360. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2361. id = item_data->nameid;
  2362. else
  2363. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2364. ;
  2365. else
  2366. id = atoi(message);
  2367. pet_id = search_petDB_index(id, PET_CLASS);
  2368. if (pet_id < 0)
  2369. pet_id = search_petDB_index(id, PET_EGG);
  2370. if (pet_id >= 0) {
  2371. sd->catch_target_class = pet_db[pet_id].class_;
  2372. intif_create_pet(
  2373. sd->status.account_id, sd->status.char_id,
  2374. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2375. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2376. 100, 0, 1, pet_db[pet_id].jname);
  2377. } else {
  2378. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2379. return -1;
  2380. }
  2381. return 0;
  2382. }
  2383. /*==========================================
  2384. *
  2385. *------------------------------------------*/
  2386. ACMD_FUNC(hatch)
  2387. {
  2388. nullpo_retr(-1, sd);
  2389. if (sd->status.pet_id <= 0)
  2390. clif_sendegg(sd);
  2391. else {
  2392. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2393. return -1;
  2394. }
  2395. return 0;
  2396. }
  2397. /*==========================================
  2398. *
  2399. *------------------------------------------*/
  2400. ACMD_FUNC(petfriendly)
  2401. {
  2402. int friendly;
  2403. struct pet_data *pd;
  2404. nullpo_retr(-1, sd);
  2405. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2406. clif_displaymessage(fd, msg_txt(1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2407. return -1;
  2408. }
  2409. pd = sd->pd;
  2410. if (!pd) {
  2411. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2412. return -1;
  2413. }
  2414. if (friendly < 0 || friendly > 1000)
  2415. {
  2416. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2417. return -1;
  2418. }
  2419. if (friendly == pd->pet.intimate) {
  2420. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2421. return -1;
  2422. }
  2423. pet_set_intimate(pd, friendly);
  2424. clif_send_petstatus(sd);
  2425. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2426. return 0;
  2427. }
  2428. /*==========================================
  2429. *
  2430. *------------------------------------------*/
  2431. ACMD_FUNC(pethungry)
  2432. {
  2433. int hungry;
  2434. struct pet_data *pd;
  2435. nullpo_retr(-1, sd);
  2436. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2437. clif_displaymessage(fd, msg_txt(1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2438. return -1;
  2439. }
  2440. pd = sd->pd;
  2441. if (!sd->status.pet_id || !pd) {
  2442. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2443. return -1;
  2444. }
  2445. if (hungry < 0 || hungry > 100) {
  2446. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2447. return -1;
  2448. }
  2449. if (hungry == pd->pet.hungry) {
  2450. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2451. return -1;
  2452. }
  2453. pd->pet.hungry = hungry;
  2454. clif_send_petstatus(sd);
  2455. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2456. return 0;
  2457. }
  2458. /*==========================================
  2459. *
  2460. *------------------------------------------*/
  2461. ACMD_FUNC(petrename)
  2462. {
  2463. struct pet_data *pd;
  2464. nullpo_retr(-1, sd);
  2465. if (!sd->status.pet_id || !sd->pd) {
  2466. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2467. return -1;
  2468. }
  2469. pd = sd->pd;
  2470. if (!pd->pet.rename_flag) {
  2471. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2472. return -1;
  2473. }
  2474. pd->pet.rename_flag = 0;
  2475. intif_save_petdata(sd->status.account_id, &pd->pet);
  2476. clif_send_petstatus(sd);
  2477. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2478. return 0;
  2479. }
  2480. /*==========================================
  2481. *
  2482. *------------------------------------------*/
  2483. ACMD_FUNC(recall) {
  2484. struct map_session_data *pl_sd = NULL;
  2485. nullpo_retr(-1, sd);
  2486. if (!message || !*message) {
  2487. clif_displaymessage(fd, msg_txt(1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2488. return -1;
  2489. }
  2490. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2491. {
  2492. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2493. return -1;
  2494. }
  2495. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2496. {
  2497. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2498. return -1;
  2499. }
  2500. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2501. clif_displaymessage(fd, msg_txt(1019)); // You are not authorized to warp someone to this map.
  2502. return -1;
  2503. }
  2504. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2505. clif_displaymessage(fd, msg_txt(1020)); // You are not authorized to warp this player from their map.
  2506. return -1;
  2507. }
  2508. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2509. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  2510. clif_displaymessage(fd, atcmd_output);
  2511. return 0;
  2512. }
  2513. /*==========================================
  2514. * charblock command (usage: charblock <player_name>)
  2515. * This command do a definitiv ban on a player
  2516. *------------------------------------------*/
  2517. ACMD_FUNC(char_block)
  2518. {
  2519. nullpo_retr(-1, sd);
  2520. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2521. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2522. clif_displaymessage(fd, msg_txt(1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2523. return -1;
  2524. }
  2525. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2526. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2527. return 0;
  2528. }
  2529. /*==========================================
  2530. * charban command (usage: charban <time> <player_name>)
  2531. * This command do a limited ban on a player
  2532. * Time is done as follows:
  2533. * Adjustment value (-1, 1, +1, etc...)
  2534. * Modified element:
  2535. * a or y: year
  2536. * m: month
  2537. * j or d: day
  2538. * h: hour
  2539. * mn: minute
  2540. * s: second
  2541. * <example> @ban +1m-2mn1s-6y test_player
  2542. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2543. *------------------------------------------*/
  2544. ACMD_FUNC(char_ban)
  2545. {
  2546. char * modif_p;
  2547. int year, month, day, hour, minute, second, value;
  2548. time_t timestamp;
  2549. struct tm *tmtime;
  2550. nullpo_retr(-1, sd);
  2551. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2552. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2553. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2554. clif_displaymessage(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2555. return -1;
  2556. }
  2557. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2558. modif_p = atcmd_output;
  2559. year = month = day = hour = minute = second = 0;
  2560. while (modif_p[0] != '\0') {
  2561. value = atoi(modif_p);
  2562. if (value == 0)
  2563. modif_p++;
  2564. else {
  2565. if (modif_p[0] == '-' || modif_p[0] == '+')
  2566. modif_p++;
  2567. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2568. modif_p++;
  2569. if (modif_p[0] == 's') {
  2570. second = value;
  2571. modif_p++;
  2572. } else if (modif_p[0] == 'n') {
  2573. minute = value;
  2574. modif_p++;
  2575. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2576. minute = value;
  2577. modif_p = modif_p + 2;
  2578. } else if (modif_p[0] == 'h') {
  2579. hour = value;
  2580. modif_p++;
  2581. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2582. day = value;
  2583. modif_p++;
  2584. } else if (modif_p[0] == 'm') {
  2585. month = value;
  2586. modif_p++;
  2587. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2588. year = value;
  2589. modif_p++;
  2590. } else if (modif_p[0] != '\0') {
  2591. modif_p++;
  2592. }
  2593. }
  2594. }
  2595. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2596. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  2597. return -1;
  2598. }
  2599. /**
  2600. * We now check if you can adjust the ban to negative (and if this is the case)
  2601. **/
  2602. timestamp = time(NULL);
  2603. tmtime = localtime(&timestamp);
  2604. tmtime->tm_year = tmtime->tm_year + year;
  2605. tmtime->tm_mon = tmtime->tm_mon + month;
  2606. tmtime->tm_mday = tmtime->tm_mday + day;
  2607. tmtime->tm_hour = tmtime->tm_hour + hour;
  2608. tmtime->tm_min = tmtime->tm_min + minute;
  2609. tmtime->tm_sec = tmtime->tm_sec + second;
  2610. timestamp = mktime(tmtime);
  2611. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2612. clif_displaymessage(fd,msg_txt(1023)); // You are not allowed to reduce the length of a ban.
  2613. return -1;
  2614. }
  2615. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2616. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2617. return 0;
  2618. }
  2619. /*==========================================
  2620. * charunblock command (usage: charunblock <player_name>)
  2621. *------------------------------------------*/
  2622. ACMD_FUNC(char_unblock)
  2623. {
  2624. nullpo_retr(-1, sd);
  2625. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2626. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2627. clif_displaymessage(fd, msg_txt(1024)); // Please enter a player name (usage: @charunblock <char name>).
  2628. return -1;
  2629. }
  2630. // send answer to login server via char-server
  2631. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2632. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2633. return 0;
  2634. }
  2635. /*==========================================
  2636. * charunban command (usage: charunban <player_name>)
  2637. *------------------------------------------*/
  2638. ACMD_FUNC(char_unban)
  2639. {
  2640. nullpo_retr(-1, sd);
  2641. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2642. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2643. clif_displaymessage(fd, msg_txt(1025)); // Please enter a player name (usage: @charunban <char name>).
  2644. return -1;
  2645. }
  2646. // send answer to login server via char-server
  2647. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2648. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  2649. return 0;
  2650. }
  2651. /*==========================================
  2652. *
  2653. *------------------------------------------*/
  2654. ACMD_FUNC(night)
  2655. {
  2656. nullpo_retr(-1, sd);
  2657. if (night_flag != 1) {
  2658. map_night_timer(night_timer_tid, 0, 0, 1);
  2659. } else {
  2660. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  2661. return -1;
  2662. }
  2663. return 0;
  2664. }
  2665. /*==========================================
  2666. *
  2667. *------------------------------------------*/
  2668. ACMD_FUNC(day)
  2669. {
  2670. nullpo_retr(-1, sd);
  2671. if (night_flag != 0) {
  2672. map_day_timer(day_timer_tid, 0, 0, 1);
  2673. } else {
  2674. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  2675. return -1;
  2676. }
  2677. return 0;
  2678. }
  2679. /*==========================================
  2680. *
  2681. *------------------------------------------*/
  2682. ACMD_FUNC(doom)
  2683. {
  2684. struct map_session_data* pl_sd;
  2685. struct s_mapiterator* iter;
  2686. nullpo_retr(-1, sd);
  2687. iter = mapit_getallusers();
  2688. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2689. {
  2690. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2691. {
  2692. status_kill(&pl_sd->bl);
  2693. clif_specialeffect(&pl_sd->bl,450,AREA);
  2694. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2695. }
  2696. }
  2697. mapit_free(iter);
  2698. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2699. return 0;
  2700. }
  2701. /*==========================================
  2702. *
  2703. *------------------------------------------*/
  2704. ACMD_FUNC(doommap)
  2705. {
  2706. struct map_session_data* pl_sd;
  2707. struct s_mapiterator* iter;
  2708. nullpo_retr(-1, sd);
  2709. iter = mapit_getallusers();
  2710. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2711. {
  2712. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2713. {
  2714. status_kill(&pl_sd->bl);
  2715. clif_specialeffect(&pl_sd->bl,450,AREA);
  2716. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  2717. }
  2718. }
  2719. mapit_free(iter);
  2720. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  2721. return 0;
  2722. }
  2723. /*==========================================
  2724. *
  2725. *------------------------------------------*/
  2726. static void atcommand_raise_sub(struct map_session_data* sd) {
  2727. status_revive(&sd->bl, 100, 100);
  2728. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2729. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  2730. }
  2731. /*==========================================
  2732. *
  2733. *------------------------------------------*/
  2734. ACMD_FUNC(raise)
  2735. {
  2736. struct map_session_data* pl_sd;
  2737. struct s_mapiterator* iter;
  2738. nullpo_retr(-1, sd);
  2739. iter = mapit_getallusers();
  2740. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2741. if( pc_isdead(pl_sd) )
  2742. atcommand_raise_sub(pl_sd);
  2743. mapit_free(iter);
  2744. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2745. return 0;
  2746. }
  2747. /*==========================================
  2748. *
  2749. *------------------------------------------*/
  2750. ACMD_FUNC(raisemap)
  2751. {
  2752. struct map_session_data* pl_sd;
  2753. struct s_mapiterator* iter;
  2754. nullpo_retr(-1, sd);
  2755. iter = mapit_getallusers();
  2756. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2757. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2758. atcommand_raise_sub(pl_sd);
  2759. mapit_free(iter);
  2760. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  2761. return 0;
  2762. }
  2763. /*==========================================
  2764. *
  2765. *------------------------------------------*/
  2766. ACMD_FUNC(kick)
  2767. {
  2768. struct map_session_data *pl_sd;
  2769. nullpo_retr(-1, sd);
  2770. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2771. if (!message || !*message) {
  2772. clif_displaymessage(fd, msg_txt(1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2773. return -1;
  2774. }
  2775. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2776. {
  2777. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2778. return -1;
  2779. }
  2780. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2781. {
  2782. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2783. return -1;
  2784. }
  2785. clif_GM_kick(sd, pl_sd);
  2786. return 0;
  2787. }
  2788. /*==========================================
  2789. *
  2790. *------------------------------------------*/
  2791. ACMD_FUNC(kickall)
  2792. {
  2793. struct map_session_data* pl_sd;
  2794. struct s_mapiterator* iter;
  2795. nullpo_retr(-1, sd);
  2796. iter = mapit_getallusers();
  2797. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2798. {
  2799. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2800. if (sd->status.account_id != pl_sd->status.account_id)
  2801. clif_GM_kick(NULL, pl_sd);
  2802. }
  2803. }
  2804. mapit_free(iter);
  2805. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  2806. return 0;
  2807. }
  2808. /*==========================================
  2809. *
  2810. *------------------------------------------*/
  2811. ACMD_FUNC(allskill)
  2812. {
  2813. nullpo_retr(-1, sd);
  2814. pc_allskillup(sd); // all skills
  2815. sd->status.skill_point = 0; // 0 skill points
  2816. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2817. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  2818. return 0;
  2819. }
  2820. /*==========================================
  2821. *
  2822. *------------------------------------------*/
  2823. ACMD_FUNC(questskill)
  2824. {
  2825. int skill_id;
  2826. nullpo_retr(-1, sd);
  2827. if (!message || !*message || (skill_id = atoi(message)) < 0)
  2828. {// also send a list of skills applicable to this command
  2829. const char* text;
  2830. // attempt to find the text corresponding to this command
  2831. text = atcommand_help_string( command );
  2832. // send the error message as always
  2833. clif_displaymessage(fd, msg_txt(1027)); // Please enter a quest skill number.
  2834. if( text )
  2835. {// send the skill ID list associated with this command
  2836. clif_displaymessage( fd, text );
  2837. }
  2838. return -1;
  2839. }
  2840. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  2841. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2842. return -1;
  2843. }
  2844. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2845. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2846. return -1;
  2847. }
  2848. if (pc_checkskill(sd, skill_id) > 0) {
  2849. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  2850. return -1;
  2851. }
  2852. pc_skill(sd, skill_id, 1, 0);
  2853. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  2854. return 0;
  2855. }
  2856. /*==========================================
  2857. *
  2858. *------------------------------------------*/
  2859. ACMD_FUNC(lostskill)
  2860. {
  2861. int skill_id;
  2862. nullpo_retr(-1, sd);
  2863. if (!message || !*message || (skill_id = atoi(message)) < 0)
  2864. {// also send a list of skills applicable to this command
  2865. const char* text;
  2866. // attempt to find the text corresponding to this command
  2867. text = atcommand_help_string( command );
  2868. // send the error message as always
  2869. clif_displaymessage(fd, msg_txt(1027)); // Please enter a quest skill number.
  2870. if( text )
  2871. {// send the skill ID list associated with this command
  2872. clif_displaymessage( fd, text );
  2873. }
  2874. return -1;
  2875. }
  2876. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  2877. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  2878. return -1;
  2879. }
  2880. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2881. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  2882. return -1;
  2883. }
  2884. if (pc_checkskill(sd, skill_id) == 0) {
  2885. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  2886. return -1;
  2887. }
  2888. sd->status.skill[skill_id].lv = 0;
  2889. sd->status.skill[skill_id].flag = 0;
  2890. clif_deleteskill(sd,skill_id);
  2891. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  2892. return 0;
  2893. }
  2894. /*==========================================
  2895. *
  2896. *------------------------------------------*/
  2897. ACMD_FUNC(spiritball)
  2898. {
  2899. int max_spiritballs;
  2900. int number;
  2901. nullpo_retr(-1, sd);
  2902. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2903. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2904. {
  2905. char msg[CHAT_SIZE_MAX];
  2906. safesnprintf(msg, sizeof(msg), msg_txt(1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2907. clif_displaymessage(fd, msg);
  2908. return -1;
  2909. }
  2910. if( sd->spiritball > 0 )
  2911. pc_delspiritball(sd, sd->spiritball, 1);
  2912. sd->spiritball = number;
  2913. clif_spiritball(&sd->bl);
  2914. // no message, player can look the difference
  2915. return 0;
  2916. }
  2917. /*==========================================
  2918. *
  2919. *------------------------------------------*/
  2920. ACMD_FUNC(party)
  2921. {
  2922. char party[NAME_LENGTH];
  2923. nullpo_retr(-1, sd);
  2924. memset(party, '\0', sizeof(party));
  2925. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2926. clif_displaymessage(fd, msg_txt(1029)); // Please enter a party name (usage: @party <party_name>).
  2927. return -1;
  2928. }
  2929. party_create(sd, party, 0, 0);
  2930. return 0;
  2931. }
  2932. /*==========================================
  2933. *
  2934. *------------------------------------------*/
  2935. ACMD_FUNC(guild)
  2936. {
  2937. char guild[NAME_LENGTH];
  2938. int prev;
  2939. nullpo_retr(-1, sd);
  2940. memset(guild, '\0', sizeof(guild));
  2941. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2942. clif_displaymessage(fd, msg_txt(1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2943. return -1;
  2944. }
  2945. prev = battle_config.guild_emperium_check;
  2946. battle_config.guild_emperium_check = 0;
  2947. guild_create(sd, guild);
  2948. battle_config.guild_emperium_check = prev;
  2949. return 0;
  2950. }
  2951. /*==========================================
  2952. *
  2953. *------------------------------------------*/
  2954. ACMD_FUNC(agitstart)
  2955. {
  2956. nullpo_retr(-1, sd);
  2957. if (agit_flag == 1) {
  2958. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  2959. return -1;
  2960. }
  2961. agit_flag = 1;
  2962. guild_agit_start();
  2963. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  2964. return 0;
  2965. }
  2966. /*==========================================
  2967. *
  2968. *------------------------------------------*/
  2969. ACMD_FUNC(agitstart2)
  2970. {
  2971. nullpo_retr(-1, sd);
  2972. if (agit2_flag == 1) {
  2973. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  2974. return -1;
  2975. }
  2976. agit2_flag = 1;
  2977. guild_agit2_start();
  2978. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  2979. return 0;
  2980. }
  2981. /*==========================================
  2982. *
  2983. *------------------------------------------*/
  2984. ACMD_FUNC(agitend)
  2985. {
  2986. nullpo_retr(-1, sd);
  2987. if (agit_flag == 0) {
  2988. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  2989. return -1;
  2990. }
  2991. agit_flag = 0;
  2992. guild_agit_end();
  2993. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  2994. return 0;
  2995. }
  2996. /*==========================================
  2997. *
  2998. *------------------------------------------*/
  2999. ACMD_FUNC(agitend2)
  3000. {
  3001. nullpo_retr(-1, sd);
  3002. if (agit2_flag == 0) {
  3003. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3004. return -1;
  3005. }
  3006. agit2_flag = 0;
  3007. guild_agit2_end();
  3008. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3009. return 0;
  3010. }
  3011. /*==========================================
  3012. * @mapexit - shuts down the map server
  3013. *------------------------------------------*/
  3014. ACMD_FUNC(mapexit)
  3015. {
  3016. nullpo_retr(-1, sd);
  3017. do_shutdown();
  3018. return 0;
  3019. }
  3020. /*==========================================
  3021. * idsearch <part_of_name>: revrited by [Yor]
  3022. *------------------------------------------*/
  3023. ACMD_FUNC(idsearch)
  3024. {
  3025. char item_name[100];
  3026. unsigned int i, match;
  3027. struct item_data *item_array[MAX_SEARCH];
  3028. nullpo_retr(-1, sd);
  3029. memset(item_name, '\0', sizeof(item_name));
  3030. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3031. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3032. clif_displaymessage(fd, msg_txt(1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3033. return -1;
  3034. }
  3035. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3036. clif_displaymessage(fd, atcmd_output);
  3037. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3038. if (match > MAX_SEARCH) {
  3039. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3040. clif_displaymessage(fd, atcmd_output);
  3041. match = MAX_SEARCH;
  3042. }
  3043. for(i = 0; i < match; i++) {
  3044. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3045. clif_displaymessage(fd, atcmd_output);
  3046. }
  3047. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3048. clif_displaymessage(fd, atcmd_output);
  3049. return 0;
  3050. }
  3051. /*==========================================
  3052. * Recall All Characters Online To Your Location
  3053. *------------------------------------------*/
  3054. ACMD_FUNC(recallall)
  3055. {
  3056. struct map_session_data* pl_sd;
  3057. struct s_mapiterator* iter;
  3058. int count;
  3059. nullpo_retr(-1, sd);
  3060. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3061. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3062. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3063. return -1;
  3064. }
  3065. count = 0;
  3066. iter = mapit_getallusers();
  3067. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3068. {
  3069. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3070. {
  3071. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3072. count++;
  3073. else {
  3074. if (pc_isdead(pl_sd)) { //Wake them up
  3075. pc_setstand(pl_sd);
  3076. pc_setrestartvalue(pl_sd,1);
  3077. }
  3078. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3079. }
  3080. }
  3081. }
  3082. mapit_free(iter);
  3083. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3084. if (count) {
  3085. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3086. clif_displaymessage(fd, atcmd_output);
  3087. }
  3088. return 0;
  3089. }
  3090. /*==========================================
  3091. * Recall online characters of a guild to your location
  3092. *------------------------------------------*/
  3093. ACMD_FUNC(guildrecall)
  3094. {
  3095. struct map_session_data* pl_sd;
  3096. struct s_mapiterator* iter;
  3097. int count;
  3098. char guild_name[NAME_LENGTH];
  3099. struct guild *g;
  3100. nullpo_retr(-1, sd);
  3101. memset(guild_name, '\0', sizeof(guild_name));
  3102. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3103. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3104. clif_displaymessage(fd, msg_txt(1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3105. return -1;
  3106. }
  3107. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3108. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3109. return -1;
  3110. }
  3111. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3112. (g = guild_search(atoi(message))) == NULL)
  3113. {
  3114. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3115. return -1;
  3116. }
  3117. count = 0;
  3118. iter = mapit_getallusers();
  3119. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3120. {
  3121. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3122. {
  3123. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3124. continue; //Skip GMs greater than you.
  3125. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3126. count++;
  3127. else
  3128. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3129. }
  3130. }
  3131. mapit_free(iter);
  3132. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3133. clif_displaymessage(fd, atcmd_output);
  3134. if (count) {
  3135. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3136. clif_displaymessage(fd, atcmd_output);
  3137. }
  3138. return 0;
  3139. }
  3140. /*==========================================
  3141. * Recall online characters of a party to your location
  3142. *------------------------------------------*/
  3143. ACMD_FUNC(partyrecall)
  3144. {
  3145. struct map_session_data* pl_sd;
  3146. struct s_mapiterator* iter;
  3147. char party_name[NAME_LENGTH];
  3148. struct party_data *p;
  3149. int count;
  3150. nullpo_retr(-1, sd);
  3151. memset(party_name, '\0', sizeof(party_name));
  3152. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3153. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3154. clif_displaymessage(fd, msg_txt(1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3155. return -1;
  3156. }
  3157. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3158. clif_displaymessage(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map.
  3159. return -1;
  3160. }
  3161. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3162. (p = party_search(atoi(message))) == NULL)
  3163. {
  3164. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3165. return -1;
  3166. }
  3167. count = 0;
  3168. iter = mapit_getallusers();
  3169. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3170. {
  3171. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3172. {
  3173. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd))
  3174. continue; //Skip GMs greater than you.
  3175. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3176. count++;
  3177. else
  3178. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3179. }
  3180. }
  3181. mapit_free(iter);
  3182. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3183. clif_displaymessage(fd, atcmd_output);
  3184. if (count) {
  3185. sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3186. clif_displaymessage(fd, atcmd_output);
  3187. }
  3188. return 0;
  3189. }
  3190. /*==========================================
  3191. *
  3192. *------------------------------------------*/
  3193. ACMD_FUNC(reloaditemdb)
  3194. {
  3195. nullpo_retr(-1, sd);
  3196. itemdb_reload();
  3197. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3198. return 0;
  3199. }
  3200. /*==========================================
  3201. *
  3202. *------------------------------------------*/
  3203. ACMD_FUNC(reloadmobdb)
  3204. {
  3205. nullpo_retr(-1, sd);
  3206. mob_reload();
  3207. read_petdb();
  3208. merc_reload();
  3209. read_mercenarydb();
  3210. read_mercenary_skilldb();
  3211. reload_elementaldb();
  3212. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3213. return 0;
  3214. }
  3215. /*==========================================
  3216. *
  3217. *------------------------------------------*/
  3218. ACMD_FUNC(reloadskilldb)
  3219. {
  3220. nullpo_retr(-1, sd);
  3221. skill_reload();
  3222. merc_skill_reload();
  3223. reload_elemental_skilldb();
  3224. read_mercenary_skilldb();
  3225. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3226. return 0;
  3227. }
  3228. /*==========================================
  3229. * @reloadatcommand - reloads atcommand_athena.conf groups.conf
  3230. *------------------------------------------*/
  3231. void atcommand_doload();
  3232. ACMD_FUNC(reloadatcommand) {
  3233. config_t run_test;
  3234. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3235. clif_displaymessage(fd, msg_txt(1036)); // Error reading groups.conf, reload failed.
  3236. return -1;
  3237. }
  3238. config_destroy(&run_test);
  3239. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3240. clif_displaymessage(fd, msg_txt(1037)); // Error reading atcommand_athena.conf, reload failed.
  3241. return -1;
  3242. }
  3243. config_destroy(&run_test);
  3244. atcommand_doload();
  3245. pc_groups_reload();
  3246. clif_displaymessage(fd, msg_txt(254));
  3247. return 0;
  3248. }
  3249. /*==========================================
  3250. * @reloadbattleconf - reloads battle_athena.conf
  3251. *------------------------------------------*/
  3252. ACMD_FUNC(reloadbattleconf)
  3253. {
  3254. struct Battle_Config prev_config;
  3255. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3256. battle_config_read(BATTLE_CONF_FILENAME);
  3257. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3258. || prev_config.item_rate_common != battle_config.item_rate_common
  3259. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3260. || prev_config.item_rate_card != battle_config.item_rate_card
  3261. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3262. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3263. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3264. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3265. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3266. || prev_config.item_rate_use != battle_config.item_rate_use
  3267. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3268. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3269. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3270. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3271. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3272. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3273. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3274. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3275. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3276. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3277. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3278. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3279. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3280. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3281. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3282. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3283. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3284. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3285. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3286. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3287. )
  3288. { // Exp or Drop rates changed.
  3289. mob_reload(); //Needed as well so rate changes take effect.
  3290. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3291. }
  3292. clif_displaymessage(fd, msg_txt(255));
  3293. return 0;
  3294. }
  3295. /*==========================================
  3296. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3297. *------------------------------------------*/
  3298. ACMD_FUNC(reloadstatusdb)
  3299. {
  3300. status_readdb();
  3301. clif_displaymessage(fd, msg_txt(256));
  3302. return 0;
  3303. }
  3304. /*==========================================
  3305. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3306. *------------------------------------------*/
  3307. ACMD_FUNC(reloadpcdb)
  3308. {
  3309. pc_readdb();
  3310. clif_displaymessage(fd, msg_txt(257));
  3311. return 0;
  3312. }
  3313. /*==========================================
  3314. * @reloadmotd - reloads motd.txt
  3315. *------------------------------------------*/
  3316. ACMD_FUNC(reloadmotd)
  3317. {
  3318. pc_read_motd();
  3319. clif_displaymessage(fd, msg_txt(268));
  3320. return 0;
  3321. }
  3322. /*==========================================
  3323. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3324. *------------------------------------------*/
  3325. ACMD_FUNC(reloadscript)
  3326. {
  3327. nullpo_retr(-1, sd);
  3328. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3329. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3330. flush_fifos();
  3331. map_reloadnpc(true); // reload config files seeking for npcs
  3332. script_reload();
  3333. npc_reload();
  3334. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3335. return 0;
  3336. }
  3337. /*==========================================
  3338. * @mapinfo [0-3] <map name> by MC_Cameri
  3339. * => Shows information about the map [map name]
  3340. * 0 = no additional information
  3341. * 1 = Show users in that map and their location
  3342. * 2 = Shows NPCs in that map
  3343. * 3 = Shows the shops/chats in that map (not implemented)
  3344. *------------------------------------------*/
  3345. ACMD_FUNC(mapinfo)
  3346. {
  3347. struct map_session_data* pl_sd;
  3348. struct s_mapiterator* iter;
  3349. struct npc_data *nd = NULL;
  3350. struct chat_data *cd = NULL;
  3351. char direction[12];
  3352. int i, m_id, chat_num, list = 0;
  3353. unsigned short m_index;
  3354. char mapname[24];
  3355. nullpo_retr(-1, sd);
  3356. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3357. memset(mapname, '\0', sizeof(mapname));
  3358. memset(direction, '\0', sizeof(direction));
  3359. sscanf(message, "%d %23[^\n]", &list, mapname);
  3360. if (list < 0 || list > 3) {
  3361. clif_displaymessage(fd, msg_txt(1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3362. return -1;
  3363. }
  3364. if (mapname[0] == '\0') {
  3365. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3366. m_id = map_mapindex2mapid(sd->mapindex);
  3367. } else {
  3368. m_id = map_mapname2mapid(mapname);
  3369. }
  3370. if (m_id < 0) {
  3371. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3372. return -1;
  3373. }
  3374. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3375. clif_displaymessage(fd, msg_txt(1039)); // ------ Map Info ------
  3376. // count chats (for initial message)
  3377. chat_num = 0;
  3378. iter = mapit_getallusers();
  3379. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3380. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3381. chat_num++;
  3382. mapit_free(iter);
  3383. 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
  3384. clif_displaymessage(fd, atcmd_output);
  3385. clif_displaymessage(fd, msg_txt(1041)); // ------ Map Flags ------
  3386. if (map[m_id].flag.town)
  3387. clif_displaymessage(fd, msg_txt(1042)); // Town Map
  3388. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3389. clif_displaymessage(fd, msg_txt(1043)); // Autotrade Enabled
  3390. else
  3391. clif_displaymessage(fd, msg_txt(1044)); // Autotrade Disabled
  3392. if (map[m_id].flag.battleground)
  3393. clif_displaymessage(fd, msg_txt(1045)); // Battlegrounds ON
  3394. strcpy(atcmd_output,msg_txt(1046)); // PvP Flags:
  3395. if (map[m_id].flag.pvp)
  3396. strcat(atcmd_output, msg_txt(1047)); // Pvp ON |
  3397. if (map[m_id].flag.pvp_noguild)
  3398. strcat(atcmd_output, msg_txt(1048)); // NoGuild |
  3399. if (map[m_id].flag.pvp_noparty)
  3400. strcat(atcmd_output, msg_txt(1049)); // NoParty |
  3401. if (map[m_id].flag.pvp_nightmaredrop)
  3402. strcat(atcmd_output, msg_txt(1050)); // NightmareDrop |
  3403. if (map[m_id].flag.pvp_nocalcrank)
  3404. strcat(atcmd_output, msg_txt(1051)); // NoCalcRank |
  3405. clif_displaymessage(fd, atcmd_output);
  3406. strcpy(atcmd_output,msg_txt(1052)); // GvG Flags:
  3407. if (map[m_id].flag.gvg)
  3408. strcat(atcmd_output, msg_txt(1053)); // GvG ON |
  3409. if (map[m_id].flag.gvg_dungeon)
  3410. strcat(atcmd_output, msg_txt(1054)); // GvG Dungeon |
  3411. if (map[m_id].flag.gvg_castle)
  3412. strcat(atcmd_output, msg_txt(1055)); // GvG Castle |
  3413. if (map[m_id].flag.gvg_noparty)
  3414. strcat(atcmd_output, msg_txt(1056)); // NoParty |
  3415. clif_displaymessage(fd, atcmd_output);
  3416. strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags:
  3417. if (map[m_id].flag.noteleport)
  3418. strcat(atcmd_output, msg_txt(1058)); // NoTeleport |
  3419. if (map[m_id].flag.monster_noteleport)
  3420. strcat(atcmd_output, msg_txt(1059)); // Monster NoTeleport |
  3421. if (map[m_id].flag.nowarp)
  3422. strcat(atcmd_output, msg_txt(1060)); // NoWarp |
  3423. if (map[m_id].flag.nowarpto)
  3424. strcat(atcmd_output, msg_txt(1061)); // NoWarpTo |
  3425. if (map[m_id].flag.noreturn)
  3426. strcat(atcmd_output, msg_txt(1062)); // NoReturn |
  3427. if (map[m_id].flag.nogo)
  3428. strcat(atcmd_output, msg_txt(1063)); // NoGo |
  3429. if (map[m_id].flag.nomemo)
  3430. strcat(atcmd_output, msg_txt(1064)); // NoMemo |
  3431. clif_displaymessage(fd, atcmd_output);
  3432. sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3433. (map[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off
  3434. clif_displaymessage(fd, atcmd_output);
  3435. if (map[m_id].flag.nosave) {
  3436. if (!map[m_id].save.map)
  3437. clif_displaymessage(fd, msg_txt(1068)); // No Save (Return to last Save Point)
  3438. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3439. sprintf(atcmd_output, msg_txt(1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3440. clif_displaymessage(fd, atcmd_output);
  3441. }
  3442. else {
  3443. sprintf(atcmd_output, msg_txt(1070), // No Save, Save Point: %s,%d,%d
  3444. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3445. clif_displaymessage(fd, atcmd_output);
  3446. }
  3447. }
  3448. strcpy(atcmd_output,msg_txt(1071)); // Weather Flags:
  3449. if (map[m_id].flag.snow)
  3450. strcat(atcmd_output, msg_txt(1072)); // Snow |
  3451. if (map[m_id].flag.fog)
  3452. strcat(atcmd_output, msg_txt(1073)); // Fog |
  3453. if (map[m_id].flag.sakura)
  3454. strcat(atcmd_output, msg_txt(1074)); // Sakura |
  3455. if (map[m_id].flag.clouds)
  3456. strcat(atcmd_output, msg_txt(1075)); // Clouds |
  3457. if (map[m_id].flag.clouds2)
  3458. strcat(atcmd_output, msg_txt(1076)); // Clouds2 |
  3459. if (map[m_id].flag.fireworks)
  3460. strcat(atcmd_output, msg_txt(1077)); // Fireworks |
  3461. if (map[m_id].flag.leaves)
  3462. strcat(atcmd_output, msg_txt(1078)); // Leaves |
  3463. /**
  3464. * No longer available, keeping here just in case it's back someday. [Ind]
  3465. **/
  3466. //if (map[m_id].flag.rain)
  3467. // strcat(atcmd_output, msg_txt(1079)); // Rain |
  3468. if (map[m_id].flag.nightenabled)
  3469. strcat(atcmd_output, msg_txt(1080)); // Displays Night |
  3470. clif_displaymessage(fd, atcmd_output);
  3471. strcpy(atcmd_output,msg_txt(1081)); // Other Flags:
  3472. if (map[m_id].flag.nobranch)
  3473. strcat(atcmd_output, msg_txt(1082)); // NoBranch |
  3474. if (map[m_id].flag.notrade)
  3475. strcat(atcmd_output, msg_txt(1083)); // NoTrade |
  3476. if (map[m_id].flag.novending)
  3477. strcat(atcmd_output, msg_txt(1084)); // NoVending |
  3478. if (map[m_id].flag.nodrop)
  3479. strcat(atcmd_output, msg_txt(1085)); // NoDrop |
  3480. if (map[m_id].flag.noskill)
  3481. strcat(atcmd_output, msg_txt(1086)); // NoSkill |
  3482. if (map[m_id].flag.noicewall)
  3483. strcat(atcmd_output, msg_txt(1087)); // NoIcewall |
  3484. if (map[m_id].flag.allowks)
  3485. strcat(atcmd_output, msg_txt(1088)); // AllowKS |
  3486. if (map[m_id].flag.reset)
  3487. strcat(atcmd_output, msg_txt(1089)); // Reset |
  3488. clif_displaymessage(fd, atcmd_output);
  3489. strcpy(atcmd_output,msg_txt(1090)); // Other Flags:
  3490. if (map[m_id].nocommand)
  3491. strcat(atcmd_output, msg_txt(1091)); // NoCommand |
  3492. if (map[m_id].flag.nobaseexp)
  3493. strcat(atcmd_output, msg_txt(1092)); // NoBaseEXP |
  3494. if (map[m_id].flag.nojobexp)
  3495. strcat(atcmd_output, msg_txt(1093)); // NoJobEXP |
  3496. if (map[m_id].flag.nomobloot)
  3497. strcat(atcmd_output, msg_txt(1094)); // NoMobLoot |
  3498. if (map[m_id].flag.nomvploot)
  3499. strcat(atcmd_output, msg_txt(1095)); // NoMVPLoot |
  3500. if (map[m_id].flag.partylock)
  3501. strcat(atcmd_output, msg_txt(1096)); // PartyLock |
  3502. if (map[m_id].flag.guildlock)
  3503. strcat(atcmd_output, msg_txt(1097)); // GuildLock |
  3504. clif_displaymessage(fd, atcmd_output);
  3505. switch (list) {
  3506. case 0:
  3507. // Do nothing. It's list 0, no additional display.
  3508. break;
  3509. case 1:
  3510. clif_displaymessage(fd, msg_txt(1098)); // ----- Players in Map -----
  3511. iter = mapit_getallusers();
  3512. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3513. {
  3514. if (pl_sd->mapindex == m_index) {
  3515. sprintf(atcmd_output, msg_txt(1099), // Player '%s' (session #%d) | Location: %d,%d
  3516. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3517. clif_displaymessage(fd, atcmd_output);
  3518. }
  3519. }
  3520. mapit_free(iter);
  3521. break;
  3522. case 2:
  3523. clif_displaymessage(fd, msg_txt(1100)); // ----- NPCs in Map -----
  3524. for (i = 0; i < map[m_id].npc_num;)
  3525. {
  3526. nd = map[m_id].npc[i];
  3527. switch(nd->ud.dir) {
  3528. case 0: strcpy(direction, msg_txt(1101)); break; // North
  3529. case 1: strcpy(direction, msg_txt(1102)); break; // North West
  3530. case 2: strcpy(direction, msg_txt(1103)); break; // West
  3531. case 3: strcpy(direction, msg_txt(1104)); break; // South West
  3532. case 4: strcpy(direction, msg_txt(1105)); break; // South
  3533. case 5: strcpy(direction, msg_txt(1106)); break; // South East
  3534. case 6: strcpy(direction, msg_txt(1107)); break; // East
  3535. case 7: strcpy(direction, msg_txt(1108)); break; // North East
  3536. case 9: strcpy(direction, msg_txt(1109)); break; // North
  3537. default: strcpy(direction, msg_txt(1110)); break; // Unknown
  3538. }
  3539. if(strcmp(nd->name,nd->exname) == 0)
  3540. sprintf(atcmd_output, msg_txt(1111), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3541. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3542. else
  3543. sprintf(atcmd_output, msg_txt(1112), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3544. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3545. clif_displaymessage(fd, atcmd_output);
  3546. }
  3547. break;
  3548. case 3:
  3549. clif_displaymessage(fd, msg_txt(1113)); // ----- Chats in Map -----
  3550. iter = mapit_getallusers();
  3551. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3552. {
  3553. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3554. pl_sd->mapindex == m_index &&
  3555. cd->usersd[0] == pl_sd)
  3556. {
  3557. sprintf(atcmd_output, msg_txt(1114), // Chat: %s | Player: %s | Location: %d %d
  3558. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3559. clif_displaymessage(fd, atcmd_output);
  3560. sprintf(atcmd_output, msg_txt(1115), // Users: %d/%d | Password: %s | Public: %s
  3561. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(1116) : msg_txt(1117)); // Yes / No
  3562. clif_displaymessage(fd, atcmd_output);
  3563. }
  3564. }
  3565. mapit_free(iter);
  3566. break;
  3567. default: // normally impossible to arrive here
  3568. clif_displaymessage(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3569. return -1;
  3570. break;
  3571. }
  3572. return 0;
  3573. }
  3574. /*==========================================
  3575. *
  3576. *------------------------------------------*/
  3577. ACMD_FUNC(mount_peco)
  3578. {
  3579. nullpo_retr(-1, sd);
  3580. if (sd->disguise) {
  3581. clif_displaymessage(fd, msg_txt(212)); // Cannot mount while in disguise.
  3582. return -1;
  3583. }
  3584. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3585. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3586. clif_displaymessage(sd->fd,msg_txt(1119)); // You have mounted your Dragon.
  3587. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3588. } else {
  3589. clif_displaymessage(sd->fd,msg_txt(1120)); // You have released your Dragon.
  3590. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3591. }
  3592. return 0;
  3593. }
  3594. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  3595. if( !pc_isridingwug(sd) ) {
  3596. clif_displaymessage(sd->fd,msg_txt(1121)); // You have mounted your Warg.
  3597. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3598. } else {
  3599. clif_displaymessage(sd->fd,msg_txt(1122)); // You have released your Warg.
  3600. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3601. }
  3602. return 0;
  3603. }
  3604. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3605. if( !pc_ismadogear(sd) ) {
  3606. clif_displaymessage(sd->fd,msg_txt(1123)); // You have mounted your Mado Gear.
  3607. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3608. } else {
  3609. clif_displaymessage(sd->fd,msg_txt(1124)); // You have released your Mado Gear.
  3610. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3611. }
  3612. return 0;
  3613. }
  3614. if (!pc_isriding(sd)) { // if actually no peco
  3615. if (!pc_checkskill(sd, KN_RIDING)) {
  3616. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  3617. return -1;
  3618. }
  3619. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3620. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  3621. } else {//Dismount
  3622. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3623. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  3624. }
  3625. return 0;
  3626. }
  3627. /*==========================================
  3628. *Spy Commands by Syrus22
  3629. *------------------------------------------*/
  3630. ACMD_FUNC(guildspy)
  3631. {
  3632. char guild_name[NAME_LENGTH];
  3633. struct guild *g;
  3634. nullpo_retr(-1, sd);
  3635. memset(guild_name, '\0', sizeof(guild_name));
  3636. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3637. if (!enable_spy)
  3638. {
  3639. clif_displaymessage(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
  3640. return -1;
  3641. }
  3642. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3643. clif_displaymessage(fd, msg_txt(1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3644. return -1;
  3645. }
  3646. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3647. (g = guild_search(atoi(message))) != NULL) {
  3648. if (sd->guildspy == g->guild_id) {
  3649. sd->guildspy = 0;
  3650. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  3651. clif_displaymessage(fd, atcmd_output);
  3652. } else {
  3653. sd->guildspy = g->guild_id;
  3654. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  3655. clif_displaymessage(fd, atcmd_output);
  3656. }
  3657. } else {
  3658. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  3659. return -1;
  3660. }
  3661. return 0;
  3662. }
  3663. /*==========================================
  3664. *
  3665. *------------------------------------------*/
  3666. ACMD_FUNC(partyspy)
  3667. {
  3668. char party_name[NAME_LENGTH];
  3669. struct party_data *p;
  3670. nullpo_retr(-1, sd);
  3671. memset(party_name, '\0', sizeof(party_name));
  3672. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3673. if (!enable_spy)
  3674. {
  3675. clif_displaymessage(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
  3676. return -1;
  3677. }
  3678. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3679. clif_displaymessage(fd, msg_txt(1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3680. return -1;
  3681. }
  3682. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3683. (p = party_search(atoi(message))) != NULL) {
  3684. if (sd->partyspy == p->party.party_id) {
  3685. sd->partyspy = 0;
  3686. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  3687. clif_displaymessage(fd, atcmd_output);
  3688. } else {
  3689. sd->partyspy = p->party.party_id;
  3690. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  3691. clif_displaymessage(fd, atcmd_output);
  3692. }
  3693. } else {
  3694. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  3695. return -1;
  3696. }
  3697. return 0;
  3698. }
  3699. /*==========================================
  3700. * @repairall [Valaris]
  3701. *------------------------------------------*/
  3702. ACMD_FUNC(repairall)
  3703. {
  3704. int count, i;
  3705. nullpo_retr(-1, sd);
  3706. count = 0;
  3707. for (i = 0; i < MAX_INVENTORY; i++) {
  3708. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3709. sd->status.inventory[i].attribute = 0;
  3710. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3711. count++;
  3712. }
  3713. }
  3714. if (count > 0) {
  3715. clif_misceffect(&sd->bl, 3);
  3716. clif_equiplist(sd);
  3717. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  3718. } else {
  3719. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  3720. return -1;
  3721. }
  3722. return 0;
  3723. }
  3724. /*==========================================
  3725. * @nuke [Valaris]
  3726. *------------------------------------------*/
  3727. ACMD_FUNC(nuke)
  3728. {
  3729. struct map_session_data *pl_sd;
  3730. nullpo_retr(-1, sd);
  3731. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3732. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3733. clif_displaymessage(fd, msg_txt(1128)); // Please enter a player name (usage: @nuke <char name>).
  3734. return -1;
  3735. }
  3736. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3737. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3738. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3739. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  3740. } else {
  3741. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3742. return -1;
  3743. }
  3744. } else {
  3745. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3746. return -1;
  3747. }
  3748. return 0;
  3749. }
  3750. /*==========================================
  3751. * @tonpc
  3752. *------------------------------------------*/
  3753. ACMD_FUNC(tonpc)
  3754. {
  3755. char npcname[NAME_LENGTH+1];
  3756. struct npc_data *nd;
  3757. nullpo_retr(-1, sd);
  3758. memset(npcname, 0, sizeof(npcname));
  3759. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3760. clif_displaymessage(fd, msg_txt(1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3761. return -1;
  3762. }
  3763. if ((nd = npc_name2id(npcname)) != NULL) {
  3764. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3765. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3766. else
  3767. return -1;
  3768. } else {
  3769. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3770. return -1;
  3771. }
  3772. return 0;
  3773. }
  3774. /*==========================================
  3775. *
  3776. *------------------------------------------*/
  3777. ACMD_FUNC(shownpc)
  3778. {
  3779. char NPCname[NAME_LENGTH+1];
  3780. nullpo_retr(-1, sd);
  3781. memset(NPCname, '\0', sizeof(NPCname));
  3782. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3783. clif_displaymessage(fd, msg_txt(1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3784. return -1;
  3785. }
  3786. if (npc_name2id(NPCname) != NULL) {
  3787. npc_enable(NPCname, 1);
  3788. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  3789. } else {
  3790. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3791. return -1;
  3792. }
  3793. return 0;
  3794. }
  3795. /*==========================================
  3796. *
  3797. *------------------------------------------*/
  3798. ACMD_FUNC(hidenpc)
  3799. {
  3800. char NPCname[NAME_LENGTH+1];
  3801. nullpo_retr(-1, sd);
  3802. memset(NPCname, '\0', sizeof(NPCname));
  3803. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3804. clif_displaymessage(fd, msg_txt(1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3805. return -1;
  3806. }
  3807. if (npc_name2id(NPCname) == NULL) {
  3808. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3809. return -1;
  3810. }
  3811. npc_enable(NPCname, 0);
  3812. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3813. return 0;
  3814. }
  3815. ACMD_FUNC(loadnpc)
  3816. {
  3817. FILE *fp;
  3818. if (!message || !*message) {
  3819. clif_displaymessage(fd, msg_txt(1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3820. return -1;
  3821. }
  3822. // check if script file exists
  3823. if ((fp = fopen(message, "r")) == NULL) {
  3824. clif_displaymessage(fd, msg_txt(261));
  3825. return -1;
  3826. }
  3827. fclose(fp);
  3828. // add to list of script sources and run it
  3829. npc_addsrcfile(message);
  3830. npc_parsesrcfile(message,true);
  3831. npc_read_event_script();
  3832. clif_displaymessage(fd, msg_txt(262));
  3833. return 0;
  3834. }
  3835. ACMD_FUNC(unloadnpc)
  3836. {
  3837. struct npc_data *nd;
  3838. char NPCname[NAME_LENGTH+1];
  3839. nullpo_retr(-1, sd);
  3840. memset(NPCname, '\0', sizeof(NPCname));
  3841. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3842. clif_displaymessage(fd, msg_txt(1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
  3843. return -1;
  3844. }
  3845. if ((nd = npc_name2id(NPCname)) == NULL) {
  3846. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  3847. return -1;
  3848. }
  3849. npc_unload_duplicates(nd);
  3850. npc_unload(nd,true);
  3851. npc_read_event_script();
  3852. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  3853. return 0;
  3854. }
  3855. /*==========================================
  3856. * time in txt for time command (by [Yor])
  3857. *------------------------------------------*/
  3858. char* txt_time(unsigned int duration)
  3859. {
  3860. int days, hours, minutes, seconds;
  3861. char temp[CHAT_SIZE_MAX];
  3862. static char temp1[CHAT_SIZE_MAX];
  3863. memset(temp, '\0', sizeof(temp));
  3864. memset(temp1, '\0', sizeof(temp1));
  3865. days = duration / (60 * 60 * 24);
  3866. duration = duration - (60 * 60 * 24 * days);
  3867. hours = duration / (60 * 60);
  3868. duration = duration - (60 * 60 * hours);
  3869. minutes = duration / 60;
  3870. seconds = duration - (60 * minutes);
  3871. if (days == 1)
  3872. sprintf(temp, msg_txt(219), days); // %d day
  3873. else if (days > 1)
  3874. sprintf(temp, msg_txt(220), days); // %d days
  3875. if (hours == 1)
  3876. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  3877. else if (hours > 1)
  3878. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  3879. if (minutes < 2)
  3880. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  3881. else
  3882. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  3883. if (seconds == 1)
  3884. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  3885. else if (seconds > 1)
  3886. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  3887. return temp1;
  3888. }
  3889. /*==========================================
  3890. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3891. * Calculation management of GM modification (@day/@night GM commands) is done
  3892. *------------------------------------------*/
  3893. ACMD_FUNC(servertime)
  3894. {
  3895. const struct TimerData * timer_data;
  3896. const struct TimerData * timer_data2;
  3897. time_t time_server; // variable for number of seconds (used with time() function)
  3898. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3899. char temp[CHAT_SIZE_MAX];
  3900. nullpo_retr(-1, sd);
  3901. memset(temp, '\0', sizeof(temp));
  3902. time(&time_server); // get time in seconds since 1/1/1970
  3903. datetime = localtime(&time_server); // convert seconds in structure
  3904. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3905. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3906. clif_displaymessage(fd, temp);
  3907. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3908. if (night_flag == 0)
  3909. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3910. else
  3911. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3912. } else if (battle_config.night_duration == 0)
  3913. if (night_flag == 1) { // we start with night
  3914. timer_data = get_timer(day_timer_tid);
  3915. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  3916. clif_displaymessage(fd, temp);
  3917. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  3918. } else
  3919. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  3920. else if (battle_config.day_duration == 0)
  3921. if (night_flag == 0) { // we start with day
  3922. timer_data = get_timer(night_timer_tid);
  3923. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3924. clif_displaymessage(fd, temp);
  3925. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  3926. } else
  3927. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  3928. else {
  3929. if (night_flag == 0) {
  3930. timer_data = get_timer(night_timer_tid);
  3931. timer_data2 = get_timer(day_timer_tid);
  3932. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3933. clif_displaymessage(fd, temp);
  3934. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3935. 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.
  3936. else
  3937. 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.
  3938. clif_displaymessage(fd, temp);
  3939. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3940. clif_displaymessage(fd, temp);
  3941. } else {
  3942. timer_data = get_timer(day_timer_tid);
  3943. timer_data2 = get_timer(night_timer_tid);
  3944. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  3945. clif_displaymessage(fd, temp);
  3946. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3947. 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.
  3948. else
  3949. 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.
  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. }
  3954. }
  3955. return 0;
  3956. }
  3957. //Added by Coltaro
  3958. //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...).
  3959. //Well, using time_t could still work but for some reason that looks like more coding x_x
  3960. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  3961. {
  3962. const int factor_year = 518400; //12*30*24*60 = 518400
  3963. const int factor_month = 43200; //30*24*60 = 43200
  3964. const int factor_day = 1440; //24*60 = 1440
  3965. const int factor_hour = 60;
  3966. *year = jailtime/factor_year;
  3967. jailtime -= *year*factor_year;
  3968. *month = jailtime/factor_month;
  3969. jailtime -= *month*factor_month;
  3970. *day = jailtime/factor_day;
  3971. jailtime -= *day*factor_day;
  3972. *hour = jailtime/factor_hour;
  3973. jailtime -= *hour*factor_hour;
  3974. *minute = jailtime;
  3975. *year = *year > 0? *year : 0;
  3976. *month = *month > 0? *month : 0;
  3977. *day = *day > 0? *day : 0;
  3978. *hour = *hour > 0? *hour : 0;
  3979. *minute = *minute > 0? *minute : 0;
  3980. return;
  3981. }
  3982. /*==========================================
  3983. * @jail <char_name> by [Yor]
  3984. * Special warp! No check with nowarp and nowarpto flag
  3985. *------------------------------------------*/
  3986. ACMD_FUNC(jail)
  3987. {
  3988. struct map_session_data *pl_sd;
  3989. int x, y;
  3990. unsigned short m_index;
  3991. nullpo_retr(-1, sd);
  3992. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3993. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3994. clif_displaymessage(fd, msg_txt(1134)); // Please enter a player name (usage: @jail <char_name>).
  3995. return -1;
  3996. }
  3997. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3998. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3999. return -1;
  4000. }
  4001. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  4002. { // you can jail only lower or same GM
  4003. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4004. return -1;
  4005. }
  4006. if (pl_sd->sc.data[SC_JAILED])
  4007. {
  4008. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4009. return -1;
  4010. }
  4011. switch(rnd() % 2) { //Jail Locations
  4012. case 0:
  4013. m_index = mapindex_name2id(MAP_JAIL);
  4014. x = 24;
  4015. y = 75;
  4016. break;
  4017. default:
  4018. m_index = mapindex_name2id(MAP_JAIL);
  4019. x = 49;
  4020. y = 75;
  4021. break;
  4022. }
  4023. //Duration of INT_MAX to specify infinity.
  4024. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4025. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4026. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4027. return 0;
  4028. }
  4029. /*==========================================
  4030. * @unjail/@discharge <char_name> by [Yor]
  4031. * Special warp! No check with nowarp and nowarpto flag
  4032. *------------------------------------------*/
  4033. ACMD_FUNC(unjail)
  4034. {
  4035. struct map_session_data *pl_sd;
  4036. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4037. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4038. clif_displaymessage(fd, msg_txt(1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4039. return -1;
  4040. }
  4041. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4042. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4043. return -1;
  4044. }
  4045. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4046. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4047. return -1;
  4048. }
  4049. if (!pl_sd->sc.data[SC_JAILED])
  4050. {
  4051. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4052. return -1;
  4053. }
  4054. //Reset jail time to 1 sec.
  4055. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4056. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4057. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4058. return 0;
  4059. }
  4060. ACMD_FUNC(jailfor)
  4061. {
  4062. struct map_session_data *pl_sd = NULL;
  4063. int year, month, day, hour, minute, value;
  4064. char * modif_p;
  4065. int jailtime = 0,x,y;
  4066. short m_index = 0;
  4067. nullpo_retr(-1, sd);
  4068. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4069. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4070. return -1;
  4071. }
  4072. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4073. modif_p = atcmd_output;
  4074. year = month = day = hour = minute = 0;
  4075. while (modif_p[0] != '\0') {
  4076. value = atoi(modif_p);
  4077. if (value == 0)
  4078. modif_p++;
  4079. else {
  4080. if (modif_p[0] == '-' || modif_p[0] == '+')
  4081. modif_p++;
  4082. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4083. modif_p++;
  4084. if (modif_p[0] == 'n') {
  4085. minute = value;
  4086. modif_p++;
  4087. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4088. minute = value;
  4089. modif_p = modif_p + 2;
  4090. } else if (modif_p[0] == 'h') {
  4091. hour = value;
  4092. modif_p++;
  4093. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4094. day = value;
  4095. modif_p++;
  4096. } else if (modif_p[0] == 'm') {
  4097. month = value;
  4098. modif_p++;
  4099. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4100. year = value;
  4101. modif_p++;
  4102. } else if (modif_p[0] != '\0') {
  4103. modif_p++;
  4104. }
  4105. }
  4106. }
  4107. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4108. clif_displaymessage(fd, msg_txt(1136)); // Invalid time for jail command.
  4109. return -1;
  4110. }
  4111. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4112. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4113. return -1;
  4114. }
  4115. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4116. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4117. return -1;
  4118. }
  4119. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4120. if(jailtime==0) {
  4121. clif_displaymessage(fd, msg_txt(1136)); // Invalid time for jail command.
  4122. return -1;
  4123. }
  4124. //Added by Coltaro
  4125. if(pl_sd->sc.data[SC_JAILED] &&
  4126. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4127. { //Update the player's jail time
  4128. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4129. if (jailtime <= 0) {
  4130. jailtime = 0;
  4131. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4132. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4133. } else {
  4134. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4135. 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
  4136. clif_displaymessage(pl_sd->fd, atcmd_output);
  4137. 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
  4138. clif_displaymessage(fd, atcmd_output);
  4139. }
  4140. } else if (jailtime < 0) {
  4141. clif_displaymessage(fd, msg_txt(1136));
  4142. return -1;
  4143. }
  4144. //Jail locations, add more as you wish.
  4145. switch(rnd()%2)
  4146. {
  4147. case 1: //Jail #1
  4148. m_index = mapindex_name2id(MAP_JAIL);
  4149. x = 49; y = 75;
  4150. break;
  4151. default: //Default Jail
  4152. m_index = mapindex_name2id(MAP_JAIL);
  4153. x = 24; y = 75;
  4154. break;
  4155. }
  4156. 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).
  4157. return 0;
  4158. }
  4159. //By Coltaro
  4160. ACMD_FUNC(jailtime)
  4161. {
  4162. int year, month, day, hour, minute;
  4163. nullpo_retr(-1, sd);
  4164. if (!sd->sc.data[SC_JAILED]) {
  4165. clif_displaymessage(fd, msg_txt(1139)); // You are not in jail.
  4166. return -1;
  4167. }
  4168. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4169. clif_displaymessage(fd, msg_txt(1140)); // You have been jailed indefinitely.
  4170. return 0;
  4171. }
  4172. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4173. clif_displaymessage(fd, msg_txt(1141)); // You have been jailed for an unknown amount of time.
  4174. return -1;
  4175. }
  4176. //Get remaining jail time
  4177. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4178. 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
  4179. clif_displaymessage(fd, atcmd_output);
  4180. return 0;
  4181. }
  4182. /*==========================================
  4183. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4184. *------------------------------------------*/
  4185. ACMD_FUNC(disguise)
  4186. {
  4187. int id = 0;
  4188. nullpo_retr(-1, sd);
  4189. if (!message || !*message) {
  4190. clif_displaymessage(fd, msg_txt(1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4191. return -1;
  4192. }
  4193. if ((id = atoi(message)) > 0)
  4194. { //Acquired an ID
  4195. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4196. id = 0; //Invalid id for either mobs or npcs.
  4197. } else { //Acquired a Name
  4198. if ((id = mobdb_searchname(message)) == 0)
  4199. {
  4200. struct npc_data* nd = npc_name2id(message);
  4201. if (nd != NULL)
  4202. id = nd->class_;
  4203. }
  4204. }
  4205. if (id == 0)
  4206. {
  4207. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4208. return -1;
  4209. }
  4210. if(pc_isriding(sd))
  4211. {
  4212. clif_displaymessage(fd, msg_txt(1144)); // Character cannot be disguised while mounted.
  4213. return -1;
  4214. }
  4215. pc_disguise(sd, id);
  4216. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4217. return 0;
  4218. }
  4219. /*==========================================
  4220. * DisguiseAll
  4221. *------------------------------------------*/
  4222. ACMD_FUNC(disguiseall)
  4223. {
  4224. int mob_id=0;
  4225. struct map_session_data *pl_sd;
  4226. struct s_mapiterator* iter;
  4227. nullpo_retr(-1, sd);
  4228. if (!message || !*message) {
  4229. clif_displaymessage(fd, msg_txt(1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4230. return -1;
  4231. }
  4232. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4233. mob_id = atoi(message);
  4234. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4235. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4236. return -1;
  4237. }
  4238. iter = mapit_getallusers();
  4239. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4240. pc_disguise(pl_sd, mob_id);
  4241. mapit_free(iter);
  4242. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4243. return 0;
  4244. }
  4245. /*==========================================
  4246. * DisguiseGuild
  4247. *------------------------------------------*/
  4248. ACMD_FUNC(disguiseguild)
  4249. {
  4250. int id = 0, i;
  4251. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4252. struct map_session_data *pl_sd;
  4253. struct guild *g;
  4254. memset(monster, '\0', sizeof(monster));
  4255. memset(guild, '\0', sizeof(guild));
  4256. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4257. clif_displaymessage(fd, msg_txt(1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4258. return -1;
  4259. }
  4260. if( (id = atoi(monster)) > 0 ) {
  4261. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4262. id = 0;
  4263. } else {
  4264. if( (id = mobdb_searchname(monster)) == 0 ) {
  4265. struct npc_data* nd = npc_name2id(monster);
  4266. if( nd != NULL )
  4267. id = nd->class_;
  4268. }
  4269. }
  4270. if( id == 0 ) {
  4271. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  4272. return -1;
  4273. }
  4274. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4275. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4276. return -1;
  4277. }
  4278. for( i = 0; i < g->max_member; i++ )
  4279. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4280. pc_disguise(pl_sd, id);
  4281. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4282. return 0;
  4283. }
  4284. /*==========================================
  4285. * @undisguise by [Yor]
  4286. *------------------------------------------*/
  4287. ACMD_FUNC(undisguise)
  4288. {
  4289. nullpo_retr(-1, sd);
  4290. if (sd->disguise) {
  4291. pc_disguise(sd, 0);
  4292. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4293. } else {
  4294. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4295. return -1;
  4296. }
  4297. return 0;
  4298. }
  4299. /*==========================================
  4300. * UndisguiseAll
  4301. *------------------------------------------*/
  4302. ACMD_FUNC(undisguiseall)
  4303. {
  4304. struct map_session_data *pl_sd;
  4305. struct s_mapiterator* iter;
  4306. nullpo_retr(-1, sd);
  4307. iter = mapit_getallusers();
  4308. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4309. if( pl_sd->disguise )
  4310. pc_disguise(pl_sd, 0);
  4311. mapit_free(iter);
  4312. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4313. return 0;
  4314. }
  4315. /*==========================================
  4316. * UndisguiseGuild
  4317. *------------------------------------------*/
  4318. ACMD_FUNC(undisguiseguild)
  4319. {
  4320. char guild_name[NAME_LENGTH];
  4321. struct map_session_data *pl_sd;
  4322. struct guild *g;
  4323. int i;
  4324. nullpo_retr(-1, sd);
  4325. memset(guild_name, '\0', sizeof(guild_name));
  4326. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4327. clif_displaymessage(fd, msg_txt(1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4328. return -1;
  4329. }
  4330. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4331. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4332. return -1;
  4333. }
  4334. for(i = 0; i < g->max_member; i++)
  4335. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4336. pc_disguise(pl_sd, 0);
  4337. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4338. return 0;
  4339. }
  4340. /*==========================================
  4341. * @exp by [Skotlex]
  4342. *------------------------------------------*/
  4343. ACMD_FUNC(exp)
  4344. {
  4345. char output[CHAT_SIZE_MAX];
  4346. double nextb, nextj;
  4347. nullpo_retr(-1, sd);
  4348. memset(output, '\0', sizeof(output));
  4349. nextb = pc_nextbaseexp(sd);
  4350. if (nextb)
  4351. nextb = sd->status.base_exp*100.0/nextb;
  4352. nextj = pc_nextjobexp(sd);
  4353. if (nextj)
  4354. nextj = sd->status.job_exp*100.0/nextj;
  4355. sprintf(output, msg_txt(1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4356. clif_displaymessage(fd, output);
  4357. return 0;
  4358. }
  4359. /*==========================================
  4360. * @broadcast by [Valaris]
  4361. *------------------------------------------*/
  4362. ACMD_FUNC(broadcast)
  4363. {
  4364. nullpo_retr(-1, sd);
  4365. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4366. if (!message || !*message) {
  4367. clif_displaymessage(fd, msg_txt(1149)); // Please enter a message (usage: @broadcast <message>).
  4368. return -1;
  4369. }
  4370. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4371. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4372. return 0;
  4373. }
  4374. /*==========================================
  4375. * @localbroadcast by [Valaris]
  4376. *------------------------------------------*/
  4377. ACMD_FUNC(localbroadcast)
  4378. {
  4379. nullpo_retr(-1, sd);
  4380. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4381. if (!message || !*message) {
  4382. clif_displaymessage(fd, msg_txt(1150)); // Please enter a message (usage: @localbroadcast <message>).
  4383. return -1;
  4384. }
  4385. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4386. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4387. return 0;
  4388. }
  4389. /*==========================================
  4390. * @email <actual@email> <new@email> by [Yor]
  4391. *------------------------------------------*/
  4392. ACMD_FUNC(email)
  4393. {
  4394. char actual_email[100];
  4395. char new_email[100];
  4396. nullpo_retr(-1, sd);
  4397. memset(actual_email, '\0', sizeof(actual_email));
  4398. memset(new_email, '\0', sizeof(new_email));
  4399. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4400. clif_displaymessage(fd, msg_txt(1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4401. return -1;
  4402. }
  4403. if (e_mail_check(actual_email) == 0) {
  4404. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4405. return -1;
  4406. } else if (e_mail_check(new_email) == 0) {
  4407. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4408. return -1;
  4409. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4410. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4411. return -1;
  4412. } else if (strcmpi(actual_email, new_email) == 0) {
  4413. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4414. return -1;
  4415. }
  4416. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4417. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4418. return 0;
  4419. }
  4420. /*==========================================
  4421. *@effect
  4422. *------------------------------------------*/
  4423. ACMD_FUNC(effect)
  4424. {
  4425. int type = 0, flag = 0;
  4426. nullpo_retr(-1, sd);
  4427. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4428. clif_displaymessage(fd, msg_txt(1152)); // Please enter an effect number (usage: @effect <effect number>).
  4429. return -1;
  4430. }
  4431. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4432. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4433. return 0;
  4434. }
  4435. /*==========================================
  4436. * @killer by MouseJstr
  4437. * enable killing players even when not in pvp
  4438. *------------------------------------------*/
  4439. ACMD_FUNC(killer)
  4440. {
  4441. nullpo_retr(-1, sd);
  4442. sd->state.killer = !sd->state.killer;
  4443. if(sd->state.killer)
  4444. clif_displaymessage(fd, msg_txt(241));
  4445. else {
  4446. clif_displaymessage(fd, msg_txt(292));
  4447. pc_stop_attack(sd);
  4448. }
  4449. return 0;
  4450. }
  4451. /*==========================================
  4452. * @killable by MouseJstr
  4453. * enable other people killing you
  4454. *------------------------------------------*/
  4455. ACMD_FUNC(killable)
  4456. {
  4457. nullpo_retr(-1, sd);
  4458. sd->state.killable = !sd->state.killable;
  4459. if(sd->state.killable)
  4460. clif_displaymessage(fd, msg_txt(242));
  4461. else {
  4462. clif_displaymessage(fd, msg_txt(288));
  4463. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4464. }
  4465. return 0;
  4466. }
  4467. /*==========================================
  4468. * @skillon by MouseJstr
  4469. * turn skills on for the map
  4470. *------------------------------------------*/
  4471. ACMD_FUNC(skillon)
  4472. {
  4473. nullpo_retr(-1, sd);
  4474. map[sd->bl.m].flag.noskill = 0;
  4475. clif_displaymessage(fd, msg_txt(244));
  4476. return 0;
  4477. }
  4478. /*==========================================
  4479. * @skilloff by MouseJstr
  4480. * Turn skills off on the map
  4481. *------------------------------------------*/
  4482. ACMD_FUNC(skilloff)
  4483. {
  4484. nullpo_retr(-1, sd);
  4485. map[sd->bl.m].flag.noskill = 1;
  4486. clif_displaymessage(fd, msg_txt(243));
  4487. return 0;
  4488. }
  4489. /*==========================================
  4490. * @npcmove by MouseJstr
  4491. * move a npc
  4492. *------------------------------------------*/
  4493. ACMD_FUNC(npcmove)
  4494. {
  4495. int x = 0, y = 0, m;
  4496. struct npc_data *nd = 0;
  4497. nullpo_retr(-1, sd);
  4498. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4499. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4500. clif_displaymessage(fd, msg_txt(1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4501. return -1;
  4502. }
  4503. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4504. {
  4505. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4506. return -1;
  4507. }
  4508. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4509. {
  4510. clif_displaymessage(fd, msg_txt(1154)); // NPC is not on this map.
  4511. return -1; //Not on a map.
  4512. }
  4513. x = cap_value(x, 0, map[m].xs-1);
  4514. y = cap_value(y, 0, map[m].ys-1);
  4515. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4516. map_moveblock(&nd->bl, x, y, gettick());
  4517. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4518. clif_displaymessage(fd, msg_txt(1155)); // NPC moved.
  4519. return 0;
  4520. }
  4521. /*==========================================
  4522. * @addwarp by MouseJstr
  4523. * Create a new static warp point.
  4524. *------------------------------------------*/
  4525. ACMD_FUNC(addwarp)
  4526. {
  4527. char mapname[32];
  4528. int x,y;
  4529. unsigned short m;
  4530. struct npc_data* nd;
  4531. nullpo_retr(-1, sd);
  4532. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4533. clif_displaymessage(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y>
  4534. return -1;
  4535. }
  4536. m = mapindex_name2id(mapname);
  4537. if( m == 0 )
  4538. {
  4539. sprintf(atcmd_output, msg_txt(1157), mapname); // Unknown map '%s'.
  4540. clif_displaymessage(fd, atcmd_output);
  4541. return -1;
  4542. }
  4543. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4544. if( nd == NULL )
  4545. return -1;
  4546. sprintf(atcmd_output, msg_txt(1158), nd->exname); // New warp NPC '%s' created.
  4547. clif_displaymessage(fd, atcmd_output);
  4548. return 0;
  4549. }
  4550. /*==========================================
  4551. * @follow by [MouseJstr]
  4552. * Follow a player .. staying no more then 5 spaces away
  4553. *------------------------------------------*/
  4554. ACMD_FUNC(follow)
  4555. {
  4556. struct map_session_data *pl_sd = NULL;
  4557. nullpo_retr(-1, sd);
  4558. if (!message || !*message) {
  4559. if (sd->followtarget == -1)
  4560. return -1;
  4561. pc_stop_following (sd);
  4562. clif_displaymessage(fd, msg_txt(1159)); // Follow mode OFF.
  4563. return 0;
  4564. }
  4565. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4566. {
  4567. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4568. return -1;
  4569. }
  4570. if (sd->followtarget == pl_sd->bl.id) {
  4571. pc_stop_following (sd);
  4572. clif_displaymessage(fd, msg_txt(1159)); // Follow mode OFF.
  4573. } else {
  4574. pc_follow(sd, pl_sd->bl.id);
  4575. clif_displaymessage(fd, msg_txt(1160)); // Follow mode ON.
  4576. }
  4577. return 0;
  4578. }
  4579. /*==========================================
  4580. * @dropall by [MouseJstr]
  4581. * Drop all your possession on the ground
  4582. *------------------------------------------*/
  4583. ACMD_FUNC(dropall)
  4584. {
  4585. int i;
  4586. nullpo_retr(-1, sd);
  4587. for (i = 0; i < MAX_INVENTORY; i++) {
  4588. if (sd->status.inventory[i].amount) {
  4589. if(sd->status.inventory[i].equip != 0)
  4590. pc_unequipitem(sd, i, 3);
  4591. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4592. }
  4593. }
  4594. return 0;
  4595. }
  4596. /*==========================================
  4597. * @storeall by [MouseJstr]
  4598. * Put everything into storage
  4599. *------------------------------------------*/
  4600. ACMD_FUNC(storeall)
  4601. {
  4602. int i;
  4603. nullpo_retr(-1, sd);
  4604. if (sd->state.storage_flag != 1)
  4605. { //Open storage.
  4606. if( storage_storageopen(sd) == 1 ) {
  4607. clif_displaymessage(fd, msg_txt(1161)); // You currently cannot open your storage.
  4608. return -1;
  4609. }
  4610. }
  4611. for (i = 0; i < MAX_INVENTORY; i++) {
  4612. if (sd->status.inventory[i].amount) {
  4613. if(sd->status.inventory[i].equip != 0)
  4614. pc_unequipitem(sd, i, 3);
  4615. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4616. }
  4617. }
  4618. storage_storageclose(sd);
  4619. clif_displaymessage(fd, msg_txt(1162)); // All items stored.
  4620. return 0;
  4621. }
  4622. /*==========================================
  4623. * @skillid by [MouseJstr]
  4624. * lookup a skill by name
  4625. *------------------------------------------*/
  4626. ACMD_FUNC(skillid)
  4627. {
  4628. int skillen, idx;
  4629. nullpo_retr(-1, sd);
  4630. if (!message || !*message)
  4631. {
  4632. clif_displaymessage(fd, msg_txt(1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4633. return -1;
  4634. }
  4635. skillen = strlen(message);
  4636. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  4637. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  4638. {
  4639. sprintf(atcmd_output, msg_txt(1164), idx, skill_db[idx].desc); // skill %d: %s
  4640. clif_displaymessage(fd, atcmd_output);
  4641. }
  4642. }
  4643. return 0;
  4644. }
  4645. /*==========================================
  4646. * @useskill by [MouseJstr]
  4647. * A way of using skills without having to find them in the skills menu
  4648. *------------------------------------------*/
  4649. ACMD_FUNC(useskill)
  4650. {
  4651. struct map_session_data *pl_sd = NULL;
  4652. struct block_list *bl;
  4653. int skillnum;
  4654. int skilllv;
  4655. char target[100];
  4656. nullpo_retr(-1, sd);
  4657. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  4658. clif_displaymessage(fd, msg_txt(1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4659. return -1;
  4660. }
  4661. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4662. {
  4663. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4664. return -1;
  4665. }
  4666. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4667. {
  4668. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4669. return -1;
  4670. }
  4671. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  4672. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4673. bl = &sd->hd->bl;
  4674. else
  4675. bl = &sd->bl;
  4676. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  4677. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  4678. else
  4679. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  4680. return 0;
  4681. }
  4682. /*==========================================
  4683. * @displayskill by [Skotlex]
  4684. * Debug command to locate new skill IDs. It sends the
  4685. * three possible skill-effect packets to the area.
  4686. *------------------------------------------*/
  4687. ACMD_FUNC(displayskill)
  4688. {
  4689. struct status_data * status;
  4690. unsigned int tick;
  4691. int skillnum;
  4692. int skilllv = 1;
  4693. nullpo_retr(-1, sd);
  4694. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  4695. {
  4696. clif_displaymessage(fd, msg_txt(1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4697. return -1;
  4698. }
  4699. status = status_get_status_data(&sd->bl);
  4700. tick = gettick();
  4701. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  4702. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  4703. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  4704. return 0;
  4705. }
  4706. /*==========================================
  4707. * @skilltree by [MouseJstr]
  4708. * prints the skill tree for a player required to get to a skill
  4709. *------------------------------------------*/
  4710. ACMD_FUNC(skilltree)
  4711. {
  4712. struct map_session_data *pl_sd = NULL;
  4713. int skillnum;
  4714. int meets, j, c=0;
  4715. char target[NAME_LENGTH];
  4716. struct skill_tree_entry *ent;
  4717. nullpo_retr(-1, sd);
  4718. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  4719. clif_displaymessage(fd, msg_txt(1167)); // Usage: @skilltree <skill ID> <target>
  4720. return -1;
  4721. }
  4722. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4723. {
  4724. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4725. return -1;
  4726. }
  4727. c = pc_calc_skilltree_normalize_job(pl_sd);
  4728. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4729. sprintf(atcmd_output, msg_txt(1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  4730. clif_displaymessage(fd, atcmd_output);
  4731. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  4732. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4733. {
  4734. clif_displaymessage(fd, msg_txt(1169)); // The player cannot use that skill.
  4735. return 0;
  4736. }
  4737. ent = &skill_tree[c][j];
  4738. meets = 1;
  4739. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4740. {
  4741. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4742. {
  4743. sprintf(atcmd_output, msg_txt(1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  4744. clif_displaymessage(fd, atcmd_output);
  4745. meets = 0;
  4746. }
  4747. }
  4748. if (meets == 1) {
  4749. clif_displaymessage(fd, msg_txt(1171)); // The player meets all the requirements for that skill.
  4750. }
  4751. return 0;
  4752. }
  4753. // Hand a ring with partners name on it to this char
  4754. void getring (struct map_session_data* sd)
  4755. {
  4756. int flag, item_id;
  4757. struct item item_tmp;
  4758. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4759. memset(&item_tmp, 0, sizeof(item_tmp));
  4760. item_tmp.nameid = item_id;
  4761. item_tmp.identify = 1;
  4762. item_tmp.card[0] = 255;
  4763. item_tmp.card[2] = sd->status.partner_id;
  4764. item_tmp.card[3] = sd->status.partner_id >> 16;
  4765. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4766. clif_additem(sd,0,0,flag);
  4767. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  4768. }
  4769. }
  4770. /*==========================================
  4771. * @marry by [MouseJstr], fixed by Lupus
  4772. * Marry two players
  4773. *------------------------------------------*/
  4774. ACMD_FUNC(marry)
  4775. {
  4776. struct map_session_data *pl_sd = NULL;
  4777. char player_name[NAME_LENGTH] = "";
  4778. nullpo_retr(-1, sd);
  4779. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4780. clif_displaymessage(fd, msg_txt(1172)); // Usage: @marry <char name>
  4781. return -1;
  4782. }
  4783. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4784. clif_displaymessage(fd, msg_txt(3));
  4785. return -1;
  4786. }
  4787. if (pc_marriage(sd, pl_sd) == 0) {
  4788. clif_displaymessage(fd, msg_txt(1173)); // They are married... wish them well.
  4789. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4790. getring(sd); // Auto-give named rings (Aru)
  4791. getring(pl_sd);
  4792. return 0;
  4793. }
  4794. clif_displaymessage(fd, msg_txt(1174)); // The two cannot wed because one is either a baby or already married.
  4795. return -1;
  4796. }
  4797. /*==========================================
  4798. * @divorce by [MouseJstr], fixed by [Lupus]
  4799. * divorce two players
  4800. *------------------------------------------*/
  4801. ACMD_FUNC(divorce)
  4802. {
  4803. nullpo_retr(-1, sd);
  4804. if (pc_divorce(sd) != 0) {
  4805. sprintf(atcmd_output, msg_txt(1175), sd->status.name); // '%s' is not married.
  4806. clif_displaymessage(fd, atcmd_output);
  4807. return -1;
  4808. }
  4809. sprintf(atcmd_output, msg_txt(1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4810. clif_displaymessage(fd, atcmd_output);
  4811. return 0;
  4812. }
  4813. /*==========================================
  4814. * @changelook by [Celest]
  4815. *------------------------------------------*/
  4816. ACMD_FUNC(changelook)
  4817. {
  4818. int i, j = 0, k = 0;
  4819. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4820. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4821. clif_displaymessage(fd, msg_txt(1177)); // Usage: @changelook {<position>} <view id>
  4822. clif_displaymessage(fd, msg_txt(1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4823. return -1;
  4824. } else if ( i == 2 ) {
  4825. if (j < 1 || j > 7)
  4826. j = 1;
  4827. j = pos[j - 1];
  4828. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4829. k = j; // swap
  4830. j = LOOK_HEAD_TOP;
  4831. }
  4832. clif_changelook(&sd->bl,j,k);
  4833. return 0;
  4834. }
  4835. /*==========================================
  4836. * @autotrade by durf [Lupus] [Paradox924X]
  4837. * Turns on/off Autotrade for a specific player
  4838. *------------------------------------------*/
  4839. ACMD_FUNC(autotrade)
  4840. {
  4841. nullpo_retr(-1, sd);
  4842. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4843. clif_displaymessage(fd, msg_txt(1179)); // Autotrade is not allowed on this map.
  4844. return -1;
  4845. }
  4846. if( pc_isdead(sd) ) {
  4847. clif_displaymessage(fd, msg_txt(1180)); // You cannot autotrade when dead.
  4848. return -1;
  4849. }
  4850. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4851. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  4852. return -1;
  4853. }
  4854. sd->state.autotrade = 1;
  4855. if( battle_config.at_timeout )
  4856. {
  4857. int timeout = atoi(message);
  4858. 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);
  4859. }
  4860. clif_authfail_fd(fd, 15);
  4861. return 0;
  4862. }
  4863. /*==========================================
  4864. * @changegm by durf (changed by Lupus)
  4865. * Changes Master of your Guild to a specified guild member
  4866. *------------------------------------------*/
  4867. ACMD_FUNC(changegm)
  4868. {
  4869. struct guild *g;
  4870. struct map_session_data *pl_sd;
  4871. nullpo_retr(-1, sd);
  4872. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name)) {
  4873. clif_displaymessage(fd, msg_txt(1181)); // You need to be a Guild Master to use this command.
  4874. return -1;
  4875. }
  4876. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4877. clif_displaymessage(fd, msg_txt(1182)); // You cannot change guild leaders on this map.
  4878. return -1;
  4879. }
  4880. if( !message[0] ) {
  4881. clif_displaymessage(fd, msg_txt(1183)); // Usage: @changegm <guild_member_name>
  4882. return -1;
  4883. }
  4884. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4885. clif_displaymessage(fd, msg_txt(1184)); // Target character must be online and be a guild member.
  4886. return -1;
  4887. }
  4888. guild_gm_change(sd->status.guild_id, pl_sd);
  4889. return 0;
  4890. }
  4891. /*==========================================
  4892. * @changeleader by Skotlex
  4893. * Changes the leader of a party.
  4894. *------------------------------------------*/
  4895. ACMD_FUNC(changeleader)
  4896. {
  4897. nullpo_retr(-1, sd);
  4898. if( !message[0] )
  4899. {
  4900. clif_displaymessage(fd, msg_txt(1185)); // Usage: @changeleader <party_member_name>
  4901. return -1;
  4902. }
  4903. if (party_changeleader(sd, map_nick2sd((char *) message)))
  4904. return 0;
  4905. return -1;
  4906. }
  4907. /*==========================================
  4908. * @partyoption by Skotlex
  4909. * Used to change the item share setting of a party.
  4910. *------------------------------------------*/
  4911. ACMD_FUNC(partyoption)
  4912. {
  4913. struct party_data *p;
  4914. int mi, option;
  4915. char w1[16], w2[16];
  4916. nullpo_retr(-1, sd);
  4917. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4918. {
  4919. clif_displaymessage(fd, msg_txt(282));
  4920. return -1;
  4921. }
  4922. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4923. if (mi == MAX_PARTY)
  4924. return -1; //Shouldn't happen
  4925. if (!p->party.member[mi].leader)
  4926. {
  4927. clif_displaymessage(fd, msg_txt(282));
  4928. return -1;
  4929. }
  4930. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4931. {
  4932. clif_displaymessage(fd, msg_txt(1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  4933. return -1;
  4934. }
  4935. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4936. //Change item share type.
  4937. if (option != p->party.item)
  4938. party_changeoption(sd, p->party.exp, option);
  4939. else
  4940. clif_displaymessage(fd, msg_txt(286));
  4941. return 0;
  4942. }
  4943. /*==========================================
  4944. * @autoloot by Upa-Kun
  4945. * Turns on/off AutoLoot for a specific player
  4946. *------------------------------------------*/
  4947. ACMD_FUNC(autoloot)
  4948. {
  4949. int rate;
  4950. double drate;
  4951. nullpo_retr(-1, sd);
  4952. // autoloot command without value
  4953. if(!message || !*message)
  4954. {
  4955. if (sd->state.autoloot)
  4956. rate = 0;
  4957. else
  4958. rate = 10000;
  4959. } else {
  4960. drate = atof(message);
  4961. rate = (int)(drate*100);
  4962. }
  4963. if (rate < 0) rate = 0;
  4964. if (rate > 10000) rate = 10000;
  4965. sd->state.autoloot = rate;
  4966. if (sd->state.autoloot) {
  4967. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  4968. clif_displaymessage(fd, atcmd_output);
  4969. }else
  4970. clif_displaymessage(fd, msg_txt(1188)); // Autoloot is now off.
  4971. return 0;
  4972. }
  4973. /*==========================================
  4974. * @alootid
  4975. *------------------------------------------*/
  4976. ACMD_FUNC(autolootitem)
  4977. {
  4978. struct item_data *item_data = NULL;
  4979. int i;
  4980. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4981. if (message && *message) {
  4982. if (message[0] == '+') {
  4983. message++;
  4984. action = 1;
  4985. }
  4986. else if (message[0] == '-') {
  4987. message++;
  4988. action = 2;
  4989. }
  4990. else if (!strcmp(message,"reset"))
  4991. action = 4;
  4992. }
  4993. if (action < 3) // add or remove
  4994. {
  4995. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  4996. item_data = itemdb_searchname(message);
  4997. if (!item_data) {
  4998. // No items founds in the DB with Id or Name
  4999. clif_displaymessage(fd, msg_txt(1189)); // Item not found.
  5000. return -1;
  5001. }
  5002. }
  5003. switch(action) {
  5004. case 1:
  5005. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5006. if (i != AUTOLOOTITEM_SIZE) {
  5007. clif_displaymessage(fd, msg_txt(1190)); // You're already autolooting this item.
  5008. return -1;
  5009. }
  5010. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5011. if (i == AUTOLOOTITEM_SIZE) {
  5012. clif_displaymessage(fd, msg_txt(1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5013. return -1;
  5014. }
  5015. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5016. sprintf(atcmd_output, msg_txt(1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5017. clif_displaymessage(fd, atcmd_output);
  5018. sd->state.autolooting = 1;
  5019. break;
  5020. case 2:
  5021. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5022. if (i == AUTOLOOTITEM_SIZE) {
  5023. clif_displaymessage(fd, msg_txt(1193)); // You're currently not autolooting this item.
  5024. return -1;
  5025. }
  5026. sd->state.autolootid[i] = 0;
  5027. sprintf(atcmd_output, msg_txt(1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5028. clif_displaymessage(fd, atcmd_output);
  5029. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5030. if (i == AUTOLOOTITEM_SIZE) {
  5031. sd->state.autolooting = 0;
  5032. }
  5033. break;
  5034. case 3:
  5035. sprintf(atcmd_output, msg_txt(1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5036. clif_displaymessage(fd, atcmd_output);
  5037. 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>".
  5038. clif_displaymessage(fd, msg_txt(1197)); // "@alootid reset" will clear your autolootitem list.
  5039. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5040. if (i == AUTOLOOTITEM_SIZE) {
  5041. clif_displaymessage(fd, msg_txt(1198)); // Your autolootitem list is empty.
  5042. } else {
  5043. clif_displaymessage(fd, msg_txt(1199)); // Items on your autolootitem list:
  5044. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5045. {
  5046. if (sd->state.autolootid[i] == 0)
  5047. continue;
  5048. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5049. 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);
  5050. continue;
  5051. }
  5052. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5053. clif_displaymessage(fd, atcmd_output);
  5054. }
  5055. }
  5056. break;
  5057. case 4:
  5058. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5059. clif_displaymessage(fd, msg_txt(1200)); // Your autolootitem list has been reset.
  5060. sd->state.autolooting = 0;
  5061. break;
  5062. }
  5063. return 0;
  5064. }
  5065. /**
  5066. * No longer available, keeping here just in case it's back someday. [Ind]
  5067. **/
  5068. /*==========================================
  5069. * It is made to rain.
  5070. *------------------------------------------*/
  5071. //ACMD_FUNC(rain)
  5072. //{
  5073. // nullpo_retr(-1, sd);
  5074. // if (map[sd->bl.m].flag.rain) {
  5075. // map[sd->bl.m].flag.rain=0;
  5076. // clif_weather(sd->bl.m);
  5077. // clif_displaymessage(fd, msg_txt(1201)); // The rain has stopped.
  5078. // } else {
  5079. // map[sd->bl.m].flag.rain=1;
  5080. // clif_weather(sd->bl.m);
  5081. // clif_displaymessage(fd, msg_txt(1202)); // It has started to rain.
  5082. // }
  5083. // return 0;
  5084. //}
  5085. /*==========================================
  5086. * It is made to snow.
  5087. *------------------------------------------*/
  5088. ACMD_FUNC(snow)
  5089. {
  5090. nullpo_retr(-1, sd);
  5091. if (map[sd->bl.m].flag.snow) {
  5092. map[sd->bl.m].flag.snow=0;
  5093. clif_weather(sd->bl.m);
  5094. clif_displaymessage(fd, msg_txt(1203)); // Snow has stopped falling.
  5095. } else {
  5096. map[sd->bl.m].flag.snow=1;
  5097. clif_weather(sd->bl.m);
  5098. clif_displaymessage(fd, msg_txt(1204)); // It has started to snow.
  5099. }
  5100. return 0;
  5101. }
  5102. /*==========================================
  5103. * Cherry tree snowstorm is made to fall. (Sakura)
  5104. *------------------------------------------*/
  5105. ACMD_FUNC(sakura)
  5106. {
  5107. nullpo_retr(-1, sd);
  5108. if (map[sd->bl.m].flag.sakura) {
  5109. map[sd->bl.m].flag.sakura=0;
  5110. clif_weather(sd->bl.m);
  5111. clif_displaymessage(fd, msg_txt(1205)); // Cherry tree leaves no longer fall.
  5112. } else {
  5113. map[sd->bl.m].flag.sakura=1;
  5114. clif_weather(sd->bl.m);
  5115. clif_displaymessage(fd, msg_txt(1206)); // Cherry tree leaves have begun to fall.
  5116. }
  5117. return 0;
  5118. }
  5119. /*==========================================
  5120. * Clouds appear.
  5121. *------------------------------------------*/
  5122. ACMD_FUNC(clouds)
  5123. {
  5124. nullpo_retr(-1, sd);
  5125. if (map[sd->bl.m].flag.clouds) {
  5126. map[sd->bl.m].flag.clouds=0;
  5127. clif_weather(sd->bl.m);
  5128. clif_displaymessage(fd, msg_txt(1207)); // The clouds has disappear.
  5129. } else {
  5130. map[sd->bl.m].flag.clouds=1;
  5131. clif_weather(sd->bl.m);
  5132. clif_displaymessage(fd, msg_txt(1208)); // Clouds appear.
  5133. }
  5134. return 0;
  5135. }
  5136. /*==========================================
  5137. * Different type of clouds using effect 516
  5138. *------------------------------------------*/
  5139. ACMD_FUNC(clouds2)
  5140. {
  5141. nullpo_retr(-1, sd);
  5142. if (map[sd->bl.m].flag.clouds2) {
  5143. map[sd->bl.m].flag.clouds2=0;
  5144. clif_weather(sd->bl.m);
  5145. clif_displaymessage(fd, msg_txt(1209)); // The alternative clouds disappear.
  5146. } else {
  5147. map[sd->bl.m].flag.clouds2=1;
  5148. clif_weather(sd->bl.m);
  5149. clif_displaymessage(fd, msg_txt(1210)); // Alternative clouds appear.
  5150. }
  5151. return 0;
  5152. }
  5153. /*==========================================
  5154. * Fog hangs over.
  5155. *------------------------------------------*/
  5156. ACMD_FUNC(fog)
  5157. {
  5158. nullpo_retr(-1, sd);
  5159. if (map[sd->bl.m].flag.fog) {
  5160. map[sd->bl.m].flag.fog=0;
  5161. clif_weather(sd->bl.m);
  5162. clif_displaymessage(fd, msg_txt(1211)); // The fog has gone.
  5163. } else {
  5164. map[sd->bl.m].flag.fog=1;
  5165. clif_weather(sd->bl.m);
  5166. clif_displaymessage(fd, msg_txt(1212)); // Fog hangs over.
  5167. }
  5168. return 0;
  5169. }
  5170. /*==========================================
  5171. * Fallen leaves fall.
  5172. *------------------------------------------*/
  5173. ACMD_FUNC(leaves)
  5174. {
  5175. nullpo_retr(-1, sd);
  5176. if (map[sd->bl.m].flag.leaves) {
  5177. map[sd->bl.m].flag.leaves=0;
  5178. clif_weather(sd->bl.m);
  5179. clif_displaymessage(fd, msg_txt(1213)); // Leaves no longer fall.
  5180. } else {
  5181. map[sd->bl.m].flag.leaves=1;
  5182. clif_weather(sd->bl.m);
  5183. clif_displaymessage(fd, msg_txt(1214)); // Fallen leaves fall.
  5184. }
  5185. return 0;
  5186. }
  5187. /*==========================================
  5188. * Fireworks appear.
  5189. *------------------------------------------*/
  5190. ACMD_FUNC(fireworks)
  5191. {
  5192. nullpo_retr(-1, sd);
  5193. if (map[sd->bl.m].flag.fireworks) {
  5194. map[sd->bl.m].flag.fireworks=0;
  5195. clif_weather(sd->bl.m);
  5196. clif_displaymessage(fd, msg_txt(1215)); // Fireworks have ended.
  5197. } else {
  5198. map[sd->bl.m].flag.fireworks=1;
  5199. clif_weather(sd->bl.m);
  5200. clif_displaymessage(fd, msg_txt(1216)); // Fireworks have launched.
  5201. }
  5202. return 0;
  5203. }
  5204. /*==========================================
  5205. * Clearing Weather Effects by Dexity
  5206. *------------------------------------------*/
  5207. ACMD_FUNC(clearweather)
  5208. {
  5209. nullpo_retr(-1, sd);
  5210. /**
  5211. * No longer available, keeping here just in case it's back someday. [Ind]
  5212. **/
  5213. //map[sd->bl.m].flag.rain=0;
  5214. map[sd->bl.m].flag.snow=0;
  5215. map[sd->bl.m].flag.sakura=0;
  5216. map[sd->bl.m].flag.clouds=0;
  5217. map[sd->bl.m].flag.clouds2=0;
  5218. map[sd->bl.m].flag.fog=0;
  5219. map[sd->bl.m].flag.fireworks=0;
  5220. map[sd->bl.m].flag.leaves=0;
  5221. clif_weather(sd->bl.m);
  5222. clif_displaymessage(fd, msg_txt(291));
  5223. return 0;
  5224. }
  5225. /*===============================================================
  5226. * Sound Command - plays a sound for everyone around! [Codemaster]
  5227. *---------------------------------------------------------------*/
  5228. ACMD_FUNC(sound)
  5229. {
  5230. char sound_file[100];
  5231. memset(sound_file, '\0', sizeof(sound_file));
  5232. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5233. clif_displaymessage(fd, msg_txt(1217)); // Please enter a sound filename (usage: @sound <filename>).
  5234. return -1;
  5235. }
  5236. if(strstr(sound_file, ".wav") == NULL)
  5237. strcat(sound_file, ".wav");
  5238. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5239. return 0;
  5240. }
  5241. /*==========================================
  5242. * MOB Search
  5243. *------------------------------------------*/
  5244. ACMD_FUNC(mobsearch)
  5245. {
  5246. char mob_name[100];
  5247. int mob_id;
  5248. int number = 0;
  5249. struct s_mapiterator* it;
  5250. nullpo_retr(-1, sd);
  5251. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5252. clif_displaymessage(fd, msg_txt(1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5253. return -1;
  5254. }
  5255. if ((mob_id = atoi(mob_name)) == 0)
  5256. mob_id = mobdb_searchname(mob_name);
  5257. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5258. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1219),mob_name); // Invalid mob ID %s!
  5259. clif_displaymessage(fd, atcmd_output);
  5260. return -1;
  5261. }
  5262. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5263. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5264. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5265. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5266. clif_displaymessage(fd, atcmd_output);
  5267. it = mapit_geteachmob();
  5268. for(;;)
  5269. {
  5270. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5271. if( md == NULL )
  5272. break;// no more mobs
  5273. if( md->bl.m != sd->bl.m )
  5274. continue;
  5275. if( mob_id != -1 && md->class_ != mob_id )
  5276. continue;
  5277. ++number;
  5278. if( md->spawn_timer == INVALID_TIMER )
  5279. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5280. else
  5281. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5282. clif_displaymessage(fd, atcmd_output);
  5283. }
  5284. mapit_free(it);
  5285. return 0;
  5286. }
  5287. /*==========================================
  5288. * @cleanmap - cleans items on the ground
  5289. *------------------------------------------*/
  5290. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5291. {
  5292. nullpo_ret(bl);
  5293. map_clearflooritem(bl);
  5294. return 0;
  5295. }
  5296. ACMD_FUNC(cleanmap)
  5297. {
  5298. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5299. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5300. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5301. BL_ITEM);
  5302. clif_displaymessage(fd, msg_txt(1221)); // All dropped items have been cleaned up.
  5303. return 0;
  5304. }
  5305. /*==========================================
  5306. * make a NPC/PET talk
  5307. * @npctalkc [SnakeDrak]
  5308. *------------------------------------------*/
  5309. ACMD_FUNC(npctalk)
  5310. {
  5311. char name[NAME_LENGTH],mes[100],temp[100];
  5312. struct npc_data *nd;
  5313. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5314. unsigned long color=0;
  5315. if (sd->sc.count && //no "chatting" while muted.
  5316. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5317. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5318. return -1;
  5319. if(!ifcolor) {
  5320. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5321. clif_displaymessage(fd, msg_txt(1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5322. return -1;
  5323. }
  5324. }
  5325. else {
  5326. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5327. clif_displaymessage(fd, msg_txt(1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5328. return -1;
  5329. }
  5330. }
  5331. if (!(nd = npc_name2id(name))) {
  5332. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5333. return -1;
  5334. }
  5335. strtok(name, "#"); // discard extra name identifier if present
  5336. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5337. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5338. else clif_message(&nd->bl, temp);
  5339. return 0;
  5340. }
  5341. ACMD_FUNC(pettalk)
  5342. {
  5343. char mes[100],temp[100];
  5344. struct pet_data *pd;
  5345. nullpo_retr(-1, sd);
  5346. if ( battle_config.min_chat_delay ) {
  5347. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5348. return 0;
  5349. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5350. }
  5351. if(!sd->status.pet_id || !(pd=sd->pd))
  5352. {
  5353. clif_displaymessage(fd, msg_txt(184));
  5354. return -1;
  5355. }
  5356. if (sd->sc.count && //no "chatting" while muted.
  5357. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5358. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5359. return -1;
  5360. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5361. clif_displaymessage(fd, msg_txt(1224)); // Please enter a message (usage: @pettalk <message>).
  5362. return -1;
  5363. }
  5364. if (message[0] == '/')
  5365. {// pet emotion processing
  5366. const char* emo[] = {
  5367. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5368. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5369. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5370. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5371. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5372. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5373. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5374. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5375. "/whisp"
  5376. };
  5377. int i;
  5378. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5379. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5380. if( i < ARRAYLENGTH(emo) )
  5381. {
  5382. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5383. sd->emotionlasttime = time(NULL);
  5384. return 0;
  5385. }
  5386. sd->emotionlasttime = time(NULL);
  5387. clif_emotion(&pd->bl, i);
  5388. return 0;
  5389. }
  5390. }
  5391. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5392. clif_message(&pd->bl, temp);
  5393. return 0;
  5394. }
  5395. /// @users - displays the number of players present on each map (and percentage)
  5396. /// #users displays on the target user instead of self
  5397. ACMD_FUNC(users)
  5398. {
  5399. char buf[CHAT_SIZE_MAX];
  5400. int i;
  5401. int users[MAX_MAPINDEX];
  5402. int users_all;
  5403. struct s_mapiterator* iter;
  5404. memset(users, 0, sizeof(users));
  5405. users_all = 0;
  5406. // count users on each map
  5407. iter = mapit_getallusers();
  5408. for(;;)
  5409. {
  5410. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5411. if( sd2 == NULL )
  5412. break;// no more users
  5413. if( sd2->mapindex >= MAX_MAPINDEX )
  5414. continue;// invalid mapindex
  5415. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5416. if( users_all < INT_MAX ) ++users_all;
  5417. }
  5418. mapit_free(iter);
  5419. // display results for each map
  5420. for( i = 0; i < MAX_MAPINDEX; ++i )
  5421. {
  5422. if( users[i] == 0 )
  5423. continue;// empty
  5424. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5425. clif_displaymessage(sd->fd, buf);
  5426. }
  5427. // display overall count
  5428. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5429. clif_displaymessage(sd->fd, buf);
  5430. return 0;
  5431. }
  5432. /*==========================================
  5433. *
  5434. *------------------------------------------*/
  5435. ACMD_FUNC(reset)
  5436. {
  5437. pc_resetstate(sd);
  5438. pc_resetskill(sd,1);
  5439. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5440. clif_displaymessage(fd, atcmd_output);
  5441. return 0;
  5442. }
  5443. /*==========================================
  5444. *
  5445. *------------------------------------------*/
  5446. ACMD_FUNC(summon)
  5447. {
  5448. char name[NAME_LENGTH];
  5449. int mob_id = 0;
  5450. int duration = 0;
  5451. struct mob_data *md;
  5452. unsigned int tick=gettick();
  5453. nullpo_retr(-1, sd);
  5454. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5455. {
  5456. clif_displaymessage(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5457. return -1;
  5458. }
  5459. if (duration < 1)
  5460. duration =1;
  5461. else if (duration > 60)
  5462. duration =60;
  5463. if ((mob_id = atoi(name)) == 0)
  5464. mob_id = mobdb_searchname(name);
  5465. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5466. {
  5467. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5468. return -1;
  5469. }
  5470. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5471. if(!md)
  5472. return -1;
  5473. md->master_id=sd->bl.id;
  5474. md->special_state.ai=1;
  5475. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5476. clif_specialeffect(&md->bl,344,AREA);
  5477. mob_spawn(md);
  5478. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5479. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5480. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5481. return 0;
  5482. }
  5483. /*==========================================
  5484. * @adjgroup
  5485. * Temporarily move player to another group
  5486. * Useful during beta testing to allow players to use GM commands for short periods of time
  5487. *------------------------------------------*/
  5488. ACMD_FUNC(adjgroup)
  5489. {
  5490. int new_group = 0;
  5491. nullpo_retr(-1, sd);
  5492. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5493. clif_displaymessage(fd, msg_txt(1226)); // Usage: @adjgroup <group_id>
  5494. return -1;
  5495. }
  5496. if (!pc_group_exists(new_group)) {
  5497. clif_displaymessage(fd, msg_txt(1227)); // Specified group does not exist.
  5498. return -1;
  5499. }
  5500. sd->group_id = new_group;
  5501. pc_group_pc_load(sd);/* update cache */
  5502. clif_displaymessage(fd, msg_txt(1228)); // Group changed successfully.
  5503. clif_displaymessage(sd->fd, msg_txt(1229)); // Your group has changed.
  5504. return 0;
  5505. }
  5506. /*==========================================
  5507. * @trade by [MouseJstr]
  5508. * Open a trade window with a remote player
  5509. *------------------------------------------*/
  5510. ACMD_FUNC(trade)
  5511. {
  5512. struct map_session_data *pl_sd = NULL;
  5513. nullpo_retr(-1, sd);
  5514. if (!message || !*message) {
  5515. clif_displaymessage(fd, msg_txt(1230)); // Please enter a player name (usage: @trade <char name>).
  5516. return -1;
  5517. }
  5518. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5519. {
  5520. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5521. return -1;
  5522. }
  5523. trade_traderequest(sd, pl_sd);
  5524. return 0;
  5525. }
  5526. /*==========================================
  5527. * @setbattleflag by [MouseJstr]
  5528. * set a battle_config flag without having to reboot
  5529. *------------------------------------------*/
  5530. ACMD_FUNC(setbattleflag)
  5531. {
  5532. char flag[128], value[128];
  5533. nullpo_retr(-1, sd);
  5534. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5535. clif_displaymessage(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value>
  5536. return -1;
  5537. }
  5538. if (battle_set_value(flag, value) == 0)
  5539. {
  5540. clif_displaymessage(fd, msg_txt(1232)); // Unknown battle_config flag.
  5541. return -1;
  5542. }
  5543. clif_displaymessage(fd, msg_txt(1233)); // Set battle_config as requested.
  5544. return 0;
  5545. }
  5546. /*==========================================
  5547. * @unmute [Valaris]
  5548. *------------------------------------------*/
  5549. ACMD_FUNC(unmute)
  5550. {
  5551. struct map_session_data *pl_sd = NULL;
  5552. nullpo_retr(-1, sd);
  5553. if (!message || !*message) {
  5554. clif_displaymessage(fd, msg_txt(1234)); // Please enter a player name (usage: @unmute <char name>).
  5555. return -1;
  5556. }
  5557. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5558. {
  5559. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5560. return -1;
  5561. }
  5562. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5563. clif_displaymessage(sd->fd,msg_txt(1235)); // Player is not muted.
  5564. return -1;
  5565. }
  5566. pl_sd->status.manner = 0;
  5567. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5568. clif_displaymessage(sd->fd,msg_txt(1236)); // Player unmuted.
  5569. return 0;
  5570. }
  5571. /*==========================================
  5572. * @uptime by MC Cameri
  5573. *------------------------------------------*/
  5574. ACMD_FUNC(uptime)
  5575. {
  5576. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5577. minute = 60, days = 0, hours = 0, minutes = 0;
  5578. nullpo_retr(-1, sd);
  5579. seconds = get_uptime();
  5580. days = seconds/day;
  5581. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5582. hours = seconds/hour;
  5583. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5584. minutes = seconds/minute;
  5585. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5586. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5587. clif_displaymessage(fd, atcmd_output);
  5588. return 0;
  5589. }
  5590. /*==========================================
  5591. * @changesex <sex>
  5592. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5593. *------------------------------------------*/
  5594. ACMD_FUNC(changesex)
  5595. {
  5596. int i;
  5597. nullpo_retr(-1, sd);
  5598. pc_resetskill(sd,4);
  5599. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5600. for( i=0; i<EQI_MAX; i++ )
  5601. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5602. chrif_changesex(sd);
  5603. return 0;
  5604. }
  5605. /*================================================
  5606. * @mute - Mutes a player for a set amount of time
  5607. *------------------------------------------------*/
  5608. ACMD_FUNC(mute)
  5609. {
  5610. struct map_session_data *pl_sd = NULL;
  5611. int manner;
  5612. nullpo_retr(-1, sd);
  5613. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5614. clif_displaymessage(fd, msg_txt(1237)); // Usage: @mute <time> <char name>
  5615. return -1;
  5616. }
  5617. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5618. {
  5619. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5620. return -1;
  5621. }
  5622. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5623. {
  5624. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5625. return -1;
  5626. }
  5627. clif_manner_message(sd, 0);
  5628. clif_manner_message(pl_sd, 5);
  5629. if( pl_sd->status.manner < manner ) {
  5630. pl_sd->status.manner -= manner;
  5631. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5632. } else {
  5633. pl_sd->status.manner = 0;
  5634. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5635. }
  5636. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5637. return 0;
  5638. }
  5639. /*==========================================
  5640. * @refresh (like @jumpto <<yourself>>)
  5641. *------------------------------------------*/
  5642. ACMD_FUNC(refresh)
  5643. {
  5644. nullpo_retr(-1, sd);
  5645. clif_refresh(sd);
  5646. return 0;
  5647. }
  5648. /*==========================================
  5649. * @identify
  5650. * => GM's magnifier.
  5651. *------------------------------------------*/
  5652. ACMD_FUNC(identify)
  5653. {
  5654. int i,num;
  5655. nullpo_retr(-1, sd);
  5656. for(i=num=0;i<MAX_INVENTORY;i++){
  5657. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5658. num++;
  5659. }
  5660. }
  5661. if (num > 0) {
  5662. clif_item_identify_list(sd);
  5663. } else {
  5664. clif_displaymessage(fd,msg_txt(1238)); // There are no items to appraise.
  5665. }
  5666. return 0;
  5667. }
  5668. /*==========================================
  5669. * @gmotd (Global MOTD)
  5670. * by davidsiaw :P
  5671. *------------------------------------------*/
  5672. ACMD_FUNC(gmotd)
  5673. {
  5674. char buf[CHAT_SIZE_MAX];
  5675. size_t len;
  5676. FILE* fp;
  5677. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5678. {
  5679. while( fgets(buf, sizeof(buf), fp) )
  5680. {
  5681. if( buf[0] == '/' && buf[1] == '/' )
  5682. {
  5683. continue;
  5684. }
  5685. len = strlen(buf);
  5686. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5687. {// strip trailing EOL characters
  5688. len--;
  5689. }
  5690. if( len )
  5691. {
  5692. buf[len] = 0;
  5693. intif_broadcast(buf, len+1, 0);
  5694. }
  5695. }
  5696. fclose(fp);
  5697. }
  5698. return 0;
  5699. }
  5700. ACMD_FUNC(misceffect)
  5701. {
  5702. int effect = 0;
  5703. nullpo_retr(-1, sd);
  5704. if (!message || !*message)
  5705. return -1;
  5706. if (sscanf(message, "%d", &effect) < 1)
  5707. return -1;
  5708. clif_misceffect(&sd->bl,effect);
  5709. return 0;
  5710. }
  5711. /*==========================================
  5712. * MAIL SYSTEM
  5713. *------------------------------------------*/
  5714. ACMD_FUNC(mail)
  5715. {
  5716. nullpo_ret(sd);
  5717. mail_openmail(sd);
  5718. return 0;
  5719. }
  5720. /*==========================================
  5721. * Show Monster DB Info v 1.0
  5722. * originally by [Lupus]
  5723. *------------------------------------------*/
  5724. ACMD_FUNC(mobinfo)
  5725. {
  5726. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5727. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5728. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5729. char atcmd_output2[CHAT_SIZE_MAX];
  5730. struct item_data *item_data;
  5731. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5732. int count;
  5733. int i, j, k;
  5734. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5735. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5736. if (!message || !*message) {
  5737. clif_displaymessage(fd, msg_txt(1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5738. return -1;
  5739. }
  5740. // If monster identifier/name argument is a name
  5741. if ((i = mobdb_checkid(atoi(message))))
  5742. {
  5743. mob_array[0] = mob_db(i);
  5744. count = 1;
  5745. } else
  5746. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5747. if (!count) {
  5748. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5749. return -1;
  5750. }
  5751. if (count > MAX_SEARCH) {
  5752. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  5753. clif_displaymessage(fd, atcmd_output);
  5754. count = MAX_SEARCH;
  5755. }
  5756. for (k = 0; k < count; k++) {
  5757. mob = mob_array[k];
  5758. // stats
  5759. if (mob->mexp)
  5760. sprintf(atcmd_output, msg_txt(1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5761. else
  5762. sprintf(atcmd_output, msg_txt(1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5763. clif_displaymessage(fd, atcmd_output);
  5764. 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
  5765. clif_displaymessage(fd, atcmd_output);
  5766. sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5767. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  5768. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5769. clif_displaymessage(fd, atcmd_output);
  5770. sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5771. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5772. mob->range2 , mob->range3, msize[mob->status.size],
  5773. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5774. clif_displaymessage(fd, atcmd_output);
  5775. // drops
  5776. clif_displaymessage(fd, msg_txt(1245)); // Drops:
  5777. strcpy(atcmd_output, " ");
  5778. j = 0;
  5779. for (i = 0; i < MAX_MOB_DROP; i++) {
  5780. int droprate;
  5781. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5782. continue;
  5783. droprate = mob->dropitem[i].p;
  5784. if (item_data->slot)
  5785. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  5786. else
  5787. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  5788. strcat(atcmd_output, atcmd_output2);
  5789. if (++j % 3 == 0) {
  5790. clif_displaymessage(fd, atcmd_output);
  5791. strcpy(atcmd_output, " ");
  5792. }
  5793. }
  5794. if (j == 0)
  5795. clif_displaymessage(fd, msg_txt(1246)); // This monster has no drops.
  5796. else if (j % 3 != 0)
  5797. clif_displaymessage(fd, atcmd_output);
  5798. // mvp
  5799. if (mob->mexp) {
  5800. sprintf(atcmd_output, msg_txt(1247), mob->mexp); // MVP Bonus EXP:%u
  5801. clif_displaymessage(fd, atcmd_output);
  5802. strcpy(atcmd_output, msg_txt(1248)); // MVP Items:
  5803. j = 0;
  5804. for (i = 0; i < MAX_MVP_DROP; i++) {
  5805. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5806. continue;
  5807. if (mob->mvpitem[i].p > 0) {
  5808. j++;
  5809. if (j == 1)
  5810. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5811. else
  5812. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5813. strcat(atcmd_output, atcmd_output2);
  5814. }
  5815. }
  5816. if (j == 0)
  5817. clif_displaymessage(fd, msg_txt(1249)); // This monster has no MVP prizes.
  5818. else
  5819. clif_displaymessage(fd, atcmd_output);
  5820. }
  5821. }
  5822. return 0;
  5823. }
  5824. /*=========================================
  5825. * @showmobs by KarLaeda
  5826. * => For 15 sec displays the mobs on minimap
  5827. *------------------------------------------*/
  5828. ACMD_FUNC(showmobs)
  5829. {
  5830. char mob_name[100];
  5831. int mob_id;
  5832. int number = 0;
  5833. struct s_mapiterator* it;
  5834. nullpo_retr(-1, sd);
  5835. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5836. return -1;
  5837. if((mob_id = atoi(mob_name)) == 0)
  5838. mob_id = mobdb_searchname(mob_name);
  5839. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5840. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1250),mob_name); // Invalid mob id %s!
  5841. clif_displaymessage(fd, atcmd_output);
  5842. return 0;
  5843. }
  5844. 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.
  5845. clif_displaymessage(fd, msg_txt(1251)); // Can't show boss mobs!
  5846. return 0;
  5847. }
  5848. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5849. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5850. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5851. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s
  5852. mob_name, mapindex_id2name(sd->mapindex));
  5853. clif_displaymessage(fd, atcmd_output);
  5854. it = mapit_geteachmob();
  5855. for(;;)
  5856. {
  5857. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5858. if( md == NULL )
  5859. break;// no more mobs
  5860. if( md->bl.m != sd->bl.m )
  5861. continue;
  5862. if( mob_id != -1 && md->class_ != mob_id )
  5863. continue;
  5864. if( md->special_state.ai || md->master_id )
  5865. continue; // hide slaves and player summoned mobs
  5866. if( md->spawn_timer != INVALID_TIMER )
  5867. continue; // hide mobs waiting for respawn
  5868. ++number;
  5869. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5870. }
  5871. mapit_free(it);
  5872. return 0;
  5873. }
  5874. /*==========================================
  5875. * homunculus level up [orn]
  5876. *------------------------------------------*/
  5877. ACMD_FUNC(homlevel)
  5878. {
  5879. TBL_HOM * hd;
  5880. int level = 0, i = 0;
  5881. nullpo_retr(-1, sd);
  5882. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  5883. clif_displaymessage(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  5884. return -1;
  5885. }
  5886. if ( !merc_is_hom_active(sd->hd) ) {
  5887. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5888. return -1;
  5889. }
  5890. hd = sd->hd;
  5891. for (i = 1; i <= level && hd->exp_next; i++){
  5892. hd->homunculus.exp += hd->exp_next;
  5893. merc_hom_levelup(hd);
  5894. }
  5895. status_calc_homunculus(hd,0);
  5896. status_percent_heal(&hd->bl, 100, 100);
  5897. clif_specialeffect(&hd->bl,568,AREA);
  5898. return 0;
  5899. }
  5900. /*==========================================
  5901. * homunculus evolution H [orn]
  5902. *------------------------------------------*/
  5903. ACMD_FUNC(homevolution)
  5904. {
  5905. nullpo_retr(-1, sd);
  5906. if ( !merc_is_hom_active(sd->hd) ) {
  5907. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5908. return -1;
  5909. }
  5910. if ( !merc_hom_evolution(sd->hd) ) {
  5911. clif_displaymessage(fd, msg_txt(1255)); // Your homunculus doesn't evolve.
  5912. return -1;
  5913. }
  5914. clif_homskillinfoblock(sd);
  5915. return 0;
  5916. }
  5917. /*==========================================
  5918. * call choosen homunculus [orn]
  5919. *------------------------------------------*/
  5920. ACMD_FUNC(makehomun)
  5921. {
  5922. int homunid;
  5923. nullpo_retr(-1, sd);
  5924. if ( sd->status.hom_id ) {
  5925. clif_displaymessage(fd, msg_txt(450));
  5926. return -1;
  5927. }
  5928. if (!message || !*message) {
  5929. clif_displaymessage(fd, msg_txt(1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  5930. return -1;
  5931. }
  5932. homunid = atoi(message);
  5933. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  5934. {
  5935. clif_displaymessage(fd, msg_txt(1257)); // Invalid Homunculus ID.
  5936. return -1;
  5937. }
  5938. merc_create_homunculus_request(sd,homunid);
  5939. return 0;
  5940. }
  5941. /*==========================================
  5942. * modify homunculus intimacy [orn]
  5943. *------------------------------------------*/
  5944. ACMD_FUNC(homfriendly)
  5945. {
  5946. int friendly = 0;
  5947. nullpo_retr(-1, sd);
  5948. if ( !merc_is_hom_active(sd->hd) ) {
  5949. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5950. return -1;
  5951. }
  5952. if (!message || !*message) {
  5953. clif_displaymessage(fd, msg_txt(1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  5954. return -1;
  5955. }
  5956. friendly = atoi(message);
  5957. friendly = cap_value(friendly, 0, 1000);
  5958. sd->hd->homunculus.intimacy = friendly * 100 ;
  5959. clif_send_homdata(sd,SP_INTIMATE,friendly);
  5960. return 0;
  5961. }
  5962. /*==========================================
  5963. * modify homunculus hunger [orn]
  5964. *------------------------------------------*/
  5965. ACMD_FUNC(homhungry)
  5966. {
  5967. int hungry = 0;
  5968. nullpo_retr(-1, sd);
  5969. if ( !merc_is_hom_active(sd->hd) ) {
  5970. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  5971. return -1;
  5972. }
  5973. if (!message || !*message) {
  5974. clif_displaymessage(fd, msg_txt(1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  5975. return -1;
  5976. }
  5977. hungry = atoi(message);
  5978. hungry = cap_value(hungry, 0, 100);
  5979. sd->hd->homunculus.hunger = hungry;
  5980. clif_send_homdata(sd,SP_HUNGRY,hungry);
  5981. return 0;
  5982. }
  5983. /*==========================================
  5984. * make the homunculus speak [orn]
  5985. *------------------------------------------*/
  5986. ACMD_FUNC(homtalk)
  5987. {
  5988. char mes[100],temp[100];
  5989. nullpo_retr(-1, sd);
  5990. if ( battle_config.min_chat_delay ) {
  5991. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5992. return 0;
  5993. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5994. }
  5995. if (sd->sc.count && //no "chatting" while muted.
  5996. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5997. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5998. return -1;
  5999. if ( !merc_is_hom_active(sd->hd) ) {
  6000. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6001. return -1;
  6002. }
  6003. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6004. clif_displaymessage(fd, msg_txt(1260)); // Please enter a message (usage: @homtalk <message>).
  6005. return -1;
  6006. }
  6007. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6008. clif_message(&sd->hd->bl, temp);
  6009. return 0;
  6010. }
  6011. /*==========================================
  6012. * Show homunculus stats
  6013. *------------------------------------------*/
  6014. ACMD_FUNC(hominfo)
  6015. {
  6016. struct homun_data *hd;
  6017. struct status_data *status;
  6018. nullpo_retr(-1, sd);
  6019. if ( !merc_is_hom_active(sd->hd) ) {
  6020. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6021. return -1;
  6022. }
  6023. hd = sd->hd;
  6024. status = status_get_status_data(&hd->bl);
  6025. clif_displaymessage(fd, msg_txt(1261)); // Homunculus stats:
  6026. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1262), // HP: %d/%d - SP: %d/%d
  6027. status->hp, status->max_hp, status->sp, status->max_sp);
  6028. clif_displaymessage(fd, atcmd_output);
  6029. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1263), // ATK: %d - MATK: %d~%d
  6030. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6031. clif_displaymessage(fd, atcmd_output);
  6032. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1264), // Hungry: %d - Intimacy: %u
  6033. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6034. clif_displaymessage(fd, atcmd_output);
  6035. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6036. msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6037. status->str, status->agi, status->vit,
  6038. status->int_, status->dex, status->luk);
  6039. clif_displaymessage(fd, atcmd_output);
  6040. return 0;
  6041. }
  6042. ACMD_FUNC(homstats)
  6043. {
  6044. struct homun_data *hd;
  6045. struct s_homunculus_db *db;
  6046. struct s_homunculus *hom;
  6047. int lv, min, max, evo;
  6048. nullpo_retr(-1, sd);
  6049. if ( !merc_is_hom_active(sd->hd) ) {
  6050. clif_displaymessage(fd, msg_txt(1254)); // You do not have a homunculus.
  6051. return -1;
  6052. }
  6053. hd = sd->hd;
  6054. hom = &hd->homunculus;
  6055. db = hd->homunculusDB;
  6056. lv = hom->level;
  6057. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6058. msg_txt(1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6059. clif_displaymessage(fd, atcmd_output);
  6060. lv--; //Since the first increase is at level 2.
  6061. evo = (hom->class_ == db->evo_class);
  6062. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6063. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6064. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6065. clif_displaymessage(fd, atcmd_output);
  6066. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6067. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6068. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6069. clif_displaymessage(fd, atcmd_output);
  6070. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6071. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6072. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6073. clif_displaymessage(fd, atcmd_output);
  6074. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6075. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6076. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6077. clif_displaymessage(fd, atcmd_output);
  6078. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6079. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6080. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6081. clif_displaymessage(fd, atcmd_output);
  6082. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6083. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6084. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6085. clif_displaymessage(fd, atcmd_output);
  6086. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6087. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6088. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6089. clif_displaymessage(fd, atcmd_output);
  6090. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6091. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6092. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6093. clif_displaymessage(fd, atcmd_output);
  6094. return 0;
  6095. }
  6096. ACMD_FUNC(homshuffle)
  6097. {
  6098. nullpo_retr(-1, sd);
  6099. if(!sd->hd)
  6100. return -1; // nothing to do
  6101. if(!merc_hom_shuffle(sd->hd))
  6102. return -1;
  6103. clif_displaymessage(sd->fd, msg_txt(1275)); // Homunculus stats altered.
  6104. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6105. return 0;
  6106. }
  6107. /*==========================================
  6108. * Show Items DB Info v 1.0
  6109. * originally by [Lupus]
  6110. *------------------------------------------*/
  6111. ACMD_FUNC(iteminfo)
  6112. {
  6113. struct item_data *item_data, *item_array[MAX_SEARCH];
  6114. int i, count = 1;
  6115. if (!message || !*message) {
  6116. clif_displaymessage(fd, msg_txt(1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6117. return -1;
  6118. }
  6119. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6120. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6121. if (!count) {
  6122. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6123. return -1;
  6124. }
  6125. if (count > MAX_SEARCH) {
  6126. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6127. clif_displaymessage(fd, atcmd_output);
  6128. count = MAX_SEARCH;
  6129. }
  6130. for (i = 0; i < count; i++) {
  6131. item_data = item_array[i];
  6132. sprintf(atcmd_output, msg_txt(1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6133. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6134. itemdb_typename(item_data->type),
  6135. (item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script
  6136. );
  6137. clif_displaymessage(fd, atcmd_output);
  6138. 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
  6139. clif_displaymessage(fd, atcmd_output);
  6140. if (item_data->maxchance == -1)
  6141. strcpy(atcmd_output, msg_txt(1281)); // - Available in the shops only.
  6142. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6143. sprintf(atcmd_output, msg_txt(1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6144. else
  6145. strcpy(atcmd_output, msg_txt(1283)); // - Monsters don't drop this item.
  6146. clif_displaymessage(fd, atcmd_output);
  6147. }
  6148. return 0;
  6149. }
  6150. /*==========================================
  6151. * Show who drops the item.
  6152. *------------------------------------------*/
  6153. ACMD_FUNC(whodrops)
  6154. {
  6155. struct item_data *item_data, *item_array[MAX_SEARCH];
  6156. int i,j, count = 1;
  6157. if (!message || !*message) {
  6158. clif_displaymessage(fd, msg_txt(1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6159. return -1;
  6160. }
  6161. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6162. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6163. if (!count) {
  6164. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6165. return -1;
  6166. }
  6167. if (count > MAX_SEARCH) {
  6168. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6169. clif_displaymessage(fd, atcmd_output);
  6170. count = MAX_SEARCH;
  6171. }
  6172. for (i = 0; i < count; i++) {
  6173. item_data = item_array[i];
  6174. sprintf(atcmd_output, msg_txt(1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
  6175. clif_displaymessage(fd, atcmd_output);
  6176. if (item_data->mob[0].chance == 0) {
  6177. strcpy(atcmd_output, msg_txt(1286)); // - Item is not dropped by mobs.
  6178. clif_displaymessage(fd, atcmd_output);
  6179. } else {
  6180. sprintf(atcmd_output, msg_txt(1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6181. clif_displaymessage(fd, atcmd_output);
  6182. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6183. {
  6184. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6185. clif_displaymessage(fd, atcmd_output);
  6186. }
  6187. }
  6188. }
  6189. return 0;
  6190. }
  6191. ACMD_FUNC(whereis)
  6192. {
  6193. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6194. int count;
  6195. int i, j, k;
  6196. if (!message || !*message) {
  6197. clif_displaymessage(fd, msg_txt(1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6198. return -1;
  6199. }
  6200. // If monster identifier/name argument is a name
  6201. if ((i = mobdb_checkid(atoi(message))))
  6202. {
  6203. mob_array[0] = mob_db(i);
  6204. count = 1;
  6205. } else
  6206. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6207. if (!count) {
  6208. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6209. return -1;
  6210. }
  6211. if (count > MAX_SEARCH) {
  6212. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6213. clif_displaymessage(fd, atcmd_output);
  6214. count = MAX_SEARCH;
  6215. }
  6216. for (k = 0; k < count; k++) {
  6217. mob = mob_array[k];
  6218. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), mob->jname); // %s spawns in:
  6219. clif_displaymessage(fd, atcmd_output);
  6220. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6221. {
  6222. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6223. if (j < 0) continue;
  6224. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6225. clif_displaymessage(fd, atcmd_output);
  6226. }
  6227. if (i == 0)
  6228. clif_displaymessage(fd, msg_txt(1290)); // This monster does not spawn normally.
  6229. }
  6230. return 0;
  6231. }
  6232. /*==========================================
  6233. * @adopt by [Veider]
  6234. * adopt a novice
  6235. *------------------------------------------*/
  6236. ACMD_FUNC(adopt)
  6237. {
  6238. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6239. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6240. char output[CHAT_SIZE_MAX];
  6241. nullpo_retr(-1, sd);
  6242. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6243. clif_displaymessage(fd, msg_txt(1291)); // Usage: @adopt <father>,<mother>,<child>
  6244. return -1;
  6245. }
  6246. if (battle_config.etc_log)
  6247. ShowInfo(msg_txt(1292),player1,player2,player3); // Adopting: --%s--%s--%s--\n
  6248. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6249. sprintf(output, msg_txt(1293), player1); // Cannot find player %s online.
  6250. clif_displaymessage(fd, output);
  6251. return -1;
  6252. }
  6253. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6254. sprintf(output, msg_txt(1293), player2); // Cannot find player %s online.
  6255. clif_displaymessage(fd, output);
  6256. return -1;
  6257. }
  6258. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6259. sprintf(output, msg_txt(1293), player3); // Cannot find player %s online.
  6260. clif_displaymessage(fd, output);
  6261. return -1;
  6262. }
  6263. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6264. return -1;
  6265. }
  6266. clif_displaymessage(fd, msg_txt(1294)); // They are family... wish them luck.
  6267. return 0;
  6268. }
  6269. ACMD_FUNC(version)
  6270. {
  6271. const char * revision;
  6272. if ((revision = get_svn_revision()) != 0) {
  6273. sprintf(atcmd_output,msg_txt(1295),revision); // rAthena Version SVN r%s
  6274. clif_displaymessage(fd,atcmd_output);
  6275. } else
  6276. clif_displaymessage(fd,msg_txt(1296)); // Cannot determine SVN revision.
  6277. return 0;
  6278. }
  6279. /*==========================================
  6280. * @mutearea by MouseJstr
  6281. *------------------------------------------*/
  6282. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6283. {
  6284. int time, id;
  6285. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6286. if (pl_sd == NULL)
  6287. return 0;
  6288. id = va_arg(ap, int);
  6289. time = va_arg(ap, int);
  6290. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6291. pl_sd->status.manner -= time;
  6292. if (pl_sd->status.manner < 0)
  6293. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6294. else
  6295. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6296. }
  6297. return 0;
  6298. }
  6299. ACMD_FUNC(mutearea)
  6300. {
  6301. int time;
  6302. nullpo_ret(sd);
  6303. if (!message || !*message) {
  6304. clif_displaymessage(fd, msg_txt(1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6305. return -1;
  6306. }
  6307. time = atoi(message);
  6308. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6309. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6310. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6311. return 0;
  6312. }
  6313. ACMD_FUNC(rates)
  6314. {
  6315. char buf[CHAT_SIZE_MAX];
  6316. nullpo_ret(sd);
  6317. memset(buf, '\0', sizeof(buf));
  6318. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1298), // Experience rates: Base %.2fx / Job %.2fx
  6319. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6320. clif_displaymessage(fd, buf);
  6321. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6322. 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.);
  6323. clif_displaymessage(fd, buf);
  6324. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6325. 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.);
  6326. clif_displaymessage(fd, buf);
  6327. snprintf(buf, CHAT_SIZE_MAX, msg_txt(1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6328. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6329. clif_displaymessage(fd, buf);
  6330. return 0;
  6331. }
  6332. /*==========================================
  6333. * @me by lordalfa
  6334. * => Displays the OUTPUT string on top of the Visible players Heads.
  6335. *------------------------------------------*/
  6336. ACMD_FUNC(me)
  6337. {
  6338. char tempmes[CHAT_SIZE_MAX];
  6339. nullpo_retr(-1, sd);
  6340. memset(tempmes, '\0', sizeof(tempmes));
  6341. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6342. if (sd->sc.count && //no "chatting" while muted.
  6343. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6344. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6345. return -1;
  6346. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6347. clif_displaymessage(fd, msg_txt(1302)); // Please enter a message (usage: @me <message>).
  6348. return -1;
  6349. }
  6350. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6351. clif_disp_overhead(sd, atcmd_output);
  6352. return 0;
  6353. }
  6354. /*==========================================
  6355. * @size
  6356. * => Resize your character sprite. [Valaris]
  6357. *------------------------------------------*/
  6358. ACMD_FUNC(size)
  6359. {
  6360. int size = 0;
  6361. nullpo_retr(-1, sd);
  6362. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6363. if(sd->state.size) {
  6364. sd->state.size = SZ_SMALL;
  6365. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6366. }
  6367. sd->state.size = size;
  6368. if( size == SZ_MEDIUM )
  6369. clif_specialeffect(&sd->bl,420,AREA);
  6370. else if( size == SZ_BIG )
  6371. clif_specialeffect(&sd->bl,422,AREA);
  6372. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6373. return 0;
  6374. }
  6375. ACMD_FUNC(sizeall)
  6376. {
  6377. int size;
  6378. struct map_session_data *pl_sd;
  6379. struct s_mapiterator* iter;
  6380. size = atoi(message);
  6381. size = cap_value(size,0,2);
  6382. iter = mapit_getallusers();
  6383. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6384. if( pl_sd->state.size != size ) {
  6385. if( pl_sd->state.size ) {
  6386. pl_sd->state.size = SZ_SMALL;
  6387. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6388. }
  6389. pl_sd->state.size = size;
  6390. if( size == SZ_MEDIUM )
  6391. clif_specialeffect(&pl_sd->bl,420,AREA);
  6392. else if( size == SZ_BIG )
  6393. clif_specialeffect(&pl_sd->bl,422,AREA);
  6394. }
  6395. }
  6396. mapit_free(iter);
  6397. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6398. return 0;
  6399. }
  6400. ACMD_FUNC(sizeguild)
  6401. {
  6402. int size = 0, i;
  6403. char guild[NAME_LENGTH];
  6404. struct map_session_data *pl_sd;
  6405. struct guild *g;
  6406. nullpo_retr(-1, sd);
  6407. memset(guild, '\0', sizeof(guild));
  6408. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6409. clif_displaymessage(fd, msg_txt(1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6410. return -1;
  6411. }
  6412. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6413. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  6414. return -1;
  6415. }
  6416. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6417. for( i = 0; i < g->max_member; i++ ) {
  6418. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6419. if( pl_sd->state.size ) {
  6420. pl_sd->state.size = SZ_SMALL;
  6421. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6422. }
  6423. pl_sd->state.size = size;
  6424. if( size == SZ_MEDIUM )
  6425. clif_specialeffect(&pl_sd->bl,420,AREA);
  6426. else if( size == SZ_BIG )
  6427. clif_specialeffect(&pl_sd->bl,422,AREA);
  6428. }
  6429. }
  6430. clif_displaymessage(fd, msg_txt(1303)); // Size change applied.
  6431. return 0;
  6432. }
  6433. /*==========================================
  6434. * @monsterignore
  6435. * => Makes monsters ignore you. [Valaris]
  6436. *------------------------------------------*/
  6437. ACMD_FUNC(monsterignore)
  6438. {
  6439. nullpo_retr(-1, sd);
  6440. if (!sd->state.monster_ignore) {
  6441. sd->state.monster_ignore = 1;
  6442. clif_displaymessage(sd->fd, msg_txt(1305)); // You are now immune to attacks.
  6443. } else {
  6444. sd->state.monster_ignore = 0;
  6445. clif_displaymessage(sd->fd, msg_txt(1306)); // Returned to normal state.
  6446. }
  6447. return 0;
  6448. }
  6449. /*==========================================
  6450. * @fakename
  6451. * => Gives your character a fake name. [Valaris]
  6452. *------------------------------------------*/
  6453. ACMD_FUNC(fakename)
  6454. {
  6455. nullpo_retr(-1, sd);
  6456. if( !message || !*message )
  6457. {
  6458. if( sd->fakename[0] )
  6459. {
  6460. sd->fakename[0] = '\0';
  6461. clif_charnameack(0, &sd->bl);
  6462. clif_displaymessage(sd->fd, msg_txt(1307)); // Returned to real name.
  6463. return 0;
  6464. }
  6465. clif_displaymessage(sd->fd, msg_txt(1308)); // You must enter a name.
  6466. return -1;
  6467. }
  6468. if( strlen(message) < 2 )
  6469. {
  6470. clif_displaymessage(sd->fd, msg_txt(1309)); // Fake name must be at least two characters.
  6471. return -1;
  6472. }
  6473. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6474. clif_charnameack(0, &sd->bl);
  6475. clif_displaymessage(sd->fd, msg_txt(1310)); // Fake name enabled.
  6476. return 0;
  6477. }
  6478. /*==========================================
  6479. * Ragnarok Resources
  6480. *------------------------------------------*/
  6481. ACMD_FUNC(mapflag) {
  6482. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6483. #define setflag( cmd ) \
  6484. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6485. map[ sd->bl.m ].flag.cmd = flag;\
  6486. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6487. clif_displaymessage(sd->fd,atcmd_output);\
  6488. return 0;\
  6489. }
  6490. unsigned char flag_name[100];
  6491. int flag=9,i;
  6492. nullpo_retr(-1, sd);
  6493. memset(flag_name, '\0', sizeof(flag_name));
  6494. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6495. clif_displaymessage(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map:
  6496. clif_displaymessage(sd->fd,"----------------------------------");
  6497. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6498. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6499. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6500. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6501. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6502. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6503. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6504. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6505. checkflag(nogo); checkflag(nobaseexp);
  6506. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6507. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6508. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6509. clif_displaymessage(sd->fd," ");
  6510. clif_displaymessage(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6511. clif_displaymessage(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags.
  6512. return 1;
  6513. }
  6514. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6515. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6516. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6517. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6518. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6519. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6520. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6521. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6522. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6523. setflag(nogo); setflag(nobaseexp);
  6524. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6525. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6526. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6527. clif_displaymessage(sd->fd,msg_txt(1314)); // Invalid flag name or flag.
  6528. clif_displaymessage(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6529. clif_displaymessage(sd->fd,msg_txt(1315)); // Available Flags:
  6530. clif_displaymessage(sd->fd,"----------------------------------");
  6531. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6532. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6533. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6534. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6535. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6536. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6537. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6538. #undef checkflag
  6539. #undef setflag
  6540. return 0;
  6541. }
  6542. /*===================================
  6543. * Remove some messages
  6544. *-----------------------------------*/
  6545. ACMD_FUNC(showexp)
  6546. {
  6547. if (sd->state.showexp) {
  6548. sd->state.showexp = 0;
  6549. clif_displaymessage(fd, msg_txt(1316)); // Gained exp will not be shown.
  6550. return 0;
  6551. }
  6552. sd->state.showexp = 1;
  6553. clif_displaymessage(fd, msg_txt(1317)); // Gained exp is now shown.
  6554. return 0;
  6555. }
  6556. ACMD_FUNC(showzeny)
  6557. {
  6558. if (sd->state.showzeny) {
  6559. sd->state.showzeny = 0;
  6560. clif_displaymessage(fd, msg_txt(1318)); // Gained zeny will not be shown.
  6561. return 0;
  6562. }
  6563. sd->state.showzeny = 1;
  6564. clif_displaymessage(fd, msg_txt(1319)); // Gained zeny is now shown.
  6565. return 0;
  6566. }
  6567. ACMD_FUNC(showdelay)
  6568. {
  6569. if (sd->state.showdelay) {
  6570. sd->state.showdelay = 0;
  6571. clif_displaymessage(fd, msg_txt(1320)); // Skill delay failures will not be shown.
  6572. return 0;
  6573. }
  6574. sd->state.showdelay = 1;
  6575. clif_displaymessage(fd, msg_txt(1321)); // Skill delay failures are now shown.
  6576. return 0;
  6577. }
  6578. /*==========================================
  6579. * Duel organizing functions [LuzZza]
  6580. *
  6581. * @duel [limit|nick] - create a duel
  6582. * @invite <nick> - invite player
  6583. * @accept - accept invitation
  6584. * @reject - reject invitation
  6585. * @leave - leave duel
  6586. *------------------------------------------*/
  6587. ACMD_FUNC(invite)
  6588. {
  6589. unsigned int did = sd->duel_group;
  6590. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6591. if(did <= 0) {
  6592. // "Duel: @invite without @duel."
  6593. clif_displaymessage(fd, msg_txt(350));
  6594. return 0;
  6595. }
  6596. if(duel_list[did].max_players_limit > 0 &&
  6597. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6598. // "Duel: Limit of players is reached."
  6599. clif_displaymessage(fd, msg_txt(351));
  6600. return 0;
  6601. }
  6602. if(target_sd == NULL) {
  6603. // "Duel: Player not found."
  6604. clif_displaymessage(fd, msg_txt(352));
  6605. return 0;
  6606. }
  6607. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6608. // "Duel: Player already in duel."
  6609. clif_displaymessage(fd, msg_txt(353));
  6610. return 0;
  6611. }
  6612. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6613. {
  6614. sprintf(atcmd_output, msg_txt(364), message);
  6615. clif_displaymessage(fd, atcmd_output);
  6616. return 0;
  6617. }
  6618. duel_invite(did, sd, target_sd);
  6619. // "Duel: Invitation has been sent."
  6620. clif_displaymessage(fd, msg_txt(354));
  6621. return 0;
  6622. }
  6623. ACMD_FUNC(duel)
  6624. {
  6625. char output[CHAT_SIZE_MAX];
  6626. unsigned int maxpl=0, newduel;
  6627. struct map_session_data *target_sd;
  6628. if(sd->duel_group > 0) {
  6629. duel_showinfo(sd->duel_group, sd);
  6630. return 0;
  6631. }
  6632. if(sd->duel_invite > 0) {
  6633. // "Duel: @duel without @reject."
  6634. clif_displaymessage(fd, msg_txt(355));
  6635. return 0;
  6636. }
  6637. if(!duel_checktime(sd)) {
  6638. // "Duel: You can take part in duel only one time per %d minutes."
  6639. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6640. clif_displaymessage(fd, output);
  6641. return 0;
  6642. }
  6643. if( message[0] ) {
  6644. if(sscanf(message, "%d", &maxpl) >= 1) {
  6645. if(maxpl < 2 || maxpl > 65535) {
  6646. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6647. return 0;
  6648. }
  6649. duel_create(sd, maxpl);
  6650. } else {
  6651. target_sd = map_nick2sd((char *)message);
  6652. if(target_sd != NULL) {
  6653. if((newduel = duel_create(sd, 2)) != -1) {
  6654. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6655. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6656. return 0;
  6657. }
  6658. duel_invite(newduel, sd, target_sd);
  6659. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6660. }
  6661. } else {
  6662. // "Duel: Player not found."
  6663. clif_displaymessage(fd, msg_txt(352));
  6664. return 0;
  6665. }
  6666. }
  6667. } else
  6668. duel_create(sd, 0);
  6669. return 0;
  6670. }
  6671. ACMD_FUNC(leave)
  6672. {
  6673. if(sd->duel_group <= 0) {
  6674. // "Duel: @leave without @duel."
  6675. clif_displaymessage(fd, msg_txt(358));
  6676. return 0;
  6677. }
  6678. duel_leave(sd->duel_group, sd);
  6679. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6680. return 0;
  6681. }
  6682. ACMD_FUNC(accept)
  6683. {
  6684. char output[CHAT_SIZE_MAX];
  6685. if(!duel_checktime(sd)) {
  6686. // "Duel: You can take part in duel only one time per %d minutes."
  6687. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6688. clif_displaymessage(fd, output);
  6689. return 0;
  6690. }
  6691. if(sd->duel_invite <= 0) {
  6692. // "Duel: @accept without invititation."
  6693. clif_displaymessage(fd, msg_txt(360));
  6694. return 0;
  6695. }
  6696. 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 )
  6697. {
  6698. // "Duel: Limit of players is reached."
  6699. clif_displaymessage(fd, msg_txt(351));
  6700. return 0;
  6701. }
  6702. duel_accept(sd->duel_invite, sd);
  6703. // "Duel: Invitation has been accepted."
  6704. clif_displaymessage(fd, msg_txt(361));
  6705. return 0;
  6706. }
  6707. ACMD_FUNC(reject)
  6708. {
  6709. if(sd->duel_invite <= 0) {
  6710. // "Duel: @reject without invititation."
  6711. clif_displaymessage(fd, msg_txt(362));
  6712. return 0;
  6713. }
  6714. duel_reject(sd->duel_invite, sd);
  6715. // "Duel: Invitation has been rejected."
  6716. clif_displaymessage(fd, msg_txt(363));
  6717. return 0;
  6718. }
  6719. /*===================================
  6720. * Cash Points
  6721. *-----------------------------------*/
  6722. ACMD_FUNC(cash)
  6723. {
  6724. char output[128];
  6725. int value;
  6726. nullpo_retr(-1, sd);
  6727. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6728. clif_displaymessage(fd, msg_txt(1322)); // Please enter an amount.
  6729. return -1;
  6730. }
  6731. if( !strcmpi(command+1,"cash") )
  6732. {
  6733. if( value > 0 ) {
  6734. pc_getcash(sd, value, 0);
  6735. sprintf(output, msg_txt(505), value, sd->cashPoints);
  6736. clif_disp_onlyself(sd, output, strlen(output));
  6737. } else {
  6738. pc_paycash(sd, -value, 0);
  6739. sprintf(output, msg_txt(410), value, sd->cashPoints);
  6740. clif_disp_onlyself(sd, output, strlen(output));
  6741. }
  6742. }
  6743. else
  6744. { // @points
  6745. if( value > 0 ) {
  6746. pc_getcash(sd, 0, value);
  6747. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  6748. clif_disp_onlyself(sd, output, strlen(output));
  6749. } else {
  6750. pc_paycash(sd, -value, -value);
  6751. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  6752. clif_disp_onlyself(sd, output, strlen(output));
  6753. }
  6754. }
  6755. return 0;
  6756. }
  6757. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6758. ACMD_FUNC(clone)
  6759. {
  6760. int x=0,y=0,flag=0,master=0,i=0;
  6761. struct map_session_data *pl_sd=NULL;
  6762. if (!message || !*message) {
  6763. clif_displaymessage(sd->fd,msg_txt(1323)); // You must enter a player name or ID.
  6764. return 0;
  6765. }
  6766. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6767. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6768. return 0;
  6769. }
  6770. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6771. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  6772. return 0;
  6773. }
  6774. if (strcmpi(command+1, "clone") == 0)
  6775. flag = 1;
  6776. else if (strcmpi(command+1, "slaveclone") == 0) {
  6777. flag = 2;
  6778. master = sd->bl.id;
  6779. if (battle_config.atc_slave_clone_limit
  6780. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6781. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  6782. return 0;
  6783. }
  6784. }
  6785. do {
  6786. x = sd->bl.x + (rnd() % 10 - 5);
  6787. y = sd->bl.y + (rnd() % 10 - 5);
  6788. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6789. if (i >= 10) {
  6790. x = sd->bl.x;
  6791. y = sd->bl.y;
  6792. }
  6793. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6794. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6795. return 0;
  6796. }
  6797. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6798. return 0;
  6799. }
  6800. /*===================================
  6801. * Main chat [LuzZza]
  6802. * Usage: @main <on|off|message>
  6803. *-----------------------------------*/
  6804. ACMD_FUNC(main)
  6805. {
  6806. if( message[0] ) {
  6807. if(strcmpi(message, "on") == 0) {
  6808. if(!sd->state.mainchat) {
  6809. sd->state.mainchat = 1;
  6810. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6811. } else {
  6812. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  6813. }
  6814. } else if(strcmpi(message, "off") == 0) {
  6815. if(sd->state.mainchat) {
  6816. sd->state.mainchat = 0;
  6817. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  6818. } else {
  6819. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  6820. }
  6821. } else {
  6822. if(!sd->state.mainchat) {
  6823. sd->state.mainchat = 1;
  6824. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  6825. }
  6826. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  6827. clif_displaymessage(fd, msg_txt(387));
  6828. return -1;
  6829. }
  6830. if ( battle_config.min_chat_delay ) {
  6831. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6832. return 0;
  6833. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6834. }
  6835. // send the message using inter-server system
  6836. intif_main_message( sd, message );
  6837. }
  6838. } else {
  6839. if(sd->state.mainchat)
  6840. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  6841. else
  6842. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  6843. }
  6844. return 0;
  6845. }
  6846. /*=====================================
  6847. * Autorejecting Invites/Deals [LuzZza]
  6848. * Usage: @noask
  6849. *-------------------------------------*/
  6850. ACMD_FUNC(noask)
  6851. {
  6852. if(sd->state.noask) {
  6853. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  6854. sd->state.noask = 0;
  6855. } else {
  6856. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  6857. sd->state.noask = 1;
  6858. }
  6859. return 0;
  6860. }
  6861. /*=====================================
  6862. * Send a @request message to all GMs of lowest_gm_level.
  6863. * Usage: @request <petition>
  6864. *-------------------------------------*/
  6865. ACMD_FUNC(request)
  6866. {
  6867. if (!message || !*message) {
  6868. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  6869. return -1;
  6870. }
  6871. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  6872. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6873. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6874. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  6875. return 0;
  6876. }
  6877. /*==========================================
  6878. * Feel (SG save map) Reset [HiddenDragon]
  6879. *------------------------------------------*/
  6880. ACMD_FUNC(feelreset)
  6881. {
  6882. pc_resetfeel(sd);
  6883. clif_displaymessage(fd, msg_txt(1324)); // Reset 'Feeling' maps.
  6884. return 0;
  6885. }
  6886. /*==========================================
  6887. * AUCTION SYSTEM
  6888. *------------------------------------------*/
  6889. ACMD_FUNC(auction)
  6890. {
  6891. nullpo_ret(sd);
  6892. clif_Auction_openwindow(sd);
  6893. return 0;
  6894. }
  6895. /*==========================================
  6896. * Kill Steal Protection
  6897. *------------------------------------------*/
  6898. ACMD_FUNC(ksprotection)
  6899. {
  6900. nullpo_retr(-1,sd);
  6901. if( sd->state.noks ) {
  6902. sd->state.noks = 0;
  6903. clif_displaymessage(fd, msg_txt(1325)); // [ K.S Protection Inactive ]
  6904. }
  6905. else
  6906. {
  6907. if( !message || !*message || !strcmpi(message, "party") )
  6908. { // Default is Party
  6909. sd->state.noks = 2;
  6910. clif_displaymessage(fd, msg_txt(1326)); // [ K.S Protection Active - Option: Party ]
  6911. }
  6912. else if( !strcmpi(message, "self") )
  6913. {
  6914. sd->state.noks = 1;
  6915. clif_displaymessage(fd, msg_txt(1327)); // [ K.S Protection Active - Option: Self ]
  6916. }
  6917. else if( !strcmpi(message, "guild") )
  6918. {
  6919. sd->state.noks = 3;
  6920. clif_displaymessage(fd, msg_txt(1328)); // [ K.S Protection Active - Option: Guild ]
  6921. }
  6922. else
  6923. clif_displaymessage(fd, msg_txt(1329)); // Usage: @noks <self|party|guild>
  6924. }
  6925. return 0;
  6926. }
  6927. /*==========================================
  6928. * Map Kill Steal Protection Setting
  6929. *------------------------------------------*/
  6930. ACMD_FUNC(allowks)
  6931. {
  6932. nullpo_retr(-1,sd);
  6933. if( map[sd->bl.m].flag.allowks ) {
  6934. map[sd->bl.m].flag.allowks = 0;
  6935. clif_displaymessage(fd, msg_txt(1330)); // [ Map K.S Protection Active ]
  6936. } else {
  6937. map[sd->bl.m].flag.allowks = 1;
  6938. clif_displaymessage(fd, msg_txt(1331)); // [ Map K.S Protection Inactive ]
  6939. }
  6940. return 0;
  6941. }
  6942. ACMD_FUNC(resetstat)
  6943. {
  6944. nullpo_retr(-1, sd);
  6945. pc_resetstate(sd);
  6946. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  6947. clif_displaymessage(fd, atcmd_output);
  6948. return 0;
  6949. }
  6950. ACMD_FUNC(resetskill)
  6951. {
  6952. nullpo_retr(-1,sd);
  6953. pc_resetskill(sd,1);
  6954. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  6955. clif_displaymessage(fd, atcmd_output);
  6956. return 0;
  6957. }
  6958. /*==========================================
  6959. * #storagelist: Displays the items list of a player's storage.
  6960. * #cartlist: Displays contents of target's cart.
  6961. * #itemlist: Displays contents of target's inventory.
  6962. *------------------------------------------*/
  6963. ACMD_FUNC(itemlist)
  6964. {
  6965. int i, j, count, counter;
  6966. const char* location;
  6967. const struct item* items;
  6968. int size;
  6969. StringBuf buf;
  6970. nullpo_retr(-1, sd);
  6971. if( strcmp(command+1, "storagelist") == 0 )
  6972. {
  6973. location = "storage";
  6974. items = sd->status.storage.items;
  6975. size = MAX_STORAGE;
  6976. }
  6977. else
  6978. if( strcmp(command+1, "cartlist") == 0 )
  6979. {
  6980. location = "cart";
  6981. items = sd->status.cart;
  6982. size = MAX_CART;
  6983. }
  6984. else
  6985. if( strcmp(command+1, "itemlist") == 0 )
  6986. {
  6987. location = "inventory";
  6988. items = sd->status.inventory;
  6989. size = MAX_INVENTORY;
  6990. }
  6991. else
  6992. return 1;
  6993. StringBuf_Init(&buf);
  6994. count = 0; // total slots occupied
  6995. counter = 0; // total items found
  6996. for( i = 0; i < size; ++i )
  6997. {
  6998. const struct item* it = &items[i];
  6999. struct item_data* itd;
  7000. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7001. continue;
  7002. counter += it->amount;
  7003. count++;
  7004. if( count == 1 )
  7005. {
  7006. StringBuf_Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7007. clif_displaymessage(fd, StringBuf_Value(&buf));
  7008. StringBuf_Clear(&buf);
  7009. }
  7010. if( it->refine )
  7011. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7012. else
  7013. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7014. if( it->equip )
  7015. {
  7016. char equipstr[CHAT_SIZE_MAX];
  7017. strcpy(equipstr, msg_txt(1333)); // | equipped:
  7018. if( it->equip & EQP_GARMENT )
  7019. strcat(equipstr, msg_txt(1334)); // garment,
  7020. if( it->equip & EQP_ACC_L )
  7021. strcat(equipstr, msg_txt(1335)); // left accessory,
  7022. if( it->equip & EQP_ARMOR )
  7023. strcat(equipstr, msg_txt(1336)); // body/armor,
  7024. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7025. strcat(equipstr, msg_txt(1337)); // right hand,
  7026. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7027. strcat(equipstr, msg_txt(1338)); // left hand,
  7028. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7029. strcat(equipstr, msg_txt(1339)); // both hands,
  7030. if( it->equip & EQP_SHOES )
  7031. strcat(equipstr, msg_txt(1340)); // feet,
  7032. if( it->equip & EQP_ACC_R )
  7033. strcat(equipstr, msg_txt(1341)); // right accessory,
  7034. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7035. strcat(equipstr, msg_txt(1342)); // lower head,
  7036. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7037. strcat(equipstr, msg_txt(1343)); // top head,
  7038. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7039. strcat(equipstr, msg_txt(1344)); // lower/top head,
  7040. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7041. strcat(equipstr, msg_txt(1345)); // mid head,
  7042. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7043. strcat(equipstr, msg_txt(1346)); // lower/mid head,
  7044. if( (it->equip & EQP_HELM) == EQP_HELM )
  7045. strcat(equipstr, msg_txt(1347)); // lower/mid/top head,
  7046. // remove final ', '
  7047. equipstr[strlen(equipstr) - 2] = '\0';
  7048. StringBuf_AppendStr(&buf, equipstr);
  7049. }
  7050. clif_displaymessage(fd, StringBuf_Value(&buf));
  7051. StringBuf_Clear(&buf);
  7052. if( it->card[0] == CARD0_PET )
  7053. {// pet egg
  7054. if (it->card[3])
  7055. StringBuf_Printf(&buf, msg_txt(1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7056. else
  7057. StringBuf_Printf(&buf, msg_txt(1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7058. }
  7059. else
  7060. if(it->card[0] == CARD0_FORGE)
  7061. {// forged item
  7062. 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)
  7063. }
  7064. else
  7065. if(it->card[0] == CARD0_CREATE)
  7066. {// created item
  7067. StringBuf_Printf(&buf, msg_txt(1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7068. }
  7069. else
  7070. {// normal item
  7071. int counter2 = 0;
  7072. for( j = 0; j < itd->slot; ++j )
  7073. {
  7074. struct item_data* card;
  7075. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7076. continue;
  7077. counter2++;
  7078. if( counter2 == 1 )
  7079. StringBuf_AppendStr(&buf, msg_txt(1352)); // -> (card(s):
  7080. if( counter2 != 1 )
  7081. StringBuf_AppendStr(&buf, ", ");
  7082. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7083. }
  7084. if( counter2 > 0 )
  7085. StringBuf_AppendStr(&buf, ")");
  7086. }
  7087. if( StringBuf_Length(&buf) > 0 )
  7088. clif_displaymessage(fd, StringBuf_Value(&buf));
  7089. StringBuf_Clear(&buf);
  7090. }
  7091. if( count == 0 )
  7092. StringBuf_Printf(&buf, msg_txt(1353), location); // No item found in this player's %s.
  7093. else
  7094. StringBuf_Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots.
  7095. clif_displaymessage(fd, StringBuf_Value(&buf));
  7096. StringBuf_Destroy(&buf);
  7097. return 0;
  7098. }
  7099. ACMD_FUNC(stats)
  7100. {
  7101. char job_jobname[100];
  7102. char output[CHAT_SIZE_MAX];
  7103. int i;
  7104. struct {
  7105. const char* format;
  7106. int value;
  7107. } output_table[] = {
  7108. { "Base Level - %d", 0 },
  7109. { NULL, 0 },
  7110. { "Hp - %d", 0 },
  7111. { "MaxHp - %d", 0 },
  7112. { "Sp - %d", 0 },
  7113. { "MaxSp - %d", 0 },
  7114. { "Str - %3d", 0 },
  7115. { "Agi - %3d", 0 },
  7116. { "Vit - %3d", 0 },
  7117. { "Int - %3d", 0 },
  7118. { "Dex - %3d", 0 },
  7119. { "Luk - %3d", 0 },
  7120. { "Zeny - %d", 0 },
  7121. { "Free SK Points - %d", 0 },
  7122. { "JobChangeLvl (2nd) - %d", 0 },
  7123. { "JobChangeLvl (3rd) - %d", 0 },
  7124. { NULL, 0 }
  7125. };
  7126. memset(job_jobname, '\0', sizeof(job_jobname));
  7127. memset(output, '\0', sizeof(output));
  7128. //direct array initialization with variables is not standard C compliant.
  7129. output_table[0].value = sd->status.base_level;
  7130. output_table[1].format = job_jobname;
  7131. output_table[1].value = sd->status.job_level;
  7132. output_table[2].value = sd->status.hp;
  7133. output_table[3].value = sd->status.max_hp;
  7134. output_table[4].value = sd->status.sp;
  7135. output_table[5].value = sd->status.max_sp;
  7136. output_table[6].value = sd->status.str;
  7137. output_table[7].value = sd->status.agi;
  7138. output_table[8].value = sd->status.vit;
  7139. output_table[9].value = sd->status.int_;
  7140. output_table[10].value = sd->status.dex;
  7141. output_table[11].value = sd->status.luk;
  7142. output_table[12].value = sd->status.zeny;
  7143. output_table[13].value = sd->status.skill_point;
  7144. output_table[14].value = sd->change_level_2nd;
  7145. output_table[15].value = sd->change_level_3rd;
  7146. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7147. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7148. clif_displaymessage(fd, output);
  7149. for (i = 0; output_table[i].format != NULL; i++) {
  7150. sprintf(output, output_table[i].format, output_table[i].value);
  7151. clif_displaymessage(fd, output);
  7152. }
  7153. return 0;
  7154. }
  7155. ACMD_FUNC(delitem)
  7156. {
  7157. char item_name[100];
  7158. int nameid, amount = 0, total, idx;
  7159. struct item_data* id;
  7160. nullpo_retr(-1, sd);
  7161. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7162. {
  7163. 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>).
  7164. return -1;
  7165. }
  7166. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7167. {
  7168. nameid = id->nameid;
  7169. }
  7170. else
  7171. {
  7172. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7173. return -1;
  7174. }
  7175. total = amount;
  7176. // delete items
  7177. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7178. {
  7179. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7180. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7181. {// delete pet
  7182. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7183. }
  7184. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7185. amount-= delamount;
  7186. }
  7187. // notify target
  7188. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7189. clif_displaymessage(sd->fd, atcmd_output);
  7190. // notify source
  7191. if( amount == total )
  7192. {
  7193. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7194. }
  7195. else if( amount )
  7196. {
  7197. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7198. clif_displaymessage(fd, atcmd_output);
  7199. }
  7200. else
  7201. {
  7202. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7203. clif_displaymessage(fd, atcmd_output);
  7204. }
  7205. return 0;
  7206. }
  7207. /*==========================================
  7208. * Custom Fonts
  7209. *------------------------------------------*/
  7210. ACMD_FUNC(font)
  7211. {
  7212. int font_id;
  7213. nullpo_retr(-1,sd);
  7214. font_id = atoi(message);
  7215. if( font_id == 0 )
  7216. {
  7217. if( sd->user_font )
  7218. {
  7219. sd->user_font = 0;
  7220. clif_displaymessage(fd, msg_txt(1356)); // Returning to normal font.
  7221. clif_font(sd);
  7222. }
  7223. else
  7224. {
  7225. clif_displaymessage(fd, msg_txt(1357)); // Use @font <1-9> to change your message font.
  7226. clif_displaymessage(fd, msg_txt(1358)); // Use 0 or no parameter to return to normal font.
  7227. }
  7228. }
  7229. else if( font_id < 0 || font_id > 9 )
  7230. clif_displaymessage(fd, msg_txt(1359)); // Invalid font. Use a value from 0 to 9.
  7231. else if( font_id != sd->user_font )
  7232. {
  7233. sd->user_font = font_id;
  7234. clif_font(sd);
  7235. clif_displaymessage(fd, msg_txt(1360)); // Font changed.
  7236. }
  7237. else
  7238. clif_displaymessage(fd, msg_txt(1361)); // Already using this font.
  7239. return 0;
  7240. }
  7241. /*==========================================
  7242. * type: 1 = commands (@), 2 = charcommands (#)
  7243. *------------------------------------------*/
  7244. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7245. {
  7246. char line_buff[CHATBOX_SIZE];
  7247. char* cur = line_buff;
  7248. AtCommandInfo* cmd;
  7249. DBIterator *iter = db_iterator(atcommand_db);
  7250. int count = 0;
  7251. memset(line_buff,' ',CHATBOX_SIZE);
  7252. line_buff[CHATBOX_SIZE-1] = 0;
  7253. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  7254. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7255. unsigned int slen = 0;
  7256. switch( type ) {
  7257. case COMMAND_CHARCOMMAND:
  7258. if( cmd->char_groups[sd->group_pos] == 0 )
  7259. continue;
  7260. break;
  7261. case COMMAND_ATCOMMAND:
  7262. if( cmd->at_groups[sd->group_pos] == 0 )
  7263. continue;
  7264. break;
  7265. default:
  7266. continue;
  7267. }
  7268. slen = strlen(cmd->command);
  7269. // flush the text buffer if this command won't fit into it
  7270. if ( slen + cur - line_buff >= CHATBOX_SIZE )
  7271. {
  7272. clif_displaymessage(fd,line_buff);
  7273. cur = line_buff;
  7274. memset(line_buff,' ',CHATBOX_SIZE);
  7275. line_buff[CHATBOX_SIZE-1] = 0;
  7276. }
  7277. memcpy(cur,cmd->command,slen);
  7278. cur += slen+(10-slen%10);
  7279. count++;
  7280. }
  7281. dbi_destroy(iter);
  7282. clif_displaymessage(fd,line_buff);
  7283. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  7284. clif_displaymessage(fd, atcmd_output);
  7285. return;
  7286. }
  7287. /*==========================================
  7288. * @commands Lists available @ commands to you
  7289. *------------------------------------------*/
  7290. ACMD_FUNC(commands)
  7291. {
  7292. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7293. return 0;
  7294. }
  7295. /*==========================================
  7296. * @charcommands Lists available # commands to you
  7297. *------------------------------------------*/
  7298. ACMD_FUNC(charcommands)
  7299. {
  7300. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7301. return 0;
  7302. }
  7303. /* for new mounts */
  7304. ACMD_FUNC(mount2) {
  7305. clif_displaymessage(sd->fd,msg_txt(1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7306. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7307. clif_displaymessage(sd->fd,msg_txt(1363)); // You have mounted.
  7308. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7309. } else {
  7310. clif_displaymessage(sd->fd,msg_txt(1364)); // You have released your mount.
  7311. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7312. }
  7313. return 0;
  7314. }
  7315. ACMD_FUNC(accinfo) {
  7316. char query[NAME_LENGTH];
  7317. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7318. clif_displaymessage(fd, msg_txt(1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7319. 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".
  7320. return -1;
  7321. }
  7322. //remove const type
  7323. safestrncpy(query, message, NAME_LENGTH);
  7324. intif_request_accinfo( sd->fd, sd->bl.id, sd->group_id, query );
  7325. return 0;
  7326. }
  7327. /* [Ind] */
  7328. ACMD_FUNC(set) {
  7329. char reg[32], val[128];
  7330. struct script_data* data;
  7331. int toset = 0;
  7332. bool is_str = false;
  7333. if( !message || !*message || (toset = sscanf(message, "%32s %128[^\n]s", reg, val)) < 1 ) {
  7334. clif_displaymessage(fd, msg_txt(1367)); // Usage: @set <variable name> <value>
  7335. clif_displaymessage(fd, msg_txt(1368)); // Usage: ex. "@set PoringCharVar 50"
  7336. clif_displaymessage(fd, msg_txt(1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7337. clif_displaymessage(fd, msg_txt(1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7338. return -1;
  7339. }
  7340. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7341. if( reg[0] == '.' ) {
  7342. clif_displaymessage(fd, msg_txt(1371)); // NPC variables may not be used with @set.
  7343. return -1;
  7344. } else if( reg[0] == '\'' ) {
  7345. clif_displaymessage(fd, msg_txt(1372)); // Instance variables may not be used with @set.
  7346. return -1;
  7347. }
  7348. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7349. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7350. if( is_str )
  7351. set_var(sd, reg, (void*) val);
  7352. else
  7353. set_var(sd, reg, (void*)__64BPRTSIZE((int)(atoi(val))));
  7354. }
  7355. CREATE(data, struct script_data,1);
  7356. if( is_str ) {// string variable
  7357. switch( reg[0] ) {
  7358. case '@':
  7359. data->u.str = pc_readregstr(sd, add_str(reg));
  7360. break;
  7361. case '$':
  7362. data->u.str = mapreg_readregstr(add_str(reg));
  7363. break;
  7364. case '#':
  7365. if( reg[1] == '#' )
  7366. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7367. else
  7368. data->u.str = pc_readaccountregstr(sd, reg);// local
  7369. break;
  7370. default:
  7371. data->u.str = pc_readglobalreg_str(sd, reg);
  7372. break;
  7373. }
  7374. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7375. data->type = C_CONSTSTR;
  7376. data->u.str = "";
  7377. } else {// duplicate string
  7378. data->type = C_STR;
  7379. data->u.str = aStrdup(data->u.str);
  7380. }
  7381. } else {// integer variable
  7382. data->type = C_INT;
  7383. switch( reg[0] ) {
  7384. case '@':
  7385. data->u.num = pc_readreg(sd, add_str(reg));
  7386. break;
  7387. case '$':
  7388. data->u.num = mapreg_readreg(add_str(reg));
  7389. break;
  7390. case '#':
  7391. if( reg[1] == '#' )
  7392. data->u.num = pc_readaccountreg2(sd, reg);// global
  7393. else
  7394. data->u.num = pc_readaccountreg(sd, reg);// local
  7395. break;
  7396. default:
  7397. data->u.num = pc_readglobalreg(sd, reg);
  7398. break;
  7399. }
  7400. }
  7401. switch( data->type ) {
  7402. case C_INT:
  7403. sprintf(atcmd_output,msg_txt(1373),reg,data->u.num); // %s value is now :%d
  7404. break;
  7405. case C_STR:
  7406. sprintf(atcmd_output,msg_txt(1374),reg,data->u.str); // %s value is now :%s
  7407. break;
  7408. case C_CONSTSTR:
  7409. sprintf(atcmd_output,msg_txt(1375),reg); // %s is empty
  7410. break;
  7411. default:
  7412. sprintf(atcmd_output,msg_txt(1376),reg,data->type); // %s data type is not supported :%u
  7413. break;
  7414. }
  7415. clif_displaymessage(fd, atcmd_output);
  7416. aFree(data);
  7417. return 0;
  7418. }
  7419. ACMD_FUNC(reloadquestdb) {
  7420. do_reload_quest();
  7421. clif_displaymessage(fd, msg_txt(1377)); // Quest database has been reloaded.
  7422. return 0;
  7423. }
  7424. ACMD_FUNC(addperm) {
  7425. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7426. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7427. int i;
  7428. if( !message || !*message ) {
  7429. sprintf(atcmd_output, msg_txt(1378),command); // Usage: %s <permission_name>
  7430. clif_displaymessage(fd, atcmd_output);
  7431. clif_displaymessage(fd, msg_txt(1379)); // -- Permission List
  7432. for( i = 0; i < perm_size; i++ ) {
  7433. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7434. clif_displaymessage(fd, atcmd_output);
  7435. }
  7436. return -1;
  7437. }
  7438. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7439. if( i == perm_size ) {
  7440. sprintf(atcmd_output,msg_txt(1380),message); // '%s' is not a known permission.
  7441. clif_displaymessage(fd, atcmd_output);
  7442. clif_displaymessage(fd, msg_txt(1379)); // -- Permission List
  7443. for( i = 0; i < perm_size; i++ ) {
  7444. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7445. clif_displaymessage(fd, atcmd_output);
  7446. }
  7447. return -1;
  7448. }
  7449. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7450. sprintf(atcmd_output, msg_txt(1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7451. clif_displaymessage(fd, atcmd_output);
  7452. return -1;
  7453. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7454. sprintf(atcmd_output, msg_txt(1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7455. clif_displaymessage(fd, atcmd_output);
  7456. sprintf(atcmd_output,msg_txt(1383),sd->status.name); // -- User '%s' Permissions
  7457. clif_displaymessage(fd, atcmd_output);
  7458. for( i = 0; i < perm_size; i++ ) {
  7459. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7460. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7461. clif_displaymessage(fd, atcmd_output);
  7462. }
  7463. }
  7464. return -1;
  7465. }
  7466. if( add )
  7467. sd->permissions |= pc_g_permission_name[i].permission;
  7468. else
  7469. sd->permissions &=~ pc_g_permission_name[i].permission;
  7470. sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7471. clif_displaymessage(fd, atcmd_output);
  7472. return 0;
  7473. }
  7474. ACMD_FUNC(unloadnpcfile) {
  7475. if( !message || !*message ) {
  7476. clif_displaymessage(fd, msg_txt(1385)); // Usage: @unloadnpcfile <file name>
  7477. return -1;
  7478. }
  7479. if( npc_unloadfile(message) )
  7480. clif_displaymessage(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7481. else {
  7482. clif_displaymessage(fd, msg_txt(1387)); // File not found.
  7483. return -1;
  7484. }
  7485. return 0;
  7486. }
  7487. ACMD_FUNC(cart) {
  7488. #define MC_CART_MDFY(x) \
  7489. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7490. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7491. sd->status.skill[MC_PUSHCART].flag = x?1:0;
  7492. int val = atoi(message);
  7493. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7494. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7495. sprintf(atcmd_output, msg_txt(1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7496. clif_displaymessage(fd, atcmd_output);
  7497. return -1;
  7498. }
  7499. if( val == 0 && !pc_iscarton(sd) ) {
  7500. clif_displaymessage(fd, msg_txt(1391)); // You do not possess a cart to be removed
  7501. return -1;
  7502. }
  7503. if( need_skill ) {
  7504. MC_CART_MDFY(1);
  7505. }
  7506. if( pc_setcart(sd, val) ) {
  7507. if( need_skill ) {
  7508. MC_CART_MDFY(0);
  7509. }
  7510. return -1;/* @cart failed */
  7511. }
  7512. if( need_skill ) {
  7513. MC_CART_MDFY(0);
  7514. }
  7515. clif_displaymessage(fd, msg_txt(1392)); // Cart Added
  7516. return 0;
  7517. #undef MC_CART_MDFY
  7518. }
  7519. /**
  7520. * Fills the reference of available commands in atcommand DBMap
  7521. **/
  7522. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL }
  7523. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL }
  7524. void atcommand_basecommands(void) {
  7525. /**
  7526. * Command reference list, place the base of your commands here
  7527. **/
  7528. AtCommandInfo atcommand_base[] = {
  7529. ACMD_DEF2("warp", mapmove),
  7530. ACMD_DEF(where),
  7531. ACMD_DEF(jumpto),
  7532. ACMD_DEF(jump),
  7533. ACMD_DEF(who),
  7534. ACMD_DEF2("who2", who),
  7535. ACMD_DEF2("who3", who),
  7536. ACMD_DEF2("whomap", who),
  7537. ACMD_DEF2("whomap2", who),
  7538. ACMD_DEF2("whomap3", who),
  7539. ACMD_DEF(whogm),
  7540. ACMD_DEF(save),
  7541. ACMD_DEF(load),
  7542. ACMD_DEF(speed),
  7543. ACMD_DEF(storage),
  7544. ACMD_DEF(guildstorage),
  7545. ACMD_DEF(option),
  7546. ACMD_DEF(hide), // + /hide
  7547. ACMD_DEF(jobchange),
  7548. ACMD_DEF(kill),
  7549. ACMD_DEF(alive),
  7550. ACMD_DEF(kami),
  7551. ACMD_DEF2("kamib", kami),
  7552. ACMD_DEF2("kamic", kami),
  7553. ACMD_DEF2("lkami", kami),
  7554. ACMD_DEF(heal),
  7555. ACMD_DEF(item),
  7556. ACMD_DEF(item2),
  7557. ACMD_DEF(itemreset),
  7558. ACMD_DEF2("blvl", baselevelup),
  7559. ACMD_DEF2("jlvl", joblevelup),
  7560. ACMD_DEF(help),
  7561. ACMD_DEF(pvpoff),
  7562. ACMD_DEF(pvpon),
  7563. ACMD_DEF(gvgoff),
  7564. ACMD_DEF(gvgon),
  7565. ACMD_DEF(model),
  7566. ACMD_DEF(go),
  7567. ACMD_DEF(monster),
  7568. ACMD_DEF2("monstersmall", monster),
  7569. ACMD_DEF2("monsterbig", monster),
  7570. ACMD_DEF(killmonster),
  7571. ACMD_DEF2("killmonster2", killmonster),
  7572. ACMD_DEF(refine),
  7573. ACMD_DEF(produce),
  7574. ACMD_DEF(memo),
  7575. ACMD_DEF(gat),
  7576. ACMD_DEF(displaystatus),
  7577. ACMD_DEF2("stpoint", statuspoint),
  7578. ACMD_DEF2("skpoint", skillpoint),
  7579. ACMD_DEF(zeny),
  7580. ACMD_DEF2("str", param),
  7581. ACMD_DEF2("agi", param),
  7582. ACMD_DEF2("vit", param),
  7583. ACMD_DEF2("int", param),
  7584. ACMD_DEF2("dex", param),
  7585. ACMD_DEF2("luk", param),
  7586. ACMD_DEF2("glvl", guildlevelup),
  7587. ACMD_DEF(makeegg),
  7588. ACMD_DEF(hatch),
  7589. ACMD_DEF(petfriendly),
  7590. ACMD_DEF(pethungry),
  7591. ACMD_DEF(petrename),
  7592. ACMD_DEF(recall), // + /recall
  7593. ACMD_DEF(night),
  7594. ACMD_DEF(day),
  7595. ACMD_DEF(doom),
  7596. ACMD_DEF(doommap),
  7597. ACMD_DEF(raise),
  7598. ACMD_DEF(raisemap),
  7599. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  7600. ACMD_DEF(kickall),
  7601. ACMD_DEF(allskill),
  7602. ACMD_DEF(questskill),
  7603. ACMD_DEF(lostskill),
  7604. ACMD_DEF(spiritball),
  7605. ACMD_DEF(party),
  7606. ACMD_DEF(guild),
  7607. ACMD_DEF(agitstart),
  7608. ACMD_DEF(agitend),
  7609. ACMD_DEF(mapexit),
  7610. ACMD_DEF(idsearch),
  7611. ACMD_DEF(broadcast), // + /b and /nb
  7612. ACMD_DEF(localbroadcast), // + /lb and /nlb
  7613. ACMD_DEF(recallall),
  7614. ACMD_DEF(reloaditemdb),
  7615. ACMD_DEF(reloadmobdb),
  7616. ACMD_DEF(reloadskilldb),
  7617. ACMD_DEF(reloadscript),
  7618. ACMD_DEF(reloadatcommand),
  7619. ACMD_DEF(reloadbattleconf),
  7620. ACMD_DEF(reloadstatusdb),
  7621. ACMD_DEF(reloadpcdb),
  7622. ACMD_DEF(reloadmotd),
  7623. ACMD_DEF(mapinfo),
  7624. ACMD_DEF(dye),
  7625. ACMD_DEF2("hairstyle", hair_style),
  7626. ACMD_DEF2("haircolor", hair_color),
  7627. ACMD_DEF2("allstats", stat_all),
  7628. ACMD_DEF2("block", char_block),
  7629. ACMD_DEF2("ban", char_ban),
  7630. ACMD_DEF2("unblock", char_unblock),
  7631. ACMD_DEF2("unban", char_unban),
  7632. ACMD_DEF2("mount", mount_peco),
  7633. ACMD_DEF(guildspy),
  7634. ACMD_DEF(partyspy),
  7635. ACMD_DEF(repairall),
  7636. ACMD_DEF(guildrecall),
  7637. ACMD_DEF(partyrecall),
  7638. ACMD_DEF(nuke),
  7639. ACMD_DEF(shownpc),
  7640. ACMD_DEF(hidenpc),
  7641. ACMD_DEF(loadnpc),
  7642. ACMD_DEF(unloadnpc),
  7643. ACMD_DEF2("time", servertime),
  7644. ACMD_DEF(jail),
  7645. ACMD_DEF(unjail),
  7646. ACMD_DEF(jailfor),
  7647. ACMD_DEF(jailtime),
  7648. ACMD_DEF(disguise),
  7649. ACMD_DEF(undisguise),
  7650. ACMD_DEF(email),
  7651. ACMD_DEF(effect),
  7652. ACMD_DEF(follow),
  7653. ACMD_DEF(addwarp),
  7654. ACMD_DEF(skillon),
  7655. ACMD_DEF(skilloff),
  7656. ACMD_DEF(killer),
  7657. ACMD_DEF(npcmove),
  7658. ACMD_DEF(killable),
  7659. ACMD_DEF(dropall),
  7660. ACMD_DEF(storeall),
  7661. ACMD_DEF(skillid),
  7662. ACMD_DEF(useskill),
  7663. ACMD_DEF(displayskill),
  7664. ACMD_DEF(snow),
  7665. ACMD_DEF(sakura),
  7666. ACMD_DEF(clouds),
  7667. ACMD_DEF(clouds2),
  7668. ACMD_DEF(fog),
  7669. ACMD_DEF(fireworks),
  7670. ACMD_DEF(leaves),
  7671. ACMD_DEF(summon),
  7672. ACMD_DEF(adjgroup),
  7673. ACMD_DEF(trade),
  7674. ACMD_DEF(send),
  7675. ACMD_DEF(setbattleflag),
  7676. ACMD_DEF(unmute),
  7677. ACMD_DEF(clearweather),
  7678. ACMD_DEF(uptime),
  7679. ACMD_DEF(changesex),
  7680. ACMD_DEF(mute),
  7681. ACMD_DEF(refresh),
  7682. ACMD_DEF(identify),
  7683. ACMD_DEF(gmotd),
  7684. ACMD_DEF(misceffect),
  7685. ACMD_DEF(mobsearch),
  7686. ACMD_DEF(cleanmap),
  7687. ACMD_DEF(npctalk),
  7688. ACMD_DEF(pettalk),
  7689. ACMD_DEF(users),
  7690. ACMD_DEF(reset),
  7691. ACMD_DEF(skilltree),
  7692. ACMD_DEF(marry),
  7693. ACMD_DEF(divorce),
  7694. ACMD_DEF(sound),
  7695. ACMD_DEF(undisguiseall),
  7696. ACMD_DEF(disguiseall),
  7697. ACMD_DEF(changelook),
  7698. ACMD_DEF(autoloot),
  7699. ACMD_DEF2("alootid", autolootitem),
  7700. ACMD_DEF(mobinfo),
  7701. ACMD_DEF(exp),
  7702. ACMD_DEF(adopt),
  7703. ACMD_DEF(version),
  7704. ACMD_DEF(mutearea),
  7705. ACMD_DEF(rates),
  7706. ACMD_DEF(iteminfo),
  7707. ACMD_DEF(whodrops),
  7708. ACMD_DEF(whereis),
  7709. ACMD_DEF(mapflag),
  7710. ACMD_DEF(me),
  7711. ACMD_DEF(monsterignore),
  7712. ACMD_DEF(fakename),
  7713. ACMD_DEF(size),
  7714. ACMD_DEF(showexp),
  7715. ACMD_DEF(showzeny),
  7716. ACMD_DEF(showdelay),
  7717. ACMD_DEF(autotrade),
  7718. ACMD_DEF(changegm),
  7719. ACMD_DEF(changeleader),
  7720. ACMD_DEF(partyoption),
  7721. ACMD_DEF(invite),
  7722. ACMD_DEF(duel),
  7723. ACMD_DEF(leave),
  7724. ACMD_DEF(accept),
  7725. ACMD_DEF(reject),
  7726. ACMD_DEF(main),
  7727. ACMD_DEF(clone),
  7728. ACMD_DEF2("slaveclone", clone),
  7729. ACMD_DEF2("evilclone", clone),
  7730. ACMD_DEF(tonpc),
  7731. ACMD_DEF(commands),
  7732. ACMD_DEF(noask),
  7733. ACMD_DEF(request),
  7734. ACMD_DEF(homlevel),
  7735. ACMD_DEF(homevolution),
  7736. ACMD_DEF(makehomun),
  7737. ACMD_DEF(homfriendly),
  7738. ACMD_DEF(homhungry),
  7739. ACMD_DEF(homtalk),
  7740. ACMD_DEF(hominfo),
  7741. ACMD_DEF(homstats),
  7742. ACMD_DEF(homshuffle),
  7743. ACMD_DEF(showmobs),
  7744. ACMD_DEF(feelreset),
  7745. ACMD_DEF(auction),
  7746. ACMD_DEF(mail),
  7747. ACMD_DEF2("noks", ksprotection),
  7748. ACMD_DEF(allowks),
  7749. ACMD_DEF(cash),
  7750. ACMD_DEF2("points", cash),
  7751. ACMD_DEF(agitstart2),
  7752. ACMD_DEF(agitend2),
  7753. ACMD_DEF2("skreset", resetskill),
  7754. ACMD_DEF2("streset", resetstat),
  7755. ACMD_DEF2("storagelist", itemlist),
  7756. ACMD_DEF2("cartlist", itemlist),
  7757. ACMD_DEF2("itemlist", itemlist),
  7758. ACMD_DEF(stats),
  7759. ACMD_DEF(delitem),
  7760. ACMD_DEF(charcommands),
  7761. ACMD_DEF(font),
  7762. ACMD_DEF(accinfo),
  7763. ACMD_DEF(set),
  7764. ACMD_DEF(reloadquestdb),
  7765. ACMD_DEF(undisguiseguild),
  7766. ACMD_DEF(disguiseguild),
  7767. ACMD_DEF(sizeall),
  7768. ACMD_DEF(sizeguild),
  7769. ACMD_DEF(addperm),
  7770. ACMD_DEF2("rmvperm", addperm),
  7771. ACMD_DEF(unloadnpcfile),
  7772. ACMD_DEF(cart),
  7773. ACMD_DEF(mount2)
  7774. };
  7775. AtCommandInfo* atcommand;
  7776. int i;
  7777. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7778. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  7779. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  7780. continue;
  7781. }
  7782. CREATE(atcommand, AtCommandInfo, 1);
  7783. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  7784. atcommand->func = atcommand_base[i].func;
  7785. strdb_put(atcommand_db, atcommand->command, atcommand);
  7786. }
  7787. return;
  7788. }
  7789. /*==========================================
  7790. * Command lookup functions
  7791. *------------------------------------------*/
  7792. bool atcommand_exists(const char* name)
  7793. {
  7794. return strdb_exists(atcommand_db, name);
  7795. }
  7796. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  7797. {
  7798. if (strdb_exists(atcommand_db, name))
  7799. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7800. return NULL;
  7801. }
  7802. static const char* atcommand_checkalias(const char *aliasname)
  7803. {
  7804. AliasInfo *alias_info = NULL;
  7805. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  7806. return alias_info->command->command;
  7807. return aliasname;
  7808. }
  7809. /// AtCommand suggestion
  7810. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  7811. DBIterator* atcommand_iter;
  7812. DBIterator* alias_iter;
  7813. AtCommandInfo* command_info = NULL;
  7814. AliasInfo* alias_info = NULL;
  7815. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  7816. char* full_match[MAX_SUGGESTIONS];
  7817. char* suggestions[MAX_SUGGESTIONS];
  7818. char* match;
  7819. int prefix_count = 0, full_count = 0;
  7820. bool can_use;
  7821. if (!battle_config.atcommand_suggestions_enabled)
  7822. return;
  7823. atcommand_iter = db_iterator(atcommand_db);
  7824. alias_iter = db_iterator(atcommand_alias_db);
  7825. // Build the matches
  7826. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  7827. match = strstr(command_info->command, name);
  7828. can_use = pc_can_use_command(sd, command_info->command, type);
  7829. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  7830. suggestions[prefix_count] = command_info->command;
  7831. ++prefix_count;
  7832. }
  7833. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  7834. full_match[full_count] = command_info->command;
  7835. ++full_count;
  7836. }
  7837. }
  7838. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  7839. match = strstr(alias_info->alias, name);
  7840. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  7841. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  7842. suggestions[prefix_count] = alias_info->alias;
  7843. ++prefix_count;
  7844. }
  7845. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  7846. full_match[full_count] = alias_info->alias;
  7847. ++full_count;
  7848. }
  7849. }
  7850. if ((full_count+prefix_count) > 0) {
  7851. char buffer[512];
  7852. int i;
  7853. // Merge full match and prefix match results
  7854. if (prefix_count < MAX_SUGGESTIONS) {
  7855. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  7856. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  7857. }
  7858. // Build the suggestion string
  7859. strcpy(buffer, msg_txt(205));
  7860. strcat(buffer,"\n");
  7861. for(i=0; i < prefix_count; ++i) {
  7862. strcat(buffer,suggestions[i]);
  7863. strcat(buffer," ");
  7864. }
  7865. clif_displaymessage(sd->fd, buffer);
  7866. }
  7867. dbi_destroy(atcommand_iter);
  7868. dbi_destroy(alias_iter);
  7869. }
  7870. /// Executes an at-command.
  7871. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7872. {
  7873. char charname[NAME_LENGTH], params[100];
  7874. char charname2[NAME_LENGTH], params2[100];
  7875. char command[100];
  7876. char output[CHAT_SIZE_MAX];
  7877. //Reconstructed message
  7878. char atcmd_msg[CHAT_SIZE_MAX];
  7879. TBL_PC * ssd = NULL; //sd for target
  7880. AtCommandInfo * info;
  7881. nullpo_retr(false, sd);
  7882. //Shouldn't happen
  7883. if ( !message || !*message )
  7884. return false;
  7885. //Block NOCHAT but do not display it as a normal message
  7886. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7887. return true;
  7888. // skip 10/11-langtype's codepage indicator, if detected
  7889. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7890. message += 3;
  7891. //Should display as a normal message
  7892. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7893. return false;
  7894. // type value 0 = server invoked: bypass restrictions
  7895. // 1 = player invoked
  7896. if ( type == 1) {
  7897. //Commands are disabled on maps flagged as 'nocommand'
  7898. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  7899. clif_displaymessage(fd, msg_txt(143));
  7900. return false;
  7901. }
  7902. }
  7903. if (*message == charcommand_symbol) {
  7904. do {
  7905. int x, y, z;
  7906. //Checks to see if #command has a name or a name + parameters.
  7907. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7908. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7909. //z always has the value of the scan that was successful
  7910. z = ( x > 1 ) ? x : y;
  7911. //#command + name means the sufficient target was used and anything else after
  7912. //can be looked at by the actual command function since most scan to see if the
  7913. //right parameters are used.
  7914. if ( x > 2 ) {
  7915. sprintf(atcmd_msg, "%s %s", command, params);
  7916. break;
  7917. }
  7918. else if ( y > 2 ) {
  7919. sprintf(atcmd_msg, "%s %s", command, params2);
  7920. break;
  7921. }
  7922. //Regardless of what style the #command is used, if it's correct, it will always have
  7923. //this value if there is no parameter. Send it as just the #command
  7924. else if ( z == 2 ) {
  7925. sprintf(atcmd_msg, "%s", command);
  7926. break;
  7927. }
  7928. if( !pc_get_group_level(sd) ) {
  7929. if( x >= 1 || y >= 1 ) { /* we have command */
  7930. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  7931. 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 */
  7932. return false;
  7933. } else
  7934. return false;/* display as normal message */
  7935. }
  7936. sprintf(output, msg_txt(1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  7937. clif_displaymessage(fd, output);
  7938. return true;
  7939. } while(0);
  7940. }
  7941. else if (*message == atcommand_symbol) {
  7942. //atcmd_msg is constructed above differently for charcommands
  7943. //it's copied from message if not a charcommand so it can
  7944. //pass through the rest of the code compatible with both symbols
  7945. sprintf(atcmd_msg, "%s", message);
  7946. }
  7947. //Clearing these to be used once more.
  7948. memset(command, '\0', sizeof(command));
  7949. memset(params, '\0', sizeof(params));
  7950. //check to see if any params exist within this command
  7951. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7952. params[0] = '\0';
  7953. // @commands (script based)
  7954. if(type == 1 && atcmd_binding_count > 0) {
  7955. struct atcmd_binding_data * binding;
  7956. // Check if the command initiated is a character command
  7957. if (*message == charcommand_symbol &&
  7958. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  7959. sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
  7960. clif_displaymessage(fd, output);
  7961. return true;
  7962. }
  7963. // Get atcommand binding
  7964. binding = get_atcommandbind_byname(command);
  7965. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  7966. if( binding != NULL && binding->npc_event[0] &&
  7967. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  7968. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  7969. {
  7970. // Check if self or character invoking; if self == character invoked, then self invoke.
  7971. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  7972. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  7973. return true;
  7974. }
  7975. }
  7976. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7977. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  7978. if (info == NULL) {
  7979. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  7980. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7981. clif_displaymessage(fd, output);
  7982. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  7983. return true;
  7984. } else
  7985. return false;
  7986. }
  7987. // type == 1 : player invoked
  7988. if (type == 1) {
  7989. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  7990. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  7991. return false;
  7992. }
  7993. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  7994. clif_displaymessage(fd, msg_txt(1393)); // You can't use commands while dead
  7995. return true;
  7996. }
  7997. }
  7998. // Check if target is valid only if confirmed that player can use command.
  7999. if (*message == charcommand_symbol &&
  8000. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8001. sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
  8002. clif_displaymessage(fd, output);
  8003. return true;
  8004. }
  8005. //Attempt to use the command
  8006. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8007. {
  8008. sprintf(output,msg_txt(154), command); // %s failed.
  8009. clif_displaymessage(fd, output);
  8010. return true;
  8011. }
  8012. //Log only if successful.
  8013. if ( *atcmd_msg == atcommand_symbol )
  8014. log_atcommand(sd, atcmd_msg);
  8015. else if ( *atcmd_msg == charcommand_symbol )
  8016. log_atcommand(sd, message);
  8017. return true;
  8018. }
  8019. /*==========================================
  8020. *
  8021. *------------------------------------------*/
  8022. static void atcommand_config_read(const char* config_filename)
  8023. {
  8024. config_setting_t *aliases = NULL, *help = NULL;
  8025. const char *symbol = NULL;
  8026. int num_aliases = 0;
  8027. if (conf_read_file(&atcommand_config, config_filename))
  8028. return;
  8029. // Command symbols
  8030. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8031. if (ISPRINT(*symbol) && // no control characters
  8032. *symbol != '/' && // symbol of client commands
  8033. *symbol != '%' && // symbol of party chat
  8034. *symbol != '$' && // symbol of guild chat
  8035. *symbol != charcommand_symbol)
  8036. atcommand_symbol = *symbol;
  8037. }
  8038. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8039. if (ISPRINT(*symbol) && // no control characters
  8040. *symbol != '/' && // symbol of client commands
  8041. *symbol != '%' && // symbol of party chat
  8042. *symbol != '$' && // symbol of guild chat
  8043. *symbol != atcommand_symbol)
  8044. charcommand_symbol = *symbol;
  8045. }
  8046. // Command aliases
  8047. aliases = config_lookup(&atcommand_config, "aliases");
  8048. if (aliases != NULL) {
  8049. int i = 0;
  8050. int count = config_setting_length(aliases);
  8051. for (i = 0; i < count; ++i) {
  8052. config_setting_t *command = NULL;
  8053. const char *commandname = NULL;
  8054. int j = 0, alias_count = 0;
  8055. AtCommandInfo *commandinfo = NULL;
  8056. command = config_setting_get_elem(aliases, i);
  8057. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8058. continue;
  8059. commandname = config_setting_name(command);
  8060. if (!atcommand_exists(commandname)) {
  8061. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8062. continue;
  8063. }
  8064. commandinfo = get_atcommandinfo_byname(commandname);
  8065. alias_count = config_setting_length(command);
  8066. for (j = 0; j < alias_count; ++j) {
  8067. const char *alias = config_setting_get_string_elem(command, j);
  8068. if (alias != NULL) {
  8069. AliasInfo *alias_info;
  8070. if (strdb_exists(atcommand_alias_db, alias)) {
  8071. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8072. continue;
  8073. }
  8074. CREATE(alias_info, AliasInfo, 1);
  8075. alias_info->command = commandinfo;
  8076. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8077. strdb_put(atcommand_alias_db, alias, alias_info);
  8078. ++num_aliases;
  8079. }
  8080. }
  8081. }
  8082. }
  8083. // Commands help
  8084. // We only check if all commands exist
  8085. help = config_lookup(&atcommand_config, "help");
  8086. if (help != NULL) {
  8087. int count = config_setting_length(help);
  8088. int i;
  8089. for (i = 0; i < count; ++i) {
  8090. config_setting_t *command = NULL;
  8091. const char *commandname = NULL;
  8092. command = config_setting_get_elem(help, i);
  8093. commandname = config_setting_name(command);
  8094. if (!atcommand_exists(commandname))
  8095. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8096. }
  8097. }
  8098. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8099. return;
  8100. }
  8101. void atcommand_db_load_groups(int* group_ids) {
  8102. DBIterator *iter = db_iterator(atcommand_db);
  8103. AtCommandInfo* cmd;
  8104. int i;
  8105. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8106. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8107. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8108. for(i = 0; i < pc_group_max; i++) {
  8109. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8110. cmd->at_groups[i] = 1;
  8111. else
  8112. cmd->at_groups[i] = 0;
  8113. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8114. cmd->char_groups[i] = 1;
  8115. else
  8116. cmd->char_groups[i] = 0;
  8117. }
  8118. }
  8119. dbi_destroy(iter);
  8120. return;
  8121. }
  8122. void atcommand_db_clear(void) {
  8123. if (atcommand_db != NULL) {
  8124. DBIterator *iter = db_iterator(atcommand_db);
  8125. AtCommandInfo* cmd;
  8126. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8127. aFree(cmd->at_groups);
  8128. aFree(cmd->char_groups);
  8129. }
  8130. dbi_destroy(iter);
  8131. db_destroy(atcommand_db);
  8132. }
  8133. if (atcommand_alias_db != NULL)
  8134. db_destroy(atcommand_alias_db);
  8135. config_destroy(&atcommand_config);
  8136. }
  8137. void atcommand_doload(void) {
  8138. atcommand_db_clear();
  8139. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8140. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8141. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8142. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8143. }
  8144. void do_init_atcommand(void) {
  8145. atcommand_doload();
  8146. }
  8147. void do_final_atcommand(void) {
  8148. atcommand_db_clear();
  8149. }