atcommand.cpp 328 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "atcommand.hpp"
  4. #include <math.h>
  5. #include <stdlib.h>
  6. #include "../common/cbasetypes.hpp"
  7. #include "../common/cli.hpp"
  8. #include "../common/conf.hpp"
  9. #include "../common/malloc.hpp"
  10. #include "../common/mmo.hpp"
  11. #include "../common/nullpo.hpp"
  12. #include "../common/random.hpp"
  13. #include "../common/showmsg.hpp"
  14. #include "../common/socket.hpp"
  15. #include "../common/strlib.hpp"
  16. #include "../common/timer.hpp"
  17. #include "../common/utilities.hpp"
  18. #include "../common/utils.hpp"
  19. #include "achievement.hpp"
  20. #include "battle.hpp"
  21. #include "channel.hpp"
  22. #include "chat.hpp"
  23. #include "chrif.hpp"
  24. #include "clan.hpp"
  25. #include "clif.hpp"
  26. #include "duel.hpp"
  27. #include "elemental.hpp"
  28. #include "guild.hpp"
  29. #include "homunculus.hpp"
  30. #include "instance.hpp"
  31. #include "intif.hpp"
  32. #include "itemdb.hpp" // MAX_ITEMGROUP
  33. #include "log.hpp"
  34. #include "mail.hpp"
  35. #include "map.hpp"
  36. #include "mapreg.hpp"
  37. #include "mercenary.hpp"
  38. #include "mob.hpp"
  39. #include "npc.hpp"
  40. #include "party.hpp"
  41. #include "pc.hpp"
  42. #include "pc_groups.hpp"
  43. #include "pet.hpp"
  44. #include "quest.hpp"
  45. #include "script.hpp"
  46. #include "storage.hpp"
  47. #include "trade.hpp"
  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. typedef struct AtCommandInfo AtCommandInfo;
  51. typedef struct AliasInfo AliasInfo;
  52. int atcmd_binding_count = 0;
  53. /// Atcommand restriction usage
  54. enum e_atcmd_restict {
  55. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  56. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  57. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  58. };
  59. struct AtCommandInfo {
  60. char command[ATCOMMAND_LENGTH];
  61. AtCommandFunc func;
  62. char* at_groups; /// Quick @commands "can-use" lookup
  63. char* char_groups; /// Quick @charcommands "can-use" lookup
  64. uint8 restriction; /// Restrictions see enum e_restict
  65. };
  66. struct AliasInfo {
  67. AtCommandInfo *command;
  68. char alias[ATCOMMAND_LENGTH];
  69. };
  70. char atcommand_symbol = '@'; // first char of the commands
  71. char charcommand_symbol = '#';
  72. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  73. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  74. static config_t atcommand_config;
  75. static char atcmd_output[CHAT_SIZE_MAX];
  76. static char atcmd_player_name[NAME_LENGTH];
  77. const char *parent_cmd;
  78. struct atcmd_binding_data** atcmd_binding;
  79. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  80. static const char* atcommand_checkalias(const char *aliasname); // @help
  81. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  82. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  83. // @commands (script-based)
  84. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  85. int i = 0;
  86. if( *name == atcommand_symbol || *name == charcommand_symbol )
  87. name++; // for backwards compatibility
  88. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  89. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  90. }
  91. /**
  92. * retrieves the help string associated with a given command.
  93. *
  94. * @param name the name of the command to retrieve help information for
  95. * @return the string associated with the command, or NULL
  96. */
  97. static const char* atcommand_help_string(const char* command)
  98. {
  99. const char* str = NULL;
  100. config_setting_t* info;
  101. if( *command == atcommand_symbol || *command == charcommand_symbol )
  102. {// remove the prefix symbol for the raw name of the command
  103. command ++;
  104. }
  105. // convert alias to the real command name
  106. command = atcommand_checkalias(command);
  107. // attempt to find the first default help command
  108. info = config_lookup(&atcommand_config, "help");
  109. if( info == NULL )
  110. {// failed to find the help property in the configuration file
  111. return NULL;
  112. }
  113. if( !config_setting_lookup_string( info, command, &str ) )
  114. {// failed to find the matching help string
  115. return NULL;
  116. }
  117. // push the result from the method
  118. return str;
  119. }
  120. /*==========================================
  121. * @send (used for testing packet sends from the client)
  122. *------------------------------------------*/
  123. ACMD_FUNC(send)
  124. {
  125. int len=0,type;
  126. // read message type as hex number (without the 0x)
  127. if(!message || !*message ||
  128. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  129. || sscanf(message, "%8x", &type)==1) )
  130. {
  131. int i;
  132. for (i = 900; i <= 903; ++i)
  133. clif_displaymessage(fd, msg_txt(sd,i));
  134. return -1;
  135. }
  136. #define PARSE_ERROR(error,p) \
  137. {\
  138. clif_displaymessage(fd, (error));\
  139. sprintf(atcmd_output, ">%s", (p));\
  140. clif_displaymessage(fd, atcmd_output);\
  141. }
  142. //define PARSE_ERROR
  143. #define CHECK_EOS(p) \
  144. if(*(p) == 0){\
  145. clif_displaymessage(fd, "Unexpected end of string");\
  146. return -1;\
  147. }
  148. //define CHECK_EOS
  149. #define SKIP_VALUE(p) \
  150. {\
  151. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  152. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  153. }
  154. //define SKIP_VALUE
  155. #define GET_VALUE(p,num) \
  156. {\
  157. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  158. PARSE_ERROR("Invalid number in:",(p));\
  159. return -1;\
  160. }\
  161. }
  162. //define GET_VALUE
  163. if (type > 0 && type < MAX_PACKET_DB) {
  164. int off,end;
  165. long num;
  166. if(len)
  167. {// show packet length
  168. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  169. clif_displaymessage(fd, atcmd_output);
  170. return 0;
  171. }
  172. len=packet_db[type].len;
  173. off=2;
  174. if(len == 0)
  175. {// unknown packet - ERROR
  176. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  177. clif_displaymessage(fd, atcmd_output);
  178. return -1;
  179. } else if(len == -1)
  180. {// dynamic packet
  181. len=SHRT_MAX-4; // maximum length
  182. off=4;
  183. }
  184. WFIFOHEAD(fd, len);
  185. WFIFOW(fd,0)=TOW(type);
  186. // parse packet contents
  187. SKIP_VALUE(message);
  188. while(*message != 0 && off < len){
  189. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  190. {// default (byte)
  191. GET_VALUE(message,num);
  192. WFIFOB(fd,off)=TOB(num);
  193. ++off;
  194. } else if(TOUPPER(*message) == 'B')
  195. {// byte
  196. ++message;
  197. GET_VALUE(message,num);
  198. WFIFOB(fd,off)=TOB(num);
  199. ++off;
  200. } else if(TOUPPER(*message) == 'W')
  201. {// word (2 bytes)
  202. ++message;
  203. GET_VALUE(message,num);
  204. WFIFOW(fd,off)=TOW(num);
  205. off+=2;
  206. } else if(TOUPPER(*message) == 'L')
  207. {// long word (4 bytes)
  208. ++message;
  209. GET_VALUE(message,num);
  210. WFIFOL(fd,off)=TOL(num);
  211. off+=4;
  212. } else if(TOUPPER(*message) == 'S')
  213. {// string - escapes are valid
  214. // get string length - num <= 0 means not fixed length (default)
  215. ++message;
  216. if(*message == '"'){
  217. num=0;
  218. } else {
  219. GET_VALUE(message,num);
  220. while(*message != '"')
  221. {// find start of string
  222. if(*message == 0 || ISSPACE(*message)){
  223. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  224. return -1;
  225. }
  226. ++message;
  227. }
  228. }
  229. // parse string
  230. ++message;
  231. CHECK_EOS(message);
  232. end=(num<=0? 0: min(off+((int)num),len));
  233. for(; *message != '"' && (off < end || end == 0); ++off){
  234. if(*message == '\\'){
  235. ++message;
  236. CHECK_EOS(message);
  237. switch(*message){
  238. case 'a': num=0x07; break; // Bell
  239. case 'b': num=0x08; break; // Backspace
  240. case 't': num=0x09; break; // Horizontal tab
  241. case 'n': num=0x0A; break; // Line feed
  242. case 'v': num=0x0B; break; // Vertical tab
  243. case 'f': num=0x0C; break; // Form feed
  244. case 'r': num=0x0D; break; // Carriage return
  245. case 'e': num=0x1B; break; // Escape
  246. default: num=*message; break;
  247. case 'x': // Hexadecimal
  248. {
  249. ++message;
  250. CHECK_EOS(message);
  251. if(!ISXDIGIT(*message)){
  252. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  253. return -1;
  254. }
  255. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  256. if(ISXDIGIT(*message)){
  257. ++message;
  258. CHECK_EOS(message);
  259. num<<=8;
  260. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  261. }
  262. WFIFOB(fd,off)=TOB(num);
  263. ++message;
  264. CHECK_EOS(message);
  265. continue;
  266. }
  267. case '0':
  268. case '1':
  269. case '2':
  270. case '3':
  271. case '4':
  272. case '5':
  273. case '6':
  274. case '7': // Octal
  275. {
  276. num=*message-'0'; // 1st octal digit
  277. ++message;
  278. CHECK_EOS(message);
  279. if(ISDIGIT(*message) && *message < '8'){
  280. num<<=3;
  281. num+=*message-'0'; // 2nd octal digit
  282. ++message;
  283. CHECK_EOS(message);
  284. if(ISDIGIT(*message) && *message < '8'){
  285. num<<=3;
  286. num+=*message-'0'; // 3rd octal digit
  287. ++message;
  288. CHECK_EOS(message);
  289. }
  290. }
  291. WFIFOB(fd,off)=TOB(num);
  292. continue;
  293. }
  294. }
  295. } else
  296. num=*message;
  297. WFIFOB(fd,off)=TOB(num);
  298. ++message;
  299. CHECK_EOS(message);
  300. }//for
  301. while(*message != '"')
  302. {// ignore extra characters
  303. ++message;
  304. CHECK_EOS(message);
  305. }
  306. // terminate the string
  307. if(off < end)
  308. {// fill the rest with 0's
  309. memset(WFIFOP(fd,off),0,end-off);
  310. off=end;
  311. }
  312. } else
  313. {// unknown
  314. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  315. return -1;
  316. }
  317. SKIP_VALUE(message);
  318. }
  319. if(packet_db[type].len == -1)
  320. {// send dynamic packet
  321. WFIFOW(fd,2)=TOW(off);
  322. WFIFOSET(fd,off);
  323. } else
  324. {// send static packet
  325. if(off < len)
  326. memset(WFIFOP(fd,off),0,len-off);
  327. WFIFOSET(fd,len);
  328. }
  329. } else {
  330. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  331. return -1;
  332. }
  333. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  334. clif_displaymessage(fd, atcmd_output);
  335. return 0;
  336. #undef PARSE_ERROR
  337. #undef CHECK_EOS
  338. #undef SKIP_VALUE
  339. #undef GET_VALUE
  340. }
  341. /**
  342. * Retrieves map name suggestions for a given string.
  343. * This will first check if any map names contain the given string, and will
  344. * print out MAX_SUGGESTIONS results if any maps are found.
  345. * Otherwise, suggestions will be calculated through Levenshtein distance,
  346. * and up to 5 of the closest matches will be printed.
  347. *
  348. * @author Euphy
  349. */
  350. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  351. char buffer[512];
  352. int i, count = 0;
  353. if (strlen(name) < 2)
  354. return;
  355. // build the suggestion string
  356. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  357. strcat(buffer, "\n");
  358. // check for maps that contain string
  359. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  360. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  361. strcat(buffer, map[i].name);
  362. strcat(buffer, " ");
  363. if (++count >= MAX_SUGGESTIONS)
  364. break;
  365. }
  366. }
  367. // if no maps found, search by edit distance
  368. if (!count) {
  369. unsigned int distance[MAX_MAP_PER_SERVER][2];
  370. int j;
  371. // calculate Levenshtein distance for all maps
  372. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  373. if (strlen(map[i].name) < 4) // invalid map name?
  374. distance[i][0] = INT_MAX;
  375. else {
  376. distance[i][0] = levenshtein(map[i].name, name);
  377. distance[i][1] = i;
  378. }
  379. }
  380. // selection sort elements as needed
  381. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  382. for (i = 0; i < count; i++) {
  383. int min = i;
  384. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  385. if (distance[j][0] < distance[min][0])
  386. min = j;
  387. }
  388. // print map name
  389. if (distance[min][0] > 4) { // awful results, don't bother
  390. if (!i) return;
  391. break;
  392. }
  393. strcat(buffer, map[distance[min][1]].name);
  394. strcat(buffer, " ");
  395. // swap elements
  396. SWAP(distance[i][0], distance[min][0]);
  397. SWAP(distance[i][1], distance[min][1]);
  398. }
  399. }
  400. clif_displaymessage(sd->fd, buffer);
  401. }
  402. /*==========================================
  403. * @rura, @warp, @mapmove
  404. *------------------------------------------*/
  405. ACMD_FUNC(mapmove)
  406. {
  407. char map_name[MAP_NAME_LENGTH_EXT];
  408. unsigned short mapindex;
  409. short x = 0, y = 0;
  410. int16 m = -1;
  411. nullpo_retr(-1, sd);
  412. memset(map_name, '\0', sizeof(map_name));
  413. if (!message || !*message ||
  414. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  415. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  416. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  417. return -1;
  418. }
  419. mapindex = mapindex_name2id(map_name);
  420. if (mapindex)
  421. m = map_mapindex2mapid(mapindex);
  422. if (!mapindex) { // m < 0 means on different server! [Kevin]
  423. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  424. if (battle_config.warp_suggestions_enabled)
  425. warp_get_suggestions(sd, map_name);
  426. return -1;
  427. }
  428. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  429. { //This is to prevent the pc_setpos call from printing an error.
  430. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  431. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  432. x = y = 0; //Invalid cell, use random spot.
  433. }
  434. if ((map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, sd->group_level)) {
  435. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  436. return -1;
  437. }
  438. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  439. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  440. return -1;
  441. }
  442. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  443. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  444. return -1;
  445. }
  446. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  447. return 0;
  448. }
  449. /*==========================================
  450. * Displays where a character is. Corrected version by Silent. [Skotlex]
  451. *------------------------------------------*/
  452. ACMD_FUNC(where)
  453. {
  454. struct map_session_data* pl_sd;
  455. nullpo_retr(-1, sd);
  456. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  457. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  458. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  459. return -1;
  460. }
  461. pl_sd = map_nick2sd(atcmd_player_name,true);
  462. if (pl_sd == NULL ||
  463. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  464. (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))
  465. ) {
  466. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  467. return -1;
  468. }
  469. 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);
  470. clif_displaymessage(fd, atcmd_output);
  471. return 0;
  472. }
  473. /*==========================================
  474. *
  475. *------------------------------------------*/
  476. ACMD_FUNC(jumpto)
  477. {
  478. struct map_session_data *pl_sd = NULL;
  479. nullpo_retr(-1, sd);
  480. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  481. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  482. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  483. return -1;
  484. }
  485. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  486. {
  487. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  488. return -1;
  489. }
  490. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  491. {
  492. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  493. return -1;
  494. }
  495. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  496. {
  497. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  498. return -1;
  499. }
  500. if( pc_isdead(sd) )
  501. {
  502. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  503. return -1;
  504. }
  505. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  506. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  507. clif_displaymessage(fd, atcmd_output);
  508. return 0;
  509. }
  510. /*==========================================
  511. *
  512. *------------------------------------------*/
  513. ACMD_FUNC(jump)
  514. {
  515. short x = 0, y = 0;
  516. nullpo_retr(-1, sd);
  517. memset(atcmd_output, '\0', sizeof(atcmd_output));
  518. sscanf(message, "%6hd %6hd", &x, &y);
  519. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  520. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  521. return -1;
  522. }
  523. if( pc_isdead(sd) )
  524. {
  525. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  526. return -1;
  527. }
  528. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  529. { //This is to prevent the pc_setpos call from printing an error.
  530. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  531. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  532. x = y = 0; //Invalid cell, use random spot.
  533. }
  534. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  535. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  536. clif_displaymessage(fd, atcmd_output);
  537. return 0;
  538. }
  539. /*==========================================
  540. * Display list of online characters with
  541. * various info.
  542. *------------------------------------------*/
  543. ACMD_FUNC(who) {
  544. struct map_session_data *pl_sd = NULL;
  545. struct s_mapiterator *iter = NULL;
  546. char player_name[NAME_LENGTH] = "";
  547. int count = 0;
  548. int level = 0;
  549. StringBuf buf;
  550. /**
  551. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  552. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  553. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  554. */
  555. int display_type = 1;
  556. int map_id = -1;
  557. nullpo_retr(-1, sd);
  558. if (strstr(command, "map") != NULL) {
  559. char map_name[MAP_NAME_LENGTH_EXT] = "";
  560. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  561. map_id = sd->bl.m;
  562. } else {
  563. sscanf(message, "%23s", player_name);
  564. }
  565. if (strstr(command, "2") != NULL)
  566. display_type = 2;
  567. else if (strstr(command, "3") != NULL)
  568. display_type = 3;
  569. level = pc_get_group_level(sd);
  570. StringBuf_Init(&buf);
  571. iter = mapit_getallusers();
  572. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  573. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  574. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  575. || (map_id >= 0 && pl_sd->bl.m != map_id))
  576. continue;
  577. switch (display_type) {
  578. case 2: {
  579. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  580. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  581. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  582. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  583. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  584. break;
  585. }
  586. case 3: {
  587. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  588. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  589. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  590. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  591. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  592. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  593. break;
  594. }
  595. default: {
  596. struct party_data *p = party_search(pl_sd->status.party_id);
  597. struct guild *g = pl_sd->guild;
  598. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  599. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  600. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  601. if (p != NULL)
  602. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  603. if (g != NULL)
  604. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  605. break;
  606. }
  607. }
  608. clif_displaymessage(fd, StringBuf_Value(&buf));
  609. StringBuf_Clear(&buf);
  610. count++;
  611. }
  612. }
  613. mapit_free(iter);
  614. if (map_id < 0) {
  615. if (count == 0)
  616. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  617. else if (count == 1)
  618. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  619. else
  620. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  621. } else {
  622. if (count == 0)
  623. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  624. else if (count == 1)
  625. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  626. else
  627. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  628. }
  629. clif_displaymessage(fd, StringBuf_Value(&buf));
  630. StringBuf_Destroy(&buf);
  631. return 0;
  632. }
  633. /*==========================================
  634. *
  635. *------------------------------------------*/
  636. ACMD_FUNC(whogm)
  637. {
  638. struct map_session_data* pl_sd;
  639. struct s_mapiterator* iter;
  640. int j, count;
  641. int level;
  642. char match_text[CHAT_SIZE_MAX];
  643. char player_name[NAME_LENGTH];
  644. struct guild *g;
  645. struct party_data *p;
  646. nullpo_retr(-1, sd);
  647. memset(atcmd_output, '\0', sizeof(atcmd_output));
  648. memset(match_text, '\0', sizeof(match_text));
  649. memset(player_name, '\0', sizeof(player_name));
  650. if (sscanf(message, "%255[^\n]", match_text) < 1)
  651. strcpy(match_text, "");
  652. for (j = 0; match_text[j]; j++)
  653. match_text[j] = TOLOWER(match_text[j]);
  654. count = 0;
  655. level = pc_get_group_level(sd);
  656. iter = mapit_getallusers();
  657. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  658. {
  659. int pl_level = pc_get_group_level(pl_sd);
  660. if (!pl_level)
  661. continue;
  662. if (match_text[0])
  663. {
  664. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  665. for (j = 0; player_name[j]; j++)
  666. player_name[j] = TOLOWER(player_name[j]);
  667. // search with no case sensitive
  668. if (strstr(player_name, match_text) == NULL)
  669. continue;
  670. }
  671. if (pl_level > level) {
  672. if (pc_isinvisible(pl_sd))
  673. continue;
  674. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  675. clif_displaymessage(fd, atcmd_output);
  676. count++;
  677. continue;
  678. }
  679. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  680. pl_sd->status.name, pl_level,
  681. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  682. clif_displaymessage(fd, atcmd_output);
  683. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  684. pl_sd->status.base_level,
  685. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  686. clif_displaymessage(fd, atcmd_output);
  687. p = party_search(pl_sd->status.party_id);
  688. g = pl_sd->guild;
  689. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  690. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  691. clif_displaymessage(fd, atcmd_output);
  692. count++;
  693. }
  694. mapit_free(iter);
  695. if (count == 0)
  696. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  697. else if (count == 1)
  698. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  699. else {
  700. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  701. clif_displaymessage(fd, atcmd_output);
  702. }
  703. return 0;
  704. }
  705. /*==========================================
  706. *
  707. *------------------------------------------*/
  708. ACMD_FUNC(save)
  709. {
  710. nullpo_retr(-1, sd);
  711. if( map[sd->bl.m].instance_id ) {
  712. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  713. return 1;
  714. }
  715. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  716. if (sd->status.pet_id > 0 && sd->pd)
  717. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  718. chrif_save(sd, CSAVE_NORMAL);
  719. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  720. return 0;
  721. }
  722. /*==========================================
  723. *
  724. *------------------------------------------*/
  725. ACMD_FUNC(load)
  726. {
  727. int16 m;
  728. nullpo_retr(-1, sd);
  729. m = map_mapindex2mapid(sd->status.save_point.map);
  730. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  731. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  732. return -1;
  733. }
  734. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  735. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  736. return -1;
  737. }
  738. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  739. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  740. return 0;
  741. }
  742. /*==========================================
  743. *
  744. *------------------------------------------*/
  745. ACMD_FUNC(speed)
  746. {
  747. short speed;
  748. nullpo_retr(-1, sd);
  749. memset(atcmd_output, '\0', sizeof(atcmd_output));
  750. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  751. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  752. clif_displaymessage(fd, atcmd_output);
  753. return -1;
  754. }
  755. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  756. if (speed < 0)
  757. sd->base_status.speed = DEFAULT_WALK_SPEED;
  758. else
  759. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  760. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  761. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  762. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  763. } else
  764. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  765. status_calc_bl(&sd->bl, SCB_SPEED);
  766. return 0;
  767. }
  768. /*==========================================
  769. *
  770. *------------------------------------------*/
  771. ACMD_FUNC(storage)
  772. {
  773. nullpo_retr(-1, sd);
  774. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  775. return -1;
  776. if (storage_storageopen(sd) == 1)
  777. { //Already open.
  778. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  779. return -1;
  780. }
  781. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  782. return 0;
  783. }
  784. /*==========================================
  785. *
  786. *------------------------------------------*/
  787. ACMD_FUNC(guildstorage)
  788. {
  789. nullpo_retr(-1, sd);
  790. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  791. return -1;
  792. switch (storage_guild_storageopen(sd)) {
  793. case GSTORAGE_OPEN:
  794. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  795. break;
  796. case GSTORAGE_STORAGE_ALREADY_OPEN:
  797. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  798. return -1;
  799. case GSTORAGE_ALREADY_OPEN:
  800. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  801. return -1;
  802. case GSTORAGE_NO_GUILD:
  803. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  804. return -1;
  805. case GSTORAGE_NO_STORAGE:
  806. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  807. return -1;
  808. case GSTORAGE_NO_PERMISSION:
  809. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  810. return -1;
  811. }
  812. return 0;
  813. }
  814. /*==========================================
  815. *
  816. *------------------------------------------*/
  817. ACMD_FUNC(option)
  818. {
  819. int param1 = 0, param2 = 0, param3 = 0;
  820. nullpo_retr(-1, sd);
  821. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  822. {// failed to match the parameters so inform the user of the options
  823. const char* text;
  824. // attempt to find the setting information for this command
  825. text = atcommand_help_string( command );
  826. // notify the user of the requirement to enter an option
  827. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  828. if( text )
  829. {// send the help text associated with this command
  830. clif_displaymessage( fd, text );
  831. }
  832. return -1;
  833. }
  834. sd->sc.opt1 = param1;
  835. sd->sc.opt2 = param2;
  836. pc_setoption(sd, param3);
  837. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  838. return 0;
  839. }
  840. /*==========================================
  841. *
  842. *------------------------------------------*/
  843. ACMD_FUNC(hide)
  844. {
  845. nullpo_retr(-1, sd);
  846. if (pc_isinvisible(sd)) {
  847. sd->sc.option &= ~OPTION_INVISIBLE;
  848. if (sd->disguise)
  849. status_set_viewdata(&sd->bl, sd->disguise);
  850. else
  851. status_set_viewdata(&sd->bl, sd->status.class_);
  852. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  853. // increment the number of pvp players on the map
  854. map[sd->bl.m].users_pvp++;
  855. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  856. {// register the player for ranking calculations
  857. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  858. }
  859. //bugreport:2266
  860. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  861. } else {
  862. sd->sc.option |= OPTION_INVISIBLE;
  863. sd->vd.class_ = JT_INVISIBLE;
  864. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  865. // decrement the number of pvp players on the map
  866. map[sd->bl.m].users_pvp--;
  867. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  868. {// unregister the player for ranking
  869. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  870. sd->pvp_timer = INVALID_TIMER;
  871. }
  872. }
  873. clif_changeoption(&sd->bl);
  874. return 0;
  875. }
  876. /*==========================================
  877. * Changes a character's class
  878. *------------------------------------------*/
  879. ACMD_FUNC(jobchange)
  880. {
  881. int job = 0, upper = 0;
  882. const char* text;
  883. nullpo_retr(-1, sd);
  884. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  885. int i;
  886. bool found = false;
  887. upper = 0;
  888. // Normal Jobs
  889. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  890. if (strncmpi(message, job_name(i), 16) == 0) {
  891. job = i;
  892. found = true;
  893. }
  894. }
  895. // High Jobs, Babys and Third
  896. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  897. if (strncmpi(message, job_name(i), 16) == 0) {
  898. job = i;
  899. found = true;
  900. }
  901. }
  902. if (!found) {
  903. text = atcommand_help_string(command);
  904. if (text)
  905. clif_displaymessage(fd, text);
  906. return -1;
  907. }
  908. }
  909. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  910. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  911. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  912. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2)
  913. { // Deny direct transformation into dummy jobs
  914. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  915. return 0;
  916. }
  917. if (pcdb_checkid(job))
  918. {
  919. if (pc_jobchange(sd, job, upper))
  920. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  921. else {
  922. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  923. return -1;
  924. }
  925. } else {
  926. text = atcommand_help_string(command);
  927. if (text)
  928. clif_displaymessage(fd, text);
  929. return -1;
  930. }
  931. return 0;
  932. }
  933. /*==========================================
  934. *
  935. *------------------------------------------*/
  936. ACMD_FUNC(kill)
  937. {
  938. nullpo_retr(-1, sd);
  939. status_kill(&sd->bl);
  940. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  941. if (fd != sd->fd)
  942. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  943. return 0;
  944. }
  945. /*==========================================
  946. *
  947. *------------------------------------------*/
  948. ACMD_FUNC(alive)
  949. {
  950. nullpo_retr(-1, sd);
  951. if (!status_revive(&sd->bl, 100, 100))
  952. {
  953. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  954. return -1;
  955. }
  956. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  957. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  958. return 0;
  959. }
  960. /*==========================================
  961. * +kamic [LuzZza]
  962. *------------------------------------------*/
  963. ACMD_FUNC(kami)
  964. {
  965. unsigned long color=0;
  966. nullpo_retr(-1, sd);
  967. memset(atcmd_output, '\0', sizeof(atcmd_output));
  968. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  969. if (!message || !*message) {
  970. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  971. return -1;
  972. }
  973. sscanf(message, "%255[^\n]", atcmd_output);
  974. if (strstr(command, "l") != NULL)
  975. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  976. else
  977. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  978. } else {
  979. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  980. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  981. return -1;
  982. }
  983. if(color > 0xFFFFFF) {
  984. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  985. return -1;
  986. }
  987. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  988. }
  989. return 0;
  990. }
  991. /*==========================================
  992. *
  993. *------------------------------------------*/
  994. ACMD_FUNC(heal)
  995. {
  996. int hp = 0, sp = 0; // [Valaris] thanks to fov
  997. nullpo_retr(-1, sd);
  998. sscanf(message, "%11d %11d", &hp, &sp);
  999. // some overflow checks
  1000. if( hp == INT_MIN ) hp++;
  1001. if( sp == INT_MIN ) sp++;
  1002. if ( hp == 0 && sp == 0 ) {
  1003. if (!status_percent_heal(&sd->bl, 100, 100))
  1004. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1005. else
  1006. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1007. return 0;
  1008. }
  1009. if ( hp > 0 && sp >= 0 ) {
  1010. if(!status_heal(&sd->bl, hp, sp, 0))
  1011. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1012. else
  1013. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1014. return 0;
  1015. }
  1016. if ( hp < 0 && sp <= 0 ) {
  1017. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1018. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1019. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1020. return 0;
  1021. }
  1022. //Opposing signs.
  1023. if ( hp ) {
  1024. if (hp > 0)
  1025. status_heal(&sd->bl, hp, 0, 0);
  1026. else {
  1027. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1028. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1029. }
  1030. }
  1031. if ( sp ) {
  1032. if (sp > 0)
  1033. status_heal(&sd->bl, 0, sp, 0);
  1034. else
  1035. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1036. }
  1037. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1038. return 0;
  1039. }
  1040. /*==========================================
  1041. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1042. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1043. *------------------------------------------*/
  1044. ACMD_FUNC(item)
  1045. {
  1046. char item_name[100];
  1047. int number = 0, bound = BOUND_NONE;
  1048. char flag = 0;
  1049. struct item item_tmp;
  1050. struct item_data *item_data[10];
  1051. int get_count, i, j=0;
  1052. char *itemlist;
  1053. nullpo_retr(-1, sd);
  1054. memset(item_name, '\0', sizeof(item_name));
  1055. parent_cmd = atcommand_checkalias(command+1);
  1056. if (!strcmpi(parent_cmd,"itembound")) {
  1057. if (!message || !*message || (
  1058. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1059. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1060. {
  1061. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1062. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1063. return -1;
  1064. }
  1065. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1066. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1067. return -1;
  1068. }
  1069. } else if (!message || !*message || (
  1070. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1071. sscanf(message, "%99s %11d", item_name, &number) < 1
  1072. )) {
  1073. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1074. return -1;
  1075. }
  1076. itemlist = strtok(item_name, ":");
  1077. while (itemlist != NULL && j<10) {
  1078. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1079. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1080. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1081. return -1;
  1082. }
  1083. itemlist = strtok(NULL, ":"); //next itemline
  1084. j++;
  1085. }
  1086. if (number <= 0)
  1087. number = 1;
  1088. get_count = number;
  1089. for(j--; j>=0; j--){ //produce items in list
  1090. unsigned short item_id = item_data[j]->nameid;
  1091. //Check if it's stackable.
  1092. if (!itemdb_isstackable2(item_data[j]))
  1093. get_count = 1;
  1094. for (i = 0; i < number; i += get_count) {
  1095. // if not pet egg
  1096. if (!pet_create_egg(sd, item_id)) {
  1097. memset(&item_tmp, 0, sizeof(item_tmp));
  1098. item_tmp.nameid = item_id;
  1099. item_tmp.identify = 1;
  1100. item_tmp.bound = bound;
  1101. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1102. clif_additem(sd, 0, 0, flag);
  1103. }
  1104. }
  1105. }
  1106. if (flag == 0)
  1107. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1108. return 0;
  1109. }
  1110. /*==========================================
  1111. *
  1112. *------------------------------------------*/
  1113. ACMD_FUNC(item2)
  1114. {
  1115. struct item item_tmp;
  1116. struct item_data *item_data;
  1117. char item_name[100];
  1118. unsigned short item_id;
  1119. int number = 0, bound = BOUND_NONE;
  1120. int identify = 0, refine = 0, attr = 0;
  1121. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1122. nullpo_retr(-1, sd);
  1123. memset(item_name, '\0', sizeof(item_name));
  1124. parent_cmd = atcommand_checkalias(command+1);
  1125. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1126. if (!message || !*message || (
  1127. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1128. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1129. {
  1130. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1131. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1132. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1133. return -1;
  1134. }
  1135. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1136. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1137. return -1;
  1138. }
  1139. } else if ( !message || !*message || (
  1140. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1141. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1142. )) {
  1143. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1144. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1145. return -1;
  1146. }
  1147. if (number <= 0)
  1148. number = 1;
  1149. item_id = 0;
  1150. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1151. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1152. item_id = item_data->nameid;
  1153. if (item_id > 500) {
  1154. int loop, get_count, i;
  1155. char flag = 0;
  1156. //Check if it's stackable.
  1157. if(!itemdb_isstackable2(item_data)){
  1158. loop = number;
  1159. get_count = 1;
  1160. }else{
  1161. loop = 1;
  1162. get_count = number;
  1163. }
  1164. if( itemdb_isequip2(item_data ) ){
  1165. refine = cap_value( refine, 0, MAX_REFINE );
  1166. }else{
  1167. // All other items cannot be refined and are always identified
  1168. identify = 1;
  1169. refine = attr = 0;
  1170. }
  1171. for (i = 0; i < loop; i++) {
  1172. // if not pet egg
  1173. if (!pet_create_egg(sd, item_id)) {
  1174. memset(&item_tmp, 0, sizeof(item_tmp));
  1175. item_tmp.nameid = item_id;
  1176. item_tmp.identify = identify;
  1177. item_tmp.refine = refine;
  1178. item_tmp.attribute = attr;
  1179. item_tmp.card[0] = c1;
  1180. item_tmp.card[1] = c2;
  1181. item_tmp.card[2] = c3;
  1182. item_tmp.card[3] = c4;
  1183. item_tmp.bound = bound;
  1184. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1185. clif_additem(sd, 0, 0, flag);
  1186. }
  1187. }
  1188. if (flag == 0)
  1189. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1190. } else {
  1191. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1192. return -1;
  1193. }
  1194. return 0;
  1195. }
  1196. /*==========================================
  1197. *
  1198. *------------------------------------------*/
  1199. ACMD_FUNC(itemreset)
  1200. {
  1201. int i;
  1202. nullpo_retr(-1, sd);
  1203. for (i = 0; i < MAX_INVENTORY; i++) {
  1204. if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0) {
  1205. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1206. }
  1207. }
  1208. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1209. return 0;
  1210. }
  1211. /*==========================================
  1212. * Atcommand @lvlup
  1213. *------------------------------------------*/
  1214. ACMD_FUNC(baselevelup)
  1215. {
  1216. int level=0, i=0, status_point=0;
  1217. nullpo_retr(-1, sd);
  1218. level = atoi(message);
  1219. if (!message || !*message || !level) {
  1220. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1221. return -1;
  1222. }
  1223. if (level > 0) {
  1224. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1225. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1226. return -1;
  1227. } // End Addition
  1228. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1229. level = pc_maxbaselv(sd) - sd->status.base_level;
  1230. for (i = 0; i < level; i++)
  1231. status_point += pc_gets_status_point(sd->status.base_level + i);
  1232. sd->status.status_point += status_point;
  1233. sd->status.base_level += (unsigned int)level;
  1234. status_calc_pc(sd, SCO_FORCE);
  1235. status_percent_heal(&sd->bl, 100, 100);
  1236. clif_misceffect(&sd->bl, 0);
  1237. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.base_level);
  1238. achievement_update_objective(sd, AG_GOAL_STATUS, 2, sd->status.base_level, sd->status.class_);
  1239. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1240. } else {
  1241. if (sd->status.base_level == 1) {
  1242. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1243. return -1;
  1244. }
  1245. level*=-1;
  1246. if ((unsigned int)level >= sd->status.base_level)
  1247. level = sd->status.base_level-1;
  1248. for (i = 0; i > -level; i--)
  1249. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1250. if (sd->status.status_point < status_point)
  1251. pc_resetstate(sd);
  1252. if (sd->status.status_point < status_point)
  1253. sd->status.status_point = 0;
  1254. else
  1255. sd->status.status_point -= status_point;
  1256. sd->status.base_level -= (unsigned int)level;
  1257. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1258. status_calc_pc(sd, SCO_FORCE);
  1259. level*=-1;
  1260. }
  1261. sd->status.base_exp = 0;
  1262. clif_updatestatus(sd, SP_STATUSPOINT);
  1263. clif_updatestatus(sd, SP_BASELEVEL);
  1264. clif_updatestatus(sd, SP_BASEEXP);
  1265. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1266. pc_baselevelchanged(sd);
  1267. if(sd->status.party_id)
  1268. party_send_levelup(sd);
  1269. if( level > 0 && battle_config.atcommand_levelup_events )
  1270. npc_script_event(sd,NPCE_BASELVUP);
  1271. return 0;
  1272. }
  1273. /*==========================================
  1274. *
  1275. *------------------------------------------*/
  1276. ACMD_FUNC(joblevelup)
  1277. {
  1278. int level=0;
  1279. nullpo_retr(-1, sd);
  1280. level = atoi(message);
  1281. if (!message || !*message || !level) {
  1282. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1283. return -1;
  1284. }
  1285. if (level > 0) {
  1286. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1287. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1288. return -1;
  1289. }
  1290. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1291. level = pc_maxjoblv(sd) - sd->status.job_level;
  1292. sd->status.job_level += (unsigned int)level;
  1293. sd->status.skill_point += level;
  1294. clif_misceffect(&sd->bl, 1);
  1295. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.job_level);
  1296. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1297. } else {
  1298. if (sd->status.job_level == 1) {
  1299. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1300. return -1;
  1301. }
  1302. level *=-1;
  1303. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1304. level = sd->status.job_level-1;
  1305. sd->status.job_level -= (unsigned int)level;
  1306. if (sd->status.skill_point < level)
  1307. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1308. if (sd->status.skill_point < level)
  1309. sd->status.skill_point = 0;
  1310. else
  1311. sd->status.skill_point -= level;
  1312. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1313. level *=-1;
  1314. }
  1315. sd->status.job_exp = 0;
  1316. clif_updatestatus(sd, SP_JOBLEVEL);
  1317. clif_updatestatus(sd, SP_JOBEXP);
  1318. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1319. clif_updatestatus(sd, SP_SKILLPOINT);
  1320. status_calc_pc(sd, SCO_FORCE);
  1321. if( level > 0 && battle_config.atcommand_levelup_events )
  1322. npc_script_event(sd,NPCE_JOBLVUP);
  1323. return 0;
  1324. }
  1325. /*==========================================
  1326. * @help
  1327. *------------------------------------------*/
  1328. ACMD_FUNC(help)
  1329. {
  1330. config_setting_t *help;
  1331. const char *text = NULL;
  1332. const char *command_name = NULL;
  1333. const char *default_command = "help";
  1334. nullpo_retr(-1, sd);
  1335. help = config_lookup(&atcommand_config, "help");
  1336. if (help == NULL) {
  1337. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1338. return -1;
  1339. }
  1340. if (!message || !*message) {
  1341. command_name = default_command; // If no command_name specified, display help for @help.
  1342. } else {
  1343. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1344. ++message;
  1345. command_name = atcommand_checkalias(message);
  1346. }
  1347. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1348. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1349. clif_displaymessage(fd, atcmd_output);
  1350. atcommand_get_suggestions(sd, command_name, true);
  1351. return -1;
  1352. }
  1353. if (!config_setting_lookup_string(help, command_name, &text)) {
  1354. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1355. clif_displaymessage(fd, atcmd_output);
  1356. atcommand_get_suggestions(sd, command_name, true);
  1357. return -1;
  1358. }
  1359. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1360. clif_displaymessage(fd, atcmd_output);
  1361. { // Display aliases
  1362. DBIterator* iter;
  1363. AtCommandInfo *command_info;
  1364. AliasInfo *alias_info = NULL;
  1365. StringBuf buf;
  1366. bool has_aliases = false;
  1367. StringBuf_Init(&buf);
  1368. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1369. command_info = get_atcommandinfo_byname(command_name);
  1370. iter = db_iterator(atcommand_alias_db);
  1371. for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
  1372. if (alias_info->command == command_info) {
  1373. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1374. has_aliases = true;
  1375. }
  1376. }
  1377. dbi_destroy(iter);
  1378. if (has_aliases)
  1379. clif_displaymessage(fd, StringBuf_Value(&buf));
  1380. StringBuf_Destroy(&buf);
  1381. }
  1382. // Display help contents
  1383. clif_displaymessage(fd, text);
  1384. return 0;
  1385. }
  1386. // helper function, used in foreach calls to stop auto-attack timers
  1387. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1388. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1389. {
  1390. struct unit_data *ud = unit_bl2ud(bl);
  1391. int id = va_arg(ap, int);
  1392. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1393. {
  1394. unit_stop_attack(bl);
  1395. return 1;
  1396. }
  1397. return 0;
  1398. }
  1399. /*==========================================
  1400. *
  1401. *------------------------------------------*/
  1402. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1403. {
  1404. TBL_PC* sd = (TBL_PC*)bl;
  1405. clif_pvpset(sd, 0, 0, 2);
  1406. if (sd->pvp_timer != INVALID_TIMER) {
  1407. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1408. sd->pvp_timer = INVALID_TIMER;
  1409. }
  1410. return 0;
  1411. }
  1412. ACMD_FUNC(pvpoff)
  1413. {
  1414. nullpo_retr(-1, sd);
  1415. if (!map[sd->bl.m].flag.pvp) {
  1416. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1417. return -1;
  1418. }
  1419. map[sd->bl.m].flag.pvp = 0;
  1420. if (!battle_config.pk_mode){
  1421. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1422. }
  1423. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1424. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1425. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1426. return 0;
  1427. }
  1428. /*==========================================
  1429. *
  1430. *------------------------------------------*/
  1431. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1432. {
  1433. TBL_PC* sd = (TBL_PC*)bl;
  1434. if (sd->pvp_timer == INVALID_TIMER) {
  1435. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1436. sd->pvp_rank = 0;
  1437. sd->pvp_lastusers = 0;
  1438. sd->pvp_point = 5;
  1439. sd->pvp_won = 0;
  1440. sd->pvp_lost = 0;
  1441. }
  1442. return 0;
  1443. }
  1444. ACMD_FUNC(pvpon)
  1445. {
  1446. nullpo_retr(-1, sd);
  1447. if (map[sd->bl.m].flag.pvp) {
  1448. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1449. return -1;
  1450. }
  1451. map[sd->bl.m].flag.pvp = 1;
  1452. if (!battle_config.pk_mode) {// display pvp circle and rank
  1453. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1454. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1455. }
  1456. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1457. return 0;
  1458. }
  1459. /*==========================================
  1460. *
  1461. *------------------------------------------*/
  1462. ACMD_FUNC(gvgoff)
  1463. {
  1464. nullpo_retr(-1, sd);
  1465. if (!map[sd->bl.m].flag.gvg) {
  1466. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1467. return -1;
  1468. }
  1469. map[sd->bl.m].flag.gvg = 0;
  1470. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1471. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1472. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1473. return 0;
  1474. }
  1475. /*==========================================
  1476. *
  1477. *------------------------------------------*/
  1478. ACMD_FUNC(gvgon)
  1479. {
  1480. nullpo_retr(-1, sd);
  1481. if (map[sd->bl.m].flag.gvg) {
  1482. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1483. return -1;
  1484. }
  1485. map[sd->bl.m].flag.gvg = 1;
  1486. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1487. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1488. return 0;
  1489. }
  1490. /*==========================================
  1491. *
  1492. *------------------------------------------*/
  1493. ACMD_FUNC(model)
  1494. {
  1495. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1496. nullpo_retr(-1, sd);
  1497. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1498. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1499. sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1500. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1501. clif_displaymessage(fd, atcmd_output);
  1502. return -1;
  1503. }
  1504. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1505. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1506. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1507. pc_changelook(sd, LOOK_HAIR, hair_style);
  1508. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1509. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1510. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1511. } else {
  1512. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1513. return -1;
  1514. }
  1515. return 0;
  1516. }
  1517. /*==========================================
  1518. * @bodystyle [Rytech]
  1519. *------------------------------------------*/
  1520. ACMD_FUNC(bodystyle)
  1521. {
  1522. int body_style = 0;
  1523. nullpo_retr(-1, sd);
  1524. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1525. if (!(sd->class_&JOBL_THIRD)) {
  1526. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1527. return -1;
  1528. }
  1529. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1530. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1531. clif_displaymessage(fd, atcmd_output);
  1532. return -1;
  1533. }
  1534. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1535. pc_changelook(sd, LOOK_BODY2, body_style);
  1536. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1537. } else {
  1538. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1539. return -1;
  1540. }
  1541. return 0;
  1542. }
  1543. /*==========================================
  1544. * @dye && @ccolor
  1545. *------------------------------------------*/
  1546. ACMD_FUNC(dye)
  1547. {
  1548. int cloth_color = 0;
  1549. nullpo_retr(-1, sd);
  1550. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1551. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1552. sprintf(atcmd_output, msg_txt(sd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1553. clif_displaymessage(fd, atcmd_output);
  1554. return -1;
  1555. }
  1556. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1557. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1558. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1559. } else {
  1560. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1561. return -1;
  1562. }
  1563. return 0;
  1564. }
  1565. /*==========================================
  1566. * @hairstyle && @hstyle
  1567. *------------------------------------------*/
  1568. ACMD_FUNC(hair_style)
  1569. {
  1570. int hair_style = 0;
  1571. nullpo_retr(-1, sd);
  1572. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1573. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1574. sprintf(atcmd_output, msg_txt(sd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1575. clif_displaymessage(fd, atcmd_output);
  1576. return -1;
  1577. }
  1578. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1579. pc_changelook(sd, LOOK_HAIR, hair_style);
  1580. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1581. } else {
  1582. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1583. return -1;
  1584. }
  1585. return 0;
  1586. }
  1587. /*==========================================
  1588. * @haircolor && @hcolor
  1589. *------------------------------------------*/
  1590. ACMD_FUNC(hair_color)
  1591. {
  1592. int hair_color = 0;
  1593. nullpo_retr(-1, sd);
  1594. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1595. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1596. sprintf(atcmd_output, msg_txt(sd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1597. clif_displaymessage(fd, atcmd_output);
  1598. return -1;
  1599. }
  1600. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1601. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1602. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1603. } else {
  1604. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1605. return -1;
  1606. }
  1607. return 0;
  1608. }
  1609. /*==========================================
  1610. * @go [city_number or city_name] - Updated by Harbin
  1611. *------------------------------------------*/
  1612. ACMD_FUNC(go)
  1613. {
  1614. int i;
  1615. int town;
  1616. char map_name[MAP_NAME_LENGTH];
  1617. const struct {
  1618. char map[MAP_NAME_LENGTH];
  1619. int x, y;
  1620. } data[] = {
  1621. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1622. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1623. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1624. { MAP_PAYON, 162, 233 }, // 3=Payon
  1625. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1626. #ifdef RENEWAL
  1627. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1628. #else
  1629. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1630. #endif
  1631. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1632. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1633. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1634. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1635. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1636. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1637. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1638. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1639. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1640. #ifdef RENEWAL
  1641. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1642. #else
  1643. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1644. #endif
  1645. { MAP_JAIL, 23, 61 }, // 16=Prison
  1646. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1647. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1648. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1649. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1650. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1651. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1652. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1653. { MAP_VEINS, 216, 123 }, // 24=Veins
  1654. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1655. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1656. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1657. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1658. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1659. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1660. { MAP_MORA, 44, 151 }, // 31=Mora
  1661. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1662. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1663. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1664. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1665. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1666. };
  1667. nullpo_retr(-1, sd);
  1668. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1669. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1670. return 0;
  1671. }
  1672. memset(map_name, '\0', sizeof(map_name));
  1673. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1674. // get the number
  1675. town = atoi(message);
  1676. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1677. {// no value matched so send the list of locations
  1678. const char* text;
  1679. // attempt to find the text help string
  1680. text = atcommand_help_string( command );
  1681. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1682. if( text )
  1683. {// send the text to the client
  1684. clif_displaymessage( fd, text );
  1685. }
  1686. return -1;
  1687. }
  1688. // get possible name of the city
  1689. map_name[MAP_NAME_LENGTH-1] = '\0';
  1690. for (i = 0; map_name[i]; i++)
  1691. map_name[i] = TOLOWER(map_name[i]);
  1692. // try to identify the map name
  1693. if (strncmp(map_name, "prontera", 3) == 0) {
  1694. town = 0;
  1695. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1696. strncmp(map_name, "morroc", 4) == 0) {
  1697. town = 1;
  1698. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1699. town = 2;
  1700. } else if (strncmp(map_name, "payon", 3) == 0) {
  1701. town = 3;
  1702. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1703. town = 4;
  1704. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1705. town = 5;
  1706. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1707. town = 6;
  1708. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1709. strcmp(map_name, "christmas") == 0 ||
  1710. strncmp(map_name, "xmas", 3) == 0 ||
  1711. strncmp(map_name, "x-mas", 3) == 0) {
  1712. town = 7;
  1713. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1714. town = 8;
  1715. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1716. strncmp(map_name, "yuno", 3) == 0) {
  1717. town = 9;
  1718. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1719. town = 10;
  1720. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1721. strncmp(map_name, "gonryun", 3) == 0) {
  1722. town = 11;
  1723. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1724. town = 12;
  1725. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1726. town = 13;
  1727. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1728. town = 14;
  1729. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1730. strncmp(map_name, "startpoint", 3) == 0 ||
  1731. strncmp(map_name, "beginning", 3) == 0) {
  1732. town = 15;
  1733. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1734. strncmp(map_name, "prison", 3) == 0 ||
  1735. strncmp(map_name, "jail", 3) == 0) {
  1736. town = 16;
  1737. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1738. town = 17;
  1739. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1740. town = 18;
  1741. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1742. town = 19;
  1743. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1744. town = 20;
  1745. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1746. town = 21;
  1747. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1748. town = 22;
  1749. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1750. town = 23;
  1751. } else if (strncmp(map_name, "veins", 3) == 0) {
  1752. town = 24;
  1753. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1754. town = 25;
  1755. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1756. town = 26;
  1757. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1758. town = 27;
  1759. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1760. town = 28;
  1761. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1762. town = 29;
  1763. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1764. town = 30;
  1765. } else if (strcmp(map_name, "mora") == 0) {
  1766. town = 31;
  1767. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1768. town = 32;
  1769. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1770. town = 33;
  1771. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1772. town = 34;
  1773. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1774. town = 35;
  1775. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1776. town = 36;
  1777. }
  1778. if (town >= 0 && town < ARRAYLENGTH(data))
  1779. {
  1780. int16 m = map_mapname2mapid(data[town].map);
  1781. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1782. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1783. return -1;
  1784. }
  1785. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1786. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1787. return -1;
  1788. }
  1789. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1790. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1791. } else {
  1792. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1793. return -1;
  1794. }
  1795. } else { // if you arrive here, you have an error in town variable when reading of names
  1796. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1797. return -1;
  1798. }
  1799. return 0;
  1800. }
  1801. /*==========================================
  1802. *
  1803. *------------------------------------------*/
  1804. ACMD_FUNC(monster)
  1805. {
  1806. char name[NAME_LENGTH];
  1807. char monster[NAME_LENGTH];
  1808. char eventname[EVENT_NAME_LENGTH] = "";
  1809. int mob_id;
  1810. int number = 0;
  1811. int count;
  1812. int i, range;
  1813. short mx, my;
  1814. unsigned int size;
  1815. nullpo_retr(-1, sd);
  1816. memset(name, '\0', sizeof(name));
  1817. memset(monster, '\0', sizeof(monster));
  1818. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1819. if (!message || !*message) {
  1820. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1821. return -1;
  1822. }
  1823. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1824. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1825. //All data can be left as it is.
  1826. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1827. //Here, it is possible name was not given and we are using monster for it.
  1828. if (count < 3) //Blank mob's name.
  1829. name[0] = '\0';
  1830. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1831. //All data can be left as it is.
  1832. } else if (sscanf(message, "%23s", monster) > 0) {
  1833. //As before, name may be already filled.
  1834. name[0] = '\0';
  1835. } else {
  1836. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1837. return -1;
  1838. }
  1839. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1840. mob_id = mobdb_checkid(atoi(monster));
  1841. if (mob_id == 0) {
  1842. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1843. return -1;
  1844. }
  1845. if (mob_id == MOBID_EMPERIUM) {
  1846. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1847. return -1;
  1848. }
  1849. if (number <= 0)
  1850. number = 1;
  1851. if( !name[0] )
  1852. strcpy(name, "--ja--");
  1853. // 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
  1854. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1855. number = battle_config.atc_spawn_quantity_limit;
  1856. parent_cmd = atcommand_checkalias(command+1);
  1857. if (strcmp(parent_cmd, "monstersmall") == 0)
  1858. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1859. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1860. size = SZ_BIG;
  1861. else
  1862. size = SZ_SMALL;
  1863. if (battle_config.etc_log)
  1864. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
  1865. count = 0;
  1866. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1867. for (i = 0; i < number; i++) {
  1868. int k;
  1869. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1870. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1871. if(k) {
  1872. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1873. count ++;
  1874. }
  1875. }
  1876. if (count != 0)
  1877. if (number == count)
  1878. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1879. else {
  1880. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1881. clif_displaymessage(fd, atcmd_output);
  1882. }
  1883. else {
  1884. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1885. return -1;
  1886. }
  1887. return 0;
  1888. }
  1889. /*==========================================
  1890. *
  1891. *------------------------------------------*/
  1892. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1893. {
  1894. struct mob_data *md;
  1895. int flag;
  1896. nullpo_ret(md=(struct mob_data *)bl);
  1897. flag = va_arg(ap, int);
  1898. if (md->guardian_data)
  1899. return 0; //Do not touch WoE mobs!
  1900. if (flag)
  1901. status_zap(bl,md->status.hp, 0);
  1902. else
  1903. status_kill(bl);
  1904. return 1;
  1905. }
  1906. ACMD_FUNC(killmonster)
  1907. {
  1908. int map_id, drop_flag;
  1909. char map_name[MAP_NAME_LENGTH_EXT];
  1910. nullpo_retr(-1, sd);
  1911. memset(map_name, '\0', sizeof(map_name));
  1912. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1913. map_id = sd->bl.m;
  1914. else {
  1915. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1916. map_id = sd->bl.m;
  1917. }
  1918. parent_cmd = atcommand_checkalias(command+1);
  1919. drop_flag = strcmp(parent_cmd, "killmonster2");
  1920. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1921. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1922. return 0;
  1923. }
  1924. /*==========================================
  1925. *
  1926. *------------------------------------------*/
  1927. ACMD_FUNC(refine)
  1928. {
  1929. int j, position = 0, refine = 0, current_position, final_refine;
  1930. int count;
  1931. nullpo_retr(-1, sd);
  1932. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1933. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1934. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1935. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1936. clif_displaymessage(fd, atcmd_output);
  1937. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1938. clif_displaymessage(fd, atcmd_output);
  1939. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1940. clif_displaymessage(fd, atcmd_output);
  1941. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1942. clif_displaymessage(fd, atcmd_output);
  1943. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1944. clif_displaymessage(fd, atcmd_output);
  1945. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1946. clif_displaymessage(fd, atcmd_output);
  1947. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1948. clif_displaymessage(fd, atcmd_output);
  1949. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1950. clif_displaymessage(fd, atcmd_output);
  1951. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1952. clif_displaymessage(fd, atcmd_output);
  1953. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1954. clif_displaymessage(fd, atcmd_output);
  1955. return -1;
  1956. }
  1957. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1958. count = 0;
  1959. for (j = 0; j < EQI_MAX; j++) {
  1960. int i;
  1961. if ((i = sd->equip_index[j]) < 0)
  1962. continue;
  1963. if(j == EQI_AMMO)
  1964. continue;
  1965. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1966. continue;
  1967. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  1968. continue;
  1969. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  1970. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  1971. sd->inventory.u.items_inventory[i].refine = final_refine;
  1972. current_position = sd->inventory.u.items_inventory[i].equip;
  1973. pc_unequipitem(sd, i, 3);
  1974. clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine);
  1975. clif_delitem(sd, i, 1, 3);
  1976. clif_additem(sd, i, 1, 0);
  1977. pc_equipitem(sd, i, current_position);
  1978. clif_misceffect(&sd->bl, 3);
  1979. achievement_update_objective(sd, AG_REFINE_SUCCESS, 2, sd->inventory_data[i]->wlv, sd->inventory.u.items_inventory[i].refine);
  1980. count++;
  1981. }
  1982. }
  1983. if (count == 0)
  1984. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1985. else if (count == 1)
  1986. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1987. else {
  1988. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1989. clif_displaymessage(fd, atcmd_output);
  1990. }
  1991. return 0;
  1992. }
  1993. /*==========================================
  1994. *
  1995. *------------------------------------------*/
  1996. ACMD_FUNC(produce)
  1997. {
  1998. char item_name[100];
  1999. unsigned short item_id;
  2000. int attribute = 0, star = 0;
  2001. struct item_data *item_data;
  2002. struct item tmp_item;
  2003. nullpo_retr(-1, sd);
  2004. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2005. memset(item_name, '\0', sizeof(item_name));
  2006. if (!message || !*message || (
  2007. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2008. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2009. )) {
  2010. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2011. return -1;
  2012. }
  2013. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  2014. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  2015. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2016. return -1;
  2017. }
  2018. item_id = item_data->nameid;
  2019. if (itemdb_isequip2(item_data)) {
  2020. char flag = 0;
  2021. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2022. attribute = ATTRIBUTE_NORMAL;
  2023. if (star < MIN_STAR || star > MAX_STAR)
  2024. star = 0;
  2025. memset(&tmp_item, 0, sizeof tmp_item);
  2026. tmp_item.nameid = item_id;
  2027. tmp_item.amount = 1;
  2028. tmp_item.identify = 1;
  2029. tmp_item.card[0] = CARD0_FORGE;
  2030. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2031. ((star*5) << 8) + attribute:0;
  2032. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2033. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2034. clif_produceeffect(sd, 0, item_id);
  2035. clif_misceffect(&sd->bl, 3);
  2036. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2037. clif_additem(sd, 0, 0, flag);
  2038. } else {
  2039. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  2040. clif_displaymessage(fd, atcmd_output);
  2041. return -1;
  2042. }
  2043. return 0;
  2044. }
  2045. /*==========================================
  2046. *
  2047. *------------------------------------------*/
  2048. ACMD_FUNC(memo)
  2049. {
  2050. int position = 0;
  2051. nullpo_retr(-1, sd);
  2052. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2053. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2054. {
  2055. int i;
  2056. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2057. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2058. {
  2059. if( sd->status.memo_point[i].map )
  2060. 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);
  2061. else
  2062. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2063. clif_displaymessage(sd->fd, atcmd_output);
  2064. }
  2065. return 0;
  2066. }
  2067. if( position < 0 || position >= MAX_MEMOPOINTS )
  2068. {
  2069. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2070. clif_displaymessage(fd, atcmd_output);
  2071. return -1;
  2072. }
  2073. return !pc_memo( sd, position );
  2074. }
  2075. /*==========================================
  2076. *
  2077. *------------------------------------------*/
  2078. ACMD_FUNC(gat)
  2079. {
  2080. int y;
  2081. nullpo_retr(-1, sd);
  2082. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2083. for (y = 2; y >= -2; y--) {
  2084. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2085. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2086. map_getcell(sd->bl.m, sd->bl.x - 2, 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, sd->bl.y + y, CELL_GETTYPE),
  2089. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2090. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2091. clif_displaymessage(fd, atcmd_output);
  2092. }
  2093. return 0;
  2094. }
  2095. /*==========================================
  2096. *
  2097. *------------------------------------------*/
  2098. ACMD_FUNC(displaystatus)
  2099. {
  2100. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2101. nullpo_retr(-1, sd);
  2102. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2103. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2104. return -1;
  2105. }
  2106. if (i < 2) flag = 1;
  2107. if (i < 3) tick = 0;
  2108. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2109. return 0;
  2110. }
  2111. /*==========================================
  2112. * @stpoint (Rewritten by [Yor])
  2113. *------------------------------------------*/
  2114. ACMD_FUNC(statuspoint)
  2115. {
  2116. int point;
  2117. unsigned int new_status_point;
  2118. if (!message || !*message || (point = atoi(message)) == 0) {
  2119. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2120. return -1;
  2121. }
  2122. if(point < 0)
  2123. {
  2124. if(sd->status.status_point < (unsigned int)(-point))
  2125. {
  2126. new_status_point = 0;
  2127. }
  2128. else
  2129. {
  2130. new_status_point = sd->status.status_point + point;
  2131. }
  2132. }
  2133. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2134. {
  2135. new_status_point = UINT_MAX;
  2136. }
  2137. else
  2138. {
  2139. new_status_point = sd->status.status_point + point;
  2140. }
  2141. if (new_status_point != sd->status.status_point) {
  2142. sd->status.status_point = new_status_point;
  2143. clif_updatestatus(sd, SP_STATUSPOINT);
  2144. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2145. } else {
  2146. if (point < 0)
  2147. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2148. else
  2149. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2150. return -1;
  2151. }
  2152. return 0;
  2153. }
  2154. /*==========================================
  2155. * @skpoint (Rewritten by [Yor])
  2156. *------------------------------------------*/
  2157. ACMD_FUNC(skillpoint)
  2158. {
  2159. int point;
  2160. unsigned int new_skill_point;
  2161. nullpo_retr(-1, sd);
  2162. if (!message || !*message || (point = atoi(message)) == 0) {
  2163. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2164. return -1;
  2165. }
  2166. if(point < 0)
  2167. {
  2168. if(sd->status.skill_point < (unsigned int)(-point))
  2169. {
  2170. new_skill_point = 0;
  2171. }
  2172. else
  2173. {
  2174. new_skill_point = sd->status.skill_point + point;
  2175. }
  2176. }
  2177. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2178. {
  2179. new_skill_point = UINT_MAX;
  2180. }
  2181. else
  2182. {
  2183. new_skill_point = sd->status.skill_point + point;
  2184. }
  2185. if (new_skill_point != sd->status.skill_point) {
  2186. sd->status.skill_point = new_skill_point;
  2187. clif_updatestatus(sd, SP_SKILLPOINT);
  2188. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2189. } else {
  2190. if (point < 0)
  2191. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2192. else
  2193. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2194. return -1;
  2195. }
  2196. return 0;
  2197. }
  2198. /*==========================================
  2199. * @zeny
  2200. *------------------------------------------*/
  2201. ACMD_FUNC(zeny)
  2202. {
  2203. int zeny=0, ret=-1;
  2204. nullpo_retr(-1, sd);
  2205. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2206. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2207. return -1;
  2208. }
  2209. if(zeny > 0){
  2210. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2211. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2212. }
  2213. else {
  2214. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2215. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2216. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2217. }
  2218. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2219. return 0;
  2220. }
  2221. /*==========================================
  2222. *
  2223. *------------------------------------------*/
  2224. ACMD_FUNC(param)
  2225. {
  2226. uint8 i;
  2227. int value = 0;
  2228. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2229. unsigned short new_value, *status[6], max_status[6];
  2230. //we don't use direct initialization because it isn't part of the c standard.
  2231. nullpo_retr(-1, sd);
  2232. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2233. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2234. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2235. return -1;
  2236. }
  2237. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2238. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2239. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2240. return -1;
  2241. }
  2242. status[0] = &sd->status.str;
  2243. status[1] = &sd->status.agi;
  2244. status[2] = &sd->status.vit;
  2245. status[3] = &sd->status.int_;
  2246. status[4] = &sd->status.dex;
  2247. status[5] = &sd->status.luk;
  2248. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2249. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2250. else {
  2251. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2252. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2253. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2254. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2255. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2256. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2257. }
  2258. if(value > 0 && *status[i] + value >= max_status[i])
  2259. new_value = max_status[i];
  2260. else if(value < 0 && *status[i] <= -value)
  2261. new_value = 1;
  2262. else
  2263. new_value = *status[i] + value;
  2264. if (new_value != *status[i]) {
  2265. *status[i] = new_value;
  2266. clif_updatestatus(sd, SP_STR + i);
  2267. clif_updatestatus(sd, SP_USTR + i);
  2268. status_calc_pc(sd, SCO_FORCE);
  2269. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2270. } else {
  2271. if (value < 0)
  2272. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2273. else
  2274. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2275. return -1;
  2276. }
  2277. return 0;
  2278. }
  2279. /*==========================================
  2280. * Stat all by fritz (rewritten by [Yor])
  2281. *------------------------------------------*/
  2282. ACMD_FUNC(stat_all)
  2283. {
  2284. int value = 0;
  2285. uint8 count, i;
  2286. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2287. //we don't use direct initialization because it isn't part of the c standard.
  2288. nullpo_retr(-1, sd);
  2289. status[0] = &sd->status.str;
  2290. status[1] = &sd->status.agi;
  2291. status[2] = &sd->status.vit;
  2292. status[3] = &sd->status.int_;
  2293. status[4] = &sd->status.dex;
  2294. status[5] = &sd->status.luk;
  2295. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2296. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2297. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2298. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2299. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2300. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2301. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2302. value = SHRT_MAX;
  2303. } else {
  2304. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2305. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2306. else {
  2307. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2308. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2309. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2310. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2311. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2312. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2313. }
  2314. }
  2315. count = 0;
  2316. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2317. short new_value;
  2318. if (value > 0 && *status[i] + value >= max_status[i])
  2319. new_value = max_status[i];
  2320. else if (value < 0 && *status[i] <= -value)
  2321. new_value = 1;
  2322. else
  2323. new_value = *status[i] + value;
  2324. if (new_value != *status[i]) {
  2325. *status[i] = new_value;
  2326. clif_updatestatus(sd, SP_STR + i);
  2327. clif_updatestatus(sd, SP_USTR + i);
  2328. count++;
  2329. }
  2330. }
  2331. if (count > 0) { // if at least 1 stat modified
  2332. status_calc_pc(sd, SCO_FORCE);
  2333. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2334. } else {
  2335. if (value < 0)
  2336. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2337. else
  2338. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2339. return -1;
  2340. }
  2341. return 0;
  2342. }
  2343. /*==========================================
  2344. *
  2345. *------------------------------------------*/
  2346. ACMD_FUNC(guildlevelup) {
  2347. int level = 0;
  2348. short added_level;
  2349. struct guild *guild_info;
  2350. nullpo_retr(-1, sd);
  2351. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2352. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2353. return -1;
  2354. }
  2355. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2356. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2357. return -1;
  2358. }
  2359. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2360. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2361. // return -1;
  2362. //}
  2363. added_level = (short)level;
  2364. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2365. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2366. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2367. added_level = 1 - guild_info->guild_lv;
  2368. if (added_level != 0) {
  2369. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2370. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2371. } else {
  2372. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2373. return -1;
  2374. }
  2375. return 0;
  2376. }
  2377. /*==========================================
  2378. *
  2379. *------------------------------------------*/
  2380. ACMD_FUNC(makeegg) {
  2381. struct item_data *item_data;
  2382. int id;
  2383. struct s_pet_db* pet;
  2384. nullpo_retr(-1, sd);
  2385. if (!message || !*message) {
  2386. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2387. return -1;
  2388. }
  2389. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2390. id = item_data->nameid;
  2391. else
  2392. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2393. ;
  2394. else
  2395. id = atoi(message);
  2396. pet = pet_db(id);
  2397. if (!pet)
  2398. pet = pet_db_search(id, PET_EGG);
  2399. if (pet != nullptr) {
  2400. sd->catch_target_class = pet->class_;
  2401. intif_create_pet(sd->status.account_id, sd->status.char_id, pet->class_, mob_db(pet->class_)->lv, pet->EggID, 0, pet->intimate, 100, 0, 1, pet->jname);
  2402. } else {
  2403. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2404. return -1;
  2405. }
  2406. return 0;
  2407. }
  2408. /*==========================================
  2409. *
  2410. *------------------------------------------*/
  2411. ACMD_FUNC(hatch) {
  2412. nullpo_retr(-1, sd);
  2413. if (sd->status.pet_id <= 0)
  2414. clif_sendegg(sd);
  2415. else {
  2416. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2417. return -1;
  2418. }
  2419. return 0;
  2420. }
  2421. /*==========================================
  2422. *
  2423. *------------------------------------------*/
  2424. ACMD_FUNC(petfriendly) {
  2425. int friendly;
  2426. struct pet_data *pd;
  2427. nullpo_retr(-1, sd);
  2428. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2429. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2430. return -1;
  2431. }
  2432. pd = sd->pd;
  2433. if (!pd) {
  2434. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2435. return -1;
  2436. }
  2437. if (friendly < 0 || friendly > 1000)
  2438. {
  2439. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2440. return -1;
  2441. }
  2442. if (friendly == pd->pet.intimate) {
  2443. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2444. return -1;
  2445. }
  2446. pet_set_intimate(pd, friendly);
  2447. clif_send_petstatus(sd);
  2448. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2449. return 0;
  2450. }
  2451. /*==========================================
  2452. *
  2453. *------------------------------------------*/
  2454. ACMD_FUNC(pethungry)
  2455. {
  2456. int hungry;
  2457. struct pet_data *pd;
  2458. nullpo_retr(-1, sd);
  2459. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2460. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2461. return -1;
  2462. }
  2463. pd = sd->pd;
  2464. if (!sd->status.pet_id || !pd) {
  2465. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2466. return -1;
  2467. }
  2468. if (hungry < 0 || hungry > 100) {
  2469. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2470. return -1;
  2471. }
  2472. if (hungry == pd->pet.hungry) {
  2473. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2474. return -1;
  2475. }
  2476. pd->pet.hungry = hungry;
  2477. clif_send_petstatus(sd);
  2478. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2479. return 0;
  2480. }
  2481. /*==========================================
  2482. *
  2483. *------------------------------------------*/
  2484. ACMD_FUNC(petrename)
  2485. {
  2486. struct pet_data *pd;
  2487. nullpo_retr(-1, sd);
  2488. if (!sd->status.pet_id || !sd->pd) {
  2489. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2490. return -1;
  2491. }
  2492. pd = sd->pd;
  2493. if (!pd->pet.rename_flag) {
  2494. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2495. return -1;
  2496. }
  2497. pd->pet.rename_flag = 0;
  2498. intif_save_petdata(sd->status.account_id, &pd->pet);
  2499. clif_send_petstatus(sd);
  2500. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2501. return 0;
  2502. }
  2503. /*==========================================
  2504. *
  2505. *------------------------------------------*/
  2506. ACMD_FUNC(recall) {
  2507. struct map_session_data *pl_sd = NULL;
  2508. nullpo_retr(-1, sd);
  2509. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2510. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2511. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2512. return -1;
  2513. }
  2514. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2515. {
  2516. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2517. return -1;
  2518. }
  2519. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2520. {
  2521. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2522. return -1;
  2523. }
  2524. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2525. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2526. return -1;
  2527. }
  2528. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2529. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2530. return -1;
  2531. }
  2532. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2533. return -1;
  2534. }
  2535. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2536. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2537. return -1;
  2538. }
  2539. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2540. clif_displaymessage(fd, atcmd_output);
  2541. return 0;
  2542. }
  2543. /*==========================================
  2544. * charblock command (usage: charblock <player_name>)
  2545. * This command do a definitiv ban on a player
  2546. *------------------------------------------*/
  2547. ACMD_FUNC(char_block)
  2548. {
  2549. nullpo_retr(-1, sd);
  2550. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2551. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2552. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2553. clif_displaymessage(fd, atcmd_output);
  2554. return -1;
  2555. }
  2556. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2557. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2558. clif_displaymessage(fd, atcmd_output);
  2559. return 0;
  2560. }
  2561. /*==========================================
  2562. * accountban command (usage: ban <%time> <player_name>)
  2563. * charban command (usage: charban <%time> <player_name>)
  2564. * %time see common/timer.cpp::solve_time()
  2565. *------------------------------------------*/
  2566. ACMD_FUNC(char_ban)
  2567. {
  2568. char *modif_p, output[CHAT_SIZE_MAX];
  2569. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2570. enum chrif_req_op bantype;
  2571. nullpo_retr(-1, sd);
  2572. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2573. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2574. parent_cmd = atcommand_checkalias(command+1);
  2575. if (strcmpi(parent_cmd,"charban") == 0)
  2576. bantype = CHRIF_OP_BAN;
  2577. else if (strcmpi(parent_cmd,"ban") == 0)
  2578. bantype = CHRIF_OP_LOGIN_BAN;
  2579. else
  2580. return -1;
  2581. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2582. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2583. clif_displaymessage(fd, output);
  2584. return -1;
  2585. }
  2586. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2587. modif_p = atcmd_output;
  2588. timediff = (int32)solve_time(modif_p); //discard seconds
  2589. if (timediff == 0) { //allow negative ?
  2590. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2591. clif_displaymessage(fd, output);
  2592. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  2593. return -1;
  2594. }
  2595. if( timediff < 0 && (
  2596. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2597. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2598. ))
  2599. {
  2600. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2601. return -1;
  2602. }
  2603. if (bantype == CHRIF_OP_BAN)
  2604. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2605. else
  2606. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2607. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2608. clif_displaymessage(fd, output);
  2609. return 0;
  2610. }
  2611. /*==========================================
  2612. * charunblock command (usage: charunblock <player_name>)
  2613. *------------------------------------------*/
  2614. ACMD_FUNC(char_unblock)
  2615. {
  2616. nullpo_retr(-1, sd);
  2617. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2618. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2619. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2620. clif_displaymessage(fd, atcmd_output);
  2621. return -1;
  2622. }
  2623. // send answer to login server via char-server
  2624. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2625. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2626. clif_displaymessage(fd, atcmd_output);
  2627. return 0;
  2628. }
  2629. /*==========================================
  2630. * acc unban command (usage: unban <player_name>)
  2631. * char unban command (usage: charunban <player_name>)
  2632. *------------------------------------------*/
  2633. ACMD_FUNC(char_unban){
  2634. enum chrif_req_op unbantype;
  2635. nullpo_retr(-1, sd);
  2636. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2637. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2638. parent_cmd = atcommand_checkalias(command+1);
  2639. if (strcmpi(parent_cmd,"charunban") == 0)
  2640. unbantype = CHRIF_OP_UNBAN;
  2641. else if (strcmpi(parent_cmd,"unban") == 0)
  2642. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2643. else
  2644. return -1;
  2645. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2646. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2647. clif_displaymessage(fd, atcmd_output);
  2648. return -1;
  2649. }
  2650. if (unbantype == CHRIF_OP_UNBAN)
  2651. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2652. else
  2653. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2654. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2655. clif_displaymessage(fd, atcmd_output);
  2656. return 0;
  2657. }
  2658. /*==========================================
  2659. *
  2660. *------------------------------------------*/
  2661. ACMD_FUNC(night)
  2662. {
  2663. nullpo_retr(-1, sd);
  2664. if (night_flag != 1) {
  2665. map_night_timer(night_timer_tid, 0, 0, 1);
  2666. } else {
  2667. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2668. return -1;
  2669. }
  2670. return 0;
  2671. }
  2672. /*==========================================
  2673. *
  2674. *------------------------------------------*/
  2675. ACMD_FUNC(day)
  2676. {
  2677. nullpo_retr(-1, sd);
  2678. if (night_flag != 0) {
  2679. map_day_timer(day_timer_tid, 0, 0, 1);
  2680. } else {
  2681. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2682. return -1;
  2683. }
  2684. return 0;
  2685. }
  2686. /*==========================================
  2687. *
  2688. *------------------------------------------*/
  2689. ACMD_FUNC(doom)
  2690. {
  2691. struct map_session_data* pl_sd;
  2692. struct s_mapiterator* iter;
  2693. nullpo_retr(-1, sd);
  2694. iter = mapit_getallusers();
  2695. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2696. {
  2697. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2698. {
  2699. status_kill(&pl_sd->bl);
  2700. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2701. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2702. }
  2703. }
  2704. mapit_free(iter);
  2705. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2706. return 0;
  2707. }
  2708. /*==========================================
  2709. *
  2710. *------------------------------------------*/
  2711. ACMD_FUNC(doommap)
  2712. {
  2713. struct map_session_data* pl_sd;
  2714. struct s_mapiterator* iter;
  2715. nullpo_retr(-1, sd);
  2716. iter = mapit_getallusers();
  2717. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2718. {
  2719. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2720. {
  2721. status_kill(&pl_sd->bl);
  2722. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2723. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2724. }
  2725. }
  2726. mapit_free(iter);
  2727. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2728. return 0;
  2729. }
  2730. /*==========================================
  2731. *
  2732. *------------------------------------------*/
  2733. static void atcommand_raise_sub(struct map_session_data* sd) {
  2734. status_revive(&sd->bl, 100, 100);
  2735. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2736. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2737. }
  2738. /*==========================================
  2739. *
  2740. *------------------------------------------*/
  2741. ACMD_FUNC(raise)
  2742. {
  2743. struct map_session_data* pl_sd;
  2744. struct s_mapiterator* iter;
  2745. nullpo_retr(-1, sd);
  2746. iter = mapit_getallusers();
  2747. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2748. if( pc_isdead(pl_sd) )
  2749. atcommand_raise_sub(pl_sd);
  2750. mapit_free(iter);
  2751. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2752. return 0;
  2753. }
  2754. /*==========================================
  2755. *
  2756. *------------------------------------------*/
  2757. ACMD_FUNC(raisemap)
  2758. {
  2759. struct map_session_data* pl_sd;
  2760. struct s_mapiterator* iter;
  2761. nullpo_retr(-1, sd);
  2762. iter = mapit_getallusers();
  2763. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2764. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2765. atcommand_raise_sub(pl_sd);
  2766. mapit_free(iter);
  2767. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2768. return 0;
  2769. }
  2770. /*==========================================
  2771. *
  2772. *------------------------------------------*/
  2773. ACMD_FUNC(kick)
  2774. {
  2775. struct map_session_data *pl_sd;
  2776. nullpo_retr(-1, sd);
  2777. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2778. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2779. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2780. return -1;
  2781. }
  2782. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2783. {
  2784. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2785. return -1;
  2786. }
  2787. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2788. {
  2789. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2790. return -1;
  2791. }
  2792. clif_GM_kick(sd, pl_sd);
  2793. return 0;
  2794. }
  2795. /*==========================================
  2796. *
  2797. *------------------------------------------*/
  2798. ACMD_FUNC(kickall)
  2799. {
  2800. struct map_session_data* pl_sd;
  2801. struct s_mapiterator* iter;
  2802. nullpo_retr(-1, sd);
  2803. iter = mapit_getallusers();
  2804. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2805. {
  2806. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2807. if (sd->status.account_id != pl_sd->status.account_id)
  2808. clif_GM_kick(NULL, pl_sd);
  2809. }
  2810. }
  2811. mapit_free(iter);
  2812. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2813. return 0;
  2814. }
  2815. /*==========================================
  2816. *
  2817. *------------------------------------------*/
  2818. ACMD_FUNC(allskill)
  2819. {
  2820. nullpo_retr(-1, sd);
  2821. pc_allskillup(sd); // all skills
  2822. sd->status.skill_point = 0; // 0 skill points
  2823. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2824. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2825. return 0;
  2826. }
  2827. /*==========================================
  2828. *
  2829. *------------------------------------------*/
  2830. ACMD_FUNC(questskill)
  2831. {
  2832. uint16 skill_id;
  2833. nullpo_retr(-1, sd);
  2834. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2835. {// also send a list of skills applicable to this command
  2836. const char* text;
  2837. // attempt to find the text corresponding to this command
  2838. text = atcommand_help_string( command );
  2839. // send the error message as always
  2840. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2841. if( text )
  2842. {// send the skill ID list associated with this command
  2843. clif_displaymessage( fd, text );
  2844. }
  2845. return -1;
  2846. }
  2847. if (skill_id >= MAX_SKILL_ID) {
  2848. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2849. return -1;
  2850. }
  2851. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2852. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2853. return -1;
  2854. }
  2855. if (pc_checkskill(sd, skill_id) > 0) {
  2856. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2857. return -1;
  2858. }
  2859. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2860. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2861. return 0;
  2862. }
  2863. /*==========================================
  2864. *
  2865. *------------------------------------------*/
  2866. ACMD_FUNC(lostskill)
  2867. {
  2868. uint16 skill_id = 0, sk_idx = 0;
  2869. nullpo_retr(-1, sd);
  2870. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2871. {// also send a list of skills applicable to this command
  2872. const char* text;
  2873. // attempt to find the text corresponding to this command
  2874. text = atcommand_help_string( command );
  2875. // send the error message as always
  2876. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2877. if( text )
  2878. {// send the skill ID list associated with this command
  2879. clif_displaymessage( fd, text );
  2880. }
  2881. return -1;
  2882. }
  2883. if (!(sk_idx = skill_get_index(skill_id))) {
  2884. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2885. return -1;
  2886. }
  2887. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2888. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2889. return -1;
  2890. }
  2891. if (pc_checkskill(sd, skill_id) == 0) {
  2892. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2893. return -1;
  2894. }
  2895. sd->status.skill[sk_idx].lv = 0;
  2896. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2897. clif_deleteskill(sd,skill_id);
  2898. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2899. return 0;
  2900. }
  2901. /*==========================================
  2902. *
  2903. *------------------------------------------*/
  2904. ACMD_FUNC(spiritball)
  2905. {
  2906. uint32 max_spiritballs;
  2907. int number;
  2908. nullpo_retr(-1, sd);
  2909. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2910. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2911. {
  2912. char msg[CHAT_SIZE_MAX];
  2913. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2914. clif_displaymessage(fd, msg);
  2915. return -1;
  2916. }
  2917. if( sd->spiritball > 0 )
  2918. pc_delspiritball(sd, sd->spiritball, 1);
  2919. sd->spiritball = number;
  2920. clif_spiritball(&sd->bl);
  2921. // no message, player can look the difference
  2922. return 0;
  2923. }
  2924. /*==========================================
  2925. *
  2926. *------------------------------------------*/
  2927. ACMD_FUNC(party)
  2928. {
  2929. char party[NAME_LENGTH];
  2930. nullpo_retr(-1, sd);
  2931. memset(party, '\0', sizeof(party));
  2932. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2933. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2934. return -1;
  2935. }
  2936. party_create(sd, party, 0, 0);
  2937. return 0;
  2938. }
  2939. /*==========================================
  2940. *
  2941. *------------------------------------------*/
  2942. ACMD_FUNC(guild)
  2943. {
  2944. char guild[NAME_LENGTH];
  2945. int prev;
  2946. nullpo_retr(-1, sd);
  2947. memset(guild, '\0', sizeof(guild));
  2948. if (sd->clan) {
  2949. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  2950. return -1;
  2951. }
  2952. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2953. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2954. return -1;
  2955. }
  2956. prev = battle_config.guild_emperium_check;
  2957. battle_config.guild_emperium_check = 0;
  2958. guild_create(sd, guild);
  2959. battle_config.guild_emperium_check = prev;
  2960. return 0;
  2961. }
  2962. ACMD_FUNC(breakguild)
  2963. {
  2964. nullpo_retr(-1, sd);
  2965. if (sd->status.guild_id) { // Check if the player has a guild
  2966. struct guild *g;
  2967. g = sd->guild; // Search the guild
  2968. if (g) { // Check if guild was found
  2969. if (sd->state.gmaster_flag) { // Check if player is guild master
  2970. int ret = 0;
  2971. ret = guild_break(sd, g->name); // Break guild
  2972. if (ret) { // Check if anything went wrong
  2973. return 0; // Guild was broken
  2974. } else {
  2975. return -1; // Something went wrong
  2976. }
  2977. } else { // Not guild master
  2978. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2979. return -1;
  2980. }
  2981. } else { // Guild was not found. HOW?
  2982. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2983. return -1;
  2984. }
  2985. } else { // Player does not have a guild
  2986. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2987. return -1;
  2988. }
  2989. }
  2990. /**
  2991. * Start WoE:FE
  2992. */
  2993. ACMD_FUNC(agitstart)
  2994. {
  2995. nullpo_retr(-1, sd);
  2996. if( guild_agit_start() ){
  2997. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2998. return 0;
  2999. }else{
  3000. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3001. return -1;
  3002. }
  3003. }
  3004. /**
  3005. * Start WoE:SE
  3006. */
  3007. ACMD_FUNC(agitstart2)
  3008. {
  3009. nullpo_retr(-1, sd);
  3010. if( guild_agit2_start() ){
  3011. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3012. return 0;
  3013. }else{
  3014. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3015. return -1;
  3016. }
  3017. }
  3018. /**
  3019. * Start WoE:TE
  3020. */
  3021. ACMD_FUNC(agitstart3)
  3022. {
  3023. nullpo_retr(-1, sd);
  3024. if( guild_agit3_start() ){
  3025. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3026. return 0;
  3027. }else{
  3028. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3029. return -1;
  3030. }
  3031. }
  3032. /**
  3033. * End WoE:FE
  3034. */
  3035. ACMD_FUNC(agitend)
  3036. {
  3037. nullpo_retr(-1, sd);
  3038. if( guild_agit_end() ){
  3039. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3040. return 0;
  3041. }else{
  3042. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3043. return -1;
  3044. }
  3045. }
  3046. /**
  3047. * End WoE:SE
  3048. */
  3049. ACMD_FUNC(agitend2)
  3050. {
  3051. nullpo_retr(-1, sd);
  3052. if( guild_agit2_end() ){
  3053. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3054. return 0;
  3055. }else{
  3056. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3057. return -1;
  3058. }
  3059. }
  3060. /**
  3061. * End WoE:TE
  3062. */
  3063. ACMD_FUNC(agitend3)
  3064. {
  3065. nullpo_retr(-1, sd);
  3066. if( guild_agit3_end() ){
  3067. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3068. return 0;
  3069. }else{
  3070. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3071. return -1;
  3072. }
  3073. }
  3074. /*==========================================
  3075. * @mapexit - shuts down the map server
  3076. *------------------------------------------*/
  3077. ACMD_FUNC(mapexit)
  3078. {
  3079. nullpo_retr(-1, sd);
  3080. do_shutdown();
  3081. return 0;
  3082. }
  3083. /*==========================================
  3084. * idsearch <part_of_name>: revrited by [Yor]
  3085. *------------------------------------------*/
  3086. ACMD_FUNC(idsearch)
  3087. {
  3088. char item_name[100];
  3089. unsigned int i, match;
  3090. struct item_data *item_array[MAX_SEARCH];
  3091. nullpo_retr(-1, sd);
  3092. memset(item_name, '\0', sizeof(item_name));
  3093. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3094. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3095. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3096. return -1;
  3097. }
  3098. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3099. clif_displaymessage(fd, atcmd_output);
  3100. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3101. if (match == MAX_SEARCH) {
  3102. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3103. clif_displaymessage(fd, atcmd_output);
  3104. }
  3105. for(i = 0; i < match; i++) {
  3106. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3107. clif_displaymessage(fd, atcmd_output);
  3108. }
  3109. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3110. clif_displaymessage(fd, atcmd_output);
  3111. return 0;
  3112. }
  3113. /*==========================================
  3114. * Recall All Characters Online To Your Location
  3115. *------------------------------------------*/
  3116. ACMD_FUNC(recallall)
  3117. {
  3118. struct map_session_data* pl_sd;
  3119. struct s_mapiterator* iter;
  3120. int count;
  3121. nullpo_retr(-1, sd);
  3122. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3123. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3124. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3125. return -1;
  3126. }
  3127. count = 0;
  3128. iter = mapit_getallusers();
  3129. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3130. {
  3131. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3132. {
  3133. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3134. continue; // Don't waste time warping the character to the same place.
  3135. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3136. count++;
  3137. else {
  3138. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3139. count++;
  3140. }
  3141. }
  3142. }
  3143. }
  3144. mapit_free(iter);
  3145. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3146. if (count) {
  3147. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3148. clif_displaymessage(fd, atcmd_output);
  3149. }
  3150. return 0;
  3151. }
  3152. /*==========================================
  3153. * Recall online characters of a guild to your location
  3154. *------------------------------------------*/
  3155. ACMD_FUNC(guildrecall)
  3156. {
  3157. struct map_session_data* pl_sd;
  3158. struct s_mapiterator* iter;
  3159. int count;
  3160. char guild_name[NAME_LENGTH];
  3161. struct guild *g;
  3162. nullpo_retr(-1, sd);
  3163. memset(guild_name, '\0', sizeof(guild_name));
  3164. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3165. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3166. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3167. return -1;
  3168. }
  3169. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3170. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3171. return -1;
  3172. }
  3173. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3174. (g = guild_search(atoi(message))) == NULL)
  3175. {
  3176. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3177. return -1;
  3178. }
  3179. count = 0;
  3180. iter = mapit_getallusers();
  3181. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3182. {
  3183. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3184. {
  3185. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3186. continue; // Skip GMs greater than you... or chars already on the cell
  3187. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3188. count++;
  3189. else{
  3190. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3191. count++;
  3192. }
  3193. }
  3194. }
  3195. }
  3196. mapit_free(iter);
  3197. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3198. clif_displaymessage(fd, atcmd_output);
  3199. if (count) {
  3200. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3201. clif_displaymessage(fd, atcmd_output);
  3202. }
  3203. return 0;
  3204. }
  3205. /*==========================================
  3206. * Recall online characters of a party to your location
  3207. *------------------------------------------*/
  3208. ACMD_FUNC(partyrecall)
  3209. {
  3210. struct map_session_data* pl_sd;
  3211. struct s_mapiterator* iter;
  3212. char party_name[NAME_LENGTH];
  3213. struct party_data *p;
  3214. int count;
  3215. nullpo_retr(-1, sd);
  3216. memset(party_name, '\0', sizeof(party_name));
  3217. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3218. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3219. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3220. return -1;
  3221. }
  3222. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3223. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3224. return -1;
  3225. }
  3226. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3227. (p = party_search(atoi(message))) == NULL)
  3228. {
  3229. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3230. return -1;
  3231. }
  3232. count = 0;
  3233. iter = mapit_getallusers();
  3234. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3235. {
  3236. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3237. {
  3238. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3239. continue; // Skip GMs greater than you... or chars already on the cell
  3240. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3241. count++;
  3242. else{
  3243. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3244. count++;
  3245. }
  3246. }
  3247. }
  3248. }
  3249. mapit_free(iter);
  3250. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3251. clif_displaymessage(fd, atcmd_output);
  3252. if (count) {
  3253. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3254. clif_displaymessage(fd, atcmd_output);
  3255. }
  3256. return 0;
  3257. }
  3258. /*==========================================
  3259. *
  3260. *------------------------------------------*/
  3261. void atcommand_doload();
  3262. ACMD_FUNC(reload) {
  3263. nullpo_retr(-1, sd);
  3264. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3265. const char* text;
  3266. text = atcommand_help_string( command );
  3267. if(text)
  3268. clif_displaymessage( fd, text );
  3269. return -1;
  3270. }
  3271. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3272. itemdb_reload();
  3273. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3274. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3275. mob_reload();
  3276. read_petdb();
  3277. hom_reload();
  3278. mercenary_readdb();
  3279. mercenary_read_skilldb();
  3280. reload_elementaldb();
  3281. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3282. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3283. skill_reload();
  3284. hom_reload_skill();
  3285. reload_elemental_skilldb();
  3286. mercenary_read_skilldb();
  3287. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3288. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3289. config_t run_test;
  3290. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3291. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3292. return -1;
  3293. }
  3294. config_destroy(&run_test);
  3295. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3296. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3297. return -1;
  3298. }
  3299. config_destroy(&run_test);
  3300. atcommand_doload();
  3301. pc_groups_reload();
  3302. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3303. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3304. struct Battle_Config prev_config;
  3305. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3306. battle_config_read(BATTLE_CONF_FILENAME);
  3307. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3308. || prev_config.item_rate_common != battle_config.item_rate_common
  3309. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3310. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3311. || prev_config.item_rate_card != battle_config.item_rate_card
  3312. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3313. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3314. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3315. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3316. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3317. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3318. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3319. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3320. || prev_config.item_rate_use != battle_config.item_rate_use
  3321. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3322. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3323. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3324. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3325. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3326. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3327. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3328. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3329. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3330. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3331. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3332. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3333. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3334. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3335. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3336. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3337. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3338. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3339. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3340. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3341. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3342. )
  3343. { // Exp or Drop rates changed.
  3344. mob_reload(); //Needed as well so rate changes take effect.
  3345. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3346. }
  3347. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3348. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3349. status_readdb();
  3350. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3351. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3352. pc_readdb();
  3353. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3354. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3355. pc_read_motd();
  3356. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3357. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3358. struct s_mapiterator* iter;
  3359. struct map_session_data* pl_sd;
  3360. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3361. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3362. iter = mapit_getallusers();
  3363. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3364. pc_close_npc(pl_sd,2);
  3365. mapit_free(iter);
  3366. flush_fifos();
  3367. map_reloadnpc(true); // reload config files seeking for npcs
  3368. script_reload();
  3369. npc_reload();
  3370. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3371. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3372. map_msg_reload();
  3373. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3374. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3375. do_reload_quest();
  3376. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3377. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3378. instance_reload();
  3379. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3380. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3381. achievement_db_reload();
  3382. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3383. }
  3384. return 0;
  3385. }
  3386. /*==========================================
  3387. * @partysharelvl <share_range> [Akinari]
  3388. * Updates char server party share level range in runtime
  3389. * Temporary - Permanent update in inter_athena.conf
  3390. *------------------------------------------*/
  3391. ACMD_FUNC(partysharelvl) {
  3392. unsigned int share_lvl;
  3393. nullpo_retr(-1, sd);
  3394. if(!message || !*message) {
  3395. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3396. return -1;
  3397. } else {
  3398. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3399. }
  3400. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3401. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3402. else //Char server offline
  3403. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3404. return 0;
  3405. }
  3406. /*==========================================
  3407. * @mapinfo [0-3] <map name> by MC_Cameri
  3408. * => Shows information about the map [map name]
  3409. * 0 = no additional information
  3410. * 1 = Show users in that map and their location
  3411. * 2 = Shows NPCs in that map
  3412. * 3 = Shows the chats in that map
  3413. *------------------------------------------*/
  3414. ACMD_FUNC(mapinfo) {
  3415. struct map_session_data* pl_sd;
  3416. struct s_mapiterator* iter;
  3417. struct chat_data *cd = NULL;
  3418. char direction[12];
  3419. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3420. unsigned short m_index;
  3421. char mapname[MAP_NAME_LENGTH];
  3422. nullpo_retr(-1, sd);
  3423. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3424. memset(mapname, '\0', sizeof(mapname));
  3425. memset(direction, '\0', sizeof(direction));
  3426. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3427. if (list < 0 || list > 3) {
  3428. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3429. return -1;
  3430. }
  3431. if (mapname[0] == '\0') {
  3432. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3433. m_id = map_mapindex2mapid(sd->mapindex);
  3434. } else {
  3435. m_id = map_mapname2mapid(mapname);
  3436. }
  3437. if (m_id < 0) {
  3438. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3439. return -1;
  3440. }
  3441. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3442. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3443. // count chats (for initial message)
  3444. chat_num = 0;
  3445. iter = mapit_getallusers();
  3446. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3447. if( pl_sd->mapindex == m_index ) {
  3448. if( pl_sd->state.vending )
  3449. vend_num++;
  3450. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3451. chat_num++;
  3452. }
  3453. }
  3454. mapit_free(iter);
  3455. sprintf(atcmd_output, msg_txt(sd,1040), mapname, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3456. clif_displaymessage(fd, atcmd_output);
  3457. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3458. if (map[m_id].flag.town)
  3459. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3460. if (map[m_id].flag.restricted){
  3461. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3462. clif_displaymessage(fd, atcmd_output);
  3463. }
  3464. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3465. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3466. else
  3467. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3468. if (map[m_id].flag.battleground){
  3469. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3470. clif_displaymessage(fd, atcmd_output);
  3471. }
  3472. /* Skill damage adjustment info [Cydh] */
  3473. #ifdef ADJUST_SKILL_DAMAGE
  3474. if (map[m_id].flag.skill_damage) {
  3475. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3476. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3477. ,map[m_id].adjust.damage.pc
  3478. ,map[m_id].adjust.damage.mob
  3479. ,map[m_id].adjust.damage.boss
  3480. ,map[m_id].adjust.damage.other
  3481. ,map[m_id].adjust.damage.caster);
  3482. clif_displaymessage(fd, atcmd_output);
  3483. if (map[m_id].skill_damage.count) {
  3484. uint8 j;
  3485. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3486. for (j = 0; j < map[m_id].skill_damage.count; j++) {
  3487. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3488. ,j+1
  3489. ,skill_get_name(map[m_id].skill_damage.entries[j]->skill_id)
  3490. ,map[m_id].skill_damage.entries[j]->pc
  3491. ,map[m_id].skill_damage.entries[j]->mob
  3492. ,map[m_id].skill_damage.entries[j]->boss
  3493. ,map[m_id].skill_damage.entries[j]->other
  3494. ,map[m_id].skill_damage.entries[j]->caster);
  3495. clif_displaymessage(fd,atcmd_output);
  3496. }
  3497. }
  3498. }
  3499. #endif
  3500. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3501. if (map[m_id].flag.pvp)
  3502. strcat(atcmd_output, " Pvp ON |");
  3503. if (map[m_id].flag.pvp_noguild)
  3504. strcat(atcmd_output, " NoGuild |");
  3505. if (map[m_id].flag.pvp_noparty)
  3506. strcat(atcmd_output, " NoParty |");
  3507. if (map[m_id].flag.pvp_nightmaredrop)
  3508. strcat(atcmd_output, " NightmareDrop |");
  3509. if (map[m_id].flag.pvp_nocalcrank)
  3510. strcat(atcmd_output, " NoCalcRank |");
  3511. clif_displaymessage(fd, atcmd_output);
  3512. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3513. if (map[m_id].flag.gvg)
  3514. strcat(atcmd_output, " GvG ON |");
  3515. if (map[m_id].flag.gvg_dungeon)
  3516. strcat(atcmd_output, " GvG Dungeon |");
  3517. if (map[m_id].flag.gvg_castle)
  3518. strcat(atcmd_output, " GvG Castle |");
  3519. if (map[m_id].flag.gvg_te)
  3520. strcat(atcmd_output, " GvG TE |");
  3521. if (map[m_id].flag.gvg_te_castle)
  3522. strcat(atcmd_output, " GvG TE Castle |");
  3523. if (map[m_id].flag.gvg_noparty)
  3524. strcat(atcmd_output, " NoParty |");
  3525. clif_displaymessage(fd, atcmd_output);
  3526. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3527. if (map[m_id].flag.noteleport)
  3528. strcat(atcmd_output, " NoTeleport |");
  3529. if (map[m_id].flag.monster_noteleport)
  3530. strcat(atcmd_output, " Monster NoTeleport |");
  3531. if (map[m_id].flag.nowarp)
  3532. strcat(atcmd_output, " NoWarp |");
  3533. if (map[m_id].flag.nowarpto)
  3534. strcat(atcmd_output, " NoWarpTo |");
  3535. if (map[m_id].flag.noreturn)
  3536. strcat(atcmd_output, " NoReturn |");
  3537. if (map[m_id].flag.nogo)
  3538. strcat(atcmd_output, " NoGo |"); //
  3539. if (map[m_id].flag.nomemo)
  3540. strcat(atcmd_output, " NoMemo |");
  3541. clif_displaymessage(fd, atcmd_output);
  3542. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3543. (map[m_id].flag.noexppenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map[m_id].flag.nozenypenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3544. clif_displaymessage(fd, atcmd_output);
  3545. if (map[m_id].flag.nosave) {
  3546. if (!map[m_id].save.map)
  3547. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3548. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3549. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3550. clif_displaymessage(fd, atcmd_output);
  3551. }
  3552. else {
  3553. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3554. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3555. clif_displaymessage(fd, atcmd_output);
  3556. }
  3557. }
  3558. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3559. if (map[m_id].flag.snow)
  3560. strcat(atcmd_output, " Snow |");
  3561. if (map[m_id].flag.fog)
  3562. strcat(atcmd_output, " Fog |");
  3563. if (map[m_id].flag.sakura)
  3564. strcat(atcmd_output, " Sakura |");
  3565. if (map[m_id].flag.clouds)
  3566. strcat(atcmd_output, " Clouds |");
  3567. if (map[m_id].flag.clouds2)
  3568. strcat(atcmd_output, " Clouds2 |");
  3569. if (map[m_id].flag.fireworks)
  3570. strcat(atcmd_output, " Fireworks |");
  3571. if (map[m_id].flag.leaves)
  3572. strcat(atcmd_output, " Leaves |");
  3573. if (map[m_id].flag.nightenabled)
  3574. strcat(atcmd_output, " Displays Night |");
  3575. clif_displaymessage(fd, atcmd_output);
  3576. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3577. if (map[m_id].flag.nobranch)
  3578. strcat(atcmd_output, " NoBranch |");
  3579. if (map[m_id].flag.notrade)
  3580. strcat(atcmd_output, " NoTrade |");
  3581. if (map[m_id].flag.novending)
  3582. strcat(atcmd_output, " NoVending |");
  3583. if (map[m_id].flag.nodrop)
  3584. strcat(atcmd_output, " NoDrop |");
  3585. if (map[m_id].flag.noskill)
  3586. strcat(atcmd_output, " NoSkill |");
  3587. if (map[m_id].flag.noicewall)
  3588. strcat(atcmd_output, " NoIcewall |");
  3589. if (map[m_id].flag.allowks)
  3590. strcat(atcmd_output, " AllowKS |");
  3591. if (map[m_id].flag.reset)
  3592. strcat(atcmd_output, " Reset |");
  3593. if (map[m_id].flag.hidemobhpbar)
  3594. strcat(atcmd_output, " HideMobHPBar |");
  3595. clif_displaymessage(fd, atcmd_output);
  3596. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3597. if (map[m_id].nocommand)
  3598. strcat(atcmd_output, " NoCommand |");
  3599. if (map[m_id].flag.nobaseexp)
  3600. strcat(atcmd_output, " NoBaseEXP |");
  3601. if (map[m_id].flag.nojobexp)
  3602. strcat(atcmd_output, " NoJobEXP |");
  3603. if (map[m_id].flag.nomobloot)
  3604. strcat(atcmd_output, " NoMobLoot |");
  3605. if (map[m_id].flag.nomvploot)
  3606. strcat(atcmd_output, " NoMVPLoot |");
  3607. if (map[m_id].flag.partylock)
  3608. strcat(atcmd_output, " PartyLock |");
  3609. if (map[m_id].flag.guildlock)
  3610. strcat(atcmd_output, " GuildLock |");
  3611. if (map[m_id].flag.loadevent)
  3612. strcat(atcmd_output, " Loadevent |");
  3613. if (map[m_id].flag.chmautojoin)
  3614. strcat(atcmd_output, " Chmautojoin |");
  3615. if (map[m_id].flag.nousecart)
  3616. strcat(atcmd_output, " NoUsecart |");
  3617. if (map[m_id].flag.noitemconsumption)
  3618. strcat(atcmd_output, " NoItemConsumption |");
  3619. if (map[m_id].flag.nosumstarmiracle)
  3620. strcat(atcmd_output, " NoSumStarMiracle |");
  3621. if (map[m_id].flag.nomineeffect)
  3622. strcat(atcmd_output, " NoMineEffect |");
  3623. if (map[m_id].flag.nolockon)
  3624. strcat(atcmd_output, " NoLockOn |");
  3625. if (map[m_id].flag.notomb)
  3626. strcat(atcmd_output, " NoTomb |");
  3627. if (map[m_id].flag.nocostume)
  3628. strcat(atcmd_output, " NoCostume |");
  3629. clif_displaymessage(fd, atcmd_output);
  3630. switch (list) {
  3631. case 0:
  3632. // Do nothing. It's list 0, no additional display.
  3633. break;
  3634. case 1:
  3635. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3636. iter = mapit_getallusers();
  3637. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3638. {
  3639. if (pl_sd->mapindex == m_index) {
  3640. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3641. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3642. clif_displaymessage(fd, atcmd_output);
  3643. }
  3644. }
  3645. mapit_free(iter);
  3646. break;
  3647. case 2:
  3648. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3649. for (i = 0; i < map[m_id].npc_num;)
  3650. {
  3651. struct npc_data *nd = map[m_id].npc[i];
  3652. switch(nd->ud.dir) {
  3653. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3654. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3655. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3656. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3657. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3658. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3659. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3660. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3661. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3662. }
  3663. if(strcmp(nd->name,nd->exname) == 0)
  3664. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3665. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3666. else
  3667. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3668. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3669. clif_displaymessage(fd, atcmd_output);
  3670. }
  3671. break;
  3672. case 3:
  3673. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3674. iter = mapit_getallusers();
  3675. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3676. {
  3677. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3678. pl_sd->mapindex == m_index &&
  3679. cd->usersd[0] == pl_sd)
  3680. {
  3681. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3682. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3683. clif_displaymessage(fd, atcmd_output);
  3684. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3685. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3686. clif_displaymessage(fd, atcmd_output);
  3687. }
  3688. }
  3689. mapit_free(iter);
  3690. break;
  3691. default: // normally impossible to arrive here
  3692. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3693. return -1;
  3694. break;
  3695. }
  3696. return 0;
  3697. }
  3698. /*==========================================
  3699. *
  3700. *------------------------------------------*/
  3701. ACMD_FUNC(mount_peco)
  3702. {
  3703. nullpo_retr(-1, sd);
  3704. if (sd->disguise) {
  3705. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3706. return -1;
  3707. }
  3708. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3709. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3710. unsigned int option = OPTION_DRAGON1;
  3711. if( message[0] ) {
  3712. int color = atoi(message);
  3713. option = ( color == 2 ? OPTION_DRAGON2 :
  3714. color == 3 ? OPTION_DRAGON3 :
  3715. color == 4 ? OPTION_DRAGON4 :
  3716. color == 5 ? OPTION_DRAGON5 :
  3717. OPTION_DRAGON1 );
  3718. }
  3719. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3720. pc_setoption(sd, sd->sc.option|option);
  3721. } else {
  3722. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3723. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3724. }
  3725. return 0;
  3726. }
  3727. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3728. if( !pc_isridingwug(sd) ) {
  3729. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3730. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3731. } else {
  3732. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3733. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3734. }
  3735. return 0;
  3736. }
  3737. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3738. if( !pc_ismadogear(sd) ) {
  3739. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3740. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3741. } else {
  3742. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3743. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3744. }
  3745. return 0;
  3746. }
  3747. if (!pc_isriding(sd)) { // if actually no peco
  3748. if (!pc_checkskill(sd, KN_RIDING)) {
  3749. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3750. return -1;
  3751. }
  3752. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3753. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3754. } else {//Dismount
  3755. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3756. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3757. }
  3758. return 0;
  3759. }
  3760. /*==========================================
  3761. *Spy Commands by Syrus22
  3762. *------------------------------------------*/
  3763. ACMD_FUNC(guildspy)
  3764. {
  3765. char guild_name[NAME_LENGTH];
  3766. struct guild *g;
  3767. nullpo_retr(-1, sd);
  3768. memset(guild_name, '\0', sizeof(guild_name));
  3769. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3770. if (!enable_spy)
  3771. {
  3772. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3773. return -1;
  3774. }
  3775. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3776. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3777. return -1;
  3778. }
  3779. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3780. (g = guild_search(atoi(message))) != NULL) {
  3781. if (sd->guildspy == g->guild_id) {
  3782. sd->guildspy = 0;
  3783. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3784. clif_displaymessage(fd, atcmd_output);
  3785. } else {
  3786. sd->guildspy = g->guild_id;
  3787. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3788. clif_displaymessage(fd, atcmd_output);
  3789. }
  3790. } else {
  3791. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3792. return -1;
  3793. }
  3794. return 0;
  3795. }
  3796. /*==========================================
  3797. *
  3798. *------------------------------------------*/
  3799. ACMD_FUNC(partyspy)
  3800. {
  3801. char party_name[NAME_LENGTH];
  3802. struct party_data *p;
  3803. nullpo_retr(-1, sd);
  3804. memset(party_name, '\0', sizeof(party_name));
  3805. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3806. if (!enable_spy)
  3807. {
  3808. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3809. return -1;
  3810. }
  3811. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3812. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3813. return -1;
  3814. }
  3815. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3816. (p = party_search(atoi(message))) != NULL) {
  3817. if (sd->partyspy == p->party.party_id) {
  3818. sd->partyspy = 0;
  3819. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3820. clif_displaymessage(fd, atcmd_output);
  3821. } else {
  3822. sd->partyspy = p->party.party_id;
  3823. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3824. clif_displaymessage(fd, atcmd_output);
  3825. }
  3826. } else {
  3827. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3828. return -1;
  3829. }
  3830. return 0;
  3831. }
  3832. ACMD_FUNC(clanspy){
  3833. char clan_name[NAME_LENGTH];
  3834. struct clan* c;
  3835. nullpo_retr(-1, sd);
  3836. memset(clan_name, '\0', sizeof(clan_name));
  3837. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3838. if( !enable_spy ){
  3839. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  3840. return -1;
  3841. }
  3842. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  3843. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  3844. return -1;
  3845. }
  3846. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  3847. (c = clan_search(atoi(message))) != NULL) {
  3848. if (sd->clanspy == c->id) {
  3849. sd->clanspy = 0;
  3850. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  3851. clif_displaymessage(fd, atcmd_output);
  3852. }
  3853. else {
  3854. sd->clanspy = c->id;
  3855. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  3856. clif_displaymessage(fd, atcmd_output);
  3857. }
  3858. }
  3859. else {
  3860. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  3861. return -1;
  3862. }
  3863. return 0;
  3864. }
  3865. /*==========================================
  3866. * @repairall [Valaris]
  3867. *------------------------------------------*/
  3868. ACMD_FUNC(repairall)
  3869. {
  3870. int count, i;
  3871. nullpo_retr(-1, sd);
  3872. count = 0;
  3873. for (i = 0; i < MAX_INVENTORY; i++) {
  3874. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1) {
  3875. sd->inventory.u.items_inventory[i].attribute = 0;
  3876. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  3877. count++;
  3878. }
  3879. }
  3880. if (count > 0) {
  3881. clif_misceffect(&sd->bl, 3);
  3882. clif_equiplist(sd);
  3883. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3884. } else {
  3885. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3886. return -1;
  3887. }
  3888. return 0;
  3889. }
  3890. /*==========================================
  3891. * @nuke [Valaris]
  3892. *------------------------------------------*/
  3893. ACMD_FUNC(nuke)
  3894. {
  3895. struct map_session_data *pl_sd;
  3896. nullpo_retr(-1, sd);
  3897. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3898. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3899. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3900. return -1;
  3901. }
  3902. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  3903. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3904. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3905. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3906. } else {
  3907. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3908. return -1;
  3909. }
  3910. } else {
  3911. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3912. return -1;
  3913. }
  3914. return 0;
  3915. }
  3916. /*==========================================
  3917. * @tonpc
  3918. *------------------------------------------*/
  3919. ACMD_FUNC(tonpc)
  3920. {
  3921. char npcname[NPC_NAME_LENGTH];
  3922. struct npc_data *nd;
  3923. nullpo_retr(-1, sd);
  3924. memset(npcname, 0, sizeof(npcname));
  3925. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  3926. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3927. return -1;
  3928. }
  3929. if ((nd = npc_name2id(npcname)) != NULL) {
  3930. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  3931. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3932. else
  3933. return -1;
  3934. } else {
  3935. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3936. return -1;
  3937. }
  3938. return 0;
  3939. }
  3940. /*==========================================
  3941. *
  3942. *------------------------------------------*/
  3943. ACMD_FUNC(shownpc)
  3944. {
  3945. char NPCname[NPC_NAME_LENGTH];
  3946. nullpo_retr(-1, sd);
  3947. memset(NPCname, '\0', sizeof(NPCname));
  3948. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3949. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3950. return -1;
  3951. }
  3952. if (npc_name2id(NPCname) != NULL) {
  3953. npc_enable(NPCname, 1);
  3954. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3955. } else {
  3956. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3957. return -1;
  3958. }
  3959. return 0;
  3960. }
  3961. /*==========================================
  3962. *
  3963. *------------------------------------------*/
  3964. ACMD_FUNC(hidenpc)
  3965. {
  3966. char NPCname[NPC_NAME_LENGTH];
  3967. nullpo_retr(-1, sd);
  3968. memset(NPCname, '\0', sizeof(NPCname));
  3969. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3970. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3971. return -1;
  3972. }
  3973. if (npc_name2id(NPCname) == NULL) {
  3974. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3975. return -1;
  3976. }
  3977. npc_enable(NPCname, 0);
  3978. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3979. return 0;
  3980. }
  3981. ACMD_FUNC(loadnpc)
  3982. {
  3983. if (!message || !*message) {
  3984. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3985. return -1;
  3986. }
  3987. if (!npc_addsrcfile(message, true)) {
  3988. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  3989. return -1;
  3990. }
  3991. npc_read_event_script();
  3992. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  3993. return 0;
  3994. }
  3995. ACMD_FUNC(unloadnpc)
  3996. {
  3997. struct npc_data *nd;
  3998. char NPCname[NPC_NAME_LENGTH];
  3999. nullpo_retr(-1, sd);
  4000. memset(NPCname, '\0', sizeof(NPCname));
  4001. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4002. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4003. return -1;
  4004. }
  4005. if ((nd = npc_name2id(NPCname)) == NULL) {
  4006. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4007. return -1;
  4008. }
  4009. npc_unload_duplicates(nd);
  4010. npc_unload(nd,true);
  4011. npc_read_event_script();
  4012. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4013. return 0;
  4014. }
  4015. ACMD_FUNC(reloadnpcfile) {
  4016. if (!message || !*message) {
  4017. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4018. return -1;
  4019. }
  4020. if (npc_unloadfile(message))
  4021. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4022. if (!npc_addsrcfile(message, true)) {
  4023. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4024. return -1;
  4025. }
  4026. npc_read_event_script();
  4027. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4028. return 0;
  4029. }
  4030. /*==========================================
  4031. * time in txt for time command (by [Yor])
  4032. *------------------------------------------*/
  4033. char* txt_time(unsigned int duration)
  4034. {
  4035. int days, hours, minutes, seconds;
  4036. char temp[CHAT_SIZE_MAX];
  4037. static char temp1[CHAT_SIZE_MAX];
  4038. memset(temp, '\0', sizeof(temp));
  4039. memset(temp1, '\0', sizeof(temp1));
  4040. days = duration / (60 * 60 * 24);
  4041. duration = duration - (60 * 60 * 24 * days);
  4042. hours = duration / (60 * 60);
  4043. duration = duration - (60 * 60 * hours);
  4044. minutes = duration / 60;
  4045. seconds = duration - (60 * minutes);
  4046. if (days == 1)
  4047. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4048. else if (days > 1)
  4049. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4050. if (hours == 1)
  4051. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4052. else if (hours > 1)
  4053. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4054. if (minutes < 2)
  4055. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4056. else
  4057. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4058. if (seconds == 1)
  4059. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4060. else if (seconds > 1)
  4061. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4062. return temp1;
  4063. }
  4064. /*==========================================
  4065. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4066. * Calculation management of GM modification (@day/@night GM commands) is done
  4067. *------------------------------------------*/
  4068. ACMD_FUNC(servertime)
  4069. {
  4070. const struct TimerData * timer_data;
  4071. time_t time_server; // variable for number of seconds (used with time() function)
  4072. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4073. char temp[CHAT_SIZE_MAX];
  4074. nullpo_retr(-1, sd);
  4075. memset(temp, '\0', sizeof(temp));
  4076. time(&time_server); // get time in seconds since 1/1/1970
  4077. datetime = localtime(&time_server); // convert seconds in structure
  4078. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4079. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4080. clif_displaymessage(fd, temp);
  4081. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4082. if (night_flag == 0)
  4083. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4084. else
  4085. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4086. } else if (battle_config.night_duration == 0)
  4087. if (night_flag == 1) { // we start with night
  4088. timer_data = get_timer(day_timer_tid);
  4089. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4090. clif_displaymessage(fd, temp);
  4091. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4092. } else
  4093. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4094. else if (battle_config.day_duration == 0)
  4095. if (night_flag == 0) { // we start with day
  4096. timer_data = get_timer(night_timer_tid);
  4097. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4098. clif_displaymessage(fd, temp);
  4099. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4100. } else
  4101. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4102. else {
  4103. const struct TimerData * timer_data2;
  4104. if (night_flag == 0) {
  4105. timer_data = get_timer(night_timer_tid);
  4106. timer_data2 = get_timer(day_timer_tid);
  4107. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4108. clif_displaymessage(fd, temp);
  4109. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4110. sprintf(temp, msg_txt(sd,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.
  4111. else
  4112. sprintf(temp, msg_txt(sd,237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4113. clif_displaymessage(fd, temp);
  4114. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4115. clif_displaymessage(fd, temp);
  4116. } else {
  4117. timer_data = get_timer(day_timer_tid);
  4118. timer_data2 = get_timer(night_timer_tid);
  4119. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4120. clif_displaymessage(fd, temp);
  4121. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4122. sprintf(temp, msg_txt(sd,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.
  4123. else
  4124. sprintf(temp, msg_txt(sd,239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4125. clif_displaymessage(fd, temp);
  4126. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4127. clif_displaymessage(fd, temp);
  4128. }
  4129. }
  4130. return 0;
  4131. }
  4132. /*==========================================
  4133. * @jail <char_name> by [Yor]
  4134. * Special warp! No check with nowarp and nowarpto flag
  4135. *------------------------------------------*/
  4136. ACMD_FUNC(jail)
  4137. {
  4138. struct map_session_data *pl_sd;
  4139. int x, y;
  4140. unsigned short m_index;
  4141. nullpo_retr(-1, sd);
  4142. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4143. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4144. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4145. return -1;
  4146. }
  4147. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4148. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4149. return -1;
  4150. }
  4151. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4152. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4153. return -1;
  4154. }
  4155. if (pl_sd->sc.data[SC_JAILED]) {
  4156. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4157. return -1;
  4158. }
  4159. switch(rnd() % 2) { //Jail Locations
  4160. case 0:
  4161. m_index = mapindex_name2id(MAP_JAIL);
  4162. x = 24;
  4163. y = 75;
  4164. break;
  4165. default:
  4166. m_index = mapindex_name2id(MAP_JAIL);
  4167. x = 49;
  4168. y = 75;
  4169. break;
  4170. }
  4171. //Duration of INT_MAX to specify infinity.
  4172. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4173. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4174. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4175. return 0;
  4176. }
  4177. /*==========================================
  4178. * @unjail/@discharge <char_name> by [Yor]
  4179. * Special warp! No check with nowarp and nowarpto flag
  4180. *------------------------------------------*/
  4181. ACMD_FUNC(unjail)
  4182. {
  4183. struct map_session_data *pl_sd;
  4184. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4185. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4186. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4187. return -1;
  4188. }
  4189. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4190. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4191. return -1;
  4192. }
  4193. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4194. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4195. return -1;
  4196. }
  4197. if (!pl_sd->sc.data[SC_JAILED]) {
  4198. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4199. return -1;
  4200. }
  4201. //Reset jail time to 1 sec.
  4202. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4203. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4204. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4205. return 0;
  4206. }
  4207. ACMD_FUNC(jailfor) {
  4208. struct map_session_data *pl_sd = NULL;
  4209. char * modif_p;
  4210. int jailtime = 0,x,y;
  4211. short m_index = 0;
  4212. nullpo_retr(-1, sd);
  4213. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4214. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4215. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4216. return -1;
  4217. }
  4218. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4219. modif_p = atcmd_output;
  4220. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4221. if (jailtime == 0) {
  4222. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4223. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  4224. return -1;
  4225. }
  4226. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4227. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4228. return -1;
  4229. }
  4230. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4231. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4232. return -1;
  4233. }
  4234. // Added by Coltaro
  4235. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4236. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4237. if (jailtime <= 0) {
  4238. jailtime = 0;
  4239. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4240. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4241. } else {
  4242. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4243. char timestr[21];
  4244. time_t now=time(NULL);
  4245. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4246. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1137),year,month,day,hour,minute); // %s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4247. clif_displaymessage(pl_sd->fd, atcmd_output);
  4248. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1138),year,month,day,hour,minute); // This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4249. clif_displaymessage(fd, atcmd_output);
  4250. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4251. sprintf(atcmd_output,"Release date is: %s",timestr);
  4252. clif_displaymessage(pl_sd->fd, atcmd_output);
  4253. clif_displaymessage(fd, atcmd_output);
  4254. }
  4255. } else if (jailtime < 0) {
  4256. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4257. return -1;
  4258. }
  4259. // Jail locations, add more as you wish.
  4260. switch(rnd()%2) {
  4261. case 1: // Jail #1
  4262. m_index = mapindex_name2id(MAP_JAIL);
  4263. x = 49; y = 75;
  4264. break;
  4265. default: // Default Jail
  4266. m_index = mapindex_name2id(MAP_JAIL);
  4267. x = 24; y = 75;
  4268. break;
  4269. }
  4270. sc_start4(NULL,&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).
  4271. return 0;
  4272. }
  4273. //By Coltaro
  4274. ACMD_FUNC(jailtime){
  4275. int year, month, day, hour, minute, second;
  4276. char timestr[21];
  4277. time_t now = time(NULL);
  4278. nullpo_retr(-1, sd);
  4279. if (!sd->sc.data[SC_JAILED]) {
  4280. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4281. return -1;
  4282. }
  4283. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4284. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4285. return 0;
  4286. }
  4287. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4288. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4289. return -1;
  4290. }
  4291. // Get remaining jail time
  4292. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4293. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4294. clif_displaymessage(fd, atcmd_output);
  4295. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4296. sprintf(atcmd_output,"Release date is: %s",timestr);
  4297. clif_displaymessage(fd, atcmd_output);
  4298. return 0;
  4299. }
  4300. /*==========================================
  4301. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4302. *------------------------------------------*/
  4303. ACMD_FUNC(disguise)
  4304. {
  4305. int id = 0;
  4306. nullpo_retr(-1, sd);
  4307. if (!message || !*message) {
  4308. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4309. return -1;
  4310. }
  4311. if ((id = atoi(message)) > 0)
  4312. { //Acquired an ID
  4313. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4314. id = 0; //Invalid id for either mobs or npcs.
  4315. } else { //Acquired a Name
  4316. if ((id = mobdb_searchname(message)) == 0)
  4317. {
  4318. struct npc_data* nd = npc_name2id(message);
  4319. if (nd != NULL)
  4320. id = nd->class_;
  4321. }
  4322. }
  4323. if (id == 0)
  4324. {
  4325. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4326. return -1;
  4327. }
  4328. if(pc_isriding(sd))
  4329. {
  4330. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4331. return -1;
  4332. }
  4333. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4334. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4335. return -1;
  4336. }
  4337. pc_disguise(sd, id);
  4338. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4339. return 0;
  4340. }
  4341. /*==========================================
  4342. * DisguiseAll
  4343. *------------------------------------------*/
  4344. ACMD_FUNC(disguiseall)
  4345. {
  4346. int mob_id=0;
  4347. struct map_session_data *pl_sd;
  4348. struct s_mapiterator* iter;
  4349. nullpo_retr(-1, sd);
  4350. if (!message || !*message) {
  4351. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4352. return -1;
  4353. }
  4354. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4355. mob_id = atoi(message);
  4356. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4357. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4358. return -1;
  4359. }
  4360. iter = mapit_getallusers();
  4361. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4362. pc_disguise(pl_sd, mob_id);
  4363. mapit_free(iter);
  4364. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4365. return 0;
  4366. }
  4367. /*==========================================
  4368. * DisguiseGuild
  4369. *------------------------------------------*/
  4370. ACMD_FUNC(disguiseguild)
  4371. {
  4372. int id = 0, i;
  4373. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4374. struct guild *g;
  4375. memset(monster, '\0', sizeof(monster));
  4376. memset(guild, '\0', sizeof(guild));
  4377. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4378. clif_displaymessage(fd, msg_txt(sd,1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4379. return -1;
  4380. }
  4381. if( (id = atoi(monster)) > 0 ) {
  4382. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4383. id = 0;
  4384. } else {
  4385. if( (id = mobdb_searchname(monster)) == 0 ) {
  4386. struct npc_data* nd = npc_name2id(monster);
  4387. if( nd != NULL )
  4388. id = nd->class_;
  4389. }
  4390. }
  4391. if( id == 0 ) {
  4392. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4393. return -1;
  4394. }
  4395. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4396. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4397. return -1;
  4398. }
  4399. for( i = 0; i < g->max_member; i++ ){
  4400. struct map_session_data *pl_sd;
  4401. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4402. pc_disguise(pl_sd, id);
  4403. }
  4404. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4405. return 0;
  4406. }
  4407. /*==========================================
  4408. * @undisguise by [Yor]
  4409. *------------------------------------------*/
  4410. ACMD_FUNC(undisguise)
  4411. {
  4412. nullpo_retr(-1, sd);
  4413. if (sd->disguise) {
  4414. pc_disguise(sd, 0);
  4415. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4416. } else {
  4417. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4418. return -1;
  4419. }
  4420. return 0;
  4421. }
  4422. /*==========================================
  4423. * UndisguiseAll
  4424. *------------------------------------------*/
  4425. ACMD_FUNC(undisguiseall)
  4426. {
  4427. struct map_session_data *pl_sd;
  4428. struct s_mapiterator* iter;
  4429. nullpo_retr(-1, sd);
  4430. iter = mapit_getallusers();
  4431. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4432. if( pl_sd->disguise )
  4433. pc_disguise(pl_sd, 0);
  4434. mapit_free(iter);
  4435. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4436. return 0;
  4437. }
  4438. /*==========================================
  4439. * UndisguiseGuild
  4440. *------------------------------------------*/
  4441. ACMD_FUNC(undisguiseguild)
  4442. {
  4443. char guild_name[NAME_LENGTH];
  4444. struct guild *g;
  4445. int i;
  4446. nullpo_retr(-1, sd);
  4447. memset(guild_name, '\0', sizeof(guild_name));
  4448. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4449. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4450. return -1;
  4451. }
  4452. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4453. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4454. return -1;
  4455. }
  4456. for(i = 0; i < g->max_member; i++){
  4457. struct map_session_data *pl_sd;
  4458. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4459. pc_disguise(pl_sd, 0);
  4460. }
  4461. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4462. return 0;
  4463. }
  4464. /*==========================================
  4465. * @exp by [Skotlex]
  4466. *------------------------------------------*/
  4467. ACMD_FUNC(exp)
  4468. {
  4469. char output[CHAT_SIZE_MAX];
  4470. double nextb, nextj;
  4471. nullpo_retr(-1, sd);
  4472. memset(output, '\0', sizeof(output));
  4473. nextb = pc_nextbaseexp(sd);
  4474. if (nextb)
  4475. nextb = sd->status.base_exp*100.0/nextb;
  4476. nextj = pc_nextjobexp(sd);
  4477. if (nextj)
  4478. nextj = sd->status.job_exp*100.0/nextj;
  4479. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4480. clif_displaymessage(fd, output);
  4481. return 0;
  4482. }
  4483. /*==========================================
  4484. * @broadcast by [Valaris]
  4485. *------------------------------------------*/
  4486. ACMD_FUNC(broadcast)
  4487. {
  4488. nullpo_retr(-1, sd);
  4489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4490. if (!message || !*message) {
  4491. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4492. return -1;
  4493. }
  4494. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4495. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4496. return 0;
  4497. }
  4498. /*==========================================
  4499. * @localbroadcast by [Valaris]
  4500. *------------------------------------------*/
  4501. ACMD_FUNC(localbroadcast)
  4502. {
  4503. nullpo_retr(-1, sd);
  4504. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4505. if (!message || !*message) {
  4506. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4507. return -1;
  4508. }
  4509. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4510. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4511. return 0;
  4512. }
  4513. /*==========================================
  4514. * @email <actual@email> <new@email> by [Yor]
  4515. *------------------------------------------*/
  4516. ACMD_FUNC(email)
  4517. {
  4518. char actual_email[100];
  4519. char new_email[100];
  4520. nullpo_retr(-1, sd);
  4521. memset(actual_email, '\0', sizeof(actual_email));
  4522. memset(new_email, '\0', sizeof(new_email));
  4523. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4524. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4525. return -1;
  4526. }
  4527. if (e_mail_check(actual_email) == 0) {
  4528. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4529. return -1;
  4530. } else if (e_mail_check(new_email) == 0) {
  4531. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4532. return -1;
  4533. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4534. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4535. return -1;
  4536. } else if (strcmpi(actual_email, new_email) == 0) {
  4537. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4538. return -1;
  4539. }
  4540. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4541. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4542. return 0;
  4543. }
  4544. /*==========================================
  4545. *@effect
  4546. *------------------------------------------*/
  4547. ACMD_FUNC(effect)
  4548. {
  4549. int type = EF_NONE;
  4550. nullpo_retr(-1, sd);
  4551. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4552. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4553. return -1;
  4554. }
  4555. if( type <= EF_NONE || type >= EF_MAX ){
  4556. sprintf(atcmd_output, msg_txt(sd,1152),EF_NONE+1,EF_MAX-1); // Please enter a valid effect id in the range from %d to %d.
  4557. clif_displaymessage(fd, atcmd_output);
  4558. return -1;
  4559. }
  4560. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4561. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4562. return 0;
  4563. }
  4564. /*==========================================
  4565. * @killer by MouseJstr
  4566. * enable killing players even when not in pvp
  4567. *------------------------------------------*/
  4568. ACMD_FUNC(killer)
  4569. {
  4570. nullpo_retr(-1, sd);
  4571. sd->state.killer = !sd->state.killer;
  4572. if(sd->state.killer)
  4573. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4574. else {
  4575. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4576. pc_stop_attack(sd);
  4577. }
  4578. return 0;
  4579. }
  4580. /*==========================================
  4581. * @killable by MouseJstr
  4582. * enable other people killing you
  4583. *------------------------------------------*/
  4584. ACMD_FUNC(killable)
  4585. {
  4586. nullpo_retr(-1, sd);
  4587. sd->state.killable = !sd->state.killable;
  4588. if(sd->state.killable)
  4589. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4590. else {
  4591. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4592. map_foreachinallrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4593. }
  4594. return 0;
  4595. }
  4596. /*==========================================
  4597. * @skillon by MouseJstr
  4598. * turn skills on for the map
  4599. *------------------------------------------*/
  4600. ACMD_FUNC(skillon)
  4601. {
  4602. nullpo_retr(-1, sd);
  4603. map[sd->bl.m].flag.noskill = 0;
  4604. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4605. return 0;
  4606. }
  4607. /*==========================================
  4608. * @skilloff by MouseJstr
  4609. * Turn skills off on the map
  4610. *------------------------------------------*/
  4611. ACMD_FUNC(skilloff)
  4612. {
  4613. nullpo_retr(-1, sd);
  4614. map[sd->bl.m].flag.noskill = 1;
  4615. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4616. return 0;
  4617. }
  4618. /*==========================================
  4619. * @npcmove by MouseJstr
  4620. * move a npc
  4621. *------------------------------------------*/
  4622. ACMD_FUNC(npcmove)
  4623. {
  4624. short x = 0, y = 0;
  4625. struct npc_data *nd = 0;
  4626. char npc_name[NPC_NAME_LENGTH];
  4627. nullpo_retr(-1, sd);
  4628. memset(npc_name, '\0', sizeof npc_name);
  4629. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4630. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4631. return -1;
  4632. }
  4633. if ((nd = npc_name2id(npc_name)) == NULL)
  4634. {
  4635. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4636. return -1;
  4637. }
  4638. if ( npc_movenpc( nd, x, y ) )
  4639. { //actually failed to move
  4640. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4641. return -1; //Not on a map.
  4642. } else
  4643. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4644. return 0;
  4645. }
  4646. /*==========================================
  4647. * @addwarp by MouseJstr
  4648. * Create a new static warp point.
  4649. *------------------------------------------*/
  4650. ACMD_FUNC(addwarp)
  4651. {
  4652. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4653. short x,y;
  4654. unsigned short m;
  4655. struct npc_data* nd;
  4656. nullpo_retr(-1, sd);
  4657. memset(warpname, '\0', sizeof(warpname));
  4658. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4659. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4660. return -1;
  4661. }
  4662. m = mapindex_name2id(mapname);
  4663. if( m == 0 )
  4664. {
  4665. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4666. clif_displaymessage(fd, atcmd_output);
  4667. return -1;
  4668. }
  4669. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4670. if( nd == NULL )
  4671. return -1;
  4672. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4673. clif_displaymessage(fd, atcmd_output);
  4674. return 0;
  4675. }
  4676. /*==========================================
  4677. * @follow by [MouseJstr]
  4678. * Follow a player .. staying no more then 5 spaces away
  4679. *------------------------------------------*/
  4680. ACMD_FUNC(follow)
  4681. {
  4682. struct map_session_data *pl_sd = NULL;
  4683. nullpo_retr(-1, sd);
  4684. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4685. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4686. if (sd->followtarget == -1)
  4687. return -1;
  4688. pc_stop_following (sd);
  4689. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4690. return 0;
  4691. }
  4692. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4693. {
  4694. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4695. return -1;
  4696. }
  4697. if (sd->followtarget == pl_sd->bl.id) {
  4698. pc_stop_following (sd);
  4699. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4700. } else {
  4701. pc_follow(sd, pl_sd->bl.id);
  4702. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4703. }
  4704. return 0;
  4705. }
  4706. /*==========================================
  4707. * @dropall by [MouseJstr] and [Xantara]
  4708. * Drops all your possession on the ground based on item type
  4709. *------------------------------------------*/
  4710. ACMD_FUNC(dropall)
  4711. {
  4712. int8 type = -1;
  4713. uint16 i, count = 0, count2 = 0;
  4714. struct item_data *item_data = NULL;
  4715. nullpo_retr(-1, sd);
  4716. if( message[0] ) {
  4717. type = atoi(message);
  4718. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4719. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4720. {
  4721. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  4722. clif_displaymessage(fd, msg_txt(sd,1493)); // Type List: (default) all = -1, healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
  4723. return -1;
  4724. }
  4725. }
  4726. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4727. if( sd->inventory.u.items_inventory[i].amount ) {
  4728. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4729. ShowDebug("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->inventory.u.items_inventory[i].nameid, sd->status.account_id, sd->status.char_id);
  4730. continue;
  4731. }
  4732. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4733. continue;
  4734. if( type == -1 || type == (uint8)item_data->type ) {
  4735. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4736. pc_unequipitem(sd, i, 3);
  4737. if(pc_dropitem(sd, i, sd->inventory.u.items_inventory[i].amount))
  4738. count += sd->inventory.u.items_inventory[i].amount;
  4739. else count2 += sd->inventory.u.items_inventory[i].amount;
  4740. }
  4741. }
  4742. }
  4743. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4744. clif_displaymessage(fd, atcmd_output);
  4745. return 0;
  4746. }
  4747. /*==========================================
  4748. * @storeall by [MouseJstr]
  4749. * Put everything into storage
  4750. *------------------------------------------*/
  4751. ACMD_FUNC(storeall)
  4752. {
  4753. int i;
  4754. nullpo_retr(-1, sd);
  4755. if (sd->state.storage_flag != 1)
  4756. { //Open storage.
  4757. if( storage_storageopen(sd) == 1 ) {
  4758. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4759. return -1;
  4760. }
  4761. }
  4762. for (i = 0; i < MAX_INVENTORY; i++) {
  4763. if (sd->inventory.u.items_inventory[i].amount) {
  4764. if(sd->inventory.u.items_inventory[i].equip != 0)
  4765. pc_unequipitem(sd, i, 3);
  4766. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  4767. }
  4768. }
  4769. storage_storageclose(sd);
  4770. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4771. return 0;
  4772. }
  4773. ACMD_FUNC(clearstorage)
  4774. {
  4775. int i, j;
  4776. nullpo_retr(-1, sd);
  4777. if (sd->state.storage_flag == 1) {
  4778. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4779. return -1;
  4780. }
  4781. if (sd->state.storage_flag == 3) {
  4782. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4783. return -1;
  4784. }
  4785. j = sd->storage.amount;
  4786. for (i = 0; i < j; ++i) {
  4787. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  4788. }
  4789. sd->state.storage_flag = 1;
  4790. storage_storageclose(sd);
  4791. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4792. return 0;
  4793. }
  4794. ACMD_FUNC(cleargstorage)
  4795. {
  4796. int i, j;
  4797. struct guild *g;
  4798. struct s_storage *gstorage;
  4799. nullpo_retr(-1, sd);
  4800. g = sd->guild;
  4801. if (g == NULL) {
  4802. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  4803. return -1;
  4804. }
  4805. if (sd->state.storage_flag == 1) {
  4806. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4807. return -1;
  4808. }
  4809. if (sd->state.storage_flag == 2) {
  4810. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  4811. return -1;
  4812. }
  4813. if (sd->state.storage_flag == 3) {
  4814. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4815. return -1;
  4816. }
  4817. gstorage = guild2storage2(sd->status.guild_id);
  4818. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4819. return -1;
  4820. }
  4821. j = gstorage->amount;
  4822. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4823. for (i = 0; i < j; ++i) {
  4824. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  4825. }
  4826. storage_guild_storageclose(sd);
  4827. gstorage->lock = false; // Cleaning done, release lock
  4828. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4829. return 0;
  4830. }
  4831. ACMD_FUNC(clearcart)
  4832. {
  4833. int i;
  4834. nullpo_retr(-1, sd);
  4835. if (pc_iscarton(sd) == 0) {
  4836. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4837. return -1;
  4838. }
  4839. if (sd->state.vending == 1) { //Somehow...
  4840. return -1;
  4841. }
  4842. for (i = 0; i < MAX_CART; i++) {
  4843. if (sd->cart.u.items_cart[i].nameid > 0)
  4844. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  4845. }
  4846. clif_clearcart(fd);
  4847. clif_updatestatus(sd,SP_CARTINFO);
  4848. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4849. return 0;
  4850. }
  4851. /*==========================================
  4852. * @skillid by [MouseJstr]
  4853. * lookup a skill by name
  4854. *------------------------------------------*/
  4855. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4856. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4857. ACMD_FUNC(skillid) {
  4858. int skillen, i, found = 0;
  4859. DBIterator* iter;
  4860. DBKey key;
  4861. DBData *data;
  4862. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4863. nullpo_retr(-1, sd);
  4864. if (!message || !*message) {
  4865. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4866. return -1;
  4867. }
  4868. skillen = strlen(message);
  4869. iter = db_iterator(skilldb_name2id);
  4870. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4871. int idx = skill_get_index(db_data2i(data));
  4872. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4873. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4874. clif_displaymessage(fd, atcmd_output);
  4875. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4876. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // // skill %d: %s (%s)
  4877. }
  4878. }
  4879. dbi_destroy(iter);
  4880. if( found ) {
  4881. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4882. clif_displaymessage(fd, atcmd_output);
  4883. }
  4884. for(i = 0; i < found; i++) { /* partials */
  4885. clif_displaymessage(fd, partials[i]);
  4886. }
  4887. return 0;
  4888. }
  4889. /*==========================================
  4890. * @useskill by [MouseJstr]
  4891. * A way of using skills without having to find them in the skills menu
  4892. *------------------------------------------*/
  4893. ACMD_FUNC(useskill)
  4894. {
  4895. struct map_session_data *pl_sd = NULL;
  4896. struct block_list *bl;
  4897. uint16 skill_id;
  4898. uint16 skill_lv;
  4899. nullpo_retr(-1, sd);
  4900. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4901. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  4902. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  4903. return -1;
  4904. }
  4905. if(!strcmp(atcmd_player_name,"self"))
  4906. pl_sd = sd; //quick keyword
  4907. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
  4908. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4909. return -1;
  4910. }
  4911. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4912. {
  4913. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4914. return -1;
  4915. }
  4916. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4917. bl = &sd->hd->bl;
  4918. else
  4919. bl = &sd->bl;
  4920. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4921. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4922. else
  4923. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4924. return 0;
  4925. }
  4926. /*==========================================
  4927. * @displayskill by [Skotlex]
  4928. * Debug command to locate new skill IDs. It sends the
  4929. * three possible skill-effect packets to the area.
  4930. *------------------------------------------*/
  4931. ACMD_FUNC(displayskill)
  4932. {
  4933. struct status_data * status;
  4934. unsigned int tick;
  4935. uint16 skill_id;
  4936. uint16 skill_lv = 1;
  4937. nullpo_retr(-1, sd);
  4938. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4939. {
  4940. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4941. return -1;
  4942. }
  4943. status = status_get_status_data(&sd->bl);
  4944. tick = gettick();
  4945. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  4946. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4947. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4948. return 0;
  4949. }
  4950. /*==========================================
  4951. * @skilltree by [MouseJstr]
  4952. * prints the skill tree for a player required to get to a skill
  4953. *------------------------------------------*/
  4954. ACMD_FUNC(skilltree)
  4955. {
  4956. struct map_session_data *pl_sd = NULL;
  4957. uint16 skill_id;
  4958. int meets, i, j, c=0;
  4959. struct skill_tree_entry *ent;
  4960. nullpo_retr(-1, sd);
  4961. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4962. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  4963. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  4964. return -1;
  4965. }
  4966. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4967. {
  4968. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4969. return -1;
  4970. }
  4971. i = pc_calc_skilltree_normalize_job(pl_sd);
  4972. c = pc_mapid2jobid(i, pl_sd->status.sex);
  4973. sprintf(atcmd_output, msg_txt(sd,1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  4974. clif_displaymessage(fd, atcmd_output);
  4975. c = pc_class2idx(c);
  4976. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].skill_id == 0 || skill_tree[c][j].skill_id == skill_id );
  4977. if( j == MAX_SKILL_TREE || skill_tree[c][j].skill_id == 0 )
  4978. {
  4979. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4980. return 0;
  4981. }
  4982. ent = &skill_tree[c][j];
  4983. meets = 1;
  4984. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4985. {
  4986. if( ent->need[j].skill_id && pc_checkskill(sd,ent->need[j].skill_id) < ent->need[j].skill_lv)
  4987. {
  4988. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].skill_lv, skill_db[skill_get_index(ent->need[j].skill_id)]->desc); // Player requires level %d of skill %s.
  4989. clif_displaymessage(fd, atcmd_output);
  4990. meets = 0;
  4991. }
  4992. }
  4993. if (meets == 1) {
  4994. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4995. }
  4996. return 0;
  4997. }
  4998. // Hand a ring with partners name on it to this char
  4999. void getring (struct map_session_data* sd)
  5000. {
  5001. char flag = 0;
  5002. unsigned short item_id;
  5003. struct item item_tmp;
  5004. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5005. memset(&item_tmp, 0, sizeof(item_tmp));
  5006. item_tmp.nameid = item_id;
  5007. item_tmp.identify = 1;
  5008. item_tmp.card[0] = 255;
  5009. item_tmp.card[2] = sd->status.partner_id;
  5010. item_tmp.card[3] = sd->status.partner_id >> 16;
  5011. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5012. clif_additem(sd,0,0,flag);
  5013. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  5014. }
  5015. }
  5016. /*==========================================
  5017. * @marry by [MouseJstr], fixed by Lupus
  5018. * Marry two players
  5019. *------------------------------------------*/
  5020. ACMD_FUNC(marry)
  5021. {
  5022. struct map_session_data *pl_sd = NULL;
  5023. nullpo_retr(-1, sd);
  5024. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5025. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5026. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5027. return -1;
  5028. }
  5029. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  5030. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5031. return -1;
  5032. }
  5033. if (pc_marriage(sd, pl_sd)) {
  5034. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5035. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5036. if( pl_sd->bl.m != sd->bl.m )
  5037. clif_wedding_effect(&sd->bl);
  5038. getring(sd); // Auto-give named rings (Aru)
  5039. getring(pl_sd);
  5040. return 0;
  5041. }
  5042. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5043. return -1;
  5044. }
  5045. /*==========================================
  5046. * @divorce by [MouseJstr], fixed by [Lupus]
  5047. * divorce two players
  5048. *------------------------------------------*/
  5049. ACMD_FUNC(divorce)
  5050. {
  5051. nullpo_retr(-1, sd);
  5052. if (!pc_divorce(sd)) {
  5053. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5054. clif_displaymessage(fd, atcmd_output);
  5055. return -1;
  5056. }
  5057. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5058. clif_displaymessage(fd, atcmd_output);
  5059. return 0;
  5060. }
  5061. /*==========================================
  5062. * @changelook by [Celest]
  5063. *------------------------------------------*/
  5064. ACMD_FUNC(changelook)
  5065. {
  5066. int i, j = 0, k = 0;
  5067. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5068. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5069. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5070. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5071. return -1;
  5072. } else if ( i == 2 ) {
  5073. if (j < 1 || j > 8)
  5074. j = 1;
  5075. j = pos[j - 1];
  5076. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5077. k = j; // swap
  5078. j = LOOK_HEAD_TOP;
  5079. }
  5080. clif_changelook(&sd->bl,j,k);
  5081. return 0;
  5082. }
  5083. /*==========================================
  5084. * @autotrade by durf [Lupus] [Paradox924X]
  5085. * Turns on/off Autotrade for a specific player
  5086. *------------------------------------------*/
  5087. ACMD_FUNC(autotrade) {
  5088. nullpo_retr(-1, sd);
  5089. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5090. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5091. return -1;
  5092. }
  5093. if( pc_isdead(sd) ) {
  5094. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5095. return -1;
  5096. }
  5097. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5098. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5099. return -1;
  5100. }
  5101. sd->state.autotrade = 1;
  5102. if (battle_config.autotrade_monsterignore)
  5103. sd->state.monster_ignore = 1;
  5104. if( sd->state.vending ){
  5105. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
  5106. Sql_ShowDebug( mmysql_handle );
  5107. }
  5108. }else if( sd->state.buyingstore ){
  5109. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
  5110. Sql_ShowDebug( mmysql_handle );
  5111. }
  5112. }
  5113. if( battle_config.at_timeout ) {
  5114. int timeout = atoi(message);
  5115. status_change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
  5116. }
  5117. channel_pcquit(sd,0xF); //leave all chan
  5118. clif_authfail_fd(sd->fd, 15);
  5119. chrif_save(sd, CSAVE_AUTOTRADE);
  5120. return 0;
  5121. }
  5122. /*==========================================
  5123. * @changegm by durf (changed by Lupus)
  5124. * Changes Master of your Guild to a specified guild member
  5125. *------------------------------------------*/
  5126. ACMD_FUNC(changegm)
  5127. {
  5128. struct guild *g;
  5129. struct map_session_data *pl_sd;
  5130. nullpo_retr(-1, sd);
  5131. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5132. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5133. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5134. return -1;
  5135. }
  5136. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  5137. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5138. return -1;
  5139. }
  5140. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5141. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5142. return -1;
  5143. }
  5144. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5145. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5146. return -1;
  5147. }
  5148. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5149. return 0;
  5150. }
  5151. /*==========================================
  5152. * @changeleader by Skotlex
  5153. * Changes the leader of a party.
  5154. *------------------------------------------*/
  5155. ACMD_FUNC(changeleader)
  5156. {
  5157. nullpo_retr(-1, sd);
  5158. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5159. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5160. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5161. return -1;
  5162. }
  5163. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
  5164. return 0;
  5165. }
  5166. /*==========================================
  5167. * @partyoption by Skotlex
  5168. * Used to change the item share setting of a party.
  5169. *------------------------------------------*/
  5170. ACMD_FUNC(partyoption)
  5171. {
  5172. struct party_data *p;
  5173. int mi, option;
  5174. char w1[16], w2[16];
  5175. nullpo_retr(-1, sd);
  5176. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5177. {
  5178. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5179. return -1;
  5180. }
  5181. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5182. if (mi == MAX_PARTY)
  5183. return -1; //Shouldn't happen
  5184. if (!p->party.member[mi].leader)
  5185. {
  5186. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5187. return -1;
  5188. }
  5189. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5190. {
  5191. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5192. return -1;
  5193. }
  5194. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5195. //Change item share type.
  5196. if (option != p->party.item)
  5197. party_changeoption(sd, p->party.exp, option);
  5198. else
  5199. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5200. return 0;
  5201. }
  5202. /*==========================================
  5203. * @autoloot by Upa-Kun
  5204. * Turns on/off AutoLoot for a specific player
  5205. *------------------------------------------*/
  5206. ACMD_FUNC(autoloot)
  5207. {
  5208. int rate;
  5209. nullpo_retr(-1, sd);
  5210. // autoloot command without value
  5211. if(!message || !*message)
  5212. {
  5213. if (sd->state.autoloot)
  5214. rate = 0;
  5215. else
  5216. rate = 10000;
  5217. } else {
  5218. double drate;
  5219. drate = atof(message);
  5220. rate = (int)(drate*100);
  5221. }
  5222. if (rate < 0) rate = 0;
  5223. if (rate > 10000) rate = 10000;
  5224. sd->state.autoloot = rate;
  5225. if (sd->state.autoloot) {
  5226. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  5227. clif_displaymessage(fd, atcmd_output);
  5228. }else
  5229. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5230. return 0;
  5231. }
  5232. /*==========================================
  5233. * @alootid
  5234. *------------------------------------------*/
  5235. ACMD_FUNC(autolootitem)
  5236. {
  5237. struct item_data *item_data = NULL;
  5238. int i;
  5239. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5240. nullpo_retr(-1, sd);
  5241. if (message && *message) {
  5242. if (message[0] == '+') {
  5243. message++;
  5244. action = 1;
  5245. }
  5246. else if (message[0] == '-') {
  5247. message++;
  5248. action = 2;
  5249. }
  5250. else if (!strcmp(message,"reset"))
  5251. action = 4;
  5252. }
  5253. if (action < 3) // add or remove
  5254. {
  5255. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5256. item_data = itemdb_searchname(message);
  5257. if (!item_data) {
  5258. // No items founds in the DB with Id or Name
  5259. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5260. return -1;
  5261. }
  5262. }
  5263. switch(action) {
  5264. case 1:
  5265. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5266. if (i != AUTOLOOTITEM_SIZE) {
  5267. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5268. return -1;
  5269. }
  5270. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5271. if (i == AUTOLOOTITEM_SIZE) {
  5272. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5273. return -1;
  5274. }
  5275. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5276. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5277. clif_displaymessage(fd, atcmd_output);
  5278. sd->state.autolooting = 1;
  5279. break;
  5280. case 2:
  5281. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5282. if (i == AUTOLOOTITEM_SIZE) {
  5283. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5284. return -1;
  5285. }
  5286. sd->state.autolootid[i] = 0;
  5287. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5288. clif_displaymessage(fd, atcmd_output);
  5289. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5290. if (i == AUTOLOOTITEM_SIZE) {
  5291. sd->state.autolooting = 0;
  5292. }
  5293. break;
  5294. case 3:
  5295. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5296. clif_displaymessage(fd, atcmd_output);
  5297. clif_displaymessage(fd, msg_txt(sd,1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  5298. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5299. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5300. if (i == AUTOLOOTITEM_SIZE) {
  5301. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5302. } else {
  5303. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5304. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5305. {
  5306. if (sd->state.autolootid[i] == 0)
  5307. continue;
  5308. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5309. 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);
  5310. continue;
  5311. }
  5312. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5313. clif_displaymessage(fd, atcmd_output);
  5314. }
  5315. }
  5316. break;
  5317. case 4:
  5318. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5319. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5320. sd->state.autolooting = 0;
  5321. break;
  5322. }
  5323. return 0;
  5324. }
  5325. /*==========================================
  5326. * @autoloottype
  5327. * Flags:
  5328. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5329. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5330. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5331. * 262144: IT_CASH
  5332. *------------------------------------------
  5333. * Credits:
  5334. * chriser
  5335. * Aleos
  5336. *------------------------------------------*/
  5337. ACMD_FUNC(autoloottype)
  5338. {
  5339. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5340. enum item_types type= IT_UNKNOWN;
  5341. int ITEM_MAX = 1533;
  5342. nullpo_retr(-1, sd);
  5343. if (message && *message) {
  5344. if (message[0] == '+') {
  5345. message++;
  5346. action = 1;
  5347. }
  5348. else if (message[0] == '-') {
  5349. message++;
  5350. action = 2;
  5351. }
  5352. else if (!strcmp(message,"reset"))
  5353. action = 4;
  5354. }
  5355. if (action < 3) { // add or remove
  5356. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5357. type = IT_HEALING;
  5358. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5359. type = IT_USABLE;
  5360. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5361. type = IT_ETC;
  5362. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5363. type = IT_ARMOR;
  5364. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5365. type = IT_WEAPON;
  5366. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5367. type = IT_CARD;
  5368. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5369. type = IT_PETEGG;
  5370. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5371. type = IT_PETARMOR;
  5372. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5373. type = IT_AMMO;
  5374. else {
  5375. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5376. return -1;
  5377. }
  5378. }
  5379. switch (action) {
  5380. case 1:
  5381. if (sd->state.autoloottype&(1<<type)) {
  5382. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5383. return -1;
  5384. }
  5385. if (sd->state.autoloottype == ITEM_MAX) {
  5386. clif_displaymessage(fd, msg_txt(sd,1482)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -<type name or ID>.
  5387. return -1;
  5388. }
  5389. sd->state.autoloottype |= (1<<type); // Stores the type
  5390. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5391. clif_displaymessage(fd, atcmd_output);
  5392. break;
  5393. case 2:
  5394. if (!(sd->state.autoloottype&(1<<type))) {
  5395. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5396. return -1;
  5397. }
  5398. sd->state.autoloottype &= ~(1<<type);
  5399. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5400. clif_displaymessage(fd, atcmd_output);
  5401. break;
  5402. case 3:
  5403. clif_displaymessage(fd, msg_txt(sd,1486)); // To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>".
  5404. clif_displaymessage(fd, msg_txt(sd,1487)); // Type List: healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
  5405. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5406. if (sd->state.autoloottype == 0)
  5407. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5408. else {
  5409. uint8 i = 0;
  5410. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5411. while (i < IT_MAX) {
  5412. if (sd->state.autoloottype&(1<<i)) {
  5413. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5414. clif_displaymessage(fd, atcmd_output);
  5415. }
  5416. i++;
  5417. }
  5418. }
  5419. break;
  5420. case 4:
  5421. sd->state.autoloottype = 0;
  5422. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5423. break;
  5424. }
  5425. return 0;
  5426. }
  5427. /**
  5428. * No longer available, keeping here just in case it's back someday. [Ind]
  5429. **/
  5430. /*==========================================
  5431. * It is made to rain.
  5432. *------------------------------------------*/
  5433. //ACMD_FUNC(rain)
  5434. //{
  5435. // nullpo_retr(-1, sd);
  5436. // if (map[sd->bl.m].flag.rain) {
  5437. // map[sd->bl.m].flag.rain=0;
  5438. // clif_weather(sd->bl.m);
  5439. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5440. // } else {
  5441. // map[sd->bl.m].flag.rain=1;
  5442. // clif_weather(sd->bl.m);
  5443. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5444. // }
  5445. // return 0;
  5446. //}
  5447. /*==========================================
  5448. * It is made to snow.
  5449. *------------------------------------------*/
  5450. ACMD_FUNC(snow)
  5451. {
  5452. nullpo_retr(-1, sd);
  5453. if (map[sd->bl.m].flag.snow) {
  5454. map[sd->bl.m].flag.snow=0;
  5455. clif_weather(sd->bl.m);
  5456. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5457. } else {
  5458. map[sd->bl.m].flag.snow=1;
  5459. clif_weather(sd->bl.m);
  5460. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5461. }
  5462. return 0;
  5463. }
  5464. /*==========================================
  5465. * Cherry tree snowstorm is made to fall. (Sakura)
  5466. *------------------------------------------*/
  5467. ACMD_FUNC(sakura)
  5468. {
  5469. nullpo_retr(-1, sd);
  5470. if (map[sd->bl.m].flag.sakura) {
  5471. map[sd->bl.m].flag.sakura=0;
  5472. clif_weather(sd->bl.m);
  5473. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5474. } else {
  5475. map[sd->bl.m].flag.sakura=1;
  5476. clif_weather(sd->bl.m);
  5477. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5478. }
  5479. return 0;
  5480. }
  5481. /*==========================================
  5482. * Clouds appear.
  5483. *------------------------------------------*/
  5484. ACMD_FUNC(clouds)
  5485. {
  5486. nullpo_retr(-1, sd);
  5487. if (map[sd->bl.m].flag.clouds) {
  5488. map[sd->bl.m].flag.clouds=0;
  5489. clif_weather(sd->bl.m);
  5490. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5491. } else {
  5492. map[sd->bl.m].flag.clouds=1;
  5493. clif_weather(sd->bl.m);
  5494. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5495. }
  5496. return 0;
  5497. }
  5498. /*==========================================
  5499. * Different type of clouds using effect 516
  5500. *------------------------------------------*/
  5501. ACMD_FUNC(clouds2)
  5502. {
  5503. nullpo_retr(-1, sd);
  5504. if (map[sd->bl.m].flag.clouds2) {
  5505. map[sd->bl.m].flag.clouds2=0;
  5506. clif_weather(sd->bl.m);
  5507. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5508. } else {
  5509. map[sd->bl.m].flag.clouds2=1;
  5510. clif_weather(sd->bl.m);
  5511. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5512. }
  5513. return 0;
  5514. }
  5515. /*==========================================
  5516. * Fog hangs over.
  5517. *------------------------------------------*/
  5518. ACMD_FUNC(fog)
  5519. {
  5520. nullpo_retr(-1, sd);
  5521. if (map[sd->bl.m].flag.fog) {
  5522. map[sd->bl.m].flag.fog=0;
  5523. clif_weather(sd->bl.m);
  5524. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5525. } else {
  5526. map[sd->bl.m].flag.fog=1;
  5527. clif_weather(sd->bl.m);
  5528. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5529. }
  5530. return 0;
  5531. }
  5532. /*==========================================
  5533. * Fallen leaves fall.
  5534. *------------------------------------------*/
  5535. ACMD_FUNC(leaves)
  5536. {
  5537. nullpo_retr(-1, sd);
  5538. if (map[sd->bl.m].flag.leaves) {
  5539. map[sd->bl.m].flag.leaves=0;
  5540. clif_weather(sd->bl.m);
  5541. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5542. } else {
  5543. map[sd->bl.m].flag.leaves=1;
  5544. clif_weather(sd->bl.m);
  5545. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5546. }
  5547. return 0;
  5548. }
  5549. /*==========================================
  5550. * Fireworks appear.
  5551. *------------------------------------------*/
  5552. ACMD_FUNC(fireworks)
  5553. {
  5554. nullpo_retr(-1, sd);
  5555. if (map[sd->bl.m].flag.fireworks) {
  5556. map[sd->bl.m].flag.fireworks=0;
  5557. clif_weather(sd->bl.m);
  5558. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5559. } else {
  5560. map[sd->bl.m].flag.fireworks=1;
  5561. clif_weather(sd->bl.m);
  5562. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5563. }
  5564. return 0;
  5565. }
  5566. /*==========================================
  5567. * Clearing Weather Effects by Dexity
  5568. *------------------------------------------*/
  5569. ACMD_FUNC(clearweather)
  5570. {
  5571. nullpo_retr(-1, sd);
  5572. /**
  5573. * No longer available, keeping here just in case it's back someday. [Ind]
  5574. **/
  5575. //map[sd->bl.m].flag.rain=0;
  5576. map[sd->bl.m].flag.snow=0;
  5577. map[sd->bl.m].flag.sakura=0;
  5578. map[sd->bl.m].flag.clouds=0;
  5579. map[sd->bl.m].flag.clouds2=0;
  5580. map[sd->bl.m].flag.fog=0;
  5581. map[sd->bl.m].flag.fireworks=0;
  5582. map[sd->bl.m].flag.leaves=0;
  5583. clif_weather(sd->bl.m);
  5584. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  5585. return 0;
  5586. }
  5587. /*===============================================================
  5588. * Sound Command - plays a sound for everyone around! [Codemaster]
  5589. *---------------------------------------------------------------*/
  5590. ACMD_FUNC(sound)
  5591. {
  5592. char sound_file[100];
  5593. memset(sound_file, '\0', sizeof(sound_file));
  5594. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5595. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5596. return -1;
  5597. }
  5598. if(strstr(sound_file, ".wav") == NULL)
  5599. strcat(sound_file, ".wav");
  5600. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5601. return 0;
  5602. }
  5603. /*==========================================
  5604. * MOB Search
  5605. *------------------------------------------*/
  5606. ACMD_FUNC(mobsearch)
  5607. {
  5608. char mob_name[100];
  5609. int mob_id;
  5610. int number = 0;
  5611. struct s_mapiterator* it;
  5612. nullpo_retr(-1, sd);
  5613. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5614. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5615. return -1;
  5616. }
  5617. if ((mob_id = atoi(mob_name)) == 0)
  5618. mob_id = mobdb_searchname(mob_name);
  5619. if( mobdb_checkid(mob_id) == 0){
  5620. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5621. clif_displaymessage(fd, atcmd_output);
  5622. return -1;
  5623. }
  5624. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5625. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5626. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5627. clif_displaymessage(fd, atcmd_output);
  5628. it = mapit_geteachmob();
  5629. for(;;)
  5630. {
  5631. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5632. if( md == NULL )
  5633. break;// no more mobs
  5634. if( md->bl.m != sd->bl.m )
  5635. continue;
  5636. if( md->mob_id != mob_id )
  5637. continue;
  5638. ++number;
  5639. if( md->spawn_timer == INVALID_TIMER )
  5640. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5641. else
  5642. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5643. clif_displaymessage(fd, atcmd_output);
  5644. }
  5645. mapit_free(it);
  5646. return 0;
  5647. }
  5648. /*==========================================
  5649. * @cleanmap - cleans items on the ground
  5650. * @cleanarea - cleans items on the ground within an specified area
  5651. *------------------------------------------*/
  5652. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5653. {
  5654. nullpo_ret(bl);
  5655. map_clearflooritem(bl);
  5656. return 0;
  5657. }
  5658. ACMD_FUNC(cleanmap)
  5659. {
  5660. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5661. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5662. return 0;
  5663. }
  5664. ACMD_FUNC(cleanarea)
  5665. {
  5666. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5667. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5668. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
  5669. }
  5670. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5671. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
  5672. }
  5673. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5674. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5675. }
  5676. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5677. return 0;
  5678. }
  5679. /*==========================================
  5680. * make a NPC/PET talk
  5681. * @npctalkc [SnakeDrak]
  5682. *------------------------------------------*/
  5683. ACMD_FUNC(npctalk)
  5684. {
  5685. char name[NPC_NAME_LENGTH],mes[100],temp[100];
  5686. struct npc_data *nd;
  5687. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5688. unsigned long color=0;
  5689. if (sd->sc.cant.chat)
  5690. return -1; //no "chatting" while muted.
  5691. if(!ifcolor) {
  5692. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  5693. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5694. return -1;
  5695. }
  5696. }
  5697. else {
  5698. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5699. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5700. return -1;
  5701. }
  5702. }
  5703. if (!(nd = npc_name2id(name))) {
  5704. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5705. return -1;
  5706. }
  5707. strtok(name, "#"); // discard extra name identifier if present
  5708. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5709. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  5710. else clif_disp_overhead(&nd->bl, temp);
  5711. return 0;
  5712. }
  5713. ACMD_FUNC(pettalk)
  5714. {
  5715. char mes[100],temp[100];
  5716. struct pet_data *pd;
  5717. nullpo_retr(-1, sd);
  5718. if ( battle_config.min_chat_delay ) {
  5719. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5720. return 0;
  5721. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5722. }
  5723. if(!sd->status.pet_id || !(pd=sd->pd))
  5724. {
  5725. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  5726. return -1;
  5727. }
  5728. if (sd->sc.cant.chat)
  5729. return -1; //no "chatting" while muted.
  5730. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5731. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5732. return -1;
  5733. }
  5734. if (message[0] == '/')
  5735. {// pet emotion processing
  5736. const char* emo[] = {
  5737. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5738. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5739. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5740. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5741. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5742. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5743. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5744. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5745. "/whisp"
  5746. };
  5747. int i;
  5748. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5749. if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
  5750. if( i < ARRAYLENGTH(emo) )
  5751. {
  5752. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5753. sd->emotionlasttime = time(NULL);
  5754. return 0;
  5755. }
  5756. sd->emotionlasttime = time(NULL);
  5757. clif_emotion(&pd->bl, i);
  5758. return 0;
  5759. }
  5760. }
  5761. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5762. clif_disp_overhead(&pd->bl, temp);
  5763. return 0;
  5764. }
  5765. /// @users - displays the number of players present on each map (and percentage)
  5766. /// #users displays on the target user instead of self
  5767. ACMD_FUNC(users)
  5768. {
  5769. char buf[CHAT_SIZE_MAX];
  5770. int i;
  5771. int users[MAX_MAPINDEX];
  5772. int users_all;
  5773. struct s_mapiterator* iter;
  5774. memset(users, 0, sizeof(users));
  5775. users_all = 0;
  5776. // count users on each map
  5777. iter = mapit_getallusers();
  5778. for(;;)
  5779. {
  5780. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5781. if( sd2 == NULL )
  5782. break;// no more users
  5783. if( sd2->mapindex >= MAX_MAPINDEX )
  5784. continue;// invalid mapindex
  5785. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5786. if( users_all < INT_MAX ) ++users_all;
  5787. }
  5788. mapit_free(iter);
  5789. // display results for each map
  5790. for( i = 0; i < MAX_MAPINDEX; ++i )
  5791. {
  5792. if( users[i] == 0 )
  5793. continue;// empty
  5794. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5795. clif_displaymessage(sd->fd, buf);
  5796. }
  5797. // display overall count
  5798. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5799. clif_displaymessage(sd->fd, buf);
  5800. return 0;
  5801. }
  5802. /*==========================================
  5803. *
  5804. *------------------------------------------*/
  5805. ACMD_FUNC(reset)
  5806. {
  5807. pc_resetstate(sd);
  5808. pc_resetskill(sd,1);
  5809. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5810. clif_displaymessage(fd, atcmd_output);
  5811. return 0;
  5812. }
  5813. /*==========================================
  5814. *
  5815. *------------------------------------------*/
  5816. ACMD_FUNC(summon)
  5817. {
  5818. char name[NAME_LENGTH];
  5819. int mob_id = 0;
  5820. int duration = 0;
  5821. struct mob_data *md;
  5822. unsigned int tick=gettick();
  5823. nullpo_retr(-1, sd);
  5824. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5825. {
  5826. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5827. return -1;
  5828. }
  5829. if (duration < 1)
  5830. duration =1;
  5831. else if (duration > 60)
  5832. duration =60;
  5833. if ((mob_id = atoi(name)) == 0)
  5834. mob_id = mobdb_searchname(name);
  5835. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5836. {
  5837. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5838. return -1;
  5839. }
  5840. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5841. if(!md)
  5842. return -1;
  5843. md->master_id=sd->bl.id;
  5844. md->special_state.ai=AI_ATTACK;
  5845. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5846. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  5847. mob_spawn(md);
  5848. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5849. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5850. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5851. return 0;
  5852. }
  5853. /*==========================================
  5854. * @adjgroup
  5855. * Temporarily move player to another group
  5856. * Useful during beta testing to allow players to use GM commands for short periods of time
  5857. *------------------------------------------*/
  5858. ACMD_FUNC(adjgroup)
  5859. {
  5860. int new_group = 0;
  5861. nullpo_retr(-1, sd);
  5862. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5863. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5864. return -1;
  5865. }
  5866. if (!pc_group_exists(new_group)) {
  5867. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5868. return -1;
  5869. }
  5870. sd->group_id = new_group;
  5871. pc_group_pc_load(sd);/* update cache */
  5872. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5873. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5874. return 0;
  5875. }
  5876. /*==========================================
  5877. * @trade by [MouseJstr]
  5878. * Open a trade window with a remote player
  5879. *------------------------------------------*/
  5880. ACMD_FUNC(trade)
  5881. {
  5882. struct map_session_data *pl_sd = NULL;
  5883. nullpo_retr(-1, sd);
  5884. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5885. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5886. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5887. return -1;
  5888. }
  5889. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5890. {
  5891. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5892. return -1;
  5893. }
  5894. trade_traderequest(sd, pl_sd);
  5895. return 0;
  5896. }
  5897. /*==========================================
  5898. * @setbattleflag by [MouseJstr]
  5899. * set a battle_config flag without having to reboot
  5900. *------------------------------------------*/
  5901. ACMD_FUNC(setbattleflag)
  5902. {
  5903. char flag[128], value[128];
  5904. int reload = 0;
  5905. nullpo_retr(-1, sd);
  5906. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
  5907. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  5908. return -1;
  5909. }
  5910. if (battle_set_value(flag, value) == 0)
  5911. {
  5912. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5913. return -1;
  5914. }
  5915. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5916. if (reload)
  5917. mob_reload();
  5918. return 0;
  5919. }
  5920. /*==========================================
  5921. * @unmute [Valaris]
  5922. *------------------------------------------*/
  5923. ACMD_FUNC(unmute)
  5924. {
  5925. struct map_session_data *pl_sd = NULL;
  5926. nullpo_retr(-1, sd);
  5927. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5928. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5929. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5930. return -1;
  5931. }
  5932. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  5933. {
  5934. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5935. return -1;
  5936. }
  5937. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5938. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5939. return -1;
  5940. }
  5941. pl_sd->status.manner = 0;
  5942. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5943. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5944. return 0;
  5945. }
  5946. /*==========================================
  5947. * @uptime by MC Cameri
  5948. *------------------------------------------*/
  5949. ACMD_FUNC(uptime)
  5950. {
  5951. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5952. minute = 60, days = 0, hours = 0, minutes = 0;
  5953. nullpo_retr(-1, sd);
  5954. seconds = get_uptime();
  5955. days = seconds/day;
  5956. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5957. hours = seconds/hour;
  5958. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5959. minutes = seconds/minute;
  5960. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5961. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  5962. clif_displaymessage(fd, atcmd_output);
  5963. return 0;
  5964. }
  5965. /*==========================================
  5966. * @changesex
  5967. * => Changes one's account sex. Switch from male to female or visversa
  5968. *------------------------------------------*/
  5969. ACMD_FUNC(changesex)
  5970. {
  5971. int i;
  5972. nullpo_retr(-1, sd);
  5973. pc_resetskill(sd,4);
  5974. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5975. for (i = 0; i < EQI_MAX; i++) {
  5976. if (sd->equip_index[i] >= 0)
  5977. pc_unequipitem(sd, sd->equip_index[i], 3);
  5978. }
  5979. chrif_changesex(sd, true);
  5980. return 0;
  5981. }
  5982. /*==========================================
  5983. * @changecharsex
  5984. * => Changes one's character sex. Switch from male to female or visversa.
  5985. *------------------------------------------*/
  5986. ACMD_FUNC(changecharsex)
  5987. {
  5988. int i;
  5989. nullpo_retr(-1, sd);
  5990. pc_resetskill(sd,4);
  5991. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5992. for (i = 0; i < EQI_MAX; i++) {
  5993. if (sd->equip_index[i] >= 0)
  5994. pc_unequipitem(sd, sd->equip_index[i], 3);
  5995. }
  5996. chrif_changesex(sd, false);
  5997. return 0;
  5998. }
  5999. /*================================================
  6000. * @mute - Mutes a player for a set amount of time
  6001. *------------------------------------------------*/
  6002. ACMD_FUNC(mute)
  6003. {
  6004. struct map_session_data *pl_sd = NULL;
  6005. int manner;
  6006. nullpo_retr(-1, sd);
  6007. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6008. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6009. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6010. return -1;
  6011. }
  6012. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6013. {
  6014. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6015. return -1;
  6016. }
  6017. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6018. {
  6019. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6020. return -1;
  6021. }
  6022. clif_manner_message(sd, 0);
  6023. clif_manner_message(pl_sd, 5);
  6024. if( pl_sd->status.manner < manner ) {
  6025. pl_sd->status.manner -= manner;
  6026. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6027. } else {
  6028. pl_sd->status.manner = 0;
  6029. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6030. }
  6031. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6032. return 0;
  6033. }
  6034. /*==========================================
  6035. * @refresh (like @jumpto <<yourself>>)
  6036. *------------------------------------------*/
  6037. ACMD_FUNC(refresh)
  6038. {
  6039. nullpo_retr(-1, sd);
  6040. clif_refresh(sd);
  6041. return 0;
  6042. }
  6043. ACMD_FUNC(refreshall)
  6044. {
  6045. struct map_session_data* iter_sd;
  6046. struct s_mapiterator* iter;
  6047. nullpo_retr(-1, sd);
  6048. iter = mapit_getallusers();
  6049. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6050. clif_refresh(iter_sd);
  6051. mapit_free(iter);
  6052. return 0;
  6053. }
  6054. /*==========================================
  6055. * @identify
  6056. * => GM's magnifier.
  6057. *------------------------------------------*/
  6058. ACMD_FUNC(identify)
  6059. {
  6060. int i,num;
  6061. nullpo_retr(-1, sd);
  6062. for(i=num=0;i<MAX_INVENTORY;i++){
  6063. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6064. num++;
  6065. }
  6066. }
  6067. if (num > 0) {
  6068. clif_item_identify_list(sd);
  6069. } else {
  6070. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6071. }
  6072. return 0;
  6073. }
  6074. /*===============================================
  6075. * @identifyall
  6076. * => Indentify all items in inventory - Akinari
  6077. *-----------------------------------------------*/
  6078. ACMD_FUNC(identifyall)
  6079. {
  6080. int i;
  6081. nullpo_retr(-1, sd);
  6082. for(i=0; i<MAX_INVENTORY; i++) {
  6083. if (sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6084. sd->inventory.u.items_inventory[i].identify = 1;
  6085. clif_item_identified(sd,i,0);
  6086. }
  6087. }
  6088. return 0;
  6089. }
  6090. /*==========================================
  6091. * @gmotd (Global MOTD)
  6092. * by davidsiaw :P
  6093. *------------------------------------------*/
  6094. ACMD_FUNC(gmotd)
  6095. {
  6096. FILE* fp;
  6097. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6098. {
  6099. char buf[CHAT_SIZE_MAX];
  6100. size_t len;
  6101. while( fgets(buf, sizeof(buf), fp) )
  6102. {
  6103. if( buf[0] == '/' && buf[1] == '/' )
  6104. {
  6105. continue;
  6106. }
  6107. len = strlen(buf);
  6108. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6109. {// strip trailing EOL characters
  6110. len--;
  6111. }
  6112. if( len )
  6113. {
  6114. buf[len] = 0;
  6115. intif_broadcast(buf, len+1, 0);
  6116. }
  6117. }
  6118. fclose(fp);
  6119. }
  6120. return 0;
  6121. }
  6122. ACMD_FUNC(misceffect)
  6123. {
  6124. int effect = 0;
  6125. nullpo_retr(-1, sd);
  6126. if (!message || !*message)
  6127. return -1;
  6128. if (sscanf(message, "%11d", &effect) < 1)
  6129. return -1;
  6130. clif_misceffect(&sd->bl,effect);
  6131. return 0;
  6132. }
  6133. /*==========================================
  6134. * MAIL SYSTEM
  6135. *------------------------------------------*/
  6136. ACMD_FUNC(mail)
  6137. {
  6138. nullpo_ret(sd);
  6139. mail_openmail(sd);
  6140. return 0;
  6141. }
  6142. /*==========================================
  6143. * Show Monster DB Info v 1.0
  6144. * originally by [Lupus]
  6145. *------------------------------------------*/
  6146. ACMD_FUNC(mobinfo)
  6147. {
  6148. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6149. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6150. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6151. char atcmd_output2[CHAT_SIZE_MAX];
  6152. struct item_data *item_data;
  6153. struct mob_db *mob;
  6154. uint16 mob_ids[MAX_SEARCH];
  6155. int count;
  6156. int i, k;
  6157. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6158. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6159. if (!message || !*message) {
  6160. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6161. return -1;
  6162. }
  6163. // If monster identifier/name argument is a name
  6164. if ((i = mobdb_checkid(atoi(message))))
  6165. {
  6166. mob_ids[0] = i;
  6167. count = 1;
  6168. } else
  6169. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6170. if (!count) {
  6171. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6172. return -1;
  6173. }
  6174. if (count >= MAX_SEARCH) {
  6175. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6176. clif_displaymessage(fd, atcmd_output);
  6177. count = MAX_SEARCH;
  6178. }
  6179. for (k = 0; k < count; k++) {
  6180. unsigned int j,base_exp,job_exp;
  6181. mob = mob_db(mob_ids[k]);
  6182. base_exp = mob->base_exp;
  6183. job_exp = mob->job_exp;
  6184. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6185. base_exp = (base_exp * battle_config.vip_base_exp_increase) / 100;
  6186. job_exp = (job_exp * battle_config.vip_job_exp_increase) / 100;
  6187. }
  6188. #ifdef RENEWAL_EXP
  6189. if( battle_config.atcommand_mobinfo_type ) {
  6190. base_exp = base_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6191. job_exp = job_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6192. }
  6193. #endif
  6194. // stats
  6195. if (mob->mexp)
  6196. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6197. else
  6198. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6199. clif_displaymessage(fd, atcmd_output);
  6200. sprintf(atcmd_output, msg_txt(sd,1242), mob->lv, mob->status.max_hp, base_exp, job_exp, MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
  6201. clif_displaymessage(fd, atcmd_output);
  6202. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6203. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6204. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6205. clif_displaymessage(fd, atcmd_output);
  6206. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6207. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6208. mob->range2 , mob->range3, msize[mob->status.size],
  6209. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6210. clif_displaymessage(fd, atcmd_output);
  6211. // drops
  6212. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6213. strcpy(atcmd_output, " ");
  6214. j = 0;
  6215. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6216. int droprate;
  6217. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6218. continue;
  6219. droprate = mob->dropitem[i].p;
  6220. #ifdef RENEWAL_DROP
  6221. if( battle_config.atcommand_mobinfo_type ) {
  6222. droprate = droprate * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 2) / 100;
  6223. if (droprate <= 0 && !battle_config.drop_rate0item)
  6224. droprate = 1;
  6225. }
  6226. #endif
  6227. if (pc_isvip(sd)) // Display drop rate increase for VIP
  6228. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6229. if (item_data->slot)
  6230. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6231. else
  6232. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6233. strcat(atcmd_output, atcmd_output2);
  6234. if (++j % 3 == 0) {
  6235. clif_displaymessage(fd, atcmd_output);
  6236. strcpy(atcmd_output, " ");
  6237. }
  6238. }
  6239. if (j == 0)
  6240. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6241. else if (j % 3 != 0)
  6242. clif_displaymessage(fd, atcmd_output);
  6243. // mvp
  6244. if (mob->mexp) {
  6245. float mvppercent, mvpremain;
  6246. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6247. clif_displaymessage(fd, atcmd_output);
  6248. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6249. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6250. j = 0;
  6251. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6252. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6253. continue;
  6254. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6255. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6256. if(battle_config.item_drop_mvp_mode == 0) {
  6257. mvpremain -= mvppercent;
  6258. }
  6259. if (mvppercent > 0) {
  6260. j++;
  6261. if (j == 1) {
  6262. if (item_data->slot)
  6263. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6264. else
  6265. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6266. } else {
  6267. if (item_data->slot)
  6268. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6269. else
  6270. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6271. }
  6272. strcat(atcmd_output, atcmd_output2);
  6273. }
  6274. }
  6275. if (j == 0)
  6276. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6277. else
  6278. clif_displaymessage(fd, atcmd_output);
  6279. }
  6280. }
  6281. return 0;
  6282. }
  6283. /*=========================================
  6284. * @showmobs by KarLaeda
  6285. * => For 15 sec displays the mobs on minimap
  6286. *------------------------------------------*/
  6287. ACMD_FUNC(showmobs)
  6288. {
  6289. char mob_name[100];
  6290. int mob_id;
  6291. int number = 0;
  6292. struct s_mapiterator* it;
  6293. nullpo_retr(-1, sd);
  6294. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6295. return -1;
  6296. if((mob_id = atoi(mob_name)) == 0)
  6297. mob_id = mobdb_searchname(mob_name);
  6298. if(mobdb_checkid(mob_id) == 0){
  6299. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6300. clif_displaymessage(fd, atcmd_output);
  6301. return 0;
  6302. }
  6303. if(status_has_mode(&mob_db(mob_id)->status,MD_STATUS_IMMUNE) && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6304. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6305. return 0;
  6306. }
  6307. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname[0])
  6308. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6309. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6310. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6311. mob_name, mapindex_id2name(sd->mapindex));
  6312. clif_displaymessage(fd, atcmd_output);
  6313. it = mapit_geteachmob();
  6314. for(;;)
  6315. {
  6316. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6317. if( md == NULL )
  6318. break;// no more mobs
  6319. if( md->bl.m != sd->bl.m )
  6320. continue;
  6321. if( mob_id != -1 && md->mob_id != mob_id )
  6322. continue;
  6323. if( md->special_state.ai || md->master_id )
  6324. continue; // hide slaves and player summoned mobs
  6325. if( md->spawn_timer != INVALID_TIMER )
  6326. continue; // hide mobs waiting for respawn
  6327. ++number;
  6328. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6329. }
  6330. mapit_free(it);
  6331. return 0;
  6332. }
  6333. /*==========================================
  6334. * homunculus level up [orn]
  6335. *------------------------------------------*/
  6336. ACMD_FUNC(homlevel)
  6337. {
  6338. TBL_HOM * hd;
  6339. int level = 0, i = 0;
  6340. nullpo_retr(-1, sd);
  6341. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6342. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6343. return -1;
  6344. }
  6345. if ( !hom_is_active(sd->hd) ) {
  6346. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6347. return -1;
  6348. }
  6349. hd = sd->hd;
  6350. for (i = 1; i <= level && hd->exp_next; i++){
  6351. hd->homunculus.exp += hd->exp_next;
  6352. if( !hom_levelup(hd) )
  6353. break;
  6354. }
  6355. status_calc_homunculus(hd, SCO_NONE);
  6356. status_percent_heal(&hd->bl, 100, 100);
  6357. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6358. return 0;
  6359. }
  6360. /*==========================================
  6361. * homunculus evolution H [orn]
  6362. *------------------------------------------*/
  6363. ACMD_FUNC(homevolution)
  6364. {
  6365. nullpo_retr(-1, sd);
  6366. if ( !hom_is_active(sd->hd) ) {
  6367. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6368. return -1;
  6369. }
  6370. if ( !hom_evolution(sd->hd) ) {
  6371. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6372. return -1;
  6373. }
  6374. clif_homskillinfoblock(sd);
  6375. return 0;
  6376. }
  6377. ACMD_FUNC(hommutate)
  6378. {
  6379. int homun_id, m_class = 0, m_id;
  6380. nullpo_retr(-1, sd);
  6381. if (!hom_is_active(sd->hd)) {
  6382. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6383. return -1;
  6384. }
  6385. if (!message || !*message) {
  6386. homun_id = 6048 + (rnd() % 4);
  6387. } else {
  6388. homun_id = atoi(message);
  6389. }
  6390. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6391. m_id = hom_class2mapid(homun_id);
  6392. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6393. hom_mutate(sd->hd, homun_id);
  6394. } else {
  6395. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6396. }
  6397. return 0;
  6398. }
  6399. /*==========================================
  6400. * call choosen homunculus [orn]
  6401. *------------------------------------------*/
  6402. ACMD_FUNC(makehomun)
  6403. {
  6404. int homunid;
  6405. nullpo_retr(-1, sd);
  6406. if ( sd->status.hom_id ) {
  6407. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6408. return -1;
  6409. }
  6410. if (!message || !*message) {
  6411. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6412. return -1;
  6413. }
  6414. homunid = atoi(message);
  6415. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6416. {
  6417. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6418. return -1;
  6419. }
  6420. hom_create_request(sd,homunid);
  6421. return 0;
  6422. }
  6423. /*==========================================
  6424. * modify homunculus intimacy [orn]
  6425. *------------------------------------------*/
  6426. ACMD_FUNC(homfriendly)
  6427. {
  6428. int friendly = 0;
  6429. nullpo_retr(-1, sd);
  6430. if ( !hom_is_active(sd->hd) ) {
  6431. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6432. return -1;
  6433. }
  6434. if (!message || !*message) {
  6435. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6436. return -1;
  6437. }
  6438. friendly = atoi(message);
  6439. friendly = cap_value(friendly, 0, 1000);
  6440. sd->hd->homunculus.intimacy = friendly * 100 ;
  6441. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6442. return 0;
  6443. }
  6444. /*==========================================
  6445. * modify homunculus hunger [orn]
  6446. *------------------------------------------*/
  6447. ACMD_FUNC(homhungry)
  6448. {
  6449. int hungry = 0;
  6450. nullpo_retr(-1, sd);
  6451. if ( !hom_is_active(sd->hd) ) {
  6452. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6453. return -1;
  6454. }
  6455. if (!message || !*message) {
  6456. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6457. return -1;
  6458. }
  6459. hungry = atoi(message);
  6460. hungry = cap_value(hungry, 0, 100);
  6461. sd->hd->homunculus.hunger = hungry;
  6462. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6463. return 0;
  6464. }
  6465. /*==========================================
  6466. * make the homunculus speak [orn]
  6467. *------------------------------------------*/
  6468. ACMD_FUNC(homtalk)
  6469. {
  6470. char mes[100],temp[100];
  6471. nullpo_retr(-1, sd);
  6472. if ( battle_config.min_chat_delay ) {
  6473. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6474. return 0;
  6475. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6476. }
  6477. if (sd->sc.cant.chat)
  6478. return -1; //no "chatting" while muted.
  6479. if ( !hom_is_active(sd->hd) ) {
  6480. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6481. return -1;
  6482. }
  6483. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6484. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6485. return -1;
  6486. }
  6487. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6488. clif_disp_overhead(&sd->hd->bl, temp);
  6489. return 0;
  6490. }
  6491. /*==========================================
  6492. * Show homunculus stats
  6493. *------------------------------------------*/
  6494. ACMD_FUNC(hominfo)
  6495. {
  6496. struct homun_data *hd;
  6497. struct status_data *status;
  6498. nullpo_retr(-1, sd);
  6499. if ( !hom_is_active(sd->hd) ) {
  6500. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6501. return -1;
  6502. }
  6503. hd = sd->hd;
  6504. status = status_get_status_data(&hd->bl);
  6505. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6506. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6507. status->hp, status->max_hp, status->sp, status->max_sp);
  6508. clif_displaymessage(fd, atcmd_output);
  6509. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6510. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6511. clif_displaymessage(fd, atcmd_output);
  6512. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6513. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6514. clif_displaymessage(fd, atcmd_output);
  6515. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6516. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6517. status->str, status->agi, status->vit,
  6518. status->int_, status->dex, status->luk);
  6519. clif_displaymessage(fd, atcmd_output);
  6520. return 0;
  6521. }
  6522. ACMD_FUNC(homstats)
  6523. {
  6524. struct homun_data *hd;
  6525. struct s_homunculus_db *db;
  6526. struct s_homunculus *hom;
  6527. int lv, min, max, evo;
  6528. nullpo_retr(-1, sd);
  6529. if ( !hom_is_active(sd->hd) ) {
  6530. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6531. return -1;
  6532. }
  6533. hd = sd->hd;
  6534. hom = &hd->homunculus;
  6535. db = hd->homunculusDB;
  6536. lv = hom->level;
  6537. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6538. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6539. clif_displaymessage(fd, atcmd_output);
  6540. lv--; //Since the first increase is at level 2.
  6541. evo = (hom->class_ == db->evo_class);
  6542. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6543. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6544. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6545. clif_displaymessage(fd, atcmd_output);
  6546. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6547. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6548. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6549. clif_displaymessage(fd, atcmd_output);
  6550. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6551. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6552. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6553. clif_displaymessage(fd, atcmd_output);
  6554. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6555. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6556. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6557. clif_displaymessage(fd, atcmd_output);
  6558. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6559. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6560. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6561. clif_displaymessage(fd, atcmd_output);
  6562. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6563. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6564. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6565. clif_displaymessage(fd, atcmd_output);
  6566. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6567. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6568. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6569. clif_displaymessage(fd, atcmd_output);
  6570. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6571. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6572. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6573. clif_displaymessage(fd, atcmd_output);
  6574. return 0;
  6575. }
  6576. ACMD_FUNC(homshuffle)
  6577. {
  6578. nullpo_retr(-1, sd);
  6579. if(!sd->hd)
  6580. return -1; // nothing to do
  6581. if(!hom_shuffle(sd->hd))
  6582. return -1;
  6583. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6584. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6585. return 0;
  6586. }
  6587. /*==========================================
  6588. * Show Items DB Info v 1.0
  6589. * originally by [Lupus]
  6590. *------------------------------------------*/
  6591. ACMD_FUNC(iteminfo)
  6592. {
  6593. struct item_data *item_array[MAX_SEARCH];
  6594. int i, count = 1;
  6595. if (!message || !*message) {
  6596. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6597. return -1;
  6598. }
  6599. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6600. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6601. if (!count) {
  6602. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6603. return -1;
  6604. }
  6605. if (count == MAX_SEARCH) {
  6606. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6607. clif_displaymessage(fd, atcmd_output);
  6608. }
  6609. for (i = 0; i < count; i++) {
  6610. struct item_data * item_data = item_array[i];
  6611. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6612. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6613. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6614. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6615. );
  6616. clif_displaymessage(fd, atcmd_output);
  6617. sprintf(atcmd_output, msg_txt(sd,1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  6618. clif_displaymessage(fd, atcmd_output);
  6619. if (item_data->maxchance == -1) {
  6620. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6621. clif_displaymessage(fd, atcmd_output);
  6622. }
  6623. else if (!battle_config.atcommand_mobinfo_type) {
  6624. if (item_data->maxchance)
  6625. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6626. else
  6627. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6628. clif_displaymessage(fd, atcmd_output);
  6629. }
  6630. }
  6631. return 0;
  6632. }
  6633. /*==========================================
  6634. * Show who drops the item.
  6635. *------------------------------------------*/
  6636. ACMD_FUNC(whodrops)
  6637. {
  6638. struct item_data *item_data, *item_array[MAX_SEARCH];
  6639. int i,j, count = 1;
  6640. if (!message || !*message) {
  6641. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6642. return -1;
  6643. }
  6644. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6645. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6646. if (!count) {
  6647. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6648. return -1;
  6649. }
  6650. if (count == MAX_SEARCH) {
  6651. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6652. clif_displaymessage(fd, atcmd_output);
  6653. }
  6654. for (i = 0; i < count; i++) {
  6655. item_data = item_array[i];
  6656. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6657. clif_displaymessage(fd, atcmd_output);
  6658. if (item_data->mob[0].chance == 0) {
  6659. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6660. clif_displaymessage(fd, atcmd_output);
  6661. } else {
  6662. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6663. clif_displaymessage(fd, atcmd_output);
  6664. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6665. {
  6666. int dropchance = item_data->mob[j].chance;
  6667. #ifdef RENEWAL_DROP
  6668. if( battle_config.atcommand_mobinfo_type )
  6669. dropchance = dropchance * pc_level_penalty_mod(mob_db(item_data->mob[j].id)->lv - sd->status.base_level, mob_db(item_data->mob[j].id)->status.class_, mob_db(item_data->mob[j].id)->status.mode, 2) / 100;
  6670. #endif
  6671. if (pc_isvip(sd)) // Display item rate increase for VIP
  6672. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6673. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6674. clif_displaymessage(fd, atcmd_output);
  6675. }
  6676. }
  6677. }
  6678. return 0;
  6679. }
  6680. ACMD_FUNC(whereis)
  6681. {
  6682. uint16 mob_ids[MAX_SEARCH] = {0};
  6683. int count = 0;
  6684. if (!message || !*message) {
  6685. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6686. return -1;
  6687. }
  6688. int i_message = atoi(message);
  6689. if (mobdb_checkid(i_message)) {
  6690. // ID given
  6691. mob_ids[0] = i_message;
  6692. count = 1;
  6693. } else {
  6694. // Name given, get all monster associated whith this name
  6695. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6696. }
  6697. if (count <= 0) {
  6698. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6699. return -1;
  6700. }
  6701. if (count >= MAX_SEARCH) {
  6702. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6703. clif_displaymessage(fd, atcmd_output);
  6704. count = MAX_SEARCH;
  6705. }
  6706. for (int i = 0; i < count; i++) {
  6707. uint16 mob_id = mob_ids[i];
  6708. struct mob_db * mob = mob_db(mob_id);
  6709. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6710. clif_displaymessage(fd, atcmd_output);
  6711. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  6712. if (spawns.size() <= 0) {
  6713. // This monster does not spawn normally.
  6714. clif_displaymessage(fd, msg_txt(sd,1290));
  6715. } else {
  6716. for(auto& spawn : spawns)
  6717. {
  6718. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  6719. if (mapid < 0)
  6720. continue;
  6721. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[mapid].name, spawn.qty);
  6722. clif_displaymessage(fd, atcmd_output);
  6723. }
  6724. }
  6725. }
  6726. return 0;
  6727. }
  6728. ACMD_FUNC(version)
  6729. {
  6730. pc_show_version(sd);
  6731. return 0;
  6732. }
  6733. /*==========================================
  6734. * @mutearea by MouseJstr
  6735. *------------------------------------------*/
  6736. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6737. {
  6738. int time, id;
  6739. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6740. if (pl_sd == NULL)
  6741. return 0;
  6742. id = va_arg(ap, int);
  6743. time = va_arg(ap, int);
  6744. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6745. pl_sd->status.manner -= time;
  6746. if (pl_sd->status.manner < 0)
  6747. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6748. else
  6749. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6750. }
  6751. return 0;
  6752. }
  6753. ACMD_FUNC(mutearea)
  6754. {
  6755. int time;
  6756. nullpo_ret(sd);
  6757. if (!message || !*message) {
  6758. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6759. return -1;
  6760. }
  6761. time = atoi(message);
  6762. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  6763. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6764. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6765. return 0;
  6766. }
  6767. ACMD_FUNC(rates)
  6768. {
  6769. char buf[CHAT_SIZE_MAX];
  6770. nullpo_ret(sd);
  6771. memset(buf, '\0', sizeof(buf));
  6772. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6773. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  6774. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  6775. clif_displaymessage(fd, buf);
  6776. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6777. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6778. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6779. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6780. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6781. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6782. clif_displaymessage(fd, buf);
  6783. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6784. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6785. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6786. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6787. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6788. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6789. clif_displaymessage(fd, buf);
  6790. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6791. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6792. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6793. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6794. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6795. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6796. clif_displaymessage(fd, buf);
  6797. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6798. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6799. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6800. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6801. clif_displaymessage(fd, buf);
  6802. return 0;
  6803. }
  6804. /*==========================================
  6805. * @me by lordalfa
  6806. * => Displays the OUTPUT string on top of the Visible players Heads.
  6807. *------------------------------------------*/
  6808. ACMD_FUNC(me)
  6809. {
  6810. char tempmes[CHAT_SIZE_MAX];
  6811. nullpo_retr(-1, sd);
  6812. memset(tempmes, '\0', sizeof(tempmes));
  6813. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6814. if (sd->sc.cant.chat)
  6815. return -1; //no "chatting" while muted.
  6816. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6817. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6818. return -1;
  6819. }
  6820. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6821. clif_disp_overhead(&sd->bl, atcmd_output);
  6822. return 0;
  6823. }
  6824. /*==========================================
  6825. * @size
  6826. * => Resize your character sprite. [Valaris]
  6827. *------------------------------------------*/
  6828. ACMD_FUNC(size)
  6829. {
  6830. int size = SZ_SMALL;
  6831. nullpo_retr(-1, sd);
  6832. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6833. if(sd->state.size) {
  6834. sd->state.size = SZ_SMALL;
  6835. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6836. }
  6837. sd->state.size = size;
  6838. if( size == SZ_MEDIUM )
  6839. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  6840. else if( size == SZ_BIG )
  6841. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  6842. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6843. return 0;
  6844. }
  6845. ACMD_FUNC(sizeall)
  6846. {
  6847. int size;
  6848. struct map_session_data *pl_sd;
  6849. struct s_mapiterator* iter;
  6850. size = atoi(message);
  6851. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6852. iter = mapit_getallusers();
  6853. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6854. if( pl_sd->state.size != size ) {
  6855. if( pl_sd->state.size ) {
  6856. pl_sd->state.size = SZ_SMALL;
  6857. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6858. }
  6859. pl_sd->state.size = size;
  6860. if( size == SZ_MEDIUM )
  6861. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6862. else if( size == SZ_BIG )
  6863. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6864. }
  6865. }
  6866. mapit_free(iter);
  6867. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6868. return 0;
  6869. }
  6870. ACMD_FUNC(sizeguild)
  6871. {
  6872. int size = SZ_SMALL, i;
  6873. char guild[NAME_LENGTH];
  6874. struct map_session_data *pl_sd;
  6875. struct guild *g;
  6876. nullpo_retr(-1, sd);
  6877. memset(guild, '\0', sizeof(guild));
  6878. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6879. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6880. return -1;
  6881. }
  6882. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6883. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6884. return -1;
  6885. }
  6886. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6887. for( i = 0; i < g->max_member; i++ ) {
  6888. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6889. if( pl_sd->state.size ) {
  6890. pl_sd->state.size = SZ_SMALL;
  6891. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6892. }
  6893. pl_sd->state.size = size;
  6894. if( size == SZ_MEDIUM )
  6895. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6896. else if( size == SZ_BIG )
  6897. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6898. }
  6899. }
  6900. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6901. return 0;
  6902. }
  6903. /*==========================================
  6904. * @monsterignore
  6905. * => Makes monsters ignore you. [Valaris]
  6906. *------------------------------------------*/
  6907. ACMD_FUNC(monsterignore)
  6908. {
  6909. nullpo_retr(-1, sd);
  6910. if (!sd->state.monster_ignore) {
  6911. sd->state.monster_ignore = 1;
  6912. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6913. } else {
  6914. sd->state.monster_ignore = 0;
  6915. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6916. }
  6917. return 0;
  6918. }
  6919. /*==========================================
  6920. * @fakename
  6921. * => Gives your character a fake name. [Valaris]
  6922. *------------------------------------------*/
  6923. ACMD_FUNC(fakename)
  6924. {
  6925. nullpo_retr(-1, sd);
  6926. if( !message || !*message )
  6927. {
  6928. if( sd->fakename[0] )
  6929. {
  6930. sd->fakename[0] = '\0';
  6931. clif_name_area(&sd->bl);
  6932. if (sd->disguise)
  6933. clif_name_self(&sd->bl);
  6934. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6935. return 0;
  6936. }
  6937. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6938. return -1;
  6939. }
  6940. if( strlen(message) < 2 )
  6941. {
  6942. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6943. return -1;
  6944. }
  6945. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6946. clif_name_area(&sd->bl);
  6947. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6948. clif_name_self(&sd->bl);
  6949. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6950. return 0;
  6951. }
  6952. /*==========================================
  6953. * Ragnarok Resources
  6954. *------------------------------------------*/
  6955. ACMD_FUNC(mapflag) {
  6956. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6957. #define setflag( cmd ) \
  6958. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6959. map[ sd->bl.m ].flag.cmd = flag;\
  6960. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6961. clif_displaymessage(sd->fd,atcmd_output);\
  6962. return 0;\
  6963. }
  6964. char flag_name[100];
  6965. short flag=0,i;
  6966. nullpo_retr(-1, sd);
  6967. memset(flag_name, '\0', sizeof(flag_name));
  6968. if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
  6969. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6970. clif_displaymessage(sd->fd,"----------------------------------");
  6971. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6972. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6973. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6974. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6975. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6976. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6977. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6978. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6979. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6980. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6981. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6982. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6983. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6984. checkflag(nolockon); checkflag(notomb); checkflag(nocostume); checkflag(gvg_te);
  6985. checkflag(gvg_te_castle); checkflag(hidemobhpbar);
  6986. #ifdef ADJUST_SKILL_DAMAGE
  6987. checkflag(skill_damage);
  6988. #endif
  6989. clif_displaymessage(sd->fd," ");
  6990. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6991. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6992. return 1;
  6993. }
  6994. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6995. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6996. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6997. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6998. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6999. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  7000. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  7001. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  7002. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  7003. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  7004. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  7005. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  7006. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  7007. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  7008. setflag(nolockon); setflag(notomb); setflag(nocostume); setflag(gvg_te);
  7009. setflag(gvg_te_castle); setflag(hidemobhpbar);
  7010. #ifdef ADJUST_SKILL_DAMAGE
  7011. setflag(skill_damage);
  7012. #endif
  7013. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  7014. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7015. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7016. clif_displaymessage(sd->fd,"----------------------------------");
  7017. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  7018. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  7019. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  7020. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  7021. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  7022. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  7023. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb,");
  7024. clif_displaymessage(sd->fd,"nocostume, gvg_te, gvg_te_castle, hidemobhpbar");
  7025. #ifdef ADJUST_SKILL_DAMAGE
  7026. clif_displaymessage(sd->fd,"skill_damage");
  7027. #endif
  7028. #undef checkflag
  7029. #undef setflag
  7030. return 0;
  7031. }
  7032. /*===================================
  7033. * Remove some messages
  7034. *-----------------------------------*/
  7035. ACMD_FUNC(showexp)
  7036. {
  7037. if (sd->state.showexp) {
  7038. sd->state.showexp = 0;
  7039. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7040. return 0;
  7041. }
  7042. sd->state.showexp = 1;
  7043. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7044. return 0;
  7045. }
  7046. ACMD_FUNC(showzeny)
  7047. {
  7048. if (sd->state.showzeny) {
  7049. sd->state.showzeny = 0;
  7050. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7051. return 0;
  7052. }
  7053. sd->state.showzeny = 1;
  7054. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7055. return 0;
  7056. }
  7057. ACMD_FUNC(showdelay)
  7058. {
  7059. if (sd->state.showdelay) {
  7060. sd->state.showdelay = 0;
  7061. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7062. return 0;
  7063. }
  7064. sd->state.showdelay = 1;
  7065. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7066. return 0;
  7067. }
  7068. /*==========================================
  7069. * Duel organizing functions [LuzZza]
  7070. *
  7071. * @duel [limit|nick] - create a duel
  7072. * @invite <nick> - invite player
  7073. * @accept - accept invitation
  7074. * @reject - reject invitation
  7075. * @leave - leave duel
  7076. *------------------------------------------*/
  7077. ACMD_FUNC(invite)
  7078. {
  7079. unsigned int did = sd->duel_group;
  7080. struct map_session_data *target_sd = NULL;
  7081. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7082. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7083. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7084. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7085. clif_displaymessage(fd, atcmd_output);
  7086. return -1;
  7087. }
  7088. if(did == 0 || !duel_exist(did) ) {
  7089. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7090. return 0;
  7091. }
  7092. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7093. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7094. return 0;
  7095. }
  7096. if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
  7097. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7098. return 0;
  7099. }
  7100. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7101. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7102. return 0;
  7103. }
  7104. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7105. {
  7106. sprintf(atcmd_output, msg_txt(sd,364), atcmd_player_name); // Duel: You can't invite %s because he/she isn't on the same map.
  7107. clif_displaymessage(fd, atcmd_output);
  7108. return 0;
  7109. }
  7110. duel_invite(did, sd, target_sd);
  7111. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7112. return 0;
  7113. }
  7114. ACMD_FUNC(duel)
  7115. {
  7116. unsigned int maxpl = 0;
  7117. if(sd->duel_group > 0) {
  7118. duel_showinfo(sd->duel_group, sd);
  7119. return 0;
  7120. }
  7121. if(sd->duel_invite > 0) {
  7122. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7123. return 0;
  7124. }
  7125. if(!duel_checktime(sd)) {
  7126. char output[CHAT_SIZE_MAX];
  7127. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7128. clif_displaymessage(fd, output);
  7129. return 0;
  7130. }
  7131. if( message[0] ) {
  7132. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7133. if(maxpl < 2 || maxpl > 65535) {
  7134. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7135. return 0;
  7136. }
  7137. duel_create(sd, maxpl);
  7138. } else {
  7139. struct map_session_data *target_sd = NULL;
  7140. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7141. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7142. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7143. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7144. clif_displaymessage(fd, atcmd_output);
  7145. return -1;
  7146. }
  7147. target_sd = map_nick2sd(atcmd_player_name,true);
  7148. if(target_sd != NULL) {
  7149. unsigned int newduel;
  7150. if((newduel = duel_create(sd, 2)) != -1) {
  7151. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7152. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7153. return 0;
  7154. }
  7155. duel_invite(newduel, sd, target_sd);
  7156. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7157. }
  7158. } else {
  7159. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7160. return 0;
  7161. }
  7162. }
  7163. } else
  7164. duel_create(sd, 0);
  7165. return 0;
  7166. }
  7167. ACMD_FUNC(leave)
  7168. {
  7169. if(sd->duel_group <= 0) {
  7170. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7171. return 0;
  7172. }
  7173. duel_leave(sd->duel_group, sd);
  7174. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7175. return 0;
  7176. }
  7177. ACMD_FUNC(accept)
  7178. {
  7179. if(!duel_checktime(sd)) {
  7180. char output[CHAT_SIZE_MAX];
  7181. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7182. clif_displaymessage(fd, output);
  7183. return 0;
  7184. }
  7185. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7186. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7187. return 0;
  7188. }
  7189. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7190. {
  7191. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7192. return 0;
  7193. }
  7194. duel_accept(sd->duel_invite, sd);
  7195. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7196. return 0;
  7197. }
  7198. ACMD_FUNC(reject)
  7199. {
  7200. if(sd->duel_invite <= 0) {
  7201. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7202. return 0;
  7203. }
  7204. duel_reject(sd->duel_invite, sd);
  7205. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7206. return 0;
  7207. }
  7208. /*===================================
  7209. * Cash Points
  7210. *-----------------------------------*/
  7211. ACMD_FUNC(cash)
  7212. {
  7213. char output[128];
  7214. int value;
  7215. int ret=0;
  7216. nullpo_retr(-1, sd);
  7217. // Since there is no cashpoint update packet we need to force updating like this
  7218. if( sd->state.cashshop_open ){
  7219. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7220. return -1;
  7221. }
  7222. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7223. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7224. return -1;
  7225. }
  7226. parent_cmd = atcommand_checkalias(command+1);
  7227. if( !strcmpi(parent_cmd,"cash") )
  7228. {
  7229. if( value > 0 ) {
  7230. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7231. // If this option is set, the message is already sent by pc function
  7232. if( !battle_config.cashshop_show_points ){
  7233. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7234. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7235. }
  7236. }
  7237. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7238. } else {
  7239. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7240. value = -sd->cashPoints;
  7241. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7242. // If this option is set, the message is already sent by pc function
  7243. if( !battle_config.cashshop_show_points ){
  7244. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7245. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7246. }
  7247. }
  7248. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7249. }
  7250. }
  7251. else
  7252. { // @points
  7253. if( value > 0 ) {
  7254. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7255. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7256. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7257. }
  7258. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7259. } else {
  7260. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7261. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7262. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7263. }
  7264. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7265. }
  7266. }
  7267. return 0;
  7268. }
  7269. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7270. ACMD_FUNC(clone)
  7271. {
  7272. int x=0,y=0,flag=0,master=0,i=0;
  7273. struct map_session_data *pl_sd=NULL;
  7274. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7275. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7276. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7277. return 0;
  7278. }
  7279. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
  7280. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7281. return 0;
  7282. }
  7283. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7284. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7285. return 0;
  7286. }
  7287. parent_cmd = atcommand_checkalias(command+1);
  7288. if (strcmpi(parent_cmd, "clone") == 0)
  7289. flag = 1;
  7290. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7291. flag = 2;
  7292. if(pc_isdead(sd)){
  7293. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7294. return 0;
  7295. }
  7296. master = sd->bl.id;
  7297. if (battle_config.atc_slave_clone_limit
  7298. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7299. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7300. return 0;
  7301. }
  7302. }
  7303. do {
  7304. x = sd->bl.x + (rnd() % 10 - 5);
  7305. y = sd->bl.y + (rnd() % 10 - 5);
  7306. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7307. if (i >= 10) {
  7308. x = sd->bl.x;
  7309. y = sd->bl.y;
  7310. }
  7311. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7312. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7313. return 0;
  7314. }
  7315. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7316. return 0;
  7317. }
  7318. /*=====================================
  7319. * Autorejecting Invites/Deals [LuzZza]
  7320. * Usage: @noask
  7321. *-------------------------------------*/
  7322. ACMD_FUNC(noask)
  7323. {
  7324. if(sd->state.noask) {
  7325. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7326. sd->state.noask = 0;
  7327. } else {
  7328. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7329. sd->state.noask = 1;
  7330. }
  7331. return 0;
  7332. }
  7333. /*=====================================
  7334. * Send a @request message to all GMs of lowest_gm_level.
  7335. * Usage: @request <petition>
  7336. *-------------------------------------*/
  7337. ACMD_FUNC(request)
  7338. {
  7339. if (!message || !*message) {
  7340. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7341. return -1;
  7342. }
  7343. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7344. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7345. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7346. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7347. return 0;
  7348. }
  7349. /*==========================================
  7350. * Feel (SG save map) Reset [HiddenDragon]
  7351. *------------------------------------------*/
  7352. ACMD_FUNC(feelreset)
  7353. {
  7354. pc_resetfeel(sd);
  7355. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7356. return 0;
  7357. }
  7358. /*==========================================
  7359. * AUCTION SYSTEM
  7360. *------------------------------------------*/
  7361. ACMD_FUNC(auction)
  7362. {
  7363. nullpo_ret(sd);
  7364. if (!battle_config.feature_auction) {
  7365. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7366. return 0;
  7367. }
  7368. clif_Auction_openwindow(sd);
  7369. return 0;
  7370. }
  7371. /*==========================================
  7372. * Kill Steal Protection
  7373. *------------------------------------------*/
  7374. ACMD_FUNC(ksprotection)
  7375. {
  7376. nullpo_retr(-1,sd);
  7377. if( sd->state.noks ) {
  7378. sd->state.noks = 0;
  7379. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7380. }
  7381. else
  7382. {
  7383. if( !message || !*message || !strcmpi(message, "party") )
  7384. { // Default is Party
  7385. sd->state.noks = 2;
  7386. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7387. }
  7388. else if( !strcmpi(message, "self") )
  7389. {
  7390. sd->state.noks = 1;
  7391. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7392. }
  7393. else if( !strcmpi(message, "guild") )
  7394. {
  7395. sd->state.noks = 3;
  7396. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7397. }
  7398. else
  7399. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7400. }
  7401. return 0;
  7402. }
  7403. /*==========================================
  7404. * Map Kill Steal Protection Setting
  7405. *------------------------------------------*/
  7406. ACMD_FUNC(allowks)
  7407. {
  7408. nullpo_retr(-1,sd);
  7409. if( map[sd->bl.m].flag.allowks ) {
  7410. map[sd->bl.m].flag.allowks = 0;
  7411. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7412. } else {
  7413. map[sd->bl.m].flag.allowks = 1;
  7414. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7415. }
  7416. return 0;
  7417. }
  7418. ACMD_FUNC(resetstat)
  7419. {
  7420. nullpo_retr(-1, sd);
  7421. pc_resetstate(sd);
  7422. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7423. clif_displaymessage(fd, atcmd_output);
  7424. return 0;
  7425. }
  7426. ACMD_FUNC(resetskill)
  7427. {
  7428. nullpo_retr(-1,sd);
  7429. pc_resetskill(sd,1);
  7430. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7431. clif_displaymessage(fd, atcmd_output);
  7432. return 0;
  7433. }
  7434. /*==========================================
  7435. * #storagelist: Displays the items list of a player's storage.
  7436. * #cartlist: Displays contents of target's cart.
  7437. * #itemlist: Displays contents of target's inventory.
  7438. *------------------------------------------*/
  7439. ACMD_FUNC(itemlist)
  7440. {
  7441. int i, j, count, counter;
  7442. const char* location;
  7443. const struct item* items;
  7444. int size;
  7445. StringBuf buf;
  7446. nullpo_retr(-1, sd);
  7447. parent_cmd = atcommand_checkalias(command+1);
  7448. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7449. location = "storage";
  7450. items = sd->storage.u.items_storage;
  7451. size = sd->storage.max_amount;
  7452. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7453. location = "cart";
  7454. items = sd->cart.u.items_cart;
  7455. size = MAX_CART;
  7456. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7457. location = "inventory";
  7458. items = sd->inventory.u.items_inventory;
  7459. size = MAX_INVENTORY;
  7460. } else
  7461. return 1;
  7462. StringBuf_Init(&buf);
  7463. count = 0; // total slots occupied
  7464. counter = 0; // total items found
  7465. for( i = 0; i < size; ++i ) {
  7466. const struct item* it = &items[i];
  7467. struct item_data* itd;
  7468. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7469. continue;
  7470. counter += it->amount;
  7471. count++;
  7472. if( count == 1 ) {
  7473. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7474. clif_displaymessage(fd, StringBuf_Value(&buf));
  7475. StringBuf_Clear(&buf);
  7476. }
  7477. if( it->refine )
  7478. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7479. else
  7480. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7481. if( it->equip ) {
  7482. char equipstr[CHAT_SIZE_MAX];
  7483. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7484. if( it->equip&EQP_GARMENT )
  7485. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7486. if( it->equip&EQP_ACC_L )
  7487. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7488. if( it->equip&EQP_ARMOR )
  7489. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7490. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7491. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7492. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7493. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7494. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7495. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7496. if( it->equip&EQP_SHOES )
  7497. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7498. if( it->equip&EQP_ACC_R )
  7499. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7500. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7501. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7502. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7503. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7504. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7505. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7506. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7507. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7508. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7509. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7510. if( (it->equip&EQP_HELM) == EQP_HELM )
  7511. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7512. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7513. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7514. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7515. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7516. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7517. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7518. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7519. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7520. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7521. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7522. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7523. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7524. if( it->equip&EQP_COSTUME_GARMENT )
  7525. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7526. //if( it->equip&EQP_COSTUME_FLOOR )
  7527. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7528. if( it->equip&EQP_AMMO )
  7529. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7530. if( it->equip&EQP_SHADOW_ARMOR )
  7531. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7532. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7533. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7534. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7535. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7536. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7537. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7538. if( it->equip&EQP_SHADOW_SHOES )
  7539. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7540. if( it->equip&EQP_SHADOW_ACC_R )
  7541. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7542. if( it->equip&EQP_SHADOW_ACC_L )
  7543. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7544. // remove final ', '
  7545. equipstr[strlen(equipstr) - 2] = '\0';
  7546. StringBuf_AppendStr(&buf, equipstr);
  7547. }
  7548. clif_displaymessage(fd, StringBuf_Value(&buf));
  7549. StringBuf_Clear(&buf);
  7550. if( it->card[0] == CARD0_PET ) { // pet egg
  7551. if (it->card[3])
  7552. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7553. else
  7554. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7555. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7556. StringBuf_Printf(&buf, msg_txt(sd,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)
  7557. } else if(it->card[0] == CARD0_CREATE) { // created item
  7558. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7559. } else { // normal item
  7560. int counter2 = 0;
  7561. for( j = 0; j < itd->slot; ++j ) {
  7562. struct item_data* card;
  7563. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7564. continue;
  7565. counter2++;
  7566. if( counter2 == 1 )
  7567. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7568. if( counter2 != 1 )
  7569. StringBuf_AppendStr(&buf, ", ");
  7570. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7571. }
  7572. if( counter2 > 0 )
  7573. StringBuf_AppendStr(&buf, ")");
  7574. }
  7575. if( StringBuf_Length(&buf) > 0 )
  7576. clif_displaymessage(fd, StringBuf_Value(&buf));
  7577. StringBuf_Clear(&buf);
  7578. }
  7579. if( count == 0 )
  7580. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7581. else
  7582. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7583. clif_displaymessage(fd, StringBuf_Value(&buf));
  7584. StringBuf_Destroy(&buf);
  7585. return 0;
  7586. }
  7587. ACMD_FUNC(stats)
  7588. {
  7589. char job_jobname[100];
  7590. char output[CHAT_SIZE_MAX];
  7591. int i;
  7592. struct {
  7593. const char* format;
  7594. int value;
  7595. } output_table[] = {
  7596. { "Base Level - %d", 0 },
  7597. { NULL, 0 },
  7598. { "Hp - %d", 0 },
  7599. { "MaxHp - %d", 0 },
  7600. { "Sp - %d", 0 },
  7601. { "MaxSp - %d", 0 },
  7602. { "Str - %3d", 0 },
  7603. { "Agi - %3d", 0 },
  7604. { "Vit - %3d", 0 },
  7605. { "Int - %3d", 0 },
  7606. { "Dex - %3d", 0 },
  7607. { "Luk - %3d", 0 },
  7608. { "Zeny - %d", 0 },
  7609. { "Free SK Points - %d", 0 },
  7610. { "JobChangeLvl (2nd) - %d", 0 },
  7611. { "JobChangeLvl (3rd) - %d", 0 },
  7612. { NULL, 0 }
  7613. };
  7614. memset(job_jobname, '\0', sizeof(job_jobname));
  7615. memset(output, '\0', sizeof(output));
  7616. //direct array initialization with variables is not standard C compliant.
  7617. output_table[0].value = sd->status.base_level;
  7618. output_table[1].format = job_jobname;
  7619. output_table[1].value = sd->status.job_level;
  7620. output_table[2].value = sd->status.hp;
  7621. output_table[3].value = sd->status.max_hp;
  7622. output_table[4].value = sd->status.sp;
  7623. output_table[5].value = sd->status.max_sp;
  7624. output_table[6].value = sd->status.str;
  7625. output_table[7].value = sd->status.agi;
  7626. output_table[8].value = sd->status.vit;
  7627. output_table[9].value = sd->status.int_;
  7628. output_table[10].value = sd->status.dex;
  7629. output_table[11].value = sd->status.luk;
  7630. output_table[12].value = sd->status.zeny;
  7631. output_table[13].value = sd->status.skill_point;
  7632. output_table[14].value = sd->change_level_2nd;
  7633. output_table[15].value = sd->change_level_3rd;
  7634. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7635. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7636. clif_displaymessage(fd, output);
  7637. for (i = 0; output_table[i].format != NULL; i++) {
  7638. sprintf(output, output_table[i].format, output_table[i].value);
  7639. clif_displaymessage(fd, output);
  7640. }
  7641. return 0;
  7642. }
  7643. ACMD_FUNC(delitem)
  7644. {
  7645. char item_name[100];
  7646. unsigned short nameid;
  7647. int amount = 0, total, idx;
  7648. struct item_data* id;
  7649. nullpo_retr(-1, sd);
  7650. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7651. {
  7652. clif_displaymessage(fd, msg_txt(sd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  7653. return -1;
  7654. }
  7655. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7656. {
  7657. nameid = id->nameid;
  7658. }
  7659. else
  7660. {
  7661. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7662. return -1;
  7663. }
  7664. total = amount;
  7665. // delete items
  7666. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7667. {
  7668. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  7669. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  7670. {// delete pet
  7671. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  7672. }
  7673. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7674. amount-= delamount;
  7675. }
  7676. // notify target
  7677. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7678. clif_displaymessage(sd->fd, atcmd_output);
  7679. // notify source
  7680. if( amount == total )
  7681. {
  7682. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7683. }
  7684. else if( amount )
  7685. {
  7686. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7687. clif_displaymessage(fd, atcmd_output);
  7688. }
  7689. else
  7690. {
  7691. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7692. clif_displaymessage(fd, atcmd_output);
  7693. }
  7694. return 0;
  7695. }
  7696. /*==========================================
  7697. * Custom Fonts
  7698. *------------------------------------------*/
  7699. ACMD_FUNC(font)
  7700. {
  7701. int font_id;
  7702. nullpo_retr(-1,sd);
  7703. font_id = atoi(message);
  7704. if( font_id == 0 ) {
  7705. if( sd->status.font ) {
  7706. sd->status.font = 0;
  7707. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7708. clif_font(sd);
  7709. } else {
  7710. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7711. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7712. }
  7713. } else if( font_id < 0 || font_id > 9 )
  7714. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7715. else if( font_id != sd->status.font ) {
  7716. sd->status.font = font_id;
  7717. clif_font(sd);
  7718. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7719. } else
  7720. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7721. return 0;
  7722. }
  7723. /*==========================================
  7724. * type: 1 = commands (@), 2 = charcommands (#)
  7725. *------------------------------------------*/
  7726. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7727. {
  7728. char line_buff[CHATBOX_SIZE];
  7729. char* cur = line_buff;
  7730. AtCommandInfo* cmd;
  7731. DBIterator *iter = db_iterator(atcommand_db);
  7732. int count = 0;
  7733. memset(line_buff,' ',CHATBOX_SIZE);
  7734. line_buff[CHATBOX_SIZE-1] = 0;
  7735. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7736. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7737. unsigned int slen = 0;
  7738. switch( type ) {
  7739. case COMMAND_CHARCOMMAND:
  7740. if( cmd->char_groups[sd->group_pos] == 0 )
  7741. continue;
  7742. break;
  7743. case COMMAND_ATCOMMAND:
  7744. if( cmd->at_groups[sd->group_pos] == 0 )
  7745. continue;
  7746. break;
  7747. default:
  7748. continue;
  7749. }
  7750. slen = strlen(cmd->command);
  7751. // flush the text buffer if this command won't fit into it
  7752. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7753. clif_displaymessage(fd,line_buff);
  7754. cur = line_buff;
  7755. memset(line_buff,' ',CHATBOX_SIZE);
  7756. line_buff[CHATBOX_SIZE-1] = 0;
  7757. }
  7758. memcpy(cur,cmd->command,slen);
  7759. cur += slen+(10-slen%10);
  7760. count++;
  7761. }
  7762. dbi_destroy(iter);
  7763. clif_displaymessage(fd,line_buff);
  7764. if ( atcmd_binding_count ) {
  7765. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7766. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7767. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7768. unsigned int slen = strlen(atcmd_binding[i]->command);
  7769. if ( count_bind == 0 ) {
  7770. cur = line_buff;
  7771. memset(line_buff,' ',CHATBOX_SIZE);
  7772. line_buff[CHATBOX_SIZE-1] = 0;
  7773. clif_displaymessage(fd, "-----------------");
  7774. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7775. }
  7776. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7777. clif_displaymessage(fd,line_buff);
  7778. cur = line_buff;
  7779. memset(line_buff,' ',CHATBOX_SIZE);
  7780. line_buff[CHATBOX_SIZE-1] = 0;
  7781. }
  7782. memcpy(cur,atcmd_binding[i]->command,slen);
  7783. cur += slen+(10-slen%10);
  7784. count_bind++;
  7785. }
  7786. }
  7787. if ( count_bind )
  7788. clif_displaymessage(fd,line_buff);// last one
  7789. count += count_bind;
  7790. }
  7791. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7792. clif_displaymessage(fd, atcmd_output);
  7793. return;
  7794. }
  7795. /*==========================================
  7796. * @commands Lists available @ commands to you
  7797. *------------------------------------------*/
  7798. ACMD_FUNC(commands)
  7799. {
  7800. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7801. return 0;
  7802. }
  7803. /*==========================================
  7804. * @charcommands Lists available # commands to you
  7805. *------------------------------------------*/
  7806. ACMD_FUNC(charcommands) {
  7807. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7808. return 0;
  7809. }
  7810. /* for new mounts */
  7811. ACMD_FUNC(mount2) {
  7812. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7813. if (!sd->sc.data[SC_ALL_RIDING]) {
  7814. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7815. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7816. } else {
  7817. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7818. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7819. }
  7820. return 0;
  7821. }
  7822. ACMD_FUNC(accinfo) {
  7823. char query[NAME_LENGTH];
  7824. char type = 0; // type = 1, get only account name
  7825. if (!message || !*message || strlen(message) > NAME_LENGTH
  7826. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7827. {
  7828. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7829. clif_displaymessage(fd, msg_txt(sd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  7830. return -1;
  7831. } else if (type != 0) {
  7832. type = type-'0'; //make it int
  7833. if (type != 1) {
  7834. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7835. return -1;
  7836. }
  7837. }
  7838. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7839. return 0;
  7840. }
  7841. /**
  7842. * @set <variable name{[index]}>{ <value>}
  7843. *
  7844. * Gets or sets a value of a non server variable.
  7845. * If a value is specified it is used to set the variable's value,
  7846. * if not the variable's value is read.
  7847. * In any case it reads and displays the variable's value.
  7848. *
  7849. * Original implementation by Ind
  7850. */
  7851. ACMD_FUNC(set) {
  7852. char reg[46], val[128], name[32];
  7853. int toset = 0, len, index;
  7854. bool is_str = false;
  7855. int64 uid;
  7856. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7857. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7858. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7859. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7860. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7861. return -1;
  7862. }
  7863. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7864. if( reg[0] == '.' ) {
  7865. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7866. return -1;
  7867. } else if( reg[0] == '\'' ) {
  7868. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7869. return -1;
  7870. }
  7871. // Check if the user wanted to set an array
  7872. if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){
  7873. // The user did not specify array brackets, so we set the index to zero
  7874. index = 0;
  7875. }
  7876. is_str = is_string_variable(name);
  7877. if( ( len = strlen(val) ) > 1 ) {
  7878. if( val[0] == '"' && val[len-1] == '"') {
  7879. val[len-1] = '\0'; //Strip quotes.
  7880. memmove(val, val+1, len-1);
  7881. }
  7882. }
  7883. // Only set the variable if there is a value for it
  7884. if( toset >= 2 ){
  7885. setd_sub( NULL, sd, name, index, is_str ? (void*)val : (void*)__64BPRTSIZE((atoi(val))), NULL );
  7886. }
  7887. uid = reference_uid( add_str( name ), index );
  7888. if( is_str ) {// string variable
  7889. char* value;
  7890. switch( reg[0] ) {
  7891. case '@':
  7892. value = pc_readregstr(sd, uid);
  7893. break;
  7894. case '$':
  7895. value = mapreg_readregstr(uid);
  7896. break;
  7897. case '#':
  7898. if( reg[1] == '#' )
  7899. value = pc_readaccountreg2str(sd, uid);// global
  7900. else
  7901. value = pc_readaccountregstr(sd, uid);// local
  7902. break;
  7903. default:
  7904. value = pc_readglobalreg_str(sd, uid);
  7905. break;
  7906. }
  7907. if( value == NULL || *value == '\0' ){// empty string
  7908. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7909. }else{
  7910. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
  7911. }
  7912. } else {// integer variable
  7913. int value;
  7914. switch( reg[0] ) {
  7915. case '@':
  7916. value = pc_readreg(sd, uid);
  7917. break;
  7918. case '$':
  7919. value = mapreg_readreg(uid);
  7920. break;
  7921. case '#':
  7922. if( reg[1] == '#' )
  7923. value = pc_readaccountreg2(sd, uid);// global
  7924. else
  7925. value = pc_readaccountreg(sd, uid);// local
  7926. break;
  7927. default:
  7928. value = pc_readglobalreg(sd, uid);
  7929. break;
  7930. }
  7931. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d
  7932. }
  7933. clif_displaymessage(fd, atcmd_output);
  7934. return 0;
  7935. }
  7936. ACMD_FUNC(addperm) {
  7937. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7938. bool add;
  7939. int i;
  7940. parent_cmd = atcommand_checkalias(command+1);
  7941. add = (strcmpi(parent_cmd, "addperm") == 0);
  7942. if( !message || !*message ) {
  7943. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7944. clif_displaymessage(fd, atcmd_output);
  7945. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7946. for( i = 0; i < perm_size; i++ ) {
  7947. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7948. clif_displaymessage(fd, atcmd_output);
  7949. }
  7950. return -1;
  7951. }
  7952. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7953. if( i == perm_size ) {
  7954. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7955. clif_displaymessage(fd, atcmd_output);
  7956. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7957. for( i = 0; i < perm_size; i++ ) {
  7958. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7959. clif_displaymessage(fd, atcmd_output);
  7960. }
  7961. return -1;
  7962. }
  7963. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7964. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7965. clif_displaymessage(fd, atcmd_output);
  7966. return -1;
  7967. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7968. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7969. clif_displaymessage(fd, atcmd_output);
  7970. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7971. clif_displaymessage(fd, atcmd_output);
  7972. for( i = 0; i < perm_size; i++ ) {
  7973. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7974. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7975. clif_displaymessage(fd, atcmd_output);
  7976. }
  7977. }
  7978. return -1;
  7979. }
  7980. if( add )
  7981. sd->permissions |= pc_g_permission_name[i].permission;
  7982. else
  7983. sd->permissions &=~ pc_g_permission_name[i].permission;
  7984. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7985. clif_displaymessage(fd, atcmd_output);
  7986. return 0;
  7987. }
  7988. ACMD_FUNC(unloadnpcfile) {
  7989. if( !message || !*message ) {
  7990. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7991. return -1;
  7992. }
  7993. if( npc_unloadfile(message) )
  7994. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7995. else {
  7996. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7997. return -1;
  7998. }
  7999. return 0;
  8000. }
  8001. ACMD_FUNC(cart) {
  8002. #define MC_CART_MDFY(idx, x) \
  8003. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8004. sd->status.skill[(idx)].lv = (x)?1:0; \
  8005. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8006. int val = atoi(message);
  8007. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8008. uint16 sk_idx = 0;
  8009. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8010. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8011. clif_displaymessage(fd, atcmd_output);
  8012. return -1;
  8013. }
  8014. if( val == 0 && !pc_iscarton(sd) ) {
  8015. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8016. return -1;
  8017. }
  8018. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8019. return -1;
  8020. if( need_skill ) {
  8021. MC_CART_MDFY(sk_idx,1);
  8022. }
  8023. if( !pc_setcart(sd, val) ) {
  8024. if( need_skill ) {
  8025. MC_CART_MDFY(sk_idx,0);
  8026. }
  8027. return -1;/* @cart failed */
  8028. }
  8029. if( need_skill ) {
  8030. MC_CART_MDFY(sk_idx,0);
  8031. }
  8032. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8033. return 0;
  8034. #undef MC_CART_MDFY
  8035. }
  8036. /* Channel System [Ind] */
  8037. ACMD_FUNC(join){
  8038. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8039. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8040. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8041. clif_displaymessage(fd, atcmd_output);
  8042. return -1;
  8043. }
  8044. return channel_pcjoin(sd, chname, pass);
  8045. }
  8046. /*
  8047. * Display available option for @channel command
  8048. * @command : the name of used command (for alias case)
  8049. */
  8050. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8051. {
  8052. int fd = sd->fd;
  8053. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8054. bool can_create = (can_delete || channel_config.private_channel.allow);
  8055. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8056. //option create
  8057. if( can_create ) {
  8058. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8059. clif_displaymessage(fd, atcmd_output);
  8060. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8061. }
  8062. //option delete
  8063. if(can_delete){
  8064. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8065. clif_displaymessage(fd, atcmd_output);
  8066. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8067. }
  8068. //option list
  8069. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8070. clif_displaymessage(fd, atcmd_output);
  8071. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8072. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8073. clif_displaymessage(fd, atcmd_output);
  8074. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8075. if( can_create ) {
  8076. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8077. clif_displaymessage(fd, atcmd_output);
  8078. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8079. }
  8080. //option setcolor
  8081. if(can_create){
  8082. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8083. clif_displaymessage(fd, atcmd_output);
  8084. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8085. }
  8086. //option join
  8087. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8088. clif_displaymessage(fd, atcmd_output);
  8089. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8090. //option leave
  8091. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8092. clif_displaymessage(fd, atcmd_output);
  8093. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8094. //option bindto
  8095. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8096. clif_displaymessage(fd, atcmd_output);
  8097. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8098. //option unbind
  8099. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8100. clif_displaymessage(fd, atcmd_output);
  8101. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8102. //option ban/unban/banlist
  8103. if( can_create ) {
  8104. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8105. clif_displaymessage(fd, atcmd_output);
  8106. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8107. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8108. clif_displaymessage(fd, atcmd_output);
  8109. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8110. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8111. clif_displaymessage(fd, atcmd_output);
  8112. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8113. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8114. clif_displaymessage(fd, atcmd_output);
  8115. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8116. }
  8117. //option setopt
  8118. if(can_create){
  8119. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8120. clif_displaymessage(fd, atcmd_output);
  8121. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8122. }
  8123. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8124. clif_displaymessage(fd, atcmd_output);
  8125. }
  8126. ACMD_FUNC(channel) {
  8127. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8128. sub1[0] = sub2[0] = '\0';
  8129. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8130. atcmd_channel_help(sd,command);
  8131. return 0;
  8132. }
  8133. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8134. return channel_pcdelete(sd,sub1);
  8135. } else if ( strcmpi(key,"list") == 0 ) {
  8136. return channel_display_list(sd,sub1);
  8137. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8138. return channel_pccolor(sd, sub1, sub2);
  8139. } else if ( strcmpi(key,"join") == 0 ) {
  8140. return channel_pcjoin(sd, sub1, sub2);
  8141. }else if ( strcmpi(key,"leave") == 0 ) {
  8142. return channel_pcleave(sd, sub1);
  8143. } else if ( strcmpi(key,"bindto") == 0 ) {
  8144. return channel_pcbind(sd, sub1);
  8145. } else if ( strcmpi(key,"unbind") == 0 ) {
  8146. return channel_pcunbind(sd);
  8147. } else if ( strcmpi(key,"ban") == 0 ) {
  8148. return channel_pcban(sd,sub1,sub2,0);
  8149. } else if ( strcmpi(key,"kick") == 0 ) {
  8150. return channel_pckick(sd,sub1,sub2);
  8151. } else if ( strcmpi(key,"banlist") == 0 ) {
  8152. return channel_pcban(sd,sub1,NULL,3);
  8153. } else if ( strcmpi(key,"unban") == 0 ) {
  8154. return channel_pcban(sd,sub1,sub2,1);
  8155. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8156. return channel_pcban(sd,sub1,NULL,2);
  8157. } else {
  8158. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8159. sub3[0] = sub4[0] = '\0';
  8160. sscanf(sub2, "%19s %19s", sub3, sub4);
  8161. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8162. if (sub4[0] != '\0') {
  8163. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8164. return -1;
  8165. }
  8166. return channel_pccreate(sd,sub1,sub3);
  8167. } else if ( strcmpi(key,"setopt") == 0 ) {
  8168. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8169. }
  8170. atcmd_channel_help(sd,command);
  8171. }
  8172. return 0;
  8173. }
  8174. ACMD_FUNC(fontcolor)
  8175. {
  8176. if( !message || !*message ) {
  8177. channel_display_list(sd,"colors");
  8178. return -1;
  8179. }
  8180. if( strcmpi(message,"Normal") == 0 ) {
  8181. sd->fontcolor = 0;
  8182. } else {
  8183. unsigned char k;
  8184. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8185. if( k == channel_config.colors_count ) {
  8186. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8187. clif_displaymessage(fd, atcmd_output);
  8188. return -1;
  8189. }
  8190. sd->fontcolor = k;
  8191. }
  8192. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8193. clif_displaymessage(fd, atcmd_output);
  8194. return 0;
  8195. }
  8196. ACMD_FUNC(langtype)
  8197. {
  8198. char langstr[8];
  8199. int i=0, fail=0;
  8200. memset(langstr, '\0', sizeof(langstr));
  8201. if(sscanf(message, "%3s", langstr) >= 1){
  8202. int lang=0;
  8203. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8204. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8205. char output[100];
  8206. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8207. sd->langtype = lang;
  8208. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8209. clif_displaymessage(fd,output);
  8210. return 0;
  8211. } else if (lang != -1) { //defined langage but failed check
  8212. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8213. return -1;
  8214. }
  8215. }
  8216. //wrong or no entry
  8217. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8218. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8219. while(fail != -1){ //out of range
  8220. fail = msg_checklangtype(i,false);
  8221. if(fail == 1)
  8222. clif_displaymessage(fd,msg_langtype2langstr(i));
  8223. i++;
  8224. }
  8225. return -1;
  8226. }
  8227. #ifdef VIP_ENABLE
  8228. ACMD_FUNC(vip) {
  8229. struct map_session_data *pl_sd = NULL;
  8230. char * modif_p;
  8231. int32 vipdifftime = 0;
  8232. time_t now=time(NULL);
  8233. nullpo_retr(-1, sd);
  8234. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8235. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8236. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8237. return -1;
  8238. }
  8239. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8240. modif_p = atcmd_output;
  8241. vipdifftime = (int32)solve_time(modif_p);
  8242. if (vipdifftime == 0) {
  8243. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8244. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  8245. return -1;
  8246. }
  8247. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8248. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8249. return -1;
  8250. }
  8251. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8252. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8253. return -1;
  8254. }
  8255. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8256. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8257. if (pl_sd->vip.time <= now) {
  8258. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8259. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8260. } else {
  8261. int year,month,day,hour,minute,second;
  8262. char timestr[21];
  8263. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8264. sprintf(atcmd_output,msg_txt(pl_sd,705),year,month,day,hour,minute); // Your VIP status is valid for %d years, %d months, %d days, %d hours and %d minutes.
  8265. clif_displaymessage(pl_sd->fd,atcmd_output);
  8266. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8267. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8268. clif_displaymessage(pl_sd->fd,atcmd_output);
  8269. if (pl_sd != sd) {
  8270. sprintf(atcmd_output,msg_txt(sd,706),pl_sd->status.name,year,month,day,hour,minute); // Player '%s' is now VIP for %d years, %d months, %d days, %d hours and %d minutes.
  8271. clif_displaymessage(fd,atcmd_output);
  8272. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8273. clif_displaymessage(fd,atcmd_output);
  8274. }
  8275. }
  8276. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8277. return 0;
  8278. }
  8279. /** Enable/disable rate info */
  8280. ACMD_FUNC(showrate) {
  8281. nullpo_retr(-1,sd);
  8282. if (!sd->vip.disableshowrate) {
  8283. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8284. sd->vip.disableshowrate = 1;
  8285. } else {
  8286. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8287. sd->vip.disableshowrate = 0;
  8288. }
  8289. clif_displaymessage(fd,atcmd_output);
  8290. return 0;
  8291. }
  8292. #endif
  8293. ACMD_FUNC(fullstrip) {
  8294. int i;
  8295. TBL_PC *tsd;
  8296. nullpo_retr(-1,sd);
  8297. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8298. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8299. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8300. return -1;
  8301. }
  8302. if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
  8303. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8304. return -1;
  8305. }
  8306. for( i = 0; i < EQI_MAX; i++ ) {
  8307. if( tsd->equip_index[ i ] >= 0 )
  8308. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8309. }
  8310. return 0;
  8311. }
  8312. ACMD_FUNC(changedress){
  8313. sc_type name2id[] = {
  8314. SC_WEDDING,
  8315. SC_XMAS,
  8316. SC_SUMMER,
  8317. SC_DRESSUP,
  8318. SC_HANBOK,
  8319. SC_OKTOBERFEST
  8320. };
  8321. for( sc_type type : name2id ) {
  8322. if( sd->sc.data[type] ) {
  8323. status_change_end( &sd->bl, type, INVALID_TIMER );
  8324. // You should only be able to have one - so we cancel here
  8325. return 0;
  8326. }
  8327. }
  8328. return -1;
  8329. }
  8330. ACMD_FUNC(costume) {
  8331. const char* names[] = {
  8332. "Wedding",
  8333. "Xmas",
  8334. "Summer",
  8335. "Summer2",
  8336. "Hanbok",
  8337. "Oktoberfest"
  8338. };
  8339. const int name2id[] = {
  8340. SC_WEDDING,
  8341. SC_XMAS,
  8342. SC_SUMMER,
  8343. SC_DRESSUP,
  8344. SC_HANBOK,
  8345. SC_OKTOBERFEST
  8346. };
  8347. unsigned short k = 0, len = ARRAYLENGTH(names);
  8348. if( !message || !*message ) {
  8349. for( k = 0; k < len; k++ ) {
  8350. if( sd->sc.data[name2id[k]] ) {
  8351. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8352. clif_displaymessage(sd->fd, atcmd_output);
  8353. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8354. return 0;
  8355. }
  8356. }
  8357. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8358. for( k = 0; k < len; k++ ) {
  8359. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8360. clif_displaymessage(sd->fd, atcmd_output);
  8361. }
  8362. return -1;
  8363. }
  8364. for( k = 0; k < len; k++ ) {
  8365. if( sd->sc.data[name2id[k]] ) {
  8366. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8367. clif_displaymessage(sd->fd, atcmd_output);
  8368. return -1;
  8369. }
  8370. }
  8371. for( k = 0; k < len; k++ )
  8372. if( strcmpi(message, names[k]) == 0 )
  8373. break;
  8374. if( k == len ) {
  8375. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8376. clif_displaymessage(sd->fd, atcmd_output);
  8377. return -1;
  8378. }
  8379. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, -1);
  8380. return 0;
  8381. }
  8382. /**
  8383. * Clone other player's equipments
  8384. * Usage: @cloneequip <char name/ID>
  8385. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8386. * @author [Cydh], [Antares]
  8387. */
  8388. ACMD_FUNC(cloneequip) {
  8389. struct map_session_data *pl_sd;
  8390. nullpo_retr(-1, sd);
  8391. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8392. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8393. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8394. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8395. clif_displaymessage(fd, atcmd_output);
  8396. return -1;
  8397. }
  8398. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8399. clif_displaymessage(fd, msg_txt(sd, 3));
  8400. return -1;
  8401. }
  8402. if (sd == pl_sd) {
  8403. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8404. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8405. clif_displaymessage(fd, atcmd_output);
  8406. return -1;
  8407. }
  8408. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8409. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8410. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8411. clif_displaymessage(fd, atcmd_output);
  8412. return -1;
  8413. }
  8414. else {
  8415. int8 i;
  8416. for (i = 0; i < EQI_MAX; i++) {
  8417. short idx;
  8418. char flag = 0;
  8419. struct item tmp_item;
  8420. if ((idx = pl_sd->equip_index[i]) < 0)
  8421. continue;
  8422. if (i == EQI_AMMO)
  8423. continue;
  8424. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8425. continue;
  8426. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8427. if (itemdb_isspecial(tmp_item.card[0]))
  8428. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8429. tmp_item.bound = 0;
  8430. tmp_item.expire_time = 0;
  8431. tmp_item.unique_id = 0;
  8432. tmp_item.favorite = 0;
  8433. tmp_item.amount = 1;
  8434. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8435. clif_additem(sd, 0, 0, flag);
  8436. else
  8437. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8438. }
  8439. }
  8440. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8441. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8442. clif_displaymessage(fd, atcmd_output);
  8443. return 0;
  8444. }
  8445. /**
  8446. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8447. * Usage: @clonestat <char name/ID>
  8448. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8449. * @author [Cydh], [Antares]
  8450. */
  8451. ACMD_FUNC(clonestat) {
  8452. struct map_session_data *pl_sd;
  8453. nullpo_retr(-1, sd);
  8454. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8455. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8456. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8457. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8458. clif_displaymessage(fd, atcmd_output);
  8459. return -1;
  8460. }
  8461. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8462. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8463. return -1;
  8464. }
  8465. if (sd == pl_sd) {
  8466. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8467. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8468. clif_displaymessage(fd, atcmd_output);
  8469. return -1;
  8470. }
  8471. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8472. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8473. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8474. clif_displaymessage(fd, atcmd_output);
  8475. return -1;
  8476. }
  8477. else {
  8478. uint8 i;
  8479. short max_status[6];
  8480. pc_resetstate(sd);
  8481. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8482. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8483. else {
  8484. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8485. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8486. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8487. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8488. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8489. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8490. }
  8491. #define clonestat_check(cmd,stat)\
  8492. {\
  8493. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8494. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8495. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8496. clif_displaymessage(fd, atcmd_output);\
  8497. sd->status.cmd = max_status[(stat)];\
  8498. }\
  8499. else\
  8500. sd->status.cmd = pl_sd->status.cmd;\
  8501. }
  8502. clonestat_check(str, PARAM_STR);
  8503. clonestat_check(agi, PARAM_AGI);
  8504. clonestat_check(vit, PARAM_VIT);
  8505. clonestat_check(int_, PARAM_INT);
  8506. clonestat_check(dex, PARAM_DEX);
  8507. clonestat_check(luk, PARAM_LUK);
  8508. for (i = 0; i < PARAM_MAX; i++) {
  8509. clif_updatestatus(sd, SP_STR + i);
  8510. clif_updatestatus(sd, SP_USTR + i);
  8511. }
  8512. status_calc_pc(sd, SCO_FORCE);
  8513. }
  8514. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8515. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  8516. clif_displaymessage(fd, atcmd_output);
  8517. #undef clonestat_check
  8518. return 0;
  8519. }
  8520. /**
  8521. * Adopt a character.
  8522. * Usage: @adopt <char name>
  8523. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8524. */
  8525. ACMD_FUNC(adopt)
  8526. {
  8527. TBL_PC *b_sd;
  8528. enum adopt_responses response;
  8529. nullpo_retr(-1, sd);
  8530. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8531. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8532. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8533. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8534. clif_displaymessage(fd, atcmd_output);
  8535. return -1;
  8536. }
  8537. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8538. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8539. return -1;
  8540. }
  8541. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8542. if (response == ADOPT_ALLOWED) {
  8543. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8544. b_sd->adopt_invite = sd->status.account_id;
  8545. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8546. return 0;
  8547. }
  8548. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8549. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8550. return -1;
  8551. }
  8552. /**
  8553. * Opens the limited sale window.
  8554. * Usage: @limitedsale or client command /limitedsale on supported clients
  8555. */
  8556. ACMD_FUNC(limitedsale){
  8557. nullpo_retr(-1, sd);
  8558. clif_sale_open(sd);
  8559. return 0;
  8560. }
  8561. #include "../custom/atcommand.inc"
  8562. /**
  8563. * Fills the reference of available commands in atcommand DBMap
  8564. **/
  8565. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8566. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8567. // Define with restriction
  8568. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8569. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8570. void atcommand_basecommands(void) {
  8571. /**
  8572. * Command reference list, place the base of your commands here
  8573. * TODO: List all commands that causing crash
  8574. **/
  8575. AtCommandInfo atcommand_base[] = {
  8576. #include "../custom/atcommand_def.inc"
  8577. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8578. ACMD_DEF(where),
  8579. ACMD_DEF(jumpto),
  8580. ACMD_DEF(jump),
  8581. ACMD_DEF(who),
  8582. ACMD_DEF2("who2", who),
  8583. ACMD_DEF2("who3", who),
  8584. ACMD_DEF2("whomap", who),
  8585. ACMD_DEF2("whomap2", who),
  8586. ACMD_DEF2("whomap3", who),
  8587. ACMD_DEF(whogm),
  8588. ACMD_DEF(save),
  8589. ACMD_DEF(load),
  8590. ACMD_DEF(speed),
  8591. ACMD_DEF(storage),
  8592. ACMD_DEF(guildstorage),
  8593. ACMD_DEF(option),
  8594. ACMD_DEF(hide), // + /hide
  8595. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8596. ACMD_DEF(kill),
  8597. ACMD_DEF(alive),
  8598. ACMD_DEF(kami),
  8599. ACMD_DEF2("kamib", kami),
  8600. ACMD_DEF2("kamic", kami),
  8601. ACMD_DEF2("lkami", kami),
  8602. ACMD_DEF(heal),
  8603. ACMD_DEF(item),
  8604. ACMD_DEF(item2),
  8605. ACMD_DEF2("itembound",item),
  8606. ACMD_DEF2("itembound2",item2),
  8607. ACMD_DEF(itemreset),
  8608. ACMD_DEF(clearstorage),
  8609. ACMD_DEF(cleargstorage),
  8610. ACMD_DEF(clearcart),
  8611. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8612. ACMD_DEF2("jlvl", joblevelup),
  8613. ACMD_DEF(help),
  8614. ACMD_DEF(pvpoff),
  8615. ACMD_DEF(pvpon),
  8616. ACMD_DEF(gvgoff),
  8617. ACMD_DEF(gvgon),
  8618. ACMD_DEF(model),
  8619. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8620. ACMD_DEF(monster),
  8621. ACMD_DEF2("monstersmall", monster),
  8622. ACMD_DEF2("monsterbig", monster),
  8623. ACMD_DEF(killmonster),
  8624. ACMD_DEF2("killmonster2", killmonster),
  8625. ACMD_DEF(refine),
  8626. ACMD_DEF(produce),
  8627. ACMD_DEF(memo),
  8628. ACMD_DEF(gat),
  8629. ACMD_DEF(displaystatus),
  8630. ACMD_DEF2("stpoint", statuspoint),
  8631. ACMD_DEF2("skpoint", skillpoint),
  8632. ACMD_DEF(zeny),
  8633. ACMD_DEF2("str", param),
  8634. ACMD_DEF2("agi", param),
  8635. ACMD_DEF2("vit", param),
  8636. ACMD_DEF2("int", param),
  8637. ACMD_DEF2("dex", param),
  8638. ACMD_DEF2("luk", param),
  8639. ACMD_DEF2("glvl", guildlevelup),
  8640. ACMD_DEF(makeegg),
  8641. ACMD_DEF(hatch),
  8642. ACMD_DEF(petfriendly),
  8643. ACMD_DEF(pethungry),
  8644. ACMD_DEF(petrename),
  8645. ACMD_DEF(recall), // + /recall
  8646. ACMD_DEF(night),
  8647. ACMD_DEF(day),
  8648. ACMD_DEF(doom),
  8649. ACMD_DEF(doommap),
  8650. ACMD_DEF(raise),
  8651. ACMD_DEF(raisemap),
  8652. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8653. ACMD_DEF(kickall),
  8654. ACMD_DEF(allskill),
  8655. ACMD_DEF(questskill),
  8656. ACMD_DEF(lostskill),
  8657. ACMD_DEF(spiritball),
  8658. ACMD_DEF(party),
  8659. ACMD_DEF(guild),
  8660. ACMD_DEF(breakguild),
  8661. ACMD_DEF(agitstart),
  8662. ACMD_DEF(agitend),
  8663. ACMD_DEF(mapexit),
  8664. ACMD_DEF(idsearch),
  8665. ACMD_DEF(broadcast), // + /b and /nb
  8666. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8667. ACMD_DEF(recallall),
  8668. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8669. ACMD_DEF2("reloaditemdb", reload),
  8670. ACMD_DEF2("reloadmobdb", reload),
  8671. ACMD_DEF2("reloadskilldb", reload),
  8672. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8673. ACMD_DEF2("reloadatcommand", reload),
  8674. ACMD_DEF2("reloadbattleconf", reload),
  8675. ACMD_DEF2("reloadstatusdb", reload),
  8676. ACMD_DEF2("reloadpcdb", reload),
  8677. ACMD_DEF2("reloadmotd", reload),
  8678. ACMD_DEF2("reloadquestdb", reload),
  8679. ACMD_DEF2("reloadmsgconf", reload),
  8680. ACMD_DEF2("reloadinstancedb", reload),
  8681. ACMD_DEF2("reloadachievementdb",reload),
  8682. ACMD_DEF(partysharelvl),
  8683. ACMD_DEF(mapinfo),
  8684. ACMD_DEF(dye),
  8685. ACMD_DEF2("hairstyle", hair_style),
  8686. ACMD_DEF2("haircolor", hair_color),
  8687. ACMD_DEF2("allstats", stat_all),
  8688. ACMD_DEF2("block", char_block),
  8689. ACMD_DEF2("ban", char_ban),
  8690. ACMD_DEF2("unblock", char_unblock),
  8691. ACMD_DEF2("unban", char_unban),
  8692. ACMD_DEF2("charban", char_ban),
  8693. ACMD_DEF2("charunban", char_unban),
  8694. ACMD_DEF2("mount", mount_peco),
  8695. ACMD_DEF(guildspy),
  8696. ACMD_DEF(partyspy),
  8697. ACMD_DEF(clanspy),
  8698. ACMD_DEF(repairall),
  8699. ACMD_DEF(guildrecall),
  8700. ACMD_DEF(partyrecall),
  8701. ACMD_DEF(nuke),
  8702. ACMD_DEF(shownpc),
  8703. ACMD_DEF(hidenpc),
  8704. ACMD_DEF(loadnpc),
  8705. ACMD_DEF(unloadnpc),
  8706. ACMD_DEF(reloadnpcfile),
  8707. ACMD_DEF2("time", servertime),
  8708. ACMD_DEF(jail),
  8709. ACMD_DEF(unjail),
  8710. ACMD_DEF(jailfor),
  8711. ACMD_DEF(jailtime),
  8712. ACMD_DEF(disguise),
  8713. ACMD_DEF(undisguise),
  8714. ACMD_DEF(email),
  8715. ACMD_DEF(effect),
  8716. ACMD_DEF(follow),
  8717. ACMD_DEF(addwarp),
  8718. ACMD_DEF(skillon),
  8719. ACMD_DEF(skilloff),
  8720. ACMD_DEF(killer),
  8721. ACMD_DEF(npcmove),
  8722. ACMD_DEF(killable),
  8723. ACMD_DEF(dropall),
  8724. ACMD_DEF(storeall),
  8725. ACMD_DEF(skillid),
  8726. ACMD_DEF(useskill),
  8727. ACMD_DEF(displayskill),
  8728. ACMD_DEF(snow),
  8729. ACMD_DEF(sakura),
  8730. ACMD_DEF(clouds),
  8731. ACMD_DEF(clouds2),
  8732. ACMD_DEF(fog),
  8733. ACMD_DEF(fireworks),
  8734. ACMD_DEF(leaves),
  8735. ACMD_DEF(summon),
  8736. ACMD_DEF(adjgroup),
  8737. ACMD_DEF(trade),
  8738. ACMD_DEF(send),
  8739. ACMD_DEF(setbattleflag),
  8740. ACMD_DEF(unmute),
  8741. ACMD_DEF(clearweather),
  8742. ACMD_DEF(uptime),
  8743. ACMD_DEF(changesex),
  8744. ACMD_DEF(changecharsex),
  8745. ACMD_DEF(mute),
  8746. ACMD_DEF(refresh),
  8747. ACMD_DEF(refreshall),
  8748. ACMD_DEF(identify),
  8749. ACMD_DEF(identifyall),
  8750. ACMD_DEF(gmotd),
  8751. ACMD_DEF(misceffect),
  8752. ACMD_DEF(mobsearch),
  8753. ACMD_DEF(cleanmap),
  8754. ACMD_DEF(cleanarea),
  8755. ACMD_DEF(npctalk),
  8756. ACMD_DEF(pettalk),
  8757. ACMD_DEF(users),
  8758. ACMD_DEF(reset),
  8759. ACMD_DEF(skilltree),
  8760. ACMD_DEF(marry),
  8761. ACMD_DEF(divorce),
  8762. ACMD_DEF(sound),
  8763. ACMD_DEF(undisguiseall),
  8764. ACMD_DEF(disguiseall),
  8765. ACMD_DEF(changelook),
  8766. ACMD_DEF(autoloot),
  8767. ACMD_DEF2("alootid", autolootitem),
  8768. ACMD_DEF(autoloottype),
  8769. ACMD_DEF(mobinfo),
  8770. ACMD_DEF(exp),
  8771. ACMD_DEF(version),
  8772. ACMD_DEF(mutearea),
  8773. ACMD_DEF(rates),
  8774. ACMD_DEF(iteminfo),
  8775. ACMD_DEF(whodrops),
  8776. ACMD_DEF(whereis),
  8777. ACMD_DEF(mapflag),
  8778. ACMD_DEF(me),
  8779. ACMD_DEF(monsterignore),
  8780. ACMD_DEF(fakename),
  8781. ACMD_DEF(size),
  8782. ACMD_DEF(showexp),
  8783. ACMD_DEF(showzeny),
  8784. ACMD_DEF(showdelay),
  8785. ACMD_DEF(autotrade),
  8786. ACMD_DEF(changegm),
  8787. ACMD_DEF(changeleader),
  8788. ACMD_DEF(partyoption),
  8789. ACMD_DEF(invite),
  8790. ACMD_DEF(duel),
  8791. ACMD_DEF(leave),
  8792. ACMD_DEF(accept),
  8793. ACMD_DEF(reject),
  8794. ACMD_DEF(clone),
  8795. ACMD_DEF2("slaveclone", clone),
  8796. ACMD_DEF2("evilclone", clone),
  8797. ACMD_DEF(tonpc),
  8798. ACMD_DEF(commands),
  8799. ACMD_DEF(noask),
  8800. ACMD_DEF(request),
  8801. ACMD_DEF(homlevel),
  8802. ACMD_DEF(homevolution),
  8803. ACMD_DEF(hommutate),
  8804. ACMD_DEF(makehomun),
  8805. ACMD_DEF(homfriendly),
  8806. ACMD_DEF(homhungry),
  8807. ACMD_DEF(homtalk),
  8808. ACMD_DEF(hominfo),
  8809. ACMD_DEF(homstats),
  8810. ACMD_DEF(homshuffle),
  8811. ACMD_DEF(showmobs),
  8812. ACMD_DEF(feelreset),
  8813. ACMD_DEF(auction),
  8814. ACMD_DEF(mail),
  8815. ACMD_DEF2("noks", ksprotection),
  8816. ACMD_DEF(allowks),
  8817. ACMD_DEF(cash),
  8818. ACMD_DEF2("points", cash),
  8819. ACMD_DEF(agitstart2),
  8820. ACMD_DEF(agitend2),
  8821. ACMD_DEF(resetskill),
  8822. ACMD_DEF(resetstat),
  8823. ACMD_DEF2("storagelist", itemlist),
  8824. ACMD_DEF2("cartlist", itemlist),
  8825. ACMD_DEF2("itemlist", itemlist),
  8826. ACMD_DEF(stats),
  8827. ACMD_DEF(delitem),
  8828. ACMD_DEF(charcommands),
  8829. ACMD_DEF(font),
  8830. ACMD_DEF(accinfo),
  8831. ACMD_DEF(set),
  8832. ACMD_DEF(undisguiseguild),
  8833. ACMD_DEF(disguiseguild),
  8834. ACMD_DEF(sizeall),
  8835. ACMD_DEF(sizeguild),
  8836. ACMD_DEF(addperm),
  8837. ACMD_DEF2("rmvperm", addperm),
  8838. ACMD_DEF(unloadnpcfile),
  8839. ACMD_DEF(cart),
  8840. ACMD_DEF(mount2),
  8841. ACMD_DEF(join),
  8842. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  8843. ACMD_DEF(fontcolor),
  8844. ACMD_DEF(langtype),
  8845. #ifdef VIP_ENABLE
  8846. ACMD_DEF(vip),
  8847. ACMD_DEF(showrate),
  8848. #endif
  8849. ACMD_DEF(fullstrip),
  8850. ACMD_DEF(costume),
  8851. ACMD_DEF(cloneequip),
  8852. ACMD_DEF(clonestat),
  8853. ACMD_DEF(bodystyle),
  8854. ACMD_DEF(adopt),
  8855. ACMD_DEF(agitstart3),
  8856. ACMD_DEF(agitend3),
  8857. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  8858. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  8859. };
  8860. AtCommandInfo* atcommand;
  8861. int i;
  8862. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8863. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8864. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8865. continue;
  8866. }
  8867. CREATE(atcommand, AtCommandInfo, 1);
  8868. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8869. atcommand->func = atcommand_base[i].func;
  8870. atcommand->restriction = atcommand_base[i].restriction;
  8871. strdb_put(atcommand_db, atcommand->command, atcommand);
  8872. }
  8873. return;
  8874. }
  8875. /*==========================================
  8876. * Command lookup functions
  8877. *------------------------------------------*/
  8878. bool atcommand_exists(const char* name)
  8879. {
  8880. return strdb_exists(atcommand_db, name);
  8881. }
  8882. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8883. {
  8884. if (strdb_exists(atcommand_db, name))
  8885. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8886. return NULL;
  8887. }
  8888. static const char* atcommand_checkalias(const char *aliasname)
  8889. {
  8890. AliasInfo *alias_info = NULL;
  8891. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8892. return alias_info->command->command;
  8893. return aliasname;
  8894. }
  8895. /// AtCommand suggestion
  8896. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8897. DBIterator* atcommand_iter;
  8898. DBIterator* alias_iter;
  8899. AtCommandInfo* command_info = NULL;
  8900. AliasInfo* alias_info = NULL;
  8901. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8902. char* full_match[MAX_SUGGESTIONS];
  8903. char* suggestions[MAX_SUGGESTIONS];
  8904. char* match;
  8905. int prefix_count = 0, full_count = 0;
  8906. bool can_use;
  8907. if (!battle_config.atcommand_suggestions_enabled)
  8908. return;
  8909. atcommand_iter = db_iterator(atcommand_db);
  8910. alias_iter = db_iterator(atcommand_alias_db);
  8911. // Build the matches
  8912. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8913. match = strstr(command_info->command, name);
  8914. can_use = pc_can_use_command(sd, command_info->command, type);
  8915. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8916. suggestions[prefix_count] = command_info->command;
  8917. ++prefix_count;
  8918. }
  8919. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8920. full_match[full_count] = command_info->command;
  8921. ++full_count;
  8922. }
  8923. }
  8924. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8925. match = strstr(alias_info->alias, name);
  8926. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8927. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8928. suggestions[prefix_count] = alias_info->alias;
  8929. ++prefix_count;
  8930. }
  8931. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8932. full_match[full_count] = alias_info->alias;
  8933. ++full_count;
  8934. }
  8935. }
  8936. if ((full_count+prefix_count) > 0) {
  8937. char buffer[512];
  8938. int i;
  8939. // Merge full match and prefix match results
  8940. if (prefix_count < MAX_SUGGESTIONS) {
  8941. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8942. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8943. }
  8944. // Build the suggestion string
  8945. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  8946. strcat(buffer,"\n");
  8947. for(i=0; i < prefix_count; ++i) {
  8948. strcat(buffer,suggestions[i]);
  8949. strcat(buffer," ");
  8950. }
  8951. clif_displaymessage(sd->fd, buffer);
  8952. }
  8953. dbi_destroy(atcommand_iter);
  8954. dbi_destroy(alias_iter);
  8955. }
  8956. /**
  8957. * Executes an at-command
  8958. * @param fd
  8959. * @param sd
  8960. * @param message
  8961. * @param type
  8962. * 0 : script call (atcommand)
  8963. * 1 : normal player @atcommand
  8964. * 2 : console (admin:@atcommand)
  8965. * 3 : script call (useatcmd)
  8966. */
  8967. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8968. {
  8969. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8970. char output[CHAT_SIZE_MAX];
  8971. //Reconstructed message
  8972. char atcmd_msg[CHAT_SIZE_MAX];
  8973. TBL_PC * ssd = NULL; //sd for target
  8974. AtCommandInfo * info;
  8975. bool is_atcommand = true; // false if it's a charcommand
  8976. nullpo_retr(false, sd);
  8977. //Shouldn't happen
  8978. if ( !message || !*message )
  8979. return false;
  8980. //If cannot use atcomamnd while talking with NPC [Kichi]
  8981. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8982. return false;
  8983. //Block NOCHAT but do not display it as a normal message
  8984. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8985. return true;
  8986. // skip 10/11-langtype's codepage indicator, if detected
  8987. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8988. message += 3;
  8989. //Should display as a normal message
  8990. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8991. return false;
  8992. // type value 0|2 = script|console invoked: bypass restrictions
  8993. if ( type == 1 || type == 3) {
  8994. //Commands are disabled on maps flagged as 'nocommand'
  8995. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8996. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  8997. return false;
  8998. }
  8999. }
  9000. if (*message == charcommand_symbol)
  9001. is_atcommand = false;
  9002. if (is_atcommand) { // @command
  9003. sprintf(atcmd_msg, "%s", message);
  9004. ssd = sd;
  9005. } else { // #command
  9006. char charname[NAME_LENGTH];
  9007. int n;
  9008. //Checks to see if #command has a name or a name + parameters.
  9009. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  9010. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  9011. ) {
  9012. if (pc_get_group_level(sd) == 0) {
  9013. if (n < 1)
  9014. return false; // No command found. Display as normal message.
  9015. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9016. 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
  9017. return false;
  9018. }
  9019. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9020. clif_displaymessage(fd, output);
  9021. return true;
  9022. }
  9023. ssd = map_nick2sd(charname,true);
  9024. if (ssd == NULL) {
  9025. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9026. clif_displaymessage(fd, output);
  9027. return true;
  9028. }
  9029. if (n > 2)
  9030. sprintf(atcmd_msg, "%s %s", command, params);
  9031. else
  9032. sprintf(atcmd_msg, "%s", command);
  9033. }
  9034. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9035. sd->idletime = last_tick;
  9036. //Clearing these to be used once more.
  9037. memset(command, '\0', sizeof(command));
  9038. memset(params, '\0', sizeof(params));
  9039. //check to see if any params exist within this command
  9040. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9041. params[0] = '\0';
  9042. // @commands (script based)
  9043. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9044. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9045. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  9046. if( binding != NULL && binding->npc_event[0] &&
  9047. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9048. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9049. {
  9050. // Check if self or character invoking; if self == character invoked, then self invoke.
  9051. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9052. return true;
  9053. }
  9054. }
  9055. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9056. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9057. if (info == NULL) {
  9058. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9059. return false;
  9060. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9061. clif_displaymessage(fd, output);
  9062. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9063. return true;
  9064. }
  9065. //check restriction
  9066. if (info->restriction) {
  9067. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9068. return true;
  9069. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9070. return true;
  9071. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9072. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9073. return true;
  9074. }
  9075. // type == 1 : player invoked
  9076. if (type == 1) {
  9077. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9078. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9079. return false;
  9080. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9081. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9082. return true;
  9083. }
  9084. }
  9085. //Attempt to use the command
  9086. if ( (info->func(fd, ssd, command, params) != 0) )
  9087. {
  9088. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9089. clif_displaymessage(fd, output);
  9090. return true;
  9091. }
  9092. //Log only if successful.
  9093. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9094. return true;
  9095. }
  9096. /*==========================================
  9097. *
  9098. *------------------------------------------*/
  9099. static void atcommand_config_read(const char* config_filename)
  9100. {
  9101. config_setting_t *aliases = NULL, *help = NULL;
  9102. const char *symbol = NULL;
  9103. int num_aliases = 0;
  9104. if (conf_read_file(&atcommand_config, config_filename))
  9105. return;
  9106. // Command symbols
  9107. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  9108. if (ISPRINT(*symbol) && // no control characters
  9109. *symbol != '/' && // symbol of client commands
  9110. *symbol != '%' && // symbol of party chat
  9111. *symbol != '$' && // symbol of guild chat
  9112. *symbol != charcommand_symbol)
  9113. atcommand_symbol = *symbol;
  9114. }
  9115. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  9116. if (ISPRINT(*symbol) && // no control characters
  9117. *symbol != '/' && // symbol of client commands
  9118. *symbol != '%' && // symbol of party chat
  9119. *symbol != '$' && // symbol of guild chat
  9120. *symbol != atcommand_symbol)
  9121. charcommand_symbol = *symbol;
  9122. }
  9123. // Command aliases
  9124. aliases = config_lookup(&atcommand_config, "aliases");
  9125. if (aliases != NULL) {
  9126. int i = 0;
  9127. int count = config_setting_length(aliases);
  9128. for (i = 0; i < count; ++i) {
  9129. config_setting_t *command;
  9130. const char *commandname = NULL;
  9131. int j = 0, alias_count = 0;
  9132. AtCommandInfo *commandinfo = NULL;
  9133. command = config_setting_get_elem(aliases, i);
  9134. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  9135. continue;
  9136. commandname = config_setting_name(command);
  9137. if (!atcommand_exists(commandname)) {
  9138. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  9139. continue;
  9140. }
  9141. commandinfo = get_atcommandinfo_byname(commandname);
  9142. alias_count = config_setting_length(command);
  9143. for (j = 0; j < alias_count; ++j) {
  9144. const char *alias = config_setting_get_string_elem(command, j);
  9145. if (alias != NULL) {
  9146. AliasInfo *alias_info;
  9147. if (strdb_exists(atcommand_alias_db, alias)) {
  9148. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  9149. continue;
  9150. }
  9151. CREATE(alias_info, AliasInfo, 1);
  9152. alias_info->command = commandinfo;
  9153. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  9154. strdb_put(atcommand_alias_db, alias, alias_info);
  9155. ++num_aliases;
  9156. }
  9157. }
  9158. }
  9159. }
  9160. // Commands help
  9161. // We only check if all commands exist
  9162. help = config_lookup(&atcommand_config, "help");
  9163. if (help != NULL) {
  9164. int count = config_setting_length(help);
  9165. int i;
  9166. for (i = 0; i < count; ++i) {
  9167. config_setting_t *command;
  9168. const char *commandname;
  9169. command = config_setting_get_elem(help, i);
  9170. commandname = config_setting_name(command);
  9171. if (!atcommand_exists(commandname))
  9172. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  9173. }
  9174. }
  9175. ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' command aliases in '" CL_WHITE "%s" CL_RESET "'.\n", num_aliases, config_filename);
  9176. return;
  9177. }
  9178. void atcommand_db_load_groups(int* group_ids) {
  9179. DBIterator *iter = db_iterator(atcommand_db);
  9180. AtCommandInfo* cmd;
  9181. int i;
  9182. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9183. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9184. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9185. for(i = 0; i < pc_group_max; i++) {
  9186. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9187. cmd->at_groups[i] = 1;
  9188. else
  9189. cmd->at_groups[i] = 0;
  9190. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9191. cmd->char_groups[i] = 1;
  9192. else
  9193. cmd->char_groups[i] = 0;
  9194. }
  9195. }
  9196. dbi_destroy(iter);
  9197. return;
  9198. }
  9199. void atcommand_db_clear(void) {
  9200. if (atcommand_db != NULL) {
  9201. DBIterator *iter = db_iterator(atcommand_db);
  9202. AtCommandInfo* cmd;
  9203. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9204. aFree(cmd->at_groups);
  9205. aFree(cmd->char_groups);
  9206. }
  9207. dbi_destroy(iter);
  9208. db_destroy(atcommand_db);
  9209. }
  9210. if (atcommand_alias_db != NULL)
  9211. db_destroy(atcommand_alias_db);
  9212. config_destroy(&atcommand_config);
  9213. }
  9214. void atcommand_doload(void) {
  9215. atcommand_db_clear();
  9216. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9217. atcommand_alias_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9218. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9219. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9220. }
  9221. void do_init_atcommand(void) {
  9222. atcommand_doload();
  9223. }
  9224. void do_final_atcommand(void) {
  9225. atcommand_db_clear();
  9226. }