atcommand.cpp 355 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911
  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 <cmath>
  5. #include <cstdlib>
  6. #include <set>
  7. #include <unordered_map>
  8. #include <common/cbasetypes.hpp>
  9. #include <common/database.hpp>
  10. #include <common/cli.hpp>
  11. #include <common/malloc.hpp>
  12. #include <common/mmo.hpp>
  13. #include <common/nullpo.hpp>
  14. #include <common/random.hpp>
  15. #include <common/showmsg.hpp>
  16. #include <common/socket.hpp>
  17. #include <common/strlib.hpp>
  18. #include <common/timer.hpp>
  19. #include <common/utilities.hpp>
  20. #include <common/utils.hpp>
  21. #include "achievement.hpp"
  22. #include "battle.hpp"
  23. #include "buyingstore.hpp"
  24. #include "channel.hpp"
  25. #include "chat.hpp"
  26. #include "chrif.hpp"
  27. #include "clan.hpp"
  28. #include "clif.hpp"
  29. #include "duel.hpp"
  30. #include "elemental.hpp"
  31. #include "guild.hpp"
  32. #include "homunculus.hpp"
  33. #include "instance.hpp"
  34. #include "intif.hpp"
  35. #include "itemdb.hpp" // MAX_ITEMGROUP
  36. #include "cashshop.hpp"
  37. #include "log.hpp"
  38. #include "mail.hpp"
  39. #include "map.hpp"
  40. #include "mapreg.hpp"
  41. #include "mercenary.hpp"
  42. #include "mob.hpp"
  43. #include "npc.hpp"
  44. #include "party.hpp"
  45. #include "pc.hpp"
  46. #include "pc_groups.hpp"
  47. #include "pet.hpp"
  48. #include "quest.hpp"
  49. #include "script.hpp"
  50. #include "storage.hpp"
  51. #include "trade.hpp"
  52. #include "vending.hpp"
  53. using namespace rathena;
  54. #define ATCOMMAND_LENGTH 50
  55. #define ACMD_FUNC(x) static int32 atcommand_ ## x (const int32 fd, map_session_data* sd, const char* command, const char* message)
  56. typedef struct AtCommandInfo AtCommandInfo;
  57. int32 atcmd_binding_count = 0;
  58. /// Atcommand restriction usage
  59. enum e_atcmd_restict {
  60. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  61. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  62. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  63. };
  64. struct AtCommandInfo {
  65. char command[ATCOMMAND_LENGTH];
  66. AtCommandFunc func;
  67. char* at_groups; /// Quick @commands "can-use" lookup
  68. char* char_groups; /// Quick @charcommands "can-use" lookup
  69. uint8 restriction; /// Restrictions see enum e_restict
  70. };
  71. struct s_atcommand_alias_info{
  72. AtCommandInfo *command;
  73. std::set<std::string> aliases;
  74. std::string help;
  75. };
  76. char atcommand_symbol = '@'; // first char of the commands
  77. char charcommand_symbol = '#';
  78. static DBMap* atcommand_db = nullptr; //name -> AtCommandInfo
  79. static AtCommandInfo* get_atcommandinfo_byname( const char* name );
  80. class AtcommandAliasDatabase : public TypesafeYamlDatabase<std::string, s_atcommand_alias_info>{
  81. private:
  82. std::unordered_map<std::string, std::string> aliases;
  83. public:
  84. AtcommandAliasDatabase() : TypesafeYamlDatabase( "ATCOMMAND_DB", 1 ){
  85. }
  86. void clear() override;
  87. const std::string getDefaultLocation() override;
  88. uint64 parseBodyNode( const ryml::NodeRef& node ) override;
  89. // Additional
  90. const char* checkAlias( const char* alias );
  91. };
  92. void AtcommandAliasDatabase::clear(){
  93. TypesafeYamlDatabase::clear();
  94. this->aliases.clear();
  95. }
  96. const std::string AtcommandAliasDatabase::getDefaultLocation(){
  97. return std::string(conf_path) + "/atcommands.yml";
  98. }
  99. uint64 AtcommandAliasDatabase::parseBodyNode( const ryml::NodeRef& node ){
  100. std::string command;
  101. if( !this->asString( node, "Command", command ) ){
  102. return 0;
  103. }
  104. AtCommandInfo* commandinfo = get_atcommandinfo_byname( command.c_str() );
  105. if( commandinfo == nullptr ){
  106. this->invalidWarning( node["Command"], "Command %s does not exist.\n", command.c_str() );
  107. return 0;
  108. }
  109. std::shared_ptr<s_atcommand_alias_info> info = this->find( command );
  110. bool exists = info != nullptr;
  111. if( !exists ){
  112. info = std::make_shared<s_atcommand_alias_info>();
  113. info->command = commandinfo;
  114. }
  115. if( this->nodeExists( node, "Help" ) ){
  116. std::string help;
  117. if( !this->asString( node, "Help", help ) ){
  118. return 0;
  119. }
  120. info->help = help;
  121. }
  122. if( this->nodeExists( node, "Aliases" ) ){
  123. const auto& aliasesNode = node["Aliases"];
  124. if( !aliasesNode.is_seq() ){
  125. this->invalidWarning( aliasesNode, "Aliases should be a sequence.\n" );
  126. return 0;
  127. }
  128. for( const auto& subNode : aliasesNode ){
  129. std::string alias;
  130. subNode >> alias;
  131. info->aliases.insert( alias );
  132. this->aliases[alias] = command;
  133. }
  134. }
  135. if( !exists ){
  136. this->put( command, info );
  137. }
  138. return 1;
  139. }
  140. const char* AtcommandAliasDatabase::checkAlias( const char* alias ){
  141. std::string alias_str( alias );
  142. std::string* command = util::umap_find( this->aliases, alias_str );
  143. if( command == nullptr ){
  144. return alias;
  145. }else{
  146. return command->c_str();
  147. }
  148. }
  149. AtcommandAliasDatabase atcommand_alias_db;
  150. static char atcmd_output[CHAT_SIZE_MAX];
  151. static char atcmd_player_name[NAME_LENGTH];
  152. const char *parent_cmd;
  153. struct atcmd_binding_data** atcmd_binding;
  154. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  155. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand); // @help
  156. static void warp_get_suggestions(map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  157. // @commands (script-based)
  158. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  159. int32 i = 0;
  160. if( *name == atcommand_symbol || *name == charcommand_symbol )
  161. name++; // for backwards compatibility
  162. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  163. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : nullptr;
  164. }
  165. /**
  166. * retrieves the help string associated with a given command.
  167. *
  168. * @param name the name of the command to retrieve help information for
  169. * @return the string associated with the command, or nullptr
  170. */
  171. static const char* atcommand_help_string( const char* command ){
  172. // remove the prefix symbol for the raw name of the command
  173. if( *command == atcommand_symbol || *command == charcommand_symbol ){
  174. command++;
  175. }
  176. // convert alias to the real command name
  177. command = atcommand_alias_db.checkAlias( command );
  178. // attempt to find the first default help command
  179. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command );
  180. // failed to find the help property in the configuration file
  181. if( info == nullptr ){
  182. return nullptr;
  183. }
  184. // push the result from the method
  185. return info->help.c_str();
  186. }
  187. /*==========================================
  188. * @send (used for testing packet sends from the client)
  189. *------------------------------------------*/
  190. ACMD_FUNC(send)
  191. {
  192. int32 len=0,type;
  193. // read message type as hex number (without the 0x)
  194. if(!message || !*message ||
  195. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  196. || sscanf(message, "%8x", &type)==1) )
  197. {
  198. int32 i;
  199. for (i = 900; i <= 903; ++i)
  200. clif_displaymessage(fd, msg_txt(sd,i));
  201. return -1;
  202. }
  203. #define PARSE_ERROR(error,p) \
  204. {\
  205. clif_displaymessage(fd, (error));\
  206. sprintf(atcmd_output, ">%s", (p));\
  207. clif_displaymessage(fd, atcmd_output);\
  208. }
  209. //define PARSE_ERROR
  210. #define CHECK_EOS(p) \
  211. if(*(p) == 0){\
  212. clif_displaymessage(fd, "Unexpected end of string");\
  213. return -1;\
  214. }
  215. //define CHECK_EOS
  216. #define SKIP_VALUE(p) \
  217. {\
  218. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  219. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  220. }
  221. //define SKIP_VALUE
  222. #define GET_VALUE(p,num) \
  223. {\
  224. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  225. PARSE_ERROR("Invalid number in:",(p));\
  226. return -1;\
  227. }\
  228. }
  229. //define GET_VALUE
  230. if (type > 0 && type < MAX_PACKET_DB) {
  231. int32 off,end;
  232. long num;
  233. if(len)
  234. {// show packet length
  235. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  236. clif_displaymessage(fd, atcmd_output);
  237. return 0;
  238. }
  239. len=packet_db[type].len;
  240. off=2;
  241. if(len == 0)
  242. {// unknown packet - ERROR
  243. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  244. clif_displaymessage(fd, atcmd_output);
  245. return -1;
  246. } else if(len == -1)
  247. {// dynamic packet
  248. len=SHRT_MAX-4; // maximum length
  249. off=4;
  250. }
  251. WFIFOHEAD(fd, len);
  252. WFIFOW(fd,0)=TOW(type);
  253. // parse packet contents
  254. SKIP_VALUE(message);
  255. while(*message != 0 && off < len){
  256. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  257. {// default (byte)
  258. GET_VALUE(message,num);
  259. WFIFOB(fd,off)=TOB(num);
  260. ++off;
  261. } else if(TOUPPER(*message) == 'B')
  262. {// byte
  263. ++message;
  264. GET_VALUE(message,num);
  265. WFIFOB(fd,off)=TOB(num);
  266. ++off;
  267. } else if(TOUPPER(*message) == 'W')
  268. {// word (2 bytes)
  269. ++message;
  270. GET_VALUE(message,num);
  271. WFIFOW(fd,off)=TOW(num);
  272. off+=2;
  273. } else if(TOUPPER(*message) == 'L')
  274. {// long word (4 bytes)
  275. ++message;
  276. GET_VALUE(message,num);
  277. WFIFOL(fd,off)=TOL(num);
  278. off+=4;
  279. } else if(TOUPPER(*message) == 'S')
  280. {// string - escapes are valid
  281. // get string length - num <= 0 means not fixed length (default)
  282. ++message;
  283. if(*message == '"'){
  284. num=0;
  285. } else {
  286. GET_VALUE(message,num);
  287. while(*message != '"')
  288. {// find start of string
  289. if(*message == 0 || ISSPACE(*message)){
  290. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  291. return -1;
  292. }
  293. ++message;
  294. }
  295. }
  296. // parse string
  297. ++message;
  298. CHECK_EOS(message);
  299. end=(num<=0? 0: min(off+((int32)num),len));
  300. for(; *message != '"' && (off < end || end == 0); ++off){
  301. if(*message == '\\'){
  302. ++message;
  303. CHECK_EOS(message);
  304. switch(*message){
  305. case 'a': num=0x07; break; // Bell
  306. case 'b': num=0x08; break; // Backspace
  307. case 't': num=0x09; break; // Horizontal tab
  308. case 'n': num=0x0A; break; // Line feed
  309. case 'v': num=0x0B; break; // Vertical tab
  310. case 'f': num=0x0C; break; // Form feed
  311. case 'r': num=0x0D; break; // Carriage return
  312. case 'e': num=0x1B; break; // Escape
  313. default: num=*message; break;
  314. case 'x': // Hexadecimal
  315. {
  316. ++message;
  317. CHECK_EOS(message);
  318. if(!ISXDIGIT(*message)){
  319. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  320. return -1;
  321. }
  322. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  323. if(ISXDIGIT(*message)){
  324. ++message;
  325. CHECK_EOS(message);
  326. num<<=8;
  327. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  328. }
  329. WFIFOB(fd,off)=TOB(num);
  330. ++message;
  331. CHECK_EOS(message);
  332. continue;
  333. }
  334. case '0':
  335. case '1':
  336. case '2':
  337. case '3':
  338. case '4':
  339. case '5':
  340. case '6':
  341. case '7': // Octal
  342. {
  343. num=*message-'0'; // 1st octal digit
  344. ++message;
  345. CHECK_EOS(message);
  346. if(ISDIGIT(*message) && *message < '8'){
  347. num<<=3;
  348. num+=*message-'0'; // 2nd octal digit
  349. ++message;
  350. CHECK_EOS(message);
  351. if(ISDIGIT(*message) && *message < '8'){
  352. num<<=3;
  353. num+=*message-'0'; // 3rd octal digit
  354. ++message;
  355. CHECK_EOS(message);
  356. }
  357. }
  358. WFIFOB(fd,off)=TOB(num);
  359. continue;
  360. }
  361. }
  362. } else
  363. num=*message;
  364. WFIFOB(fd,off)=TOB(num);
  365. ++message;
  366. CHECK_EOS(message);
  367. }//for
  368. while(*message != '"')
  369. {// ignore extra characters
  370. ++message;
  371. CHECK_EOS(message);
  372. }
  373. // terminate the string
  374. if(off < end)
  375. {// fill the rest with 0's
  376. memset(WFIFOP(fd,off),0,end-off);
  377. off=end;
  378. }
  379. } else
  380. {// unknown
  381. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  382. return -1;
  383. }
  384. SKIP_VALUE(message);
  385. }
  386. if(packet_db[type].len == -1)
  387. {// send dynamic packet
  388. WFIFOW(fd,2)=TOW(off);
  389. WFIFOSET(fd,off);
  390. } else
  391. {// send static packet
  392. if(off < len)
  393. memset(WFIFOP(fd,off),0,len-off);
  394. WFIFOSET(fd,len);
  395. }
  396. } else {
  397. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  398. return -1;
  399. }
  400. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  401. clif_displaymessage(fd, atcmd_output);
  402. return 0;
  403. #undef PARSE_ERROR
  404. #undef CHECK_EOS
  405. #undef SKIP_VALUE
  406. #undef GET_VALUE
  407. }
  408. /**
  409. * Retrieves map name suggestions for a given string.
  410. * This will first check if any map names contain the given string, and will
  411. * print out MAX_SUGGESTIONS results if any maps are found.
  412. * Otherwise, suggestions will be calculated through Levenshtein distance,
  413. * and up to 5 of the closest matches will be printed.
  414. *
  415. * @author Euphy
  416. */
  417. static void warp_get_suggestions(map_session_data* sd, const char *name) {
  418. // Minimum length for suggestions is 2 characters
  419. if( strlen( name ) < 2 ){
  420. return;
  421. }
  422. std::vector<const char*> suggestions;
  423. suggestions.reserve( MAX_SUGGESTIONS );
  424. // check for maps that contain string
  425. for (int32 i = 0; i < map_num; i++) {
  426. struct map_data *mapdata = map_getmapdata(i);
  427. // Prevent suggestion of instance mapnames
  428. if( mapdata->instance_id != 0 ){
  429. continue;
  430. }
  431. if( strstr( mapdata->name, name ) != nullptr ){
  432. suggestions.push_back( mapdata->name );
  433. if( suggestions.size() == MAX_SUGGESTIONS ){
  434. break;
  435. }
  436. }
  437. }
  438. // if no maps found, search by edit distance
  439. if( suggestions.empty() ){
  440. // Levenshtein > 4 is bad
  441. const int32 LEVENSHTEIN_MAX = 4;
  442. std::unordered_map<int32, std::vector<const char*>> maps;
  443. for (int32 i = 0; i < map_num; i++) {
  444. struct map_data *mapdata = map_getmapdata(i);
  445. // Prevent suggestion of instance mapnames
  446. if(mapdata->instance_id != 0 ){
  447. continue;
  448. }
  449. // Calculate the levenshtein distance of the two strings
  450. int32 distance = levenshtein(mapdata->name, name);
  451. // Check if it is above the maximum defined distance
  452. if( distance > LEVENSHTEIN_MAX ){
  453. continue;
  454. }
  455. std::vector<const char*>& vector = maps[distance];
  456. // Do not add more entries than required
  457. if( vector.size() == MAX_SUGGESTIONS ){
  458. continue;
  459. }
  460. vector.push_back(mapdata->name);
  461. }
  462. for( int32 distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){
  463. std::vector<const char*>& vector = maps[distance];
  464. for( const char* found_map : vector ){
  465. suggestions.push_back( found_map );
  466. if( suggestions.size() == MAX_SUGGESTIONS ){
  467. break;
  468. }
  469. }
  470. if( suggestions.size() == MAX_SUGGESTIONS ){
  471. break;
  472. }
  473. }
  474. }
  475. // If no suggestion could be made, do not output anything at all
  476. if( suggestions.empty() ){
  477. return;
  478. }
  479. char buffer[CHAT_SIZE_MAX];
  480. // build the suggestion string
  481. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  482. strcat(buffer, "\n");
  483. for( const char* suggestion : suggestions ){
  484. strcat(buffer, suggestion);
  485. strcat(buffer, " ");
  486. }
  487. clif_displaymessage(sd->fd, buffer);
  488. }
  489. /*==========================================
  490. * @rura, @warp, @mapmove
  491. *------------------------------------------*/
  492. ACMD_FUNC(mapmove)
  493. {
  494. char map_name[MAP_NAME_LENGTH_EXT];
  495. uint16 mapindex;
  496. int16 x = 0, y = 0;
  497. int16 m = -1;
  498. nullpo_retr(-1, sd);
  499. memset(map_name, '\0', sizeof(map_name));
  500. if (!message || !*message ||
  501. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  502. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  503. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  504. return -1;
  505. }
  506. mapindex = mapindex_name2idx(map_name, nullptr);
  507. if (mapindex)
  508. m = map_mapindex2mapid(mapindex);
  509. if (m < 0) { // m < 0 means on different server! [Kevin]
  510. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  511. if (battle_config.warp_suggestions_enabled)
  512. warp_get_suggestions(sd, map_name);
  513. return -1;
  514. }
  515. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  516. { //This is to prevent the pc_setpos call from printing an error.
  517. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  518. if (!map_search_freecell(nullptr, m, &x, &y, 10, 10, 1))
  519. x = y = 0; //Invalid cell, use random spot.
  520. }
  521. if ((map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, pc_get_group_level(sd))) {
  522. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  523. return -1;
  524. }
  525. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  526. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  527. return -1;
  528. }
  529. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  530. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  531. return -1;
  532. }
  533. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  534. return 0;
  535. }
  536. /*==========================================
  537. * Displays where a character is. Corrected version by Silent. [Skotlex]
  538. *------------------------------------------*/
  539. ACMD_FUNC(where)
  540. {
  541. map_session_data* pl_sd;
  542. nullpo_retr(-1, sd);
  543. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  544. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  545. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  546. return -1;
  547. }
  548. pl_sd = map_nick2sd(atcmd_player_name,true);
  549. if (pl_sd == nullptr ||
  550. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  551. (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))
  552. ) {
  553. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  554. return -1;
  555. }
  556. 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);
  557. clif_displaymessage(fd, atcmd_output);
  558. return 0;
  559. }
  560. /*==========================================
  561. *
  562. *------------------------------------------*/
  563. ACMD_FUNC(jumpto)
  564. {
  565. map_session_data* pl_sd = nullptr;;
  566. nullpo_retr(-1, sd);
  567. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  568. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  569. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  570. return -1;
  571. }
  572. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  573. {
  574. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  575. return -1;
  576. }
  577. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  578. {
  579. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  580. return -1;
  581. }
  582. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  583. {
  584. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  585. return -1;
  586. }
  587. if( pc_isdead(sd) )
  588. {
  589. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  590. return -1;
  591. }
  592. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  593. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  594. clif_displaymessage(fd, atcmd_output);
  595. return 0;
  596. }
  597. /*==========================================
  598. *
  599. *------------------------------------------*/
  600. ACMD_FUNC(jump)
  601. {
  602. int16 x = 0, y = 0;
  603. nullpo_retr(-1, sd);
  604. memset(atcmd_output, '\0', sizeof(atcmd_output));
  605. sscanf(message, "%6hd %6hd", &x, &y);
  606. if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  607. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  608. return -1;
  609. }
  610. if( pc_isdead(sd) )
  611. {
  612. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  613. return -1;
  614. }
  615. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  616. { //This is to prevent the pc_setpos call from printing an error.
  617. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  618. if (!map_search_freecell(nullptr, sd->bl.m, &x, &y, 10, 10, 1))
  619. x = y = 0; //Invalid cell, use random spot.
  620. }
  621. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  622. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  623. clif_displaymessage(fd, atcmd_output);
  624. return 0;
  625. }
  626. /*==========================================
  627. * Display list of online characters with
  628. * various info.
  629. *------------------------------------------*/
  630. ACMD_FUNC(who) {
  631. map_session_data* pl_sd = nullptr;;
  632. struct s_mapiterator *iter = nullptr;
  633. char player_name[NAME_LENGTH] = "";
  634. int32 count = 0;
  635. int32 level = 0;
  636. StringBuf buf;
  637. /**
  638. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  639. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  640. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  641. */
  642. int32 display_type = 1;
  643. int32 map_id = -1;
  644. nullpo_retr(-1, sd);
  645. if (strstr(command, "map") != nullptr) {
  646. char map_name[MAP_NAME_LENGTH_EXT] = "";
  647. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  648. map_id = sd->bl.m;
  649. } else {
  650. sscanf(message, "%23s", player_name);
  651. }
  652. if (strstr(command, "2") != nullptr)
  653. display_type = 2;
  654. else if (strstr(command, "3") != nullptr)
  655. display_type = 3;
  656. level = pc_get_group_level(sd);
  657. StringBuf_Init(&buf);
  658. iter = mapit_getallusers();
  659. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  660. 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
  661. if (stristr(pl_sd->status.name, player_name) == nullptr // search with no case sensitive
  662. || (map_id >= 0 && pl_sd->bl.m != map_id))
  663. continue;
  664. switch (display_type) {
  665. case 2: {
  666. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  667. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  668. StringBuf_Printf(&buf, msg_txt(sd,344),pl_sd->group->name.c_str()); // "(%s) "
  669. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  670. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  671. break;
  672. }
  673. case 3: {
  674. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  675. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  676. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  677. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  678. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  679. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  680. break;
  681. }
  682. default: {
  683. struct party_data *p = party_search(pl_sd->status.party_id);
  684. auto &g = pl_sd->guild;
  685. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  686. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  687. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  688. if (p != nullptr)
  689. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  690. if (g != nullptr)
  691. StringBuf_Printf(&buf, msg_txt(sd,346), g->guild.name); // " | Guild: '%s'"
  692. break;
  693. }
  694. }
  695. clif_displaymessage(fd, StringBuf_Value(&buf));
  696. StringBuf_Clear(&buf);
  697. count++;
  698. }
  699. }
  700. mapit_free(iter);
  701. if (map_id < 0) {
  702. if (count == 0)
  703. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  704. else if (count == 1)
  705. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  706. else
  707. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  708. } else {
  709. struct map_data *mapdata = map_getmapdata(map_id);
  710. if (count == 0)
  711. StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'.
  712. else if (count == 1)
  713. StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'.
  714. else
  715. StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'.
  716. }
  717. clif_displaymessage(fd, StringBuf_Value(&buf));
  718. StringBuf_Destroy(&buf);
  719. return 0;
  720. }
  721. /*==========================================
  722. *
  723. *------------------------------------------*/
  724. ACMD_FUNC(whogm)
  725. {
  726. map_session_data* pl_sd;
  727. struct s_mapiterator* iter;
  728. int32 j, count;
  729. int32 level;
  730. char match_text[CHAT_SIZE_MAX];
  731. char player_name[NAME_LENGTH];
  732. struct party_data *p;
  733. nullpo_retr(-1, sd);
  734. memset(atcmd_output, '\0', sizeof(atcmd_output));
  735. memset(match_text, '\0', sizeof(match_text));
  736. memset(player_name, '\0', sizeof(player_name));
  737. if (sscanf(message, "%255[^\n]", match_text) < 1)
  738. strcpy(match_text, "");
  739. for (j = 0; match_text[j]; j++)
  740. match_text[j] = TOLOWER(match_text[j]);
  741. count = 0;
  742. level = pc_get_group_level(sd);
  743. iter = mapit_getallusers();
  744. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  745. {
  746. int32 pl_level = pc_get_group_level(pl_sd);
  747. if (!pl_level)
  748. continue;
  749. if (match_text[0])
  750. {
  751. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  752. for (j = 0; player_name[j]; j++)
  753. player_name[j] = TOLOWER(player_name[j]);
  754. // search with no case sensitive
  755. if (strstr(player_name, match_text) == nullptr)
  756. continue;
  757. }
  758. if (pl_level > level) {
  759. if (pc_isinvisible(pl_sd))
  760. continue;
  761. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  762. clif_displaymessage(fd, atcmd_output);
  763. count++;
  764. continue;
  765. }
  766. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  767. pl_sd->status.name, pl_level,
  768. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  769. clif_displaymessage(fd, atcmd_output);
  770. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  771. pl_sd->status.base_level,
  772. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  773. clif_displaymessage(fd, atcmd_output);
  774. p = party_search(pl_sd->status.party_id);
  775. auto &g = pl_sd->guild;
  776. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  777. p?p->party.name:msg_txt(sd,917), g?g->guild.name:msg_txt(sd,917)); // None.
  778. clif_displaymessage(fd, atcmd_output);
  779. count++;
  780. }
  781. mapit_free(iter);
  782. if (count == 0)
  783. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  784. else if (count == 1)
  785. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  786. else {
  787. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  788. clif_displaymessage(fd, atcmd_output);
  789. }
  790. return 0;
  791. }
  792. /*==========================================
  793. *
  794. *------------------------------------------*/
  795. ACMD_FUNC(save)
  796. {
  797. nullpo_retr(-1, sd);
  798. if( map_getmapdata(sd->bl.m)->instance_id ) {
  799. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  800. return 1;
  801. }
  802. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  803. if (sd->status.pet_id > 0 && sd->pd)
  804. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  805. chrif_save(sd, CSAVE_NORMAL);
  806. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  807. return 0;
  808. }
  809. /*==========================================
  810. *
  811. *------------------------------------------*/
  812. ACMD_FUNC(load){
  813. nullpo_retr(-1, sd);
  814. uint16 mapindex = mapindex_name2id( sd->status.save_point.map );
  815. int16 m = map_mapindex2mapid( mapindex );
  816. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  817. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  818. return -1;
  819. }
  820. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  821. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  822. return -1;
  823. }
  824. pc_setpos( sd, mapindex, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT );
  825. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  826. return 0;
  827. }
  828. /*==========================================
  829. *
  830. *------------------------------------------*/
  831. ACMD_FUNC(speed)
  832. {
  833. int16 speed;
  834. nullpo_retr(-1, sd);
  835. memset(atcmd_output, '\0', sizeof(atcmd_output));
  836. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  837. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  838. clif_displaymessage(fd, atcmd_output);
  839. return -1;
  840. }
  841. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  842. if (speed < 0)
  843. sd->base_status.speed = DEFAULT_WALK_SPEED;
  844. else
  845. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  846. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  847. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  848. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  849. } else
  850. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  851. status_calc_bl(&sd->bl, { SCB_SPEED });
  852. return 0;
  853. }
  854. /*==========================================
  855. *
  856. *------------------------------------------*/
  857. ACMD_FUNC(storage)
  858. {
  859. nullpo_retr(-1, sd);
  860. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  861. return -1;
  862. if (storage_storageopen(sd) == 1)
  863. { //Already open.
  864. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  865. return -1;
  866. }
  867. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  868. return 0;
  869. }
  870. /*==========================================
  871. *
  872. *------------------------------------------*/
  873. ACMD_FUNC(guildstorage)
  874. {
  875. nullpo_retr(-1, sd);
  876. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  877. return -1;
  878. switch (storage_guild_storageopen(sd)) {
  879. case GSTORAGE_OPEN:
  880. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  881. break;
  882. case GSTORAGE_STORAGE_ALREADY_OPEN:
  883. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  884. return -1;
  885. case GSTORAGE_ALREADY_OPEN:
  886. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  887. return -1;
  888. case GSTORAGE_NO_GUILD:
  889. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  890. return -1;
  891. case GSTORAGE_NO_STORAGE:
  892. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  893. return -1;
  894. case GSTORAGE_NO_PERMISSION:
  895. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  896. return -1;
  897. }
  898. return 0;
  899. }
  900. /*==========================================
  901. *
  902. *------------------------------------------*/
  903. ACMD_FUNC(option)
  904. {
  905. int32 param1 = 0, param2 = 0, param3 = 0;
  906. nullpo_retr(-1, sd);
  907. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  908. {// failed to match the parameters so inform the user of the options
  909. const char* text;
  910. // attempt to find the setting information for this command
  911. text = atcommand_help_string( command );
  912. // notify the user of the requirement to enter an option
  913. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  914. if( text )
  915. {// send the help text associated with this command
  916. clif_displaymessage( fd, text );
  917. }
  918. return -1;
  919. }
  920. sd->sc.opt1 = param1;
  921. sd->sc.opt2 = param2;
  922. pc_setoption(sd, param3);
  923. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  924. return 0;
  925. }
  926. /*==========================================
  927. *
  928. *------------------------------------------*/
  929. ACMD_FUNC(hide)
  930. {
  931. nullpo_retr(-1, sd);
  932. if (pc_isinvisible(sd)) {
  933. sd->sc.option &= ~OPTION_INVISIBLE;
  934. if (sd->disguise)
  935. status_set_viewdata(&sd->bl, sd->disguise);
  936. else
  937. status_set_viewdata(&sd->bl, sd->status.class_);
  938. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  939. // increment the number of pvp players on the map
  940. map_getmapdata(sd->bl.m)->users_pvp++;
  941. if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) )
  942. {// register the player for ranking calculations
  943. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  944. }
  945. //bugreport:2266
  946. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  947. } else {
  948. sd->sc.option |= OPTION_INVISIBLE;
  949. sd->vd.class_ = JT_INVISIBLE;
  950. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  951. // decrement the number of pvp players on the map
  952. map_getmapdata(sd->bl.m)->users_pvp--;
  953. if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER )
  954. {// unregister the player for ranking
  955. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  956. sd->pvp_timer = INVALID_TIMER;
  957. }
  958. }
  959. clif_changeoption(&sd->bl);
  960. return 0;
  961. }
  962. ACMD_FUNC(resetcooltime)
  963. {
  964. nullpo_retr(-1, sd);
  965. if (!sd->scd.empty()) {
  966. for (const auto &entry : sd->scd) {
  967. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  968. clif_displaymessage( sd->fd, atcmd_output );
  969. }
  970. skill_blockpc_clear(*sd);
  971. }
  972. if( sd->hd != nullptr && hom_is_active( sd->hd ) ){
  973. for (const auto &entry : sd->hd->scd) {
  974. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  975. clif_displaymessage( sd->fd, atcmd_output );
  976. }
  977. skill_blockhomun_clear(*sd->hd);
  978. }
  979. if( sd->md != nullptr ){
  980. for( const auto &entry : sd->md->scd ){
  981. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  982. clif_displaymessage( sd->fd, atcmd_output );
  983. }
  984. skill_blockmerc_clear(*sd->md);
  985. }
  986. return 0;
  987. }
  988. /*==========================================
  989. * Changes a character's class
  990. *------------------------------------------*/
  991. ACMD_FUNC(jobchange)
  992. {
  993. int32 job = 0, upper = 0;
  994. const char* text;
  995. nullpo_retr(-1, sd);
  996. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  997. int32 i;
  998. bool found = false;
  999. upper = 0;
  1000. // Normal Jobs
  1001. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  1002. if (strncmpi(message, job_name(i), 16) == 0) {
  1003. job = i;
  1004. found = true;
  1005. }
  1006. }
  1007. // High Jobs, Babys, Third, and Fourth
  1008. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  1009. if (strncmpi(message, job_name(i), 16) == 0) {
  1010. job = i;
  1011. found = true;
  1012. }
  1013. }
  1014. if (!found) {
  1015. text = atcommand_help_string(command);
  1016. if (text)
  1017. clif_displaymessage(fd, text);
  1018. return -1;
  1019. }
  1020. }
  1021. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  1022. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  1023. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE_KNIGHT2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  1024. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2
  1025. || (job >= JOB_WINDHAWK2 && job <= JOB_IMPERIAL_GUARD2) || job == JOB_SKY_EMPEROR2)
  1026. { // Deny direct transformation into dummy jobs
  1027. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  1028. return 0;
  1029. }
  1030. if (pcdb_checkid(job))
  1031. {
  1032. if (pc_jobchange(sd, job, upper))
  1033. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  1034. else {
  1035. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  1036. return -1;
  1037. }
  1038. } else {
  1039. text = atcommand_help_string(command);
  1040. if (text)
  1041. clif_displaymessage(fd, text);
  1042. return -1;
  1043. }
  1044. return 0;
  1045. }
  1046. /*==========================================
  1047. *
  1048. *------------------------------------------*/
  1049. ACMD_FUNC(kill)
  1050. {
  1051. nullpo_retr(-1, sd);
  1052. status_kill(&sd->bl);
  1053. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1054. if (fd != sd->fd)
  1055. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1056. return 0;
  1057. }
  1058. /*==========================================
  1059. *
  1060. *------------------------------------------*/
  1061. ACMD_FUNC(alive)
  1062. {
  1063. nullpo_retr(-1, sd);
  1064. if (!status_revive(&sd->bl, 100, 100))
  1065. {
  1066. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  1067. return -1;
  1068. }
  1069. clif_skill_nodamage(&sd->bl,sd->bl,ALL_RESURRECTION,4);
  1070. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1071. return 0;
  1072. }
  1073. ACMD_FUNC(kami){
  1074. nullpo_retr(-1, sd);
  1075. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1076. if (!message || !*message) {
  1077. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1078. return -1;
  1079. }
  1080. sscanf(message, "%255[^\n]", atcmd_output);
  1081. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  1082. return 0;
  1083. }
  1084. ACMD_FUNC(lkami){
  1085. nullpo_retr(-1, sd);
  1086. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1087. if (!message || !*message) {
  1088. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1089. return -1;
  1090. }
  1091. sscanf(message, "%255[^\n]", atcmd_output);
  1092. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  1093. return 0;
  1094. }
  1095. ACMD_FUNC(kamib){
  1096. nullpo_retr(-1, sd);
  1097. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1098. if (!message || !*message) {
  1099. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1100. return -1;
  1101. }
  1102. sscanf(message, "%255[^\n]", atcmd_output);
  1103. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_BLUE);
  1104. return 0;
  1105. }
  1106. ACMD_FUNC(kamic){
  1107. unsigned long color=0;
  1108. nullpo_retr(-1, sd);
  1109. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1110. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1111. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1112. return -1;
  1113. }
  1114. if(color > 0xFFFFFF) {
  1115. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1116. return -1;
  1117. }
  1118. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1119. return 0;
  1120. }
  1121. /*==========================================
  1122. *
  1123. *------------------------------------------*/
  1124. ACMD_FUNC(heal)
  1125. {
  1126. int32 hp = 0, sp = 0; // [Valaris] thanks to fov
  1127. nullpo_retr(-1, sd);
  1128. sscanf(message, "%11d %11d", &hp, &sp);
  1129. // some overflow checks
  1130. if( hp == INT_MIN ) hp++;
  1131. if( sp == INT_MIN ) sp++;
  1132. if ( hp == 0 && sp == 0 ) {
  1133. if (!status_percent_heal(&sd->bl, 100, 100))
  1134. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1135. else
  1136. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1137. return 0;
  1138. }
  1139. if ( hp > 0 && sp >= 0 ) {
  1140. if(!status_heal(&sd->bl, hp, sp, 0))
  1141. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1142. else
  1143. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1144. return 0;
  1145. }
  1146. if ( hp < 0 && sp <= 0 ) {
  1147. status_damage(nullptr, &sd->bl, -hp, -sp, 0, 0, 0);
  1148. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1149. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1150. return 0;
  1151. }
  1152. //Opposing signs.
  1153. if ( hp ) {
  1154. if (hp > 0)
  1155. status_heal(&sd->bl, hp, 0, 0);
  1156. else {
  1157. status_damage(nullptr, &sd->bl, -hp, 0, 0, 0, 0);
  1158. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1159. }
  1160. }
  1161. if ( sp ) {
  1162. if (sp > 0)
  1163. status_heal(&sd->bl, 0, sp, 0);
  1164. else
  1165. status_damage(nullptr, &sd->bl, 0, -sp, 0, 0, 0);
  1166. }
  1167. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1168. return 0;
  1169. }
  1170. /*==========================================
  1171. * Recover's AP and allows exact adjustments. [Rytech]
  1172. *------------------------------------------*/
  1173. ACMD_FUNC(healap)
  1174. {
  1175. int32 ap = 0;
  1176. nullpo_retr(-1, sd);
  1177. sscanf(message, "%11d", &ap);
  1178. // Overflow check.
  1179. if (ap == INT_MIN) ap++;
  1180. if (ap == 0) {
  1181. if (!status_percent_heal(&sd->bl, 0, 0, 100))
  1182. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1183. else
  1184. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1185. return 0;
  1186. }else if (ap > 0) {
  1187. if (!status_heal(&sd->bl, 0, 0, ap, 0))
  1188. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1189. else
  1190. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1191. return 0;
  1192. }else{
  1193. status_damage(nullptr, &sd->bl, 0, 0, -ap, 0, 0, 0);
  1194. clif_displaymessage(fd, msg_txt(sd, 822));// AP modified.
  1195. return 0;
  1196. }
  1197. }
  1198. /*==========================================
  1199. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1200. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1201. *------------------------------------------*/
  1202. ACMD_FUNC(item)
  1203. {
  1204. char item_name[100];
  1205. int32 number = 0, bound = BOUND_NONE;
  1206. char flag = 0;
  1207. char *itemlist;
  1208. nullpo_retr(-1, sd);
  1209. memset(item_name, '\0', sizeof(item_name));
  1210. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1211. if (!strcmpi(parent_cmd,"itembound")) {
  1212. if (!message || !*message || (
  1213. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1214. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1215. {
  1216. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1217. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1218. return -1;
  1219. }
  1220. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1221. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1222. return -1;
  1223. }
  1224. } else if (!message || !*message || (
  1225. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1226. sscanf(message, "%99s %11d", item_name, &number) < 1
  1227. )) {
  1228. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1229. return -1;
  1230. }
  1231. std::vector<std::shared_ptr<item_data>> items;
  1232. itemlist = strtok(item_name, ":");
  1233. while( itemlist != nullptr ){
  1234. std::shared_ptr<item_data> item = item_db.searchname( itemlist );
  1235. if( item == nullptr ){
  1236. item = item_db.find( strtoul( itemlist, nullptr, 10 ) );
  1237. }
  1238. if( item == nullptr ){
  1239. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1240. return -1;
  1241. }
  1242. items.push_back( item );
  1243. itemlist = strtok(nullptr, ":"); //next itemline
  1244. }
  1245. if (number <= 0)
  1246. number = 1;
  1247. int32 get_count = number;
  1248. // Produce items in list
  1249. for( const auto& item : items ){
  1250. t_itemid item_id = item->nameid;
  1251. //Check if it's stackable.
  1252. if( !itemdb_isstackable2( item.get() ) ){
  1253. get_count = 1;
  1254. }
  1255. for( int32 i = 0; i < number; i += get_count ){
  1256. // if not pet egg
  1257. if (!pet_create_egg(sd, item_id)) {
  1258. struct item item_tmp = {};
  1259. item_tmp.nameid = item_id;
  1260. item_tmp.identify = 1;
  1261. item_tmp.bound = bound;
  1262. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1263. clif_additem(sd, 0, 0, flag);
  1264. }
  1265. }
  1266. }
  1267. if (flag == 0)
  1268. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1269. return 0;
  1270. }
  1271. /*==========================================
  1272. *
  1273. *------------------------------------------*/
  1274. ACMD_FUNC(item2)
  1275. {
  1276. char item_name[100];
  1277. int32 number = 0, bound = BOUND_NONE;
  1278. int32 identify = 0, refine = 0, attr = 0;
  1279. int32 c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1280. nullpo_retr(-1, sd);
  1281. memset(item_name, '\0', sizeof(item_name));
  1282. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1283. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1284. if (!message || !*message || (
  1285. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1286. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1287. {
  1288. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1289. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1290. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1291. return -1;
  1292. }
  1293. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1294. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1295. return -1;
  1296. }
  1297. } else if ( !message || !*message || (
  1298. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1299. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1300. )) {
  1301. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1302. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1303. return -1;
  1304. }
  1305. if (number <= 0)
  1306. number = 1;
  1307. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  1308. if( item_data == nullptr ){
  1309. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  1310. }
  1311. if( item_data != nullptr ){
  1312. int32 loop, get_count, i;
  1313. char flag = 0;
  1314. //Check if it's stackable.
  1315. if( !itemdb_isstackable2( item_data.get() ) ){
  1316. loop = number;
  1317. get_count = 1;
  1318. }else{
  1319. loop = 1;
  1320. get_count = number;
  1321. }
  1322. if( itemdb_isequip2( item_data.get() ) ){
  1323. refine = cap_value( refine, 0, MAX_REFINE );
  1324. }else{
  1325. // All other items cannot be refined and are always identified
  1326. identify = 1;
  1327. refine = attr = 0;
  1328. }
  1329. for (i = 0; i < loop; i++) {
  1330. // if not pet egg
  1331. if (!pet_create_egg(sd, item_data->nameid)) {
  1332. struct item item_tmp = {};
  1333. item_tmp.nameid = item_data->nameid;
  1334. item_tmp.identify = identify;
  1335. item_tmp.refine = refine;
  1336. item_tmp.attribute = attr;
  1337. item_tmp.card[0] = c1;
  1338. item_tmp.card[1] = c2;
  1339. item_tmp.card[2] = c3;
  1340. item_tmp.card[3] = c4;
  1341. item_tmp.bound = bound;
  1342. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1343. clif_additem(sd, 0, 0, flag);
  1344. }
  1345. }
  1346. if (flag == 0)
  1347. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1348. } else {
  1349. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1350. return -1;
  1351. }
  1352. return 0;
  1353. }
  1354. /*==========================================
  1355. *
  1356. *------------------------------------------*/
  1357. ACMD_FUNC(itemreset)
  1358. {
  1359. int32 i;
  1360. nullpo_retr(-1, sd);
  1361. for (i = 0; i < MAX_INVENTORY; i++) {
  1362. if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0 && !itemdb_ishatched_egg(&sd->inventory.u.items_inventory[i])) {
  1363. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1364. }
  1365. }
  1366. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1367. return 0;
  1368. }
  1369. /*==========================================
  1370. * Atcommand @lvlup
  1371. *------------------------------------------*/
  1372. ACMD_FUNC(baselevelup)
  1373. {
  1374. int32 level=0, i=0, status_point=0, trait_point=0;
  1375. nullpo_retr(-1, sd);
  1376. level = atoi(message);
  1377. if (!message || !*message || !level) {
  1378. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1379. return -1;
  1380. }
  1381. if (level > 0) {
  1382. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1383. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1384. return -1;
  1385. } // End Addition
  1386. if ((uint32)level > pc_maxbaselv(sd) || (uint32)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1387. level = pc_maxbaselv(sd) - sd->status.base_level;
  1388. for (i = 0; i < level; i++)
  1389. {
  1390. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i);
  1391. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i);
  1392. }
  1393. sd->status.status_point += status_point;
  1394. sd->status.trait_point += trait_point;
  1395. sd->status.base_level += (uint32)level;
  1396. status_calc_pc(sd, SCO_FORCE);
  1397. status_percent_heal(&sd->bl, 100, 100);
  1398. clif_misceffect( sd->bl, NOTIFYEFFECT_BASE_LEVEL_UP );
  1399. for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) {
  1400. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j);
  1401. achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_);
  1402. }
  1403. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1404. } else {
  1405. if (sd->status.base_level == 1) {
  1406. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1407. return -1;
  1408. }
  1409. level*=-1;
  1410. if ((uint32)level >= sd->status.base_level)
  1411. level = sd->status.base_level-1;
  1412. for (i = 0; i > -level; i--)
  1413. {
  1414. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i - 1);
  1415. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i - 1);
  1416. }
  1417. if (sd->status.status_point < status_point || sd->status.trait_point < trait_point)
  1418. pc_resetstate(sd);
  1419. if (sd->status.status_point < status_point)
  1420. sd->status.status_point = 0;
  1421. else
  1422. sd->status.status_point -= status_point;
  1423. if (sd->status.trait_point < trait_point)
  1424. sd->status.trait_point = 0;
  1425. else
  1426. sd->status.trait_point -= trait_point;
  1427. sd->status.base_level -= (uint32)level;
  1428. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1429. status_calc_pc(sd, SCO_FORCE);
  1430. level*=-1;
  1431. }
  1432. sd->status.base_exp = 0;
  1433. clif_updatestatus(*sd, SP_STATUSPOINT);
  1434. clif_updatestatus(*sd, SP_TRAITPOINT);
  1435. clif_updatestatus(*sd, SP_BASELEVEL);
  1436. clif_updatestatus(*sd, SP_BASEEXP);
  1437. clif_updatestatus(*sd, SP_NEXTBASEEXP);
  1438. pc_baselevelchanged(sd);
  1439. if(sd->status.party_id)
  1440. party_send_levelup(sd);
  1441. if( level > 0 && battle_config.atcommand_levelup_events )
  1442. npc_script_event( *sd, NPCE_BASELVUP );
  1443. return 0;
  1444. }
  1445. /*==========================================
  1446. *
  1447. *------------------------------------------*/
  1448. ACMD_FUNC(joblevelup)
  1449. {
  1450. int32 level=0;
  1451. nullpo_retr(-1, sd);
  1452. level = atoi(message);
  1453. if (!message || !*message || !level) {
  1454. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1455. return -1;
  1456. }
  1457. if (level > 0) {
  1458. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1459. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1460. return -1;
  1461. }
  1462. if ((uint32)level > pc_maxjoblv(sd) || (uint32)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1463. level = pc_maxjoblv(sd) - sd->status.job_level;
  1464. sd->status.job_level += (uint32)level;
  1465. sd->status.skill_point += level;
  1466. clif_misceffect( sd->bl, NOTIFYEFFECT_JOB_LEVEL_UP );
  1467. for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++)
  1468. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i);
  1469. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1470. } else {
  1471. if (sd->status.job_level == 1) {
  1472. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1473. return -1;
  1474. }
  1475. level *=-1;
  1476. if ((uint32)level >= sd->status.job_level) // fix negative overflow
  1477. level = sd->status.job_level-1;
  1478. sd->status.job_level -= (uint32)level;
  1479. if (sd->status.skill_point < level)
  1480. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1481. if (sd->status.skill_point < level)
  1482. sd->status.skill_point = 0;
  1483. else
  1484. sd->status.skill_point -= level;
  1485. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1486. level *=-1;
  1487. }
  1488. sd->status.job_exp = 0;
  1489. clif_updatestatus(*sd, SP_JOBLEVEL);
  1490. clif_updatestatus(*sd, SP_JOBEXP);
  1491. clif_updatestatus(*sd, SP_NEXTJOBEXP);
  1492. clif_updatestatus(*sd, SP_SKILLPOINT);
  1493. status_calc_pc(sd, SCO_FORCE);
  1494. if( level > 0 && battle_config.atcommand_levelup_events )
  1495. npc_script_event( *sd, NPCE_JOBLVUP );
  1496. return 0;
  1497. }
  1498. /*==========================================
  1499. * @help
  1500. *------------------------------------------*/
  1501. ACMD_FUNC(help){
  1502. const char *command_name = nullptr;
  1503. nullpo_retr(-1, sd);
  1504. if (!message || !*message) {
  1505. command_name = "help"; // If no command_name specified, display help for @help.
  1506. } else {
  1507. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1508. ++message;
  1509. command_name = atcommand_alias_db.checkAlias(message);
  1510. }
  1511. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1512. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1513. clif_displaymessage(fd, atcmd_output);
  1514. atcommand_get_suggestions(sd, command_name, true);
  1515. return -1;
  1516. }
  1517. // attempt to find the first default help command
  1518. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_name );
  1519. const char* text = info != nullptr ? info->help.c_str() : nullptr;
  1520. if( text == nullptr ){
  1521. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1522. clif_displaymessage(fd, atcmd_output);
  1523. atcommand_get_suggestions(sd, command_name, true);
  1524. return -1;
  1525. }
  1526. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1527. clif_displaymessage(fd, atcmd_output);
  1528. { // Display aliases
  1529. StringBuf buf;
  1530. bool has_aliases = false;
  1531. StringBuf_Init(&buf);
  1532. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1533. for( const std::string& alias : info->aliases ){
  1534. StringBuf_Printf( &buf, " %s", alias.c_str() );
  1535. has_aliases = true;
  1536. }
  1537. if (has_aliases)
  1538. clif_displaymessage(fd, StringBuf_Value(&buf));
  1539. StringBuf_Destroy(&buf);
  1540. }
  1541. // Display help contents
  1542. clif_displaymessage(fd, text);
  1543. return 0;
  1544. }
  1545. /*==========================================
  1546. *
  1547. *------------------------------------------*/
  1548. ACMD_FUNC(pvpoff)
  1549. {
  1550. nullpo_retr(-1, sd);
  1551. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1552. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1553. return -1;
  1554. }
  1555. map_setmapflag(sd->bl.m, MF_PVP, false);
  1556. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1557. return 0;
  1558. }
  1559. /*==========================================
  1560. *
  1561. *------------------------------------------*/
  1562. ACMD_FUNC(pvpon)
  1563. {
  1564. nullpo_retr(-1, sd);
  1565. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1566. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1567. return -1;
  1568. }
  1569. map_setmapflag(sd->bl.m, MF_PVP, true);
  1570. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1571. return 0;
  1572. }
  1573. /*==========================================
  1574. *
  1575. *------------------------------------------*/
  1576. ACMD_FUNC(gvgoff)
  1577. {
  1578. nullpo_retr(-1, sd);
  1579. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1580. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1581. return -1;
  1582. }
  1583. map_setmapflag(sd->bl.m, MF_GVG, false);
  1584. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1585. return 0;
  1586. }
  1587. /*==========================================
  1588. *
  1589. *------------------------------------------*/
  1590. ACMD_FUNC(gvgon)
  1591. {
  1592. nullpo_retr(-1, sd);
  1593. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1594. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1595. return -1;
  1596. }
  1597. map_setmapflag(sd->bl.m, MF_GVG, true);
  1598. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1599. return 0;
  1600. }
  1601. /*==========================================
  1602. *
  1603. *------------------------------------------*/
  1604. ACMD_FUNC(model)
  1605. {
  1606. int32 hair_style = 0, hair_color = 0, cloth_color = 0;
  1607. nullpo_retr(-1, sd);
  1608. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1609. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1610. 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>).
  1611. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1612. clif_displaymessage(fd, atcmd_output);
  1613. return -1;
  1614. }
  1615. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1616. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1617. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1618. pc_changelook(sd, LOOK_HAIR, hair_style);
  1619. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1620. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1621. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1622. } else {
  1623. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1624. return -1;
  1625. }
  1626. return 0;
  1627. }
  1628. /*==========================================
  1629. * @bodystyle [Rytech]
  1630. *------------------------------------------*/
  1631. ACMD_FUNC(bodystyle)
  1632. {
  1633. int32 body_style = 0;
  1634. nullpo_retr(-1, sd);
  1635. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1636. if ( (sd->class_ & JOBL_FOURTH) || !(sd->class_ & JOBL_THIRD) || (sd->class_ & MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E || (sd->class_ & MAPID_THIRDMASK) == MAPID_STAR_EMPEROR || (sd->class_ & MAPID_THIRDMASK) == MAPID_SOUL_REAPER) {
  1637. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1638. return -1;
  1639. }
  1640. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1641. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1642. clif_displaymessage(fd, atcmd_output);
  1643. return -1;
  1644. }
  1645. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1646. pc_changelook(sd, LOOK_BODY2, body_style);
  1647. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1648. } else {
  1649. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1650. return -1;
  1651. }
  1652. return 0;
  1653. }
  1654. /*==========================================
  1655. * @dye && @ccolor
  1656. *------------------------------------------*/
  1657. ACMD_FUNC(dye)
  1658. {
  1659. int32 cloth_color = 0;
  1660. nullpo_retr(-1, sd);
  1661. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1662. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1663. 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>).
  1664. clif_displaymessage(fd, atcmd_output);
  1665. return -1;
  1666. }
  1667. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1668. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1669. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1670. } else {
  1671. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1672. return -1;
  1673. }
  1674. return 0;
  1675. }
  1676. /*==========================================
  1677. * @hairstyle && @hstyle
  1678. *------------------------------------------*/
  1679. ACMD_FUNC(hair_style)
  1680. {
  1681. int32 hair_style = 0;
  1682. nullpo_retr(-1, sd);
  1683. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1684. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1685. 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>).
  1686. clif_displaymessage(fd, atcmd_output);
  1687. return -1;
  1688. }
  1689. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1690. pc_changelook(sd, LOOK_HAIR, hair_style);
  1691. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1692. } else {
  1693. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1694. return -1;
  1695. }
  1696. return 0;
  1697. }
  1698. /*==========================================
  1699. * @haircolor && @hcolor
  1700. *------------------------------------------*/
  1701. ACMD_FUNC(hair_color)
  1702. {
  1703. int32 hair_color = 0;
  1704. nullpo_retr(-1, sd);
  1705. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1706. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1707. 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>).
  1708. clif_displaymessage(fd, atcmd_output);
  1709. return -1;
  1710. }
  1711. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1712. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1713. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1714. } else {
  1715. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1716. return -1;
  1717. }
  1718. return 0;
  1719. }
  1720. /*==========================================
  1721. * @go [city_number or city_name] - Updated by Harbin
  1722. *------------------------------------------*/
  1723. ACMD_FUNC(go)
  1724. {
  1725. int32 i;
  1726. int32 town;
  1727. char map_name[MAP_NAME_LENGTH];
  1728. const struct {
  1729. char map[MAP_NAME_LENGTH];
  1730. int32 x, y;
  1731. } data[] = {
  1732. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1733. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1734. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1735. { MAP_PAYON, 162, 233 }, // 3=Payon
  1736. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1737. #ifdef RENEWAL
  1738. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1739. #else
  1740. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1741. #endif
  1742. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1743. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1744. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1745. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1746. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1747. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1748. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1749. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1750. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1751. #ifdef RENEWAL
  1752. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1753. #else
  1754. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1755. #endif
  1756. { MAP_JAIL, 23, 61 }, // 16=Prison
  1757. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1758. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1759. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1760. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1761. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1762. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1763. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1764. { MAP_VEINS, 216, 123 }, // 24=Veins
  1765. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1766. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1767. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1768. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1769. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1770. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1771. { MAP_MORA, 44, 151 }, // 31=Mora
  1772. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1773. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1774. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1775. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1776. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1777. };
  1778. nullpo_retr(-1, sd);
  1779. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1780. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1781. return 0;
  1782. }
  1783. memset(map_name, '\0', sizeof(map_name));
  1784. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1785. // get the number
  1786. town = atoi(message);
  1787. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1788. {// no value matched so send the list of locations
  1789. const char* text;
  1790. // attempt to find the text help string
  1791. text = atcommand_help_string( command );
  1792. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1793. if( text )
  1794. {// send the text to the client
  1795. clif_displaymessage( fd, text );
  1796. }
  1797. return -1;
  1798. }
  1799. // get possible name of the city
  1800. map_name[MAP_NAME_LENGTH-1] = '\0';
  1801. for (i = 0; map_name[i]; i++)
  1802. map_name[i] = TOLOWER(map_name[i]);
  1803. // try to identify the map name
  1804. if (strncmp(map_name, "prontera", 3) == 0) {
  1805. town = 0;
  1806. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1807. strncmp(map_name, "morroc", 4) == 0) {
  1808. town = 1;
  1809. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1810. town = 2;
  1811. } else if (strncmp(map_name, "payon", 3) == 0) {
  1812. town = 3;
  1813. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1814. town = 4;
  1815. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1816. town = 5;
  1817. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1818. town = 6;
  1819. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1820. strcmp(map_name, "christmas") == 0 ||
  1821. strncmp(map_name, "xmas", 3) == 0 ||
  1822. strncmp(map_name, "x-mas", 3) == 0) {
  1823. town = 7;
  1824. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1825. town = 8;
  1826. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1827. strncmp(map_name, "yuno", 3) == 0) {
  1828. town = 9;
  1829. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1830. town = 10;
  1831. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1832. strncmp(map_name, "gonryun", 3) == 0) {
  1833. town = 11;
  1834. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1835. town = 12;
  1836. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1837. town = 13;
  1838. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1839. town = 14;
  1840. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1841. strncmp(map_name, "startpoint", 3) == 0 ||
  1842. strncmp(map_name, "beginning", 3) == 0) {
  1843. town = 15;
  1844. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1845. strncmp(map_name, "prison", 3) == 0 ||
  1846. strncmp(map_name, "jail", 3) == 0) {
  1847. town = 16;
  1848. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1849. town = 17;
  1850. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1851. town = 18;
  1852. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1853. town = 19;
  1854. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1855. town = 20;
  1856. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1857. town = 21;
  1858. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1859. town = 22;
  1860. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1861. town = 23;
  1862. } else if (strncmp(map_name, "veins", 3) == 0) {
  1863. town = 24;
  1864. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1865. town = 25;
  1866. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1867. town = 26;
  1868. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1869. town = 27;
  1870. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1871. town = 28;
  1872. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1873. town = 29;
  1874. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1875. town = 30;
  1876. } else if (strcmp(map_name, "mora") == 0) {
  1877. town = 31;
  1878. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1879. town = 32;
  1880. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1881. town = 33;
  1882. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1883. town = 34;
  1884. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1885. town = 35;
  1886. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1887. town = 36;
  1888. }
  1889. if (town >= 0 && town < ARRAYLENGTH(data))
  1890. {
  1891. int16 m = map_mapname2mapid(data[town].map);
  1892. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1893. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1894. return -1;
  1895. }
  1896. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1897. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1898. return -1;
  1899. }
  1900. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1901. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1902. } else {
  1903. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1904. return -1;
  1905. }
  1906. } else { // if you arrive here, you have an error in town variable when reading of names
  1907. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1908. return -1;
  1909. }
  1910. return 0;
  1911. }
  1912. /*==========================================
  1913. *
  1914. *------------------------------------------*/
  1915. ACMD_FUNC(monster)
  1916. {
  1917. char name[NAME_LENGTH];
  1918. char monster[NAME_LENGTH];
  1919. char eventname[EVENT_NAME_LENGTH] = "";
  1920. int32 mob_id;
  1921. int32 number = 0;
  1922. int32 count;
  1923. int32 i, range;
  1924. int16 mx, my;
  1925. uint32 size;
  1926. nullpo_retr(-1, sd);
  1927. memset(name, '\0', sizeof(name));
  1928. memset(monster, '\0', sizeof(monster));
  1929. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1930. if (!message || !*message) {
  1931. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1932. return -1;
  1933. }
  1934. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1935. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1936. //All data can be left as it is.
  1937. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1938. //Here, it is possible name was not given and we are using monster for it.
  1939. if (count < 3) //Blank mob's name.
  1940. name[0] = '\0';
  1941. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1942. //All data can be left as it is.
  1943. } else if (sscanf(message, "%23s", monster) > 0) {
  1944. //As before, name may be already filled.
  1945. name[0] = '\0';
  1946. } else {
  1947. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1948. return -1;
  1949. }
  1950. // If AegisName matches exactly, summon that monster
  1951. std::shared_ptr<s_mob_db> mob = mobdb_search_aegisname(monster);
  1952. if (mob != nullptr)
  1953. mob_id = mob->id;
  1954. else {
  1955. // Otherwise, search for monster with that ID or name
  1956. // Check for ID first as this is faster; if search string is not a number it will return 0
  1957. mob_id = util::strtoint32def(monster);
  1958. if (mob_id == 0 || mobdb_checkid(mob_id) == 0)
  1959. mob_id = mobdb_searchname(monster);
  1960. }
  1961. if (mob_id == 0) {
  1962. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1963. return -1;
  1964. }
  1965. if (mob_id == MOBID_EMPERIUM) {
  1966. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1967. return -1;
  1968. }
  1969. if (number <= 0)
  1970. number = 1;
  1971. if( !name[0] )
  1972. strcpy(name, "--ja--");
  1973. // 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
  1974. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1975. number = battle_config.atc_spawn_quantity_limit;
  1976. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1977. if (strcmp(parent_cmd, "monstersmall") == 0)
  1978. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1979. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1980. size = SZ_BIG;
  1981. else
  1982. size = SZ_SMALL;
  1983. if (battle_config.etc_log)
  1984. 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);
  1985. count = 0;
  1986. range = (int32)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1987. for (i = 0; i < number; i++) {
  1988. int32 k;
  1989. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1990. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1991. if(k) {
  1992. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1993. count ++;
  1994. }
  1995. }
  1996. if (count != 0)
  1997. if (number == count)
  1998. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1999. else {
  2000. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  2001. clif_displaymessage(fd, atcmd_output);
  2002. }
  2003. else {
  2004. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  2005. return -1;
  2006. }
  2007. return 0;
  2008. }
  2009. /*==========================================
  2010. *
  2011. *------------------------------------------*/
  2012. static int32 atkillmonster_sub(struct block_list *bl, va_list ap)
  2013. {
  2014. struct mob_data *md;
  2015. int32 flag;
  2016. nullpo_ret(md=(struct mob_data *)bl);
  2017. flag = va_arg(ap, int32);
  2018. if (md->guardian_data)
  2019. return 0; //Do not touch WoE mobs!
  2020. if (flag)
  2021. status_zap(bl,md->status.hp, 0);
  2022. else
  2023. status_kill(bl);
  2024. return 1;
  2025. }
  2026. ACMD_FUNC(killmonster)
  2027. {
  2028. int32 map_id, drop_flag;
  2029. char map_name[MAP_NAME_LENGTH_EXT];
  2030. nullpo_retr(-1, sd);
  2031. memset(map_name, '\0', sizeof(map_name));
  2032. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2033. map_id = sd->bl.m;
  2034. else {
  2035. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2036. map_id = sd->bl.m;
  2037. }
  2038. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2039. drop_flag = strcmpi(parent_cmd, "killmonster2");
  2040. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  2041. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  2042. return 0;
  2043. }
  2044. /*==========================================
  2045. *
  2046. *------------------------------------------*/
  2047. ACMD_FUNC(refine)
  2048. {
  2049. int32 j, position = 0, refine = 0, current_position, final_refine;
  2050. int32 count;
  2051. nullpo_retr(-1, sd);
  2052. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2053. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  2054. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  2055. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2056. clif_displaymessage(fd, atcmd_output);
  2057. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2058. clif_displaymessage(fd, atcmd_output);
  2059. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2060. clif_displaymessage(fd, atcmd_output);
  2061. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2062. clif_displaymessage(fd, atcmd_output);
  2063. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2064. clif_displaymessage(fd, atcmd_output);
  2065. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2066. clif_displaymessage(fd, atcmd_output);
  2067. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2068. clif_displaymessage(fd, atcmd_output);
  2069. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2070. clif_displaymessage(fd, atcmd_output);
  2071. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2072. clif_displaymessage(fd, atcmd_output);
  2073. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2074. clif_displaymessage(fd, atcmd_output);
  2075. sprintf(atcmd_output, msg_txt(sd,1521), EQP_SHADOW_ARMOR); // %d: Shadow Armor
  2076. clif_displaymessage(fd, atcmd_output);
  2077. sprintf(atcmd_output, msg_txt(sd,1522), EQP_SHADOW_WEAPON); // %d: Shadow Weapon
  2078. clif_displaymessage(fd, atcmd_output);
  2079. sprintf(atcmd_output, msg_txt(sd,1523), EQP_SHADOW_SHIELD); // %d: Shadow Shield
  2080. clif_displaymessage(fd, atcmd_output);
  2081. sprintf(atcmd_output, msg_txt(sd,1524), EQP_SHADOW_SHOES); // %d: Shadow Shoes
  2082. clif_displaymessage(fd, atcmd_output);
  2083. sprintf(atcmd_output, msg_txt(sd,1525), EQP_SHADOW_ACC_R); // %d: Shadow Right Accessory
  2084. clif_displaymessage(fd, atcmd_output);
  2085. sprintf(atcmd_output, msg_txt(sd,1526), EQP_SHADOW_ACC_L); // %d: Shadow Left Accessory
  2086. clif_displaymessage(fd, atcmd_output);
  2087. return -1;
  2088. }
  2089. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2090. count = 0;
  2091. for (j = 0; j < EQI_MAX; j++) {
  2092. int32 i;
  2093. if ((i = sd->equip_index[j]) < 0)
  2094. continue;
  2095. if(j == EQI_AMMO)
  2096. continue;
  2097. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2098. continue;
  2099. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2100. continue;
  2101. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  2102. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  2103. sd->inventory.u.items_inventory[i].refine = final_refine;
  2104. current_position = sd->inventory.u.items_inventory[i].equip;
  2105. pc_unequipitem(sd, i, 3);
  2106. clif_refine( *sd, i, ITEMREFINING_SUCCESS );
  2107. clif_delitem( *sd, i, 1, 3 );
  2108. clif_additem(sd, i, 1, 0);
  2109. pc_equipitem(sd, i, current_position);
  2110. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2111. if( sd->inventory_data[i]->type == IT_WEAPON ){
  2112. achievement_update_objective(sd, AG_ENCHANT_SUCCESS, 2, sd->inventory_data[i]->weapon_level, sd->inventory.u.items_inventory[i].refine);
  2113. }
  2114. count++;
  2115. }
  2116. }
  2117. if (count == 0)
  2118. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2119. else if (count == 1)
  2120. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2121. else {
  2122. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2123. clif_displaymessage(fd, atcmd_output);
  2124. }
  2125. return 0;
  2126. }
  2127. /*==========================================
  2128. *
  2129. *------------------------------------------*/
  2130. ACMD_FUNC(grade)
  2131. {
  2132. int32 j, position = 0, grade = 0, current_position, final_grade;
  2133. int32 count;
  2134. nullpo_retr(-1, sd);
  2135. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2136. if (!message || !*message || sscanf(message, "%11d %11d", &position, &grade) < 2) {
  2137. clif_displaymessage(fd, msg_txt(sd,1519)); // Please enter a position and an amount (usage: @grade <equip position> <+/- amount>).
  2138. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2139. clif_displaymessage(fd, atcmd_output);
  2140. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2141. clif_displaymessage(fd, atcmd_output);
  2142. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2143. clif_displaymessage(fd, atcmd_output);
  2144. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2145. clif_displaymessage(fd, atcmd_output);
  2146. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2147. clif_displaymessage(fd, atcmd_output);
  2148. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2149. clif_displaymessage(fd, atcmd_output);
  2150. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2151. clif_displaymessage(fd, atcmd_output);
  2152. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2153. clif_displaymessage(fd, atcmd_output);
  2154. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2155. clif_displaymessage(fd, atcmd_output);
  2156. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2157. clif_displaymessage(fd, atcmd_output);
  2158. return -1;
  2159. }
  2160. grade = cap_value(grade, -MAX_ENCHANTGRADE, MAX_ENCHANTGRADE);
  2161. count = 0;
  2162. for (j = 0; j < EQI_MAX; j++) {
  2163. int32 i;
  2164. if ((i = sd->equip_index[j]) < 0)
  2165. continue;
  2166. if(j == EQI_AMMO)
  2167. continue;
  2168. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2169. continue;
  2170. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2171. continue;
  2172. final_grade = cap_value(sd->inventory.u.items_inventory[i].enchantgrade + grade, 0, MAX_ENCHANTGRADE);
  2173. if (sd->inventory.u.items_inventory[i].enchantgrade != final_grade) {
  2174. sd->inventory.u.items_inventory[i].enchantgrade = final_grade;
  2175. current_position = sd->inventory.u.items_inventory[i].equip;
  2176. pc_unequipitem(sd, i, 3);
  2177. clif_delitem( *sd, i, 1, 3 );
  2178. clif_additem(sd, i, 1, 0);
  2179. pc_equipitem(sd, i, current_position);
  2180. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2181. count++;
  2182. }
  2183. }
  2184. sprintf(atcmd_output, msg_txt(sd,1520), count); // %d items have been graded.
  2185. clif_displaymessage(fd, atcmd_output);
  2186. return 0;
  2187. }
  2188. /*==========================================
  2189. *
  2190. *------------------------------------------*/
  2191. ACMD_FUNC(produce)
  2192. {
  2193. char item_name[100];
  2194. t_itemid item_id;
  2195. int32 attribute = 0, star = 0;
  2196. nullpo_retr(-1, sd);
  2197. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2198. memset(item_name, '\0', sizeof(item_name));
  2199. if (!message || !*message || (
  2200. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2201. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2202. )) {
  2203. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2204. return -1;
  2205. }
  2206. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  2207. if( item_data == nullptr ){
  2208. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  2209. }
  2210. if( item_data == nullptr ){
  2211. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2212. return -1;
  2213. }
  2214. item_id = item_data->nameid;
  2215. if( itemdb_isequip2( item_data.get() ) ){
  2216. char flag = 0;
  2217. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2218. attribute = ATTRIBUTE_NORMAL;
  2219. if (star < MIN_STAR || star > MAX_STAR)
  2220. star = 0;
  2221. struct item tmp_item = {};
  2222. tmp_item.nameid = item_id;
  2223. tmp_item.amount = 1;
  2224. tmp_item.identify = 1;
  2225. tmp_item.card[0] = CARD0_FORGE;
  2226. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2227. ((star*5) << 8) + attribute:0;
  2228. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2229. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2230. clif_produceeffect(sd, 0, item_id);
  2231. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2232. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2233. clif_additem(sd, 0, 0, flag);
  2234. } else {
  2235. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name.c_str()); // The item (%u: '%s') is not equipable.
  2236. clif_displaymessage(fd, atcmd_output);
  2237. return -1;
  2238. }
  2239. return 0;
  2240. }
  2241. /*==========================================
  2242. *
  2243. *------------------------------------------*/
  2244. ACMD_FUNC(memo)
  2245. {
  2246. int32 position = 0;
  2247. nullpo_retr(-1, sd);
  2248. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2249. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2250. {
  2251. int32 i;
  2252. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2253. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2254. {
  2255. if( strcmp( "", sd->status.memo_point[i].map ) != 0 )
  2256. sprintf( atcmd_output, "%d - %s (%d,%d)", i, sd->status.memo_point[i].map, sd->status.memo_point[i].x, sd->status.memo_point[i].y );
  2257. else
  2258. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2259. clif_displaymessage(sd->fd, atcmd_output);
  2260. }
  2261. return 0;
  2262. }
  2263. if( position < 0 || position >= MAX_MEMOPOINTS )
  2264. {
  2265. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2266. clif_displaymessage(fd, atcmd_output);
  2267. return -1;
  2268. }
  2269. return !pc_memo( sd, position );
  2270. }
  2271. /*==========================================
  2272. *
  2273. *------------------------------------------*/
  2274. ACMD_FUNC(gat)
  2275. {
  2276. int32 y;
  2277. nullpo_retr(-1, sd);
  2278. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2279. for (y = 2; y >= -2; y--) {
  2280. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2281. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2282. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2283. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2284. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2285. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2286. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2287. clif_displaymessage(fd, atcmd_output);
  2288. }
  2289. return 0;
  2290. }
  2291. /*==========================================
  2292. *
  2293. *------------------------------------------*/
  2294. ACMD_FUNC(displaystatus)
  2295. {
  2296. int32 i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2297. nullpo_retr(-1, sd);
  2298. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2299. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2300. return -1;
  2301. }
  2302. if (i < 2) flag = 1;
  2303. if (i < 3) tick = 0;
  2304. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2305. return 0;
  2306. }
  2307. /*==========================================
  2308. * @stpoint (Rewritten by [Yor])
  2309. *------------------------------------------*/
  2310. ACMD_FUNC(statuspoint)
  2311. {
  2312. int32 point;
  2313. uint32 new_status_point;
  2314. if (!message || !*message || (point = atoi(message)) == 0) {
  2315. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2316. return -1;
  2317. }
  2318. if(point < 0)
  2319. {
  2320. if(sd->status.status_point < (uint32)(-point))
  2321. {
  2322. new_status_point = 0;
  2323. }
  2324. else
  2325. {
  2326. new_status_point = sd->status.status_point + point;
  2327. }
  2328. }
  2329. else if(UINT_MAX - sd->status.status_point < (uint32)point)
  2330. {
  2331. new_status_point = UINT_MAX;
  2332. }
  2333. else
  2334. {
  2335. new_status_point = sd->status.status_point + point;
  2336. }
  2337. if (new_status_point != sd->status.status_point) {
  2338. sd->status.status_point = new_status_point;
  2339. clif_updatestatus(*sd, SP_STATUSPOINT);
  2340. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2341. } else {
  2342. if (point < 0)
  2343. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2344. else
  2345. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2346. return -1;
  2347. }
  2348. return 0;
  2349. }
  2350. /*==========================================
  2351. * @trpoint
  2352. *------------------------------------------*/
  2353. ACMD_FUNC(traitpoint)
  2354. {
  2355. int32 point;
  2356. uint32 new_trait_point;
  2357. if (!message || !*message || (point = atoi(message)) == 0) {
  2358. clif_displaymessage(fd, msg_txt(sd, 820)); // Please enter a number (usage: @trpoint <number of points>).
  2359. return -1;
  2360. }
  2361. if (point < 0)
  2362. {
  2363. if (sd->status.trait_point < (uint32)(-point))
  2364. {
  2365. new_trait_point = 0;
  2366. }
  2367. else
  2368. {
  2369. new_trait_point = sd->status.trait_point + point;
  2370. }
  2371. }
  2372. else if (UINT_MAX - sd->status.trait_point < (uint32)point)
  2373. {
  2374. new_trait_point = UINT_MAX;
  2375. }
  2376. else
  2377. {
  2378. new_trait_point = sd->status.trait_point + point;
  2379. }
  2380. if (new_trait_point != sd->status.trait_point) {
  2381. sd->status.trait_point = new_trait_point;
  2382. clif_updatestatus(*sd, SP_TRAITPOINT);
  2383. clif_displaymessage(fd, msg_txt(sd, 174)); // Number of status points changed.
  2384. }
  2385. else {
  2386. if (point < 0)
  2387. clif_displaymessage(fd, msg_txt(sd, 41)); // Unable to decrease the number/value.
  2388. else
  2389. clif_displaymessage(fd, msg_txt(sd, 149)); // Unable to increase the number/value.
  2390. return -1;
  2391. }
  2392. return 0;
  2393. }
  2394. /*==========================================
  2395. * @skpoint (Rewritten by [Yor])
  2396. *------------------------------------------*/
  2397. ACMD_FUNC(skillpoint)
  2398. {
  2399. int32 point;
  2400. uint32 new_skill_point;
  2401. nullpo_retr(-1, sd);
  2402. if (!message || !*message || (point = atoi(message)) == 0) {
  2403. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2404. return -1;
  2405. }
  2406. if(point < 0)
  2407. {
  2408. if(sd->status.skill_point < (uint32)(-point))
  2409. {
  2410. new_skill_point = 0;
  2411. }
  2412. else
  2413. {
  2414. new_skill_point = sd->status.skill_point + point;
  2415. }
  2416. }
  2417. else if(UINT_MAX - sd->status.skill_point < (uint32)point)
  2418. {
  2419. new_skill_point = UINT_MAX;
  2420. }
  2421. else
  2422. {
  2423. new_skill_point = sd->status.skill_point + point;
  2424. }
  2425. if (new_skill_point != sd->status.skill_point) {
  2426. sd->status.skill_point = new_skill_point;
  2427. clif_updatestatus(*sd, SP_SKILLPOINT);
  2428. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2429. } else {
  2430. if (point < 0)
  2431. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2432. else
  2433. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2434. return -1;
  2435. }
  2436. return 0;
  2437. }
  2438. /*==========================================
  2439. * @zeny
  2440. *------------------------------------------*/
  2441. ACMD_FUNC(zeny)
  2442. {
  2443. int32 zeny=0, ret=-1;
  2444. nullpo_retr(-1, sd);
  2445. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2446. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2447. return -1;
  2448. }
  2449. if(zeny > 0){
  2450. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND)) == 1)
  2451. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2452. }
  2453. else {
  2454. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2455. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND)) == 1)
  2456. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2457. }
  2458. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2459. return 0;
  2460. }
  2461. /*==========================================
  2462. *
  2463. *------------------------------------------*/
  2464. ACMD_FUNC(param)
  2465. {
  2466. nullpo_retr(-1, sd);
  2467. uint8 stat;
  2468. int32 value = 0;
  2469. uint16 new_value, status, max_status;
  2470. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2471. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2472. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2473. return -1;
  2474. }
  2475. ARR_FIND( 0, ARRAYLENGTH(parameter_names), stat, strcmpi(command + 1, parameter_names[stat]) == 0 );
  2476. if( stat == ARRAYLENGTH(parameter_names)) { // normally impossible...
  2477. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2478. return -1;
  2479. }
  2480. if( stat < PARAM_POW ){
  2481. status = pc_getstat( sd, SP_STR + stat - PARAM_STR );
  2482. }else{
  2483. if( !( sd->class_ & JOBL_FOURTH ) ){
  2484. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2485. return -1;
  2486. }
  2487. status = pc_getstat( sd, SP_POW + stat - PARAM_POW );
  2488. }
  2489. if( pc_has_permission( sd, PC_PERM_BYPASS_MAX_STAT ) ){
  2490. max_status = SHRT_MAX;
  2491. }else{
  2492. max_status = pc_maxparameter( sd, static_cast<e_params>( stat ) );
  2493. }
  2494. if( value > 0 && status + value >= max_status ){
  2495. new_value = max_status;
  2496. }else if( value < 0 && abs( value ) >= status ){
  2497. if( stat < PARAM_POW ){
  2498. new_value = 1;
  2499. }else{
  2500. new_value = 0;
  2501. }
  2502. }else{
  2503. new_value = status + value;
  2504. }
  2505. if( new_value != status ){
  2506. if (stat < PARAM_POW) {
  2507. pc_setstat( sd, SP_STR + stat - PARAM_STR, new_value );
  2508. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + stat ) );
  2509. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + stat ) );
  2510. } else {
  2511. pc_setstat( sd, SP_POW + stat - PARAM_POW, new_value );
  2512. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + stat - PARAM_POW ) );
  2513. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + stat - PARAM_POW ) );
  2514. }
  2515. status_calc_pc(sd, SCO_FORCE);
  2516. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2517. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2518. } else {
  2519. if (value < 0)
  2520. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2521. else
  2522. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2523. return -1;
  2524. }
  2525. return 0;
  2526. }
  2527. /*==========================================
  2528. * Stat all by fritz (rewritten by [Yor])
  2529. *------------------------------------------*/
  2530. ACMD_FUNC(stat_all)
  2531. {
  2532. nullpo_retr(-1, sd);
  2533. int32 value = 0;
  2534. uint8 count, i;
  2535. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2536. for (i = PARAM_STR; i < PARAM_POW; i++)
  2537. status[i] = pc_getstat(sd, SP_STR + i);
  2538. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2539. for (i = PARAM_STR; i < PARAM_POW; i++)
  2540. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2541. value = SHRT_MAX;
  2542. } else {
  2543. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2544. for (i = PARAM_STR; i < PARAM_POW; i++)
  2545. max_status[i] = SHRT_MAX;
  2546. } else {
  2547. for (i = PARAM_STR; i < PARAM_POW; i++)
  2548. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2549. }
  2550. }
  2551. count = 0;
  2552. for (i = PARAM_STR; i < PARAM_POW; i++) {
  2553. int16 new_value;
  2554. if (value > 0 && status[i] + value >= max_status[i])
  2555. new_value = max_status[i];
  2556. else if (value < 0 && abs(value) >= status[i])
  2557. new_value = 1;
  2558. else
  2559. new_value = status[i] + value;
  2560. if (new_value != status[i]) {
  2561. pc_setstat( sd, SP_STR + i, new_value );
  2562. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  2563. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  2564. count++;
  2565. }
  2566. }
  2567. if (count > 0) { // if at least 1 stat modified
  2568. status_calc_pc(sd, SCO_FORCE);
  2569. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2570. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2571. } else {
  2572. if (value < 0)
  2573. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2574. else
  2575. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2576. return -1;
  2577. }
  2578. return 0;
  2579. }
  2580. /*==========================================
  2581. * Traits
  2582. *------------------------------------------*/
  2583. ACMD_FUNC(trait_all) {
  2584. nullpo_retr(-1, sd);
  2585. #ifndef RENEWAL
  2586. sprintf(atcmd_output, msg_txt(sd, 154), command); // %s failed.
  2587. clif_displaymessage(fd, atcmd_output);
  2588. return -1;
  2589. #endif
  2590. if( !( sd->class_ & JOBL_FOURTH ) ){
  2591. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2592. return -1;
  2593. }
  2594. int32 value = 0;
  2595. uint8 i;
  2596. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2597. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2598. status[i] = pc_getstat(sd, SP_POW + i - PARAM_POW);
  2599. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2600. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2601. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2602. value = SHRT_MAX;
  2603. } else {
  2604. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2605. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2606. max_status[i] = SHRT_MAX;
  2607. } else {
  2608. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2609. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2610. }
  2611. }
  2612. uint8 count = 0;
  2613. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  2614. int16 new_value;
  2615. if (value > 0 && status[i] + value >= max_status[i])
  2616. new_value = max_status[i];
  2617. else if (value < 0 && abs(value) >= status[i])
  2618. new_value = 0;
  2619. else
  2620. new_value = status[i] + value;
  2621. if (new_value != status[i]) {
  2622. pc_setstat( sd, SP_POW + i - PARAM_POW, new_value );
  2623. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  2624. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  2625. count++;
  2626. }
  2627. }
  2628. if (count > 0) { // if at least 1 stat modified
  2629. status_calc_pc(sd, SCO_FORCE);
  2630. clif_displaymessage(fd, msg_txt(sd, 84)); // All stats changed!
  2631. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2632. } else {
  2633. if (value < 0)
  2634. clif_displaymessage(fd, msg_txt(sd, 177)); // You cannot decrease that stat anymore.
  2635. else
  2636. clif_displaymessage(fd, msg_txt(sd, 178)); // You cannot increase that stat anymore.
  2637. return -1;
  2638. }
  2639. return 0;
  2640. }
  2641. /*==========================================
  2642. *
  2643. *------------------------------------------*/
  2644. ACMD_FUNC(guildlevelup) {
  2645. int32 level = 0;
  2646. int16 added_level;
  2647. nullpo_retr(-1, sd);
  2648. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2649. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2650. return -1;
  2651. }
  2652. auto &guild_info = sd->guild;
  2653. if (sd->status.guild_id <= 0 || guild_info == nullptr) {
  2654. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2655. return -1;
  2656. }
  2657. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2658. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2659. // return -1;
  2660. //}
  2661. added_level = (int16)level;
  2662. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((int16)MAX_GUILDLEVEL - guild_info->guild.guild_lv))) // fix positive overflow
  2663. added_level = (int16)MAX_GUILDLEVEL - guild_info->guild.guild_lv;
  2664. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild.guild_lv))) // fix negative overflow
  2665. added_level = 1 - guild_info->guild.guild_lv;
  2666. if (added_level != 0) {
  2667. intif_guild_change_basicinfo(guild_info->guild.guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2668. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2669. } else {
  2670. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2671. return -1;
  2672. }
  2673. return 0;
  2674. }
  2675. /*==========================================
  2676. *
  2677. *------------------------------------------*/
  2678. ACMD_FUNC(makeegg) {
  2679. int32 id;
  2680. nullpo_retr(-1, sd);
  2681. if (!message || !*message) {
  2682. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2683. return -1;
  2684. }
  2685. // for monster name
  2686. if ((id = mobdb_searchname(message)) != 0)
  2687. ;
  2688. else
  2689. id = atoi(message);
  2690. std::shared_ptr<s_pet_db> pet = pet_db.find(id);
  2691. if( pet == nullptr ){
  2692. t_itemid nameid;
  2693. // for egg name
  2694. std::shared_ptr<item_data> item_data = item_db.searchname( message );
  2695. if( item_data != nullptr ){
  2696. nameid = item_data->nameid;
  2697. }else{
  2698. nameid = strtoul( message, nullptr, 10 );
  2699. }
  2700. pet = pet_db_search( nameid, PET_EGG );
  2701. }
  2702. int32 res(-1);
  2703. if (pet != nullptr) {
  2704. std::shared_ptr<s_mob_db> mdb = mob_db.find(pet->class_);
  2705. if(mdb){
  2706. if(intif_create_pet(sd->status.account_id, sd->status.char_id, pet->class_, mdb->lv, pet->EggID, 0, pet->intimate, 100, 0, 1, mdb->jname.c_str())){
  2707. res = 0;
  2708. } else {
  2709. res = -2; //char server down
  2710. }
  2711. }
  2712. }
  2713. switch(res){
  2714. case -1:
  2715. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2716. break;
  2717. case -2:
  2718. clif_displaymessage(fd, msg_txt(sd,407)); //charserver link broken
  2719. break;
  2720. }
  2721. return res;
  2722. }
  2723. /*==========================================
  2724. *
  2725. *------------------------------------------*/
  2726. ACMD_FUNC(hatch) {
  2727. nullpo_retr(-1, sd);
  2728. if (sd->status.pet_id <= 0)
  2729. clif_sendegg(sd);
  2730. else {
  2731. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2732. return -1;
  2733. }
  2734. return 0;
  2735. }
  2736. /*==========================================
  2737. *
  2738. *------------------------------------------*/
  2739. ACMD_FUNC(petfriendly) {
  2740. int32 friendly;
  2741. struct pet_data *pd;
  2742. nullpo_retr(-1, sd);
  2743. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2744. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2745. return -1;
  2746. }
  2747. pd = sd->pd;
  2748. if (!pd) {
  2749. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2750. return -1;
  2751. }
  2752. if (friendly < 0 || friendly > 1000)
  2753. {
  2754. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2755. return -1;
  2756. }
  2757. if (friendly == pd->pet.intimate) {
  2758. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2759. return -1;
  2760. }
  2761. pet_set_intimate(pd, friendly);
  2762. clif_send_petstatus( *sd, *pd );
  2763. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2764. return 0;
  2765. }
  2766. /*==========================================
  2767. *
  2768. *------------------------------------------*/
  2769. ACMD_FUNC(pethungry)
  2770. {
  2771. int32 hungry;
  2772. struct pet_data *pd;
  2773. nullpo_retr(-1, sd);
  2774. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2775. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2776. return -1;
  2777. }
  2778. pd = sd->pd;
  2779. if (!sd->status.pet_id || !pd) {
  2780. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2781. return -1;
  2782. }
  2783. if (hungry < 0 || hungry > 100) {
  2784. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2785. return -1;
  2786. }
  2787. if (hungry == pd->pet.hungry) {
  2788. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2789. return -1;
  2790. }
  2791. pd->pet.hungry = hungry;
  2792. clif_send_petstatus( *sd, *pd );
  2793. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2794. return 0;
  2795. }
  2796. /*==========================================
  2797. *
  2798. *------------------------------------------*/
  2799. ACMD_FUNC(petrename)
  2800. {
  2801. struct pet_data *pd;
  2802. nullpo_retr(-1, sd);
  2803. if (!sd->status.pet_id || !sd->pd) {
  2804. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2805. return -1;
  2806. }
  2807. pd = sd->pd;
  2808. if (!pd->pet.rename_flag) {
  2809. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2810. return -1;
  2811. }
  2812. pd->pet.rename_flag = 0;
  2813. intif_save_petdata(sd->status.account_id, &pd->pet);
  2814. clif_send_petstatus( *sd, *pd );
  2815. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2816. return 0;
  2817. }
  2818. /*==========================================
  2819. *
  2820. *------------------------------------------*/
  2821. ACMD_FUNC(recall) {
  2822. map_session_data* pl_sd = nullptr;;
  2823. nullpo_retr(-1, sd);
  2824. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2825. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2826. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2827. return -1;
  2828. }
  2829. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  2830. {
  2831. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2832. return -1;
  2833. }
  2834. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2835. {
  2836. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to perform this action on the specified player.
  2837. return -1;
  2838. }
  2839. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2840. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2841. return -1;
  2842. }
  2843. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2844. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2845. return -1;
  2846. }
  2847. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2848. return -1;
  2849. }
  2850. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2851. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2852. return -1;
  2853. }
  2854. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2855. clif_displaymessage(fd, atcmd_output);
  2856. return 0;
  2857. }
  2858. /*==========================================
  2859. * charblock command (usage: charblock <player_name>)
  2860. * This command do a definitiv ban on a player
  2861. *------------------------------------------*/
  2862. ACMD_FUNC(char_block)
  2863. {
  2864. nullpo_retr(-1, sd);
  2865. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2866. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2867. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2868. clif_displaymessage(fd, atcmd_output);
  2869. return -1;
  2870. }
  2871. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2872. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2873. clif_displaymessage(fd, atcmd_output);
  2874. return 0;
  2875. }
  2876. /*==========================================
  2877. * accountban command (usage: ban <%time> <player_name>)
  2878. * charban command (usage: charban <%time> <player_name>)
  2879. * %time see common/timer.cpp::solve_time()
  2880. *------------------------------------------*/
  2881. ACMD_FUNC(char_ban)
  2882. {
  2883. char *modif_p, output[CHAT_SIZE_MAX];
  2884. int32 timediff = 0; //don't set this as uint32 as we may want to decrease banned time
  2885. enum chrif_req_op bantype;
  2886. nullpo_retr(-1, sd);
  2887. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2888. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2889. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2890. if (strcmpi(parent_cmd,"charban") == 0)
  2891. bantype = CHRIF_OP_BAN;
  2892. else if (strcmpi(parent_cmd,"ban") == 0)
  2893. bantype = CHRIF_OP_LOGIN_BAN;
  2894. else
  2895. return -1;
  2896. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2897. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2898. clif_displaymessage(fd, output);
  2899. return -1;
  2900. }
  2901. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2902. modif_p = atcmd_output;
  2903. timediff = (int32)solve_time(modif_p); //discard seconds
  2904. if (timediff == 0) { //allow negative ?
  2905. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2906. clif_displaymessage(fd, output);
  2907. 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.
  2908. return -1;
  2909. }
  2910. if( timediff < 0 && (
  2911. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2912. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2913. ))
  2914. {
  2915. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2916. return -1;
  2917. }
  2918. if (bantype == CHRIF_OP_BAN)
  2919. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2920. else
  2921. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2922. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2923. clif_displaymessage(fd, output);
  2924. return 0;
  2925. }
  2926. /*==========================================
  2927. * charunblock command (usage: charunblock <player_name>)
  2928. *------------------------------------------*/
  2929. ACMD_FUNC(char_unblock)
  2930. {
  2931. nullpo_retr(-1, sd);
  2932. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2933. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2934. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2935. clif_displaymessage(fd, atcmd_output);
  2936. return -1;
  2937. }
  2938. // send answer to login server via char-server
  2939. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2940. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2941. clif_displaymessage(fd, atcmd_output);
  2942. return 0;
  2943. }
  2944. /*==========================================
  2945. * acc unban command (usage: unban <player_name>)
  2946. * char unban command (usage: charunban <player_name>)
  2947. *------------------------------------------*/
  2948. ACMD_FUNC(char_unban){
  2949. enum chrif_req_op unbantype;
  2950. nullpo_retr(-1, sd);
  2951. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2952. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2953. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2954. if (strcmpi(parent_cmd,"charunban") == 0)
  2955. unbantype = CHRIF_OP_UNBAN;
  2956. else if (strcmpi(parent_cmd,"unban") == 0)
  2957. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2958. else
  2959. return -1;
  2960. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2961. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2962. clif_displaymessage(fd, atcmd_output);
  2963. return -1;
  2964. }
  2965. if (unbantype == CHRIF_OP_UNBAN)
  2966. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2967. else
  2968. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2969. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2970. clif_displaymessage(fd, atcmd_output);
  2971. return 0;
  2972. }
  2973. /*==========================================
  2974. *
  2975. *------------------------------------------*/
  2976. ACMD_FUNC(night)
  2977. {
  2978. nullpo_retr(-1, sd);
  2979. if (night_flag != 1) {
  2980. map_night_timer(night_timer_tid, 0, 0, 1);
  2981. } else {
  2982. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2983. return -1;
  2984. }
  2985. return 0;
  2986. }
  2987. /*==========================================
  2988. *
  2989. *------------------------------------------*/
  2990. ACMD_FUNC(day)
  2991. {
  2992. nullpo_retr(-1, sd);
  2993. if (night_flag != 0) {
  2994. map_day_timer(day_timer_tid, 0, 0, 1);
  2995. } else {
  2996. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2997. return -1;
  2998. }
  2999. return 0;
  3000. }
  3001. /*==========================================
  3002. *
  3003. *------------------------------------------*/
  3004. ACMD_FUNC(doom)
  3005. {
  3006. map_session_data* pl_sd;
  3007. struct s_mapiterator* iter;
  3008. nullpo_retr(-1, sd);
  3009. iter = mapit_getallusers();
  3010. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3011. {
  3012. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3013. {
  3014. status_kill(&pl_sd->bl);
  3015. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  3016. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3017. }
  3018. }
  3019. mapit_free(iter);
  3020. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3021. return 0;
  3022. }
  3023. /*==========================================
  3024. *
  3025. *------------------------------------------*/
  3026. ACMD_FUNC(doommap)
  3027. {
  3028. map_session_data* pl_sd;
  3029. struct s_mapiterator* iter;
  3030. nullpo_retr(-1, sd);
  3031. iter = mapit_getallusers();
  3032. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3033. {
  3034. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3035. {
  3036. status_kill(&pl_sd->bl);
  3037. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  3038. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3039. }
  3040. }
  3041. mapit_free(iter);
  3042. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3043. return 0;
  3044. }
  3045. /*==========================================
  3046. *
  3047. *------------------------------------------*/
  3048. static void atcommand_raise_sub(map_session_data* sd) {
  3049. status_revive(&sd->bl, 100, 100);
  3050. clif_skill_nodamage(&sd->bl,sd->bl,ALL_RESURRECTION,4);
  3051. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  3052. }
  3053. /*==========================================
  3054. *
  3055. *------------------------------------------*/
  3056. ACMD_FUNC(raise)
  3057. {
  3058. map_session_data* pl_sd;
  3059. struct s_mapiterator* iter;
  3060. nullpo_retr(-1, sd);
  3061. iter = mapit_getallusers();
  3062. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3063. if( pc_isdead(pl_sd) )
  3064. atcommand_raise_sub(pl_sd);
  3065. mapit_free(iter);
  3066. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3067. return 0;
  3068. }
  3069. /*==========================================
  3070. *
  3071. *------------------------------------------*/
  3072. ACMD_FUNC(raisemap)
  3073. {
  3074. map_session_data* pl_sd;
  3075. struct s_mapiterator* iter;
  3076. nullpo_retr(-1, sd);
  3077. iter = mapit_getallusers();
  3078. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3079. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  3080. atcommand_raise_sub(pl_sd);
  3081. mapit_free(iter);
  3082. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3083. return 0;
  3084. }
  3085. /*==========================================
  3086. *
  3087. *------------------------------------------*/
  3088. ACMD_FUNC(kick)
  3089. {
  3090. map_session_data *pl_sd;
  3091. nullpo_retr(-1, sd);
  3092. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3093. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3094. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  3095. return -1;
  3096. }
  3097. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  3098. {
  3099. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3100. return -1;
  3101. }
  3102. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  3103. {
  3104. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3105. return -1;
  3106. }
  3107. clif_GM_kick(sd, pl_sd);
  3108. return 0;
  3109. }
  3110. /*==========================================
  3111. *
  3112. *------------------------------------------*/
  3113. ACMD_FUNC(kickall)
  3114. {
  3115. map_session_data* pl_sd;
  3116. struct s_mapiterator* iter;
  3117. nullpo_retr(-1, sd);
  3118. iter = mapit_getallusers();
  3119. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3120. {
  3121. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  3122. if (sd->status.account_id != pl_sd->status.account_id)
  3123. clif_GM_kick(nullptr, pl_sd);
  3124. }
  3125. }
  3126. mapit_free(iter);
  3127. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  3128. return 0;
  3129. }
  3130. /*==========================================
  3131. *
  3132. *------------------------------------------*/
  3133. ACMD_FUNC(allskill)
  3134. {
  3135. nullpo_retr(-1, sd);
  3136. pc_allskillup(sd); // all skills
  3137. sd->status.skill_point = 0; // 0 skill points
  3138. clif_updatestatus(*sd, SP_SKILLPOINT); // update
  3139. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  3140. return 0;
  3141. }
  3142. /*==========================================
  3143. *
  3144. *------------------------------------------*/
  3145. ACMD_FUNC(questskill)
  3146. {
  3147. uint16 skill_id;
  3148. nullpo_retr(-1, sd);
  3149. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3150. {// also send a list of skills applicable to this command
  3151. const char* text;
  3152. // attempt to find the text corresponding to this command
  3153. text = atcommand_help_string( command );
  3154. // send the error message as always
  3155. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3156. if( text )
  3157. {// send the skill ID list associated with this command
  3158. clif_displaymessage( fd, text );
  3159. }
  3160. return -1;
  3161. }
  3162. if (skill_id >= MAX_SKILL_ID) {
  3163. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3164. return -1;
  3165. }
  3166. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3167. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3168. return -1;
  3169. }
  3170. if (pc_checkskill(sd, skill_id) > 0) {
  3171. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  3172. return -1;
  3173. }
  3174. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  3175. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  3176. return 0;
  3177. }
  3178. /*==========================================
  3179. *
  3180. *------------------------------------------*/
  3181. ACMD_FUNC(lostskill)
  3182. {
  3183. uint16 skill_id = 0, sk_idx = 0;
  3184. nullpo_retr(-1, sd);
  3185. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3186. {// also send a list of skills applicable to this command
  3187. const char* text;
  3188. // attempt to find the text corresponding to this command
  3189. text = atcommand_help_string( command );
  3190. // send the error message as always
  3191. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3192. if( text )
  3193. {// send the skill ID list associated with this command
  3194. clif_displaymessage( fd, text );
  3195. }
  3196. return -1;
  3197. }
  3198. if (!(sk_idx = skill_get_index(skill_id))) {
  3199. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3200. return -1;
  3201. }
  3202. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3203. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3204. return -1;
  3205. }
  3206. if (pc_checkskill(sd, skill_id) == 0) {
  3207. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  3208. return -1;
  3209. }
  3210. sd->status.skill[sk_idx].lv = 0;
  3211. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  3212. clif_deleteskill(*sd,skill_id);
  3213. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  3214. return 0;
  3215. }
  3216. /*==========================================
  3217. *
  3218. *------------------------------------------*/
  3219. ACMD_FUNC(spiritball)
  3220. {
  3221. int32 number;
  3222. nullpo_retr(-1, sd);
  3223. if( !message || !*message || ( number = atoi( message ) ) < 0 || number > MAX_SPIRITBALL ){
  3224. char msg[CHAT_SIZE_MAX];
  3225. safesnprintf( msg, sizeof( msg ), msg_txt( sd, 1028 ), MAX_SPIRITBALL ); // Please enter an amount (usage: @spiritball <number: 0-%d>).
  3226. clif_displaymessage(fd, msg);
  3227. return -1;
  3228. }
  3229. if( sd->spiritball > 0 )
  3230. pc_delspiritball(sd, sd->spiritball, 1);
  3231. sd->spiritball = number;
  3232. clif_spiritball(&sd->bl);
  3233. // no message, player can look the difference
  3234. return 0;
  3235. }
  3236. ACMD_FUNC(soulball)
  3237. {
  3238. int32 number;
  3239. nullpo_retr(-1, sd);
  3240. if (!message || !*message || (number = atoi(message)) < 0 || number > MAX_SOUL_BALL) {
  3241. char msg[CHAT_SIZE_MAX];
  3242. safesnprintf(msg, sizeof(msg), "Usage: @soulball <number: 0-%d>", MAX_SOUL_BALL);
  3243. clif_displaymessage(fd, msg);
  3244. return -1;
  3245. }
  3246. if (sd->soulball > 0)
  3247. pc_delsoulball( *sd, sd->soulball, true );
  3248. pc_addsoulball( *sd, number );
  3249. clif_soulball(sd);
  3250. return 0;
  3251. }
  3252. /*==========================================
  3253. *
  3254. *------------------------------------------*/
  3255. ACMD_FUNC(party)
  3256. {
  3257. char party[NAME_LENGTH];
  3258. nullpo_retr(-1, sd);
  3259. memset(party, '\0', sizeof(party));
  3260. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3261. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  3262. return -1;
  3263. }
  3264. party_create( *sd, party, 0, 0 );
  3265. return 0;
  3266. }
  3267. /*==========================================
  3268. *
  3269. *------------------------------------------*/
  3270. ACMD_FUNC(guild)
  3271. {
  3272. char guild[NAME_LENGTH];
  3273. int32 prev;
  3274. nullpo_retr(-1, sd);
  3275. memset(guild, '\0', sizeof(guild));
  3276. if (sd->clan) {
  3277. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  3278. return -1;
  3279. }
  3280. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3281. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  3282. return -1;
  3283. }
  3284. prev = battle_config.guild_emperium_check;
  3285. battle_config.guild_emperium_check = 0;
  3286. guild_create( *sd, guild );
  3287. battle_config.guild_emperium_check = prev;
  3288. return 0;
  3289. }
  3290. ACMD_FUNC(breakguild)
  3291. {
  3292. nullpo_retr(-1, sd);
  3293. if (sd->status.guild_id) { // Check if the player has a guild
  3294. if (sd->guild) { // Check if guild was found
  3295. if (sd->state.gmaster_flag) { // Check if player is guild master
  3296. // Break guild
  3297. int32 ret = guild_break( *sd, sd->guild->guild.name );
  3298. if (ret) { // Check if anything went wrong
  3299. return 0; // Guild was broken
  3300. } else {
  3301. return -1; // Something went wrong
  3302. }
  3303. } else { // Not guild master
  3304. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3305. return -1;
  3306. }
  3307. } else { // Guild was not found. HOW?
  3308. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3309. return -1;
  3310. }
  3311. } else { // Player does not have a guild
  3312. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3313. return -1;
  3314. }
  3315. }
  3316. /**
  3317. * Start WoE:FE
  3318. */
  3319. ACMD_FUNC(agitstart)
  3320. {
  3321. nullpo_retr(-1, sd);
  3322. if( guild_agit_start() ){
  3323. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3324. return 0;
  3325. }else{
  3326. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3327. return -1;
  3328. }
  3329. }
  3330. /**
  3331. * Start WoE:SE
  3332. */
  3333. ACMD_FUNC(agitstart2)
  3334. {
  3335. nullpo_retr(-1, sd);
  3336. if( guild_agit2_start() ){
  3337. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3338. return 0;
  3339. }else{
  3340. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3341. return -1;
  3342. }
  3343. }
  3344. /**
  3345. * Start WoE:TE
  3346. */
  3347. ACMD_FUNC(agitstart3)
  3348. {
  3349. nullpo_retr(-1, sd);
  3350. if( guild_agit3_start() ){
  3351. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3352. return 0;
  3353. }else{
  3354. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3355. return -1;
  3356. }
  3357. }
  3358. /**
  3359. * End WoE:FE
  3360. */
  3361. ACMD_FUNC(agitend)
  3362. {
  3363. nullpo_retr(-1, sd);
  3364. if( guild_agit_end() ){
  3365. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3366. return 0;
  3367. }else{
  3368. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3369. return -1;
  3370. }
  3371. }
  3372. /**
  3373. * End WoE:SE
  3374. */
  3375. ACMD_FUNC(agitend2)
  3376. {
  3377. nullpo_retr(-1, sd);
  3378. if( guild_agit2_end() ){
  3379. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3380. return 0;
  3381. }else{
  3382. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3383. return -1;
  3384. }
  3385. }
  3386. /**
  3387. * End WoE:TE
  3388. */
  3389. ACMD_FUNC(agitend3)
  3390. {
  3391. nullpo_retr(-1, sd);
  3392. if( guild_agit3_end() ){
  3393. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3394. return 0;
  3395. }else{
  3396. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3397. return -1;
  3398. }
  3399. }
  3400. /*==========================================
  3401. * @mapexit - shuts down the map server
  3402. *------------------------------------------*/
  3403. ACMD_FUNC(mapexit)
  3404. {
  3405. nullpo_retr(-1, sd);
  3406. global_core->signal_shutdown();
  3407. return 0;
  3408. }
  3409. /*==========================================
  3410. * idsearch <part_of_name>: revrited by [Yor]
  3411. *------------------------------------------*/
  3412. ACMD_FUNC(idsearch)
  3413. {
  3414. nullpo_retr(-1, sd);
  3415. char item_name[100];
  3416. memset(item_name, '\0', sizeof(item_name));
  3417. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3418. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3419. return -1;
  3420. }
  3421. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3422. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3423. clif_displaymessage(fd, atcmd_output);
  3424. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  3425. uint16 match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3426. if (match == MAX_SEARCH) {
  3427. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3428. clif_displaymessage(fd, atcmd_output);
  3429. }
  3430. for(const auto &result : item_array) {
  3431. std::shared_ptr<item_data> id = result.second;
  3432. sprintf(atcmd_output, msg_txt(sd,78), item_db.create_item_link( id ).c_str(), id->nameid); // %s: %u
  3433. clif_displaymessage(fd, atcmd_output);
  3434. }
  3435. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3436. clif_displaymessage(fd, atcmd_output);
  3437. return 0;
  3438. }
  3439. /*==========================================
  3440. * Recall All Characters Online To Your Location
  3441. *------------------------------------------*/
  3442. ACMD_FUNC(recallall)
  3443. {
  3444. map_session_data* pl_sd;
  3445. struct s_mapiterator* iter;
  3446. int32 count;
  3447. nullpo_retr(-1, sd);
  3448. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3449. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3450. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3451. return -1;
  3452. }
  3453. count = 0;
  3454. iter = mapit_getallusers();
  3455. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3456. {
  3457. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3458. {
  3459. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3460. continue; // Don't waste time warping the character to the same place.
  3461. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3462. count++;
  3463. else {
  3464. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3465. count++;
  3466. }
  3467. }
  3468. }
  3469. }
  3470. mapit_free(iter);
  3471. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3472. if (count) {
  3473. 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.
  3474. clif_displaymessage(fd, atcmd_output);
  3475. }
  3476. return 0;
  3477. }
  3478. /*==========================================
  3479. * Recall online characters of a guild to your location
  3480. *------------------------------------------*/
  3481. ACMD_FUNC(guildrecall)
  3482. {
  3483. map_session_data* pl_sd;
  3484. struct s_mapiterator* iter;
  3485. int32 count;
  3486. char guild_name[NAME_LENGTH];
  3487. nullpo_retr(-1, sd);
  3488. memset(guild_name, '\0', sizeof(guild_name));
  3489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3490. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3491. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3492. return -1;
  3493. }
  3494. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3495. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3496. return -1;
  3497. }
  3498. auto g = guild_searchnameid(guild_name);
  3499. if (!g) {
  3500. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3501. return -1;
  3502. }
  3503. count = 0;
  3504. iter = mapit_getallusers();
  3505. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3506. {
  3507. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild.guild_id)
  3508. {
  3509. 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))
  3510. continue; // Skip GMs greater than you... or chars already on the cell
  3511. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3512. count++;
  3513. else{
  3514. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3515. count++;
  3516. }
  3517. }
  3518. }
  3519. }
  3520. mapit_free(iter);
  3521. sprintf(atcmd_output, msg_txt(sd,93), g->guild.name); // All online characters of the %s guild have been recalled to your position.
  3522. clif_displaymessage(fd, atcmd_output);
  3523. if (count) {
  3524. 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.
  3525. clif_displaymessage(fd, atcmd_output);
  3526. }
  3527. return 0;
  3528. }
  3529. /*==========================================
  3530. * Recall online characters of a party to your location
  3531. *------------------------------------------*/
  3532. ACMD_FUNC(partyrecall)
  3533. {
  3534. map_session_data* pl_sd;
  3535. struct s_mapiterator* iter;
  3536. char party_name[NAME_LENGTH];
  3537. struct party_data *p;
  3538. int32 count;
  3539. nullpo_retr(-1, sd);
  3540. memset(party_name, '\0', sizeof(party_name));
  3541. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3542. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3543. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3544. return -1;
  3545. }
  3546. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3547. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3548. return -1;
  3549. }
  3550. if ((p = party_searchname(party_name)) == nullptr && // name first to avoid error when name begin with a number
  3551. (p = party_search(atoi(message))) == nullptr)
  3552. {
  3553. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3554. return -1;
  3555. }
  3556. count = 0;
  3557. iter = mapit_getallusers();
  3558. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3559. {
  3560. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3561. {
  3562. 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))
  3563. continue; // Skip GMs greater than you... or chars already on the cell
  3564. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3565. count++;
  3566. else{
  3567. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3568. count++;
  3569. }
  3570. }
  3571. }
  3572. }
  3573. mapit_free(iter);
  3574. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3575. clif_displaymessage(fd, atcmd_output);
  3576. if (count) {
  3577. 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.
  3578. clif_displaymessage(fd, atcmd_output);
  3579. }
  3580. return 0;
  3581. }
  3582. /*==========================================
  3583. *
  3584. *------------------------------------------*/
  3585. void atcommand_doload();
  3586. ACMD_FUNC(reloadcashdb){
  3587. nullpo_retr(-1, sd);
  3588. cashshop_reloaddb();
  3589. clif_displaymessage( fd, msg_txt( sd, 832 ) ); // Cash shop database has been reloaded.
  3590. return 0;
  3591. }
  3592. ACMD_FUNC(reloaditemdb){
  3593. nullpo_retr(-1, sd);
  3594. itemdb_reload();
  3595. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3596. return 0;
  3597. }
  3598. ACMD_FUNC(reloadmobdb){
  3599. nullpo_retr(-1, sd);
  3600. mob_reload();
  3601. pet_db.reload();
  3602. hom_reload();
  3603. mercenary_db.reload();
  3604. elemental_db.reload();
  3605. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3606. return 0;
  3607. }
  3608. ACMD_FUNC(reloadskilldb){
  3609. nullpo_retr(-1, sd);
  3610. skill_reload();
  3611. homunculus_db.reload();
  3612. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3613. return 0;
  3614. }
  3615. ACMD_FUNC(reloadscript){
  3616. nullpo_retr(-1, sd);
  3617. struct s_mapiterator* iter;
  3618. map_session_data* pl_sd;
  3619. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3620. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3621. iter = mapit_getallusers();
  3622. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3623. pc_close_npc(pl_sd,1);
  3624. clif_cutin( *pl_sd, "", 255 );
  3625. pl_sd->state.block_action &= ~(PCBLOCK_ALL ^ PCBLOCK_IMMUNE);
  3626. bg_queue_leave(pl_sd);
  3627. }
  3628. mapit_free(iter);
  3629. for (auto &bg : bg_queues) {
  3630. for (auto &bg_sd : bg->teama_members)
  3631. bg_team_leave(bg_sd, false, false); // Kick Team A from battlegrounds
  3632. for (auto &bg_sd : bg->teamb_members)
  3633. bg_team_leave(bg_sd, false, false); // Kick Team B from battlegrounds
  3634. bg_queue_clear(bg, true);
  3635. }
  3636. flush_fifos();
  3637. map_reloadnpc(true); // reload config files seeking for npcs
  3638. script_reload();
  3639. npc_reload();
  3640. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3641. return 0;
  3642. }
  3643. ACMD_FUNC(reloadatcommand){
  3644. nullpo_retr(-1, sd);
  3645. atcommand_doload();
  3646. pc_groups_reload();
  3647. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3648. return 0;
  3649. }
  3650. ACMD_FUNC(reloadbattleconf){
  3651. nullpo_retr(-1, sd);
  3652. struct Battle_Config prev_config;
  3653. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3654. battle_config_read(BATTLE_CONF_FILENAME);
  3655. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3656. || prev_config.item_rate_common != battle_config.item_rate_common
  3657. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3658. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3659. || prev_config.item_rate_card != battle_config.item_rate_card
  3660. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3661. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3662. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3663. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3664. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3665. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3666. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3667. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3668. || prev_config.item_rate_use != battle_config.item_rate_use
  3669. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3670. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3671. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3672. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3673. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3674. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3675. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3676. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3677. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3678. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3679. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3680. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3681. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3682. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3683. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3684. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3685. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3686. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3687. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3688. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3689. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3690. )
  3691. { // Exp or Drop rates changed.
  3692. mob_reload(); //Needed as well so rate changes take effect.
  3693. }
  3694. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3695. return 0;
  3696. }
  3697. ACMD_FUNC(reloadstatusdb){
  3698. nullpo_retr(-1, sd);
  3699. status_readdb( true );
  3700. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3701. return 0;
  3702. }
  3703. ACMD_FUNC(reloadpcdb){
  3704. nullpo_retr(-1, sd);
  3705. pc_readdb();
  3706. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3707. return 0;
  3708. }
  3709. ACMD_FUNC(reloadmotd){
  3710. nullpo_retr(-1, sd);
  3711. pc_read_motd();
  3712. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3713. return 0;
  3714. }
  3715. ACMD_FUNC(reloadquestdb){
  3716. nullpo_retr(-1, sd);
  3717. if (quest_db.reload())
  3718. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3719. return 0;
  3720. }
  3721. ACMD_FUNC(reloadmsgconf){
  3722. nullpo_retr(-1, sd);
  3723. map_msg_reload();
  3724. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3725. return 0;
  3726. }
  3727. ACMD_FUNC(reloadinstancedb){
  3728. nullpo_retr(-1, sd);
  3729. if (instance_db.reload())
  3730. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3731. return 0;
  3732. }
  3733. ACMD_FUNC(reloadachievementdb){
  3734. nullpo_retr(-1, sd);
  3735. achievement_db_reload();
  3736. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3737. return 0;
  3738. }
  3739. ACMD_FUNC(reloadattendancedb){
  3740. nullpo_retr(-1, sd);
  3741. attendance_db.reload();
  3742. clif_displaymessage(fd, msg_txt(sd, 795)); // Attendance database has been reloaded.
  3743. return 0;
  3744. }
  3745. ACMD_FUNC(reloadbarterdb){
  3746. nullpo_retr(-1, sd);
  3747. barter_db.reload();
  3748. clif_displaymessage(fd, msg_txt(sd, 830)); // Barter database has been reloaded.
  3749. return 0;
  3750. }
  3751. ACMD_FUNC(reloadlogconf){
  3752. nullpo_retr(-1, sd);
  3753. log_config_read(LOG_CONF_NAME);
  3754. clif_displaymessage(fd, msg_txt(sd,1536)); // Log configuration has been reloaded.
  3755. return 0;
  3756. }
  3757. /*==========================================
  3758. * @partysharelvl <share_range> [Akinari]
  3759. * Updates char server party share level range in runtime
  3760. * Temporary - Permanent update in inter_athena.conf
  3761. *------------------------------------------*/
  3762. ACMD_FUNC(partysharelvl) {
  3763. uint32 share_lvl;
  3764. nullpo_retr(-1, sd);
  3765. if(!message || !*message) {
  3766. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3767. return -1;
  3768. } else {
  3769. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3770. }
  3771. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3772. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3773. else //Char server offline
  3774. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3775. return 0;
  3776. }
  3777. /*==========================================
  3778. * @mapinfo [0-3] <map name> by MC_Cameri
  3779. * => Shows information about the map [map name]
  3780. * 0 = no additional information
  3781. * 1 = Show users in that map and their location
  3782. * 2 = Shows NPCs in that map
  3783. * 3 = Shows the chats in that map
  3784. *------------------------------------------*/
  3785. ACMD_FUNC(mapinfo) {
  3786. map_session_data* pl_sd;
  3787. struct s_mapiterator* iter;
  3788. struct chat_data *cd = nullptr;
  3789. char direction[12];
  3790. int32 i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3791. uint16 m_index;
  3792. char mapname[MAP_NAME_LENGTH];
  3793. nullpo_retr(-1, sd);
  3794. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3795. memset(mapname, '\0', sizeof(mapname));
  3796. memset(direction, '\0', sizeof(direction));
  3797. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3798. if (list < 0 || list > 3) {
  3799. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3800. return -1;
  3801. }
  3802. if (mapname[0] == '\0') {
  3803. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3804. m_id = map_mapindex2mapid(sd->mapindex);
  3805. } else {
  3806. m_id = map_mapname2mapid(mapname);
  3807. }
  3808. if (m_id < 0) {
  3809. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3810. return -1;
  3811. }
  3812. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3813. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3814. // count chats (for initial message)
  3815. chat_num = 0;
  3816. iter = mapit_getallusers();
  3817. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3818. if( pl_sd->mapindex == m_index ) {
  3819. if( pl_sd->state.vending )
  3820. vend_num++;
  3821. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr && cd->usersd[0] == pl_sd )
  3822. chat_num++;
  3823. }
  3824. }
  3825. mapit_free(iter);
  3826. struct map_data *mapdata = map_getmapdata(m_id);
  3827. sprintf(atcmd_output, msg_txt(sd,1040), mapname, mapdata->users, mapdata->npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3828. clif_displaymessage(fd, atcmd_output);
  3829. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3830. if (map_getmapflag(m_id, MF_TOWN))
  3831. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3832. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3833. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3834. clif_displaymessage(fd, atcmd_output);
  3835. }
  3836. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3837. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3838. else
  3839. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3840. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3841. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3842. clif_displaymessage(fd, atcmd_output);
  3843. }
  3844. /* Skill damage adjustment info [Cydh] */
  3845. if (mapdata->getMapFlag(MF_SKILL_DAMAGE)) {
  3846. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3847. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3848. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3849. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3850. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3851. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3852. mapdata->damage_adjust.caster);
  3853. clif_displaymessage(fd, atcmd_output);
  3854. if (!mapdata->skill_damage.empty()) {
  3855. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3856. for (const auto& skilldmg : mapdata->skill_damage) {
  3857. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3858. skill_get_name(skilldmg.first),
  3859. skilldmg.second.rate[SKILLDMG_PC],
  3860. skilldmg.second.rate[SKILLDMG_MOB],
  3861. skilldmg.second.rate[SKILLDMG_BOSS],
  3862. skilldmg.second.rate[SKILLDMG_OTHER],
  3863. skilldmg.second.caster);
  3864. clif_displaymessage(fd,atcmd_output);
  3865. }
  3866. }
  3867. }
  3868. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3869. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3870. for (const auto &it : mapdata->skill_duration) {
  3871. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3872. clif_displaymessage(fd, atcmd_output);
  3873. }
  3874. }
  3875. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3876. if (map_getmapflag(m_id, MF_PVP))
  3877. strcat(atcmd_output, " Pvp ON |");
  3878. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3879. strcat(atcmd_output, " NoGuild |");
  3880. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3881. strcat(atcmd_output, " NoParty |");
  3882. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3883. strcat(atcmd_output, " NightmareDrop |");
  3884. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3885. strcat(atcmd_output, " NoCalcRank |");
  3886. clif_displaymessage(fd, atcmd_output);
  3887. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3888. if (map_getmapflag(m_id, MF_GVG))
  3889. strcat(atcmd_output, " GvG ON |");
  3890. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3891. strcat(atcmd_output, " GvG Dungeon |");
  3892. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3893. strcat(atcmd_output, " GvG Castle |");
  3894. if (map_getmapflag(m_id, MF_GVG_TE))
  3895. strcat(atcmd_output, " GvG TE |");
  3896. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3897. strcat(atcmd_output, " GvG TE Castle |");
  3898. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3899. strcat(atcmd_output, " NoParty |");
  3900. clif_displaymessage(fd, atcmd_output);
  3901. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3902. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3903. strcat(atcmd_output, " NoTeleport |");
  3904. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3905. strcat(atcmd_output, " Monster NoTeleport |");
  3906. if (map_getmapflag(m_id, MF_NOWARP))
  3907. strcat(atcmd_output, " NoWarp |");
  3908. if (map_getmapflag(m_id, MF_NOWARPTO))
  3909. strcat(atcmd_output, " NoWarpTo |");
  3910. if (map_getmapflag(m_id, MF_NORETURN))
  3911. strcat(atcmd_output, " NoReturn |");
  3912. if (map_getmapflag(m_id, MF_NOGO))
  3913. strcat(atcmd_output, " NoGo |"); //
  3914. if (map_getmapflag(m_id, MF_NOMEMO))
  3915. strcat(atcmd_output, " NoMemo |");
  3916. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_SOURCE))
  3917. strcat(atcmd_output, " PrivateAirship_Source |");
  3918. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_DESTINATION))
  3919. strcat(atcmd_output, " PrivateAirship_Destination |");
  3920. clif_displaymessage(fd, atcmd_output);
  3921. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3922. (map_getmapflag(m_id, MF_NOEXPPENALTY)) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map_getmapflag(m_id, MF_NOZENYPENALTY)) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3923. clif_displaymessage(fd, atcmd_output);
  3924. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3925. if (!mapdata->save.map)
  3926. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3927. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3928. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3929. clif_displaymessage(fd, atcmd_output);
  3930. }
  3931. else {
  3932. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3933. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3934. clif_displaymessage(fd, atcmd_output);
  3935. }
  3936. }
  3937. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3938. if (map_getmapflag(m_id, MF_SNOW))
  3939. strcat(atcmd_output, " Snow |");
  3940. if (map_getmapflag(m_id, MF_FOG))
  3941. strcat(atcmd_output, " Fog |");
  3942. if (map_getmapflag(m_id, MF_SAKURA))
  3943. strcat(atcmd_output, " Sakura |");
  3944. if (map_getmapflag(m_id, MF_CLOUDS))
  3945. strcat(atcmd_output, " Clouds |");
  3946. if (map_getmapflag(m_id, MF_CLOUDS2))
  3947. strcat(atcmd_output, " Clouds2 |");
  3948. if (map_getmapflag(m_id, MF_FIREWORKS))
  3949. strcat(atcmd_output, " Fireworks |");
  3950. if (map_getmapflag(m_id, MF_LEAVES))
  3951. strcat(atcmd_output, " Leaves |");
  3952. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3953. strcat(atcmd_output, " Displays Night |");
  3954. clif_displaymessage(fd, atcmd_output);
  3955. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3956. if (map_getmapflag(m_id, MF_NOBRANCH))
  3957. strcat(atcmd_output, " NoBranch |");
  3958. if (map_getmapflag(m_id, MF_NOTRADE))
  3959. strcat(atcmd_output, " NoTrade |");
  3960. if (map_getmapflag(m_id, MF_NOVENDING))
  3961. strcat(atcmd_output, " NoVending |");
  3962. if (map_getmapflag(m_id, MF_NOBUYINGSTORE))
  3963. strcat(atcmd_output, " NoBuyingstore |");
  3964. if (map_getmapflag(m_id, MF_NODROP))
  3965. strcat(atcmd_output, " NoDrop |");
  3966. if (map_getmapflag(m_id, MF_NOSKILL))
  3967. strcat(atcmd_output, " NoSkill |");
  3968. if (map_getmapflag(m_id, MF_NOICEWALL))
  3969. strcat(atcmd_output, " NoIcewall |");
  3970. if (map_getmapflag(m_id, MF_ALLOWKS))
  3971. strcat(atcmd_output, " AllowKS |");
  3972. if (map_getmapflag(m_id, MF_RESET))
  3973. strcat(atcmd_output, " Reset |");
  3974. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3975. strcat(atcmd_output, " HideMobHPBar |");
  3976. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3977. strcat(atcmd_output, " NoCommand |");
  3978. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3979. strcat(atcmd_output, " NoBaseEXP |");
  3980. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3981. strcat(atcmd_output, " NoJobEXP |");
  3982. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3983. strcat(atcmd_output, " NoMobLoot |");
  3984. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3985. strcat(atcmd_output, " NoMVPLoot |");
  3986. if (map_getmapflag(m_id, MF_NORENEWALEXPPENALTY))
  3987. strcat(atcmd_output, " NoRenewalExpPenalty |");
  3988. if (map_getmapflag(m_id, MF_NORENEWALDROPPENALTY))
  3989. strcat(atcmd_output, " NoRenewalDropPenalty |");
  3990. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3991. strcat(atcmd_output, " PartyLock |");
  3992. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3993. strcat(atcmd_output, " GuildLock |");
  3994. if (map_getmapflag(m_id, MF_LOADEVENT))
  3995. strcat(atcmd_output, " Loadevent |");
  3996. if (map_getmapflag(m_id, MF_NODYNAMICNPC))
  3997. strcat(atcmd_output, " NoDynamicNPC |");
  3998. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3999. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  4000. if (map_getmapflag(m_id, MF_NOUSECART))
  4001. strcat(atcmd_output, " NoUsecart |");
  4002. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  4003. strcat(atcmd_output, " NoItemConsumption |");
  4004. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  4005. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  4006. if (map_getmapflag(m_id, MF_FORCEMINEFFECT))
  4007. strcat(atcmd_output, " ForceMinEffect |");
  4008. if (map_getmapflag(m_id, MF_NOLOCKON))
  4009. strcat(atcmd_output, " NoLockOn |");
  4010. if (map_getmapflag(m_id, MF_NOTOMB))
  4011. strcat(atcmd_output, " NoTomb |");
  4012. if (map_getmapflag(m_id, MF_NOCOSTUME))
  4013. strcat(atcmd_output, " NoCostume |");
  4014. if (map_getmapflag(m_id, MF_NOBANK))
  4015. strcat(atcmd_output, " NoBank |");
  4016. if (map_getmapflag(m_id, MF_NOCASHSHOP))
  4017. strcat(atcmd_output, " NoCashShop |");
  4018. if (map_getmapflag(m_id, MF_NORODEX))
  4019. strcat(atcmd_output, " NoRODex |");
  4020. if (map_getmapflag(m_id, MF_NOPETCAPTURE))
  4021. strcat(atcmd_output, " NoPetCapture |");
  4022. clif_displaymessage(fd, atcmd_output);
  4023. switch (list) {
  4024. case 0:
  4025. // Do nothing. It's list 0, no additional display.
  4026. break;
  4027. case 1:
  4028. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  4029. iter = mapit_getallusers();
  4030. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4031. {
  4032. if (pl_sd->mapindex == m_index) {
  4033. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  4034. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4035. clif_displaymessage(fd, atcmd_output);
  4036. }
  4037. }
  4038. mapit_free(iter);
  4039. break;
  4040. case 2:
  4041. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  4042. for (i = 0; i < mapdata->npc_num;)
  4043. {
  4044. struct npc_data *nd = mapdata->npc[i];
  4045. switch(nd->ud.dir) {
  4046. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  4047. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  4048. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  4049. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  4050. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  4051. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  4052. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  4053. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  4054. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  4055. }
  4056. if(strcmp(nd->name,nd->exname) == 0)
  4057. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  4058. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4059. else
  4060. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  4061. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  4062. clif_displaymessage(fd, atcmd_output);
  4063. }
  4064. break;
  4065. case 3:
  4066. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  4067. iter = mapit_getallusers();
  4068. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4069. {
  4070. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr &&
  4071. pl_sd->mapindex == m_index &&
  4072. cd->usersd[0] == pl_sd)
  4073. {
  4074. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  4075. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4076. clif_displaymessage(fd, atcmd_output);
  4077. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  4078. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  4079. clif_displaymessage(fd, atcmd_output);
  4080. }
  4081. }
  4082. mapit_free(iter);
  4083. break;
  4084. default: // normally impossible to arrive here
  4085. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  4086. return -1;
  4087. break;
  4088. }
  4089. return 0;
  4090. }
  4091. /*==========================================
  4092. *
  4093. *------------------------------------------*/
  4094. ACMD_FUNC(mount_peco)
  4095. {
  4096. nullpo_retr(-1, sd);
  4097. if (sd->disguise) {
  4098. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  4099. return -1;
  4100. }
  4101. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4102. if( !(sd->sc.option&OPTION_DRAGON) ) {
  4103. uint32 option = OPTION_DRAGON1;
  4104. if( message[0] ) {
  4105. int32 color = atoi(message);
  4106. option = ( color == 2 ? OPTION_DRAGON2 :
  4107. color == 3 ? OPTION_DRAGON3 :
  4108. color == 4 ? OPTION_DRAGON4 :
  4109. color == 5 ? OPTION_DRAGON5 :
  4110. OPTION_DRAGON1 );
  4111. }
  4112. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  4113. pc_setoption(sd, sd->sc.option|option);
  4114. } else {
  4115. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  4116. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  4117. }
  4118. return 0;
  4119. }
  4120. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || (pc_checkskill(sd, WH_HAWK_M) || battle_config.warg_can_falcon)) ) {
  4121. if( !pc_isridingwug(sd) ) {
  4122. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  4123. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  4124. } else {
  4125. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  4126. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  4127. }
  4128. return 0;
  4129. }
  4130. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4131. if( !pc_ismadogear(sd) ) {
  4132. e_mado_type type = MADO_ROBOT;
  4133. if (message[0]) {
  4134. int32 tmp = strtol(message, nullptr, 10);
  4135. switch (tmp) {
  4136. case MADO_ROBOT:
  4137. case MADO_SUIT:
  4138. type = static_cast<e_mado_type>(tmp);
  4139. break;
  4140. default:
  4141. type = MADO_ROBOT;
  4142. break;
  4143. }
  4144. }
  4145. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  4146. pc_setmadogear(sd, true, type);
  4147. } else {
  4148. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  4149. pc_setmadogear(sd, false);
  4150. }
  4151. return 0;
  4152. }
  4153. if (!pc_isriding(sd)) { // if actually no peco
  4154. if (!pc_checkskill(sd, KN_RIDING)) {
  4155. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  4156. return -1;
  4157. }
  4158. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4159. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  4160. } else {//Dismount
  4161. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4162. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  4163. }
  4164. return 0;
  4165. }
  4166. /*==========================================
  4167. *Spy Commands by Syrus22
  4168. *------------------------------------------*/
  4169. ACMD_FUNC(guildspy)
  4170. {
  4171. char guild_name[NAME_LENGTH];
  4172. nullpo_retr(-1, sd);
  4173. memset(guild_name, '\0', sizeof(guild_name));
  4174. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4175. if (!enable_spy)
  4176. {
  4177. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4178. return -1;
  4179. }
  4180. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4181. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  4182. return -1;
  4183. }
  4184. auto g = guild_searchnameid(guild_name);
  4185. if (!g) {
  4186. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  4187. return -1;
  4188. }
  4189. if (sd->guildspy == g->guild.guild_id) {
  4190. sd->guildspy = 0;
  4191. sprintf(atcmd_output, msg_txt(sd,103), g->guild.name); // No longer spying on the %s guild.
  4192. clif_displaymessage(fd, atcmd_output);
  4193. } else {
  4194. sd->guildspy = g->guild.guild_id;
  4195. sprintf(atcmd_output, msg_txt(sd,104), g->guild.name); // Spying on the %s guild.
  4196. clif_displaymessage(fd, atcmd_output);
  4197. }
  4198. return 0;
  4199. }
  4200. /*==========================================
  4201. *
  4202. *------------------------------------------*/
  4203. ACMD_FUNC(partyspy)
  4204. {
  4205. char party_name[NAME_LENGTH];
  4206. struct party_data *p;
  4207. nullpo_retr(-1, sd);
  4208. memset(party_name, '\0', sizeof(party_name));
  4209. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4210. if (!enable_spy)
  4211. {
  4212. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4213. return -1;
  4214. }
  4215. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4216. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  4217. return -1;
  4218. }
  4219. if ((p = party_searchname(party_name)) != nullptr || // name first to avoid error when name begin with a number
  4220. (p = party_search(atoi(message))) != nullptr) {
  4221. if (sd->partyspy == p->party.party_id) {
  4222. sd->partyspy = 0;
  4223. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  4224. clif_displaymessage(fd, atcmd_output);
  4225. } else {
  4226. sd->partyspy = p->party.party_id;
  4227. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  4228. clif_displaymessage(fd, atcmd_output);
  4229. }
  4230. } else {
  4231. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  4232. return -1;
  4233. }
  4234. return 0;
  4235. }
  4236. ACMD_FUNC(clanspy){
  4237. char clan_name[NAME_LENGTH];
  4238. struct clan* c;
  4239. nullpo_retr(-1, sd);
  4240. memset(clan_name, '\0', sizeof(clan_name));
  4241. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4242. if( !enable_spy ){
  4243. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  4244. return -1;
  4245. }
  4246. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  4247. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  4248. return -1;
  4249. }
  4250. if ((c = clan_searchname(clan_name)) != nullptr || // name first to avoid error when name begin with a number
  4251. (c = clan_search(atoi(message))) != nullptr) {
  4252. if (sd->clanspy == c->id) {
  4253. sd->clanspy = 0;
  4254. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  4255. clif_displaymessage(fd, atcmd_output);
  4256. }
  4257. else {
  4258. sd->clanspy = c->id;
  4259. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  4260. clif_displaymessage(fd, atcmd_output);
  4261. }
  4262. }
  4263. else {
  4264. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  4265. return -1;
  4266. }
  4267. return 0;
  4268. }
  4269. /*==========================================
  4270. * @repairall [Valaris]
  4271. *------------------------------------------*/
  4272. ACMD_FUNC(repairall)
  4273. {
  4274. int32 count, i;
  4275. nullpo_retr(-1, sd);
  4276. count = 0;
  4277. for (i = 0; i < MAX_INVENTORY; i++) {
  4278. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1 && !itemdb_ishatched_egg(&sd->inventory.u.items_inventory[i])) {
  4279. sd->inventory.u.items_inventory[i].attribute = 0;
  4280. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  4281. count++;
  4282. }
  4283. }
  4284. if (count > 0) {
  4285. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  4286. clif_equiplist(sd);
  4287. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  4288. } else {
  4289. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  4290. return -1;
  4291. }
  4292. return 0;
  4293. }
  4294. /*==========================================
  4295. * @nuke [Valaris]
  4296. *------------------------------------------*/
  4297. ACMD_FUNC(nuke)
  4298. {
  4299. map_session_data *pl_sd;
  4300. nullpo_retr(-1, sd);
  4301. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4302. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4303. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  4304. return -1;
  4305. }
  4306. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != nullptr) {
  4307. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  4308. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4309. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  4310. } else {
  4311. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4312. return -1;
  4313. }
  4314. } else {
  4315. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4316. return -1;
  4317. }
  4318. return 0;
  4319. }
  4320. /*==========================================
  4321. * @tonpc
  4322. *------------------------------------------*/
  4323. ACMD_FUNC(tonpc)
  4324. {
  4325. char npcname[NPC_NAME_LENGTH];
  4326. struct npc_data *nd;
  4327. nullpo_retr(-1, sd);
  4328. memset(npcname, 0, sizeof(npcname));
  4329. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  4330. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  4331. return -1;
  4332. }
  4333. if ((nd = npc_name2id(npcname)) != nullptr) {
  4334. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  4335. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  4336. else
  4337. return -1;
  4338. } else {
  4339. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4340. return -1;
  4341. }
  4342. return 0;
  4343. }
  4344. /*==========================================
  4345. *
  4346. *------------------------------------------*/
  4347. ACMD_FUNC(shownpc)
  4348. {
  4349. char NPCname[NPC_NAME_LENGTH];
  4350. nullpo_retr(-1, sd);
  4351. memset(NPCname, '\0', sizeof(NPCname));
  4352. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4353. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  4354. return -1;
  4355. }
  4356. npc_data* nd = npc_name2id(NPCname);
  4357. if (nd) {
  4358. npc_enable(*nd, NPCVIEW_ENABLE);
  4359. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4360. } else {
  4361. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4362. return -1;
  4363. }
  4364. return 0;
  4365. }
  4366. /*==========================================
  4367. *
  4368. *------------------------------------------*/
  4369. ACMD_FUNC(hidenpc)
  4370. {
  4371. char NPCname[NPC_NAME_LENGTH];
  4372. nullpo_retr(-1, sd);
  4373. memset(NPCname, '\0', sizeof(NPCname));
  4374. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4375. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4376. return -1;
  4377. }
  4378. npc_data* nd = npc_name2id(NPCname);
  4379. if (!nd) {
  4380. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4381. return -1;
  4382. }
  4383. npc_enable(*nd, NPCVIEW_DISABLE);
  4384. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4385. return 0;
  4386. }
  4387. ACMD_FUNC(loadnpc)
  4388. {
  4389. if (!message || !*message) {
  4390. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4391. return -1;
  4392. }
  4393. if (!npc_addsrcfile(message, true)) {
  4394. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4395. return -1;
  4396. }
  4397. npc_read_event_script();
  4398. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was loaded.\n", message );
  4399. npc_event_doall_path( script_config.init_event_name, message );
  4400. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4401. return 0;
  4402. }
  4403. ACMD_FUNC(unloadnpc)
  4404. {
  4405. struct npc_data *nd;
  4406. char NPCname[NPC_NAME_LENGTH];
  4407. nullpo_retr(-1, sd);
  4408. memset(NPCname, '\0', sizeof(NPCname));
  4409. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4410. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4411. return -1;
  4412. }
  4413. if ((nd = npc_name2id(NPCname)) == nullptr) {
  4414. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4415. return -1;
  4416. }
  4417. npc_unload_duplicates(nd);
  4418. npc_unload(nd,true);
  4419. npc_read_event_script();
  4420. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4421. return 0;
  4422. }
  4423. ACMD_FUNC(reloadnpcfile) {
  4424. if (!message || !*message) {
  4425. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4426. return -1;
  4427. }
  4428. if (npc_unloadfile(message))
  4429. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4430. if (!npc_addsrcfile(message, true)) {
  4431. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4432. return -1;
  4433. }
  4434. npc_read_event_script();
  4435. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was reloaded.\n", message );
  4436. npc_event_doall_path( script_config.init_event_name, message );
  4437. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4438. return 0;
  4439. }
  4440. /*==========================================
  4441. * time in txt for time command (by [Yor])
  4442. *------------------------------------------*/
  4443. char* txt_time(t_tick duration_)
  4444. {
  4445. int32 days, hours, minutes, seconds;
  4446. char temp[CHAT_SIZE_MAX];
  4447. static char temp1[CHAT_SIZE_MAX];
  4448. memset(temp, '\0', sizeof(temp));
  4449. memset(temp1, '\0', sizeof(temp1));
  4450. // Cap it
  4451. int32 duration = (int32)duration_;
  4452. days = duration / (60 * 60 * 24);
  4453. duration = duration - (60 * 60 * 24 * days);
  4454. hours = duration / (60 * 60);
  4455. duration = duration - (60 * 60 * hours);
  4456. minutes = duration / 60;
  4457. seconds = duration - (60 * minutes);
  4458. if (days == 1)
  4459. sprintf(temp, msg_txt(nullptr,219), days); // %d day
  4460. else if (days > 1)
  4461. sprintf(temp, msg_txt(nullptr,220), days); // %d days
  4462. if (hours == 1)
  4463. sprintf(temp1, msg_txt(nullptr,221), temp, hours); // %s %d hour
  4464. else if (hours > 1)
  4465. sprintf(temp1, msg_txt(nullptr,222), temp, hours); // %s %d hours
  4466. if (minutes < 2)
  4467. sprintf(temp, msg_txt(nullptr,223), temp1, minutes); // %s %d minute
  4468. else
  4469. sprintf(temp, msg_txt(nullptr,224), temp1, minutes); // %s %d minutes
  4470. if (seconds == 1)
  4471. sprintf(temp1, msg_txt(nullptr,225), temp, seconds); // %s and %d second
  4472. else if (seconds > 1)
  4473. sprintf(temp1, msg_txt(nullptr,226), temp, seconds); // %s and %d seconds
  4474. return temp1;
  4475. }
  4476. /*==========================================
  4477. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4478. * Calculation management of GM modification (@day/@night GM commands) is done
  4479. *------------------------------------------*/
  4480. ACMD_FUNC(servertime)
  4481. {
  4482. const struct TimerData * timer_data;
  4483. time_t time_server; // variable for number of seconds (used with time() function)
  4484. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4485. char temp[CHAT_SIZE_MAX];
  4486. nullpo_retr(-1, sd);
  4487. memset(temp, '\0', sizeof(temp));
  4488. time(&time_server); // get time in seconds since 1/1/1970
  4489. datetime = localtime(&time_server); // convert seconds in structure
  4490. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4491. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4492. clif_displaymessage(fd, temp);
  4493. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4494. if (night_flag == 0)
  4495. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4496. else
  4497. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4498. } else if (battle_config.night_duration == 0)
  4499. if (night_flag == 1) { // we start with night
  4500. if ((timer_data = get_timer(day_timer_tid)) != nullptr) {
  4501. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4502. clif_displaymessage(fd, temp);
  4503. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4504. } else
  4505. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4506. } else
  4507. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4508. else if (battle_config.day_duration == 0)
  4509. if (night_flag == 0) { // we start with day
  4510. if ((timer_data = get_timer(night_timer_tid)) != nullptr) {
  4511. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4512. clif_displaymessage(fd, temp);
  4513. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4514. } else
  4515. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4516. } else
  4517. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4518. else {
  4519. const struct TimerData * timer_data2;
  4520. if (night_flag == 0) {
  4521. if ((timer_data = get_timer(night_timer_tid)) != nullptr && (timer_data2 = get_timer(day_timer_tid)) != nullptr) {
  4522. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4523. clif_displaymessage(fd, temp);
  4524. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4525. 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.
  4526. else
  4527. 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.
  4528. clif_displaymessage(fd, temp);
  4529. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4530. clif_displaymessage(fd, temp);
  4531. } else
  4532. clif_displaymessage(fd, msg_txt(sd, 231)); // Game time: The game is in permanent daylight.
  4533. } else {
  4534. if ((timer_data = get_timer(day_timer_tid)) != nullptr && (timer_data2 = get_timer(night_timer_tid)) != nullptr) {
  4535. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4536. clif_displaymessage(fd, temp);
  4537. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4538. 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.
  4539. else
  4540. 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.
  4541. clif_displaymessage(fd, temp);
  4542. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4543. clif_displaymessage(fd, temp);
  4544. } else
  4545. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4546. }
  4547. }
  4548. return 0;
  4549. }
  4550. /*==========================================
  4551. * @jail <char_name> by [Yor]
  4552. * Special warp! No check with nowarp and nowarpto flag
  4553. *------------------------------------------*/
  4554. ACMD_FUNC(jail)
  4555. {
  4556. map_session_data *pl_sd;
  4557. nullpo_retr(-1, sd);
  4558. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4559. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4560. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4561. return -1;
  4562. }
  4563. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4564. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4565. return -1;
  4566. }
  4567. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4568. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4569. return -1;
  4570. }
  4571. if (pl_sd->sc.getSCE(SC_JAILED)) {
  4572. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4573. return -1;
  4574. }
  4575. pc_jail(*pl_sd);
  4576. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4577. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4578. return 0;
  4579. }
  4580. /*==========================================
  4581. * @unjail/@discharge <char_name> by [Yor]
  4582. * Special warp! No check with nowarp and nowarpto flag
  4583. *------------------------------------------*/
  4584. ACMD_FUNC(unjail)
  4585. {
  4586. map_session_data *pl_sd;
  4587. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4588. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4589. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4590. return -1;
  4591. }
  4592. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4593. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4594. return -1;
  4595. }
  4596. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4597. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4598. return -1;
  4599. }
  4600. if (!pl_sd->sc.getSCE(SC_JAILED)) {
  4601. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4602. return -1;
  4603. }
  4604. //Reset jail time to 1 sec.
  4605. pc_jail(*pl_sd, 0);
  4606. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4607. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4608. return 0;
  4609. }
  4610. ACMD_FUNC(jailfor) {
  4611. map_session_data* pl_sd = nullptr;;
  4612. char * modif_p;
  4613. int32 jailtime = 0;
  4614. nullpo_retr(-1, sd);
  4615. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4616. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4617. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4618. return -1;
  4619. }
  4620. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4621. modif_p = atcmd_output;
  4622. jailtime = (int32)solve_time(modif_p)/60; // Change to minutes
  4623. if (jailtime == 0) {
  4624. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4625. 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.
  4626. return -1;
  4627. }
  4628. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4629. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4630. return -1;
  4631. }
  4632. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4633. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4634. return -1;
  4635. }
  4636. // Added by Coltaro
  4637. if(pl_sd->sc.getSCE(SC_JAILED) && pl_sd->sc.getSCE(SC_JAILED)->val1 != INT_MAX) { // Update the player's jail time
  4638. jailtime += pl_sd->sc.getSCE(SC_JAILED)->val1;
  4639. if (jailtime <= 0) {
  4640. jailtime = 0;
  4641. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4642. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4643. } else {
  4644. int32 year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4645. char timestr[21];
  4646. time_t now=time(nullptr);
  4647. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4648. 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
  4649. clif_displaymessage(pl_sd->fd, atcmd_output);
  4650. 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
  4651. clif_displaymessage(fd, atcmd_output);
  4652. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4653. sprintf(atcmd_output,"Release date is: %s",timestr);
  4654. clif_displaymessage(pl_sd->fd, atcmd_output);
  4655. clif_displaymessage(fd, atcmd_output);
  4656. }
  4657. } else if (jailtime < 0) {
  4658. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4659. return -1;
  4660. }
  4661. pc_jail(*pl_sd, jailtime);
  4662. return 0;
  4663. }
  4664. //By Coltaro
  4665. ACMD_FUNC(jailtime){
  4666. int32 year, month, day, hour, minute, second;
  4667. char timestr[21];
  4668. time_t now = time(nullptr);
  4669. nullpo_retr(-1, sd);
  4670. if (!sd->sc.getSCE(SC_JAILED)) {
  4671. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4672. return -1;
  4673. }
  4674. if (sd->sc.getSCE(SC_JAILED)->val1 == INT_MAX) {
  4675. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4676. return 0;
  4677. }
  4678. if (sd->sc.getSCE(SC_JAILED)->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4679. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4680. return -1;
  4681. }
  4682. // Get remaining jail time
  4683. split_time(sd->sc.getSCE(SC_JAILED)->val1*60,&year,&month,&day,&hour,&minute,&second);
  4684. 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
  4685. clif_displaymessage(fd, atcmd_output);
  4686. timestamp2string(timestr,20,now+sd->sc.getSCE(SC_JAILED)->val1*60,"%Y-%m-%d %H:%M");
  4687. sprintf(atcmd_output,"Release date is: %s",timestr);
  4688. clif_displaymessage(fd, atcmd_output);
  4689. return 0;
  4690. }
  4691. /*==========================================
  4692. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4693. *------------------------------------------*/
  4694. ACMD_FUNC(disguise)
  4695. {
  4696. int32 id = 0;
  4697. nullpo_retr(-1, sd);
  4698. if (!message || !*message) {
  4699. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4700. return -1;
  4701. }
  4702. if ((id = atoi(message)) > 0)
  4703. { //Acquired an ID
  4704. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4705. id = 0; //Invalid id for either mobs or npcs.
  4706. } else { //Acquired a Name
  4707. if ((id = mobdb_searchname(message)) == 0)
  4708. {
  4709. struct npc_data* nd = npc_name2id(message);
  4710. if (nd != nullptr)
  4711. id = nd->class_;
  4712. }
  4713. }
  4714. if (id == 0)
  4715. {
  4716. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4717. return -1;
  4718. }
  4719. if(pc_isriding(sd))
  4720. {
  4721. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4722. return -1;
  4723. }
  4724. if (sd->sc.getSCE(SC_MONSTER_TRANSFORM) || sd->sc.getSCE(SC_ACTIVE_MONSTER_TRANSFORM)) {
  4725. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4726. return -1;
  4727. }
  4728. pc_disguise(sd, id);
  4729. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4730. return 0;
  4731. }
  4732. /*==========================================
  4733. * DisguiseAll
  4734. *------------------------------------------*/
  4735. ACMD_FUNC(disguiseall)
  4736. {
  4737. int32 mob_id=0;
  4738. map_session_data *pl_sd;
  4739. struct s_mapiterator* iter;
  4740. nullpo_retr(-1, sd);
  4741. if (!message || !*message) {
  4742. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4743. return -1;
  4744. }
  4745. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4746. mob_id = atoi(message);
  4747. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4748. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4749. return -1;
  4750. }
  4751. iter = mapit_getallusers();
  4752. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4753. pc_disguise(pl_sd, mob_id);
  4754. mapit_free(iter);
  4755. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4756. return 0;
  4757. }
  4758. /*==========================================
  4759. * DisguiseGuild
  4760. *------------------------------------------*/
  4761. ACMD_FUNC(disguiseguild)
  4762. {
  4763. int32 id = 0, i;
  4764. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4765. memset(monster, '\0', sizeof(monster));
  4766. memset(guild, '\0', sizeof(guild));
  4767. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4768. 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>).
  4769. return -1;
  4770. }
  4771. if( (id = atoi(monster)) > 0 ) {
  4772. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4773. id = 0;
  4774. } else {
  4775. if( (id = mobdb_searchname(monster)) == 0 ) {
  4776. struct npc_data* nd = npc_name2id(monster);
  4777. if( nd != nullptr )
  4778. id = nd->class_;
  4779. }
  4780. }
  4781. if( id == 0 ) {
  4782. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4783. return -1;
  4784. }
  4785. auto g = guild_searchnameid(guild);
  4786. if (!g) {
  4787. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4788. return -1;
  4789. }
  4790. for( i = 0; i < g->guild.max_member; i++ ){
  4791. map_session_data *pl_sd;
  4792. if( (pl_sd = g->guild.member[i].sd) && !pc_isriding(pl_sd) )
  4793. pc_disguise(pl_sd, id);
  4794. }
  4795. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4796. return 0;
  4797. }
  4798. /*==========================================
  4799. * @undisguise by [Yor]
  4800. *------------------------------------------*/
  4801. ACMD_FUNC(undisguise)
  4802. {
  4803. nullpo_retr(-1, sd);
  4804. if (sd->disguise) {
  4805. pc_disguise(sd, 0);
  4806. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4807. } else {
  4808. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4809. return -1;
  4810. }
  4811. return 0;
  4812. }
  4813. /*==========================================
  4814. * UndisguiseAll
  4815. *------------------------------------------*/
  4816. ACMD_FUNC(undisguiseall)
  4817. {
  4818. map_session_data *pl_sd;
  4819. struct s_mapiterator* iter;
  4820. nullpo_retr(-1, sd);
  4821. iter = mapit_getallusers();
  4822. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4823. if( pl_sd->disguise )
  4824. pc_disguise(pl_sd, 0);
  4825. mapit_free(iter);
  4826. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4827. return 0;
  4828. }
  4829. /*==========================================
  4830. * UndisguiseGuild
  4831. *------------------------------------------*/
  4832. ACMD_FUNC(undisguiseguild)
  4833. {
  4834. char guild_name[NAME_LENGTH];
  4835. int32 i;
  4836. nullpo_retr(-1, sd);
  4837. memset(guild_name, '\0', sizeof(guild_name));
  4838. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4839. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4840. return -1;
  4841. }
  4842. auto g = guild_searchnameid(guild_name);
  4843. if (!g) {
  4844. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4845. return -1;
  4846. }
  4847. for(i = 0; i < g->guild.max_member; i++){
  4848. map_session_data *pl_sd;
  4849. if( (pl_sd = g->guild.member[i].sd) && pl_sd->disguise )
  4850. pc_disguise(pl_sd, 0);
  4851. }
  4852. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4853. return 0;
  4854. }
  4855. /*==========================================
  4856. * @exp by [Skotlex]
  4857. *------------------------------------------*/
  4858. ACMD_FUNC(exp)
  4859. {
  4860. char output[CHAT_SIZE_MAX];
  4861. double nextb, nextj;
  4862. nullpo_retr(-1, sd);
  4863. memset(output, '\0', sizeof(output));
  4864. nextb = (double)pc_nextbaseexp(sd);
  4865. if (nextb)
  4866. nextb = sd->status.base_exp*100.0/nextb;
  4867. nextj = (double)pc_nextjobexp(sd);
  4868. if (nextj)
  4869. nextj = sd->status.job_exp*100.0/nextj;
  4870. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4871. clif_displaymessage(fd, output);
  4872. return 0;
  4873. }
  4874. /*==========================================
  4875. * @broadcast by [Valaris]
  4876. *------------------------------------------*/
  4877. ACMD_FUNC(broadcast)
  4878. {
  4879. nullpo_retr(-1, sd);
  4880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4881. if (!message || !*message) {
  4882. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4883. return -1;
  4884. }
  4885. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4886. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4887. return 0;
  4888. }
  4889. /*==========================================
  4890. * @localbroadcast by [Valaris]
  4891. *------------------------------------------*/
  4892. ACMD_FUNC(localbroadcast)
  4893. {
  4894. nullpo_retr(-1, sd);
  4895. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4896. if (!message || !*message) {
  4897. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4898. return -1;
  4899. }
  4900. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4901. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4902. return 0;
  4903. }
  4904. /*==========================================
  4905. * @email <actual@email> <new@email> by [Yor]
  4906. *------------------------------------------*/
  4907. ACMD_FUNC(email)
  4908. {
  4909. char actual_email[100];
  4910. char new_email[100];
  4911. nullpo_retr(-1, sd);
  4912. memset(actual_email, '\0', sizeof(actual_email));
  4913. memset(new_email, '\0', sizeof(new_email));
  4914. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4915. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4916. return -1;
  4917. }
  4918. if (e_mail_check(actual_email) == 0) {
  4919. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4920. return -1;
  4921. } else if (e_mail_check(new_email) == 0) {
  4922. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4923. return -1;
  4924. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4925. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4926. return -1;
  4927. } else if (strcmpi(actual_email, new_email) == 0) {
  4928. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4929. return -1;
  4930. }
  4931. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4932. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4933. return 0;
  4934. }
  4935. /*==========================================
  4936. *@effect
  4937. *------------------------------------------*/
  4938. ACMD_FUNC(effect)
  4939. {
  4940. int32 type = EF_NONE;
  4941. nullpo_retr(-1, sd);
  4942. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4943. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4944. return -1;
  4945. }
  4946. if( type <= EF_NONE || type >= EF_MAX ){
  4947. 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.
  4948. clif_displaymessage(fd, atcmd_output);
  4949. return -1;
  4950. }
  4951. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4952. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4953. return 0;
  4954. }
  4955. /*==========================================
  4956. * @killer by MouseJstr
  4957. * enable killing players even when not in pvp
  4958. *------------------------------------------*/
  4959. ACMD_FUNC(killer)
  4960. {
  4961. nullpo_retr(-1, sd);
  4962. sd->state.killer = !sd->state.killer;
  4963. if(sd->state.killer)
  4964. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4965. else {
  4966. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4967. unit_stop_attack( &sd->bl );
  4968. }
  4969. return 0;
  4970. }
  4971. /*==========================================
  4972. * @killable by MouseJstr
  4973. * enable other people killing you
  4974. *------------------------------------------*/
  4975. ACMD_FUNC(killable)
  4976. {
  4977. nullpo_retr(-1, sd);
  4978. sd->state.killable = !sd->state.killable;
  4979. if(sd->state.killable)
  4980. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4981. else {
  4982. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4983. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4984. }
  4985. return 0;
  4986. }
  4987. /*==========================================
  4988. * @skillon by MouseJstr
  4989. * turn skills on for the map
  4990. *------------------------------------------*/
  4991. ACMD_FUNC(skillon)
  4992. {
  4993. nullpo_retr(-1, sd);
  4994. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4995. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4996. return 0;
  4997. }
  4998. /*==========================================
  4999. * @skilloff by MouseJstr
  5000. * Turn skills off on the map
  5001. *------------------------------------------*/
  5002. ACMD_FUNC(skilloff)
  5003. {
  5004. nullpo_retr(-1, sd);
  5005. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  5006. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  5007. return 0;
  5008. }
  5009. /*==========================================
  5010. * @npcmove by MouseJstr
  5011. * move a npc
  5012. *------------------------------------------*/
  5013. ACMD_FUNC(npcmove)
  5014. {
  5015. int16 x = 0, y = 0;
  5016. struct npc_data *nd = 0;
  5017. char npc_name[NPC_NAME_LENGTH];
  5018. nullpo_retr(-1, sd);
  5019. memset(npc_name, '\0', sizeof npc_name);
  5020. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  5021. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  5022. return -1;
  5023. }
  5024. if ((nd = npc_name2id(npc_name)) == nullptr)
  5025. {
  5026. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  5027. return -1;
  5028. }
  5029. if ( npc_movenpc( nd, x, y ) )
  5030. { //actually failed to move
  5031. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  5032. return -1; //Not on a map.
  5033. } else
  5034. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  5035. return 0;
  5036. }
  5037. /*==========================================
  5038. * @addwarp by MouseJstr
  5039. * Create a new static warp point.
  5040. *------------------------------------------*/
  5041. ACMD_FUNC(addwarp)
  5042. {
  5043. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  5044. int16 x,y;
  5045. uint16 m;
  5046. struct npc_data* nd;
  5047. nullpo_retr(-1, sd);
  5048. memset(warpname, '\0', sizeof(warpname));
  5049. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  5050. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  5051. return -1;
  5052. }
  5053. m = mapindex_name2id(mapname);
  5054. if( m == 0 )
  5055. {
  5056. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  5057. clif_displaymessage(fd, atcmd_output);
  5058. return -1;
  5059. }
  5060. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  5061. if( nd == nullptr )
  5062. return -1;
  5063. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  5064. clif_displaymessage(fd, atcmd_output);
  5065. return 0;
  5066. }
  5067. /*==========================================
  5068. * @follow by [MouseJstr]
  5069. * Follow a player .. staying no more then 5 spaces away
  5070. *------------------------------------------*/
  5071. ACMD_FUNC(follow)
  5072. {
  5073. map_session_data* pl_sd = nullptr;;
  5074. nullpo_retr(-1, sd);
  5075. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5076. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5077. if (sd->followtarget == -1)
  5078. return -1;
  5079. pc_stop_following (sd);
  5080. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5081. return 0;
  5082. }
  5083. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5084. {
  5085. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5086. return -1;
  5087. }
  5088. if (sd->followtarget == pl_sd->bl.id) {
  5089. pc_stop_following (sd);
  5090. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5091. } else {
  5092. pc_follow(sd, pl_sd->bl.id);
  5093. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  5094. }
  5095. return 0;
  5096. }
  5097. /*==========================================
  5098. * @dropall by [MouseJstr] and [Xantara]
  5099. * Drops all your possession on the ground based on item type
  5100. *------------------------------------------*/
  5101. ACMD_FUNC(dropall)
  5102. {
  5103. int8 type = -1;
  5104. uint16 i, count = 0, count2 = 0;
  5105. nullpo_retr(-1, sd);
  5106. if( message[0] ) {
  5107. type = atoi(message);
  5108. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  5109. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  5110. {
  5111. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  5112. 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
  5113. return -1;
  5114. }
  5115. }
  5116. for( i = 0; i < MAX_INVENTORY; i++ ) {
  5117. if( sd->inventory.u.items_inventory[i].amount ) {
  5118. std::shared_ptr<item_data> id = item_db.find(sd->inventory.u.items_inventory[i].nameid);
  5119. if( id == nullptr ) {
  5120. 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);
  5121. continue;
  5122. }
  5123. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  5124. continue;
  5125. if( type == -1 || type == (uint8)id->type ) {
  5126. if( sd->inventory.u.items_inventory[i].equip != 0 )
  5127. pc_unequipitem(sd, i, 3);
  5128. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5129. pet_return_egg( sd, sd->pd );
  5130. }
  5131. pc_equipswitch_remove(sd, i);
  5132. int32 amount = sd->inventory.u.items_inventory[i].amount;
  5133. if(pc_dropitem(sd, i, amount))
  5134. count += amount;
  5135. else count2 += amount;
  5136. }
  5137. }
  5138. }
  5139. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  5140. clif_displaymessage(fd, atcmd_output);
  5141. return 0;
  5142. }
  5143. /*==========================================
  5144. * @stockall by [Hanashi]
  5145. * transfer items from cart to inventory
  5146. *------------------------------------------*/
  5147. ACMD_FUNC(stockall)
  5148. {
  5149. nullpo_retr(-1, sd);
  5150. if (!pc_iscarton(sd)) {
  5151. clif_displaymessage(fd, msg_txt(sd,1533)); // You do not have a cart.
  5152. return -1;
  5153. }
  5154. int8 type = -1;
  5155. if ( message[0] ) {
  5156. type = atoi(message);
  5157. switch (type) {
  5158. case -1:
  5159. case IT_HEALING:
  5160. case IT_USABLE:
  5161. case IT_ETC:
  5162. case IT_WEAPON:
  5163. case IT_ARMOR:
  5164. case IT_CARD:
  5165. case IT_PETEGG:
  5166. case IT_PETARMOR:
  5167. case IT_AMMO:
  5168. break;
  5169. default:
  5170. clif_displaymessage(fd, msg_txt(sd, 1534)); // Usage: @stockall {<type>}
  5171. 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
  5172. return -1;
  5173. }
  5174. }
  5175. int32 count = 0, count2 = 0;
  5176. for ( uint16 i = 0; i < MAX_CART; i++ ) {
  5177. if ( sd->cart.u.items_cart[i].amount > 0 ) {
  5178. std::shared_ptr<item_data> id = item_db.find(sd->cart.u.items_cart[i].nameid);
  5179. if ( id == nullptr ) {
  5180. ShowDebug("Non-existent item %u on stockall list (account_id: %d, char_id: %d)\n", sd->cart.u.items_cart[i].nameid, sd->status.account_id, sd->status.char_id);
  5181. continue;
  5182. }
  5183. if ( type == -1 || static_cast<item_types>(type) == id->type ) {
  5184. int32 amount = sd->cart.u.items_cart[i].amount;
  5185. if( pc_getitemfromcart( sd, i, amount ) ){
  5186. count += amount;
  5187. }else{
  5188. count2 += amount;
  5189. }
  5190. }
  5191. }
  5192. }
  5193. sprintf(atcmd_output, msg_txt(sd,1535), count,count2); // %d items are transferred (%d skipped)!
  5194. clif_displaymessage(fd, atcmd_output);
  5195. return 0;
  5196. }
  5197. /*==========================================
  5198. * @storeall by [MouseJstr]
  5199. * Put everything into storage
  5200. *------------------------------------------*/
  5201. ACMD_FUNC(storeall)
  5202. {
  5203. int32 i;
  5204. nullpo_retr(-1, sd);
  5205. if (sd->state.storage_flag != 1)
  5206. { //Open storage.
  5207. if( storage_storageopen(sd) == 1 ) {
  5208. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  5209. return -1;
  5210. }
  5211. }
  5212. for (i = 0; i < MAX_INVENTORY; i++) {
  5213. if (sd->inventory.u.items_inventory[i].amount) {
  5214. if(sd->inventory.u.items_inventory[i].equip != 0)
  5215. pc_unequipitem(sd, i, 3);
  5216. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5217. pet_return_egg( sd, sd->pd );
  5218. }
  5219. pc_equipswitch_remove(sd, i);
  5220. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  5221. }
  5222. }
  5223. storage_storageclose(sd);
  5224. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  5225. return 0;
  5226. }
  5227. ACMD_FUNC(clearstorage)
  5228. {
  5229. int32 i, j;
  5230. nullpo_retr(-1, sd);
  5231. if (sd->state.storage_flag == 1) {
  5232. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5233. return -1;
  5234. }
  5235. if (sd->state.storage_flag == 3) {
  5236. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5237. return -1;
  5238. }
  5239. j = sd->storage.amount;
  5240. for (i = 0; i < j; ++i) {
  5241. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  5242. }
  5243. sd->state.storage_flag = 1;
  5244. storage_storageclose(sd);
  5245. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  5246. return 0;
  5247. }
  5248. ACMD_FUNC(cleargstorage)
  5249. {
  5250. int32 i, j;
  5251. struct s_storage *gstorage;
  5252. nullpo_retr(-1, sd);
  5253. if (!sd->guild) {
  5254. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  5255. return -1;
  5256. }
  5257. if (sd->state.storage_flag == 1) {
  5258. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5259. return -1;
  5260. }
  5261. if (sd->state.storage_flag == 2) {
  5262. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  5263. return -1;
  5264. }
  5265. if (sd->state.storage_flag == 3) {
  5266. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5267. return -1;
  5268. }
  5269. gstorage = guild2storage2(sd->status.guild_id);
  5270. if (gstorage == nullptr) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  5271. return -1;
  5272. }
  5273. j = gstorage->amount;
  5274. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  5275. for (i = 0; i < j; ++i) {
  5276. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  5277. }
  5278. storage_guild_storageclose(sd);
  5279. gstorage->lock = false; // Cleaning done, release lock
  5280. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  5281. return 0;
  5282. }
  5283. ACMD_FUNC(clearcart)
  5284. {
  5285. int32 i;
  5286. nullpo_retr(-1, sd);
  5287. if (pc_iscarton(sd) == 0) {
  5288. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  5289. return -1;
  5290. }
  5291. if (sd->state.vending == 1) { //Somehow...
  5292. return -1;
  5293. }
  5294. for (i = 0; i < MAX_CART; i++) {
  5295. if (sd->cart.u.items_cart[i].nameid > 0)
  5296. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  5297. }
  5298. clif_clearcart(fd);
  5299. clif_updatestatus(*sd,SP_CARTINFO);
  5300. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  5301. return 0;
  5302. }
  5303. /*==========================================
  5304. * @skillid by [MouseJstr]
  5305. * lookup a skill by name
  5306. *------------------------------------------*/
  5307. #define MAX_SKILLID_PARTIAL_RESULTS 5
  5308. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  5309. ACMD_FUNC(skillid) {
  5310. int32 i, found = 0;
  5311. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  5312. nullpo_retr(-1, sd);
  5313. if (!message || !*message) {
  5314. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  5315. return -1;
  5316. }
  5317. size_t skillen = strlen( message );
  5318. for(const auto & skill : skill_db) {
  5319. uint16 skill_id = skill.second->nameid;
  5320. uint16 idx = skill_get_index(skill_id);
  5321. const char *name = skill.second->name;
  5322. const char *desc = skill.second->desc;
  5323. if (strnicmp(name, message, skillen) == 0 || strnicmp(desc, message, skillen) == 0) {
  5324. sprintf(atcmd_output, msg_txt(sd,1164), skill_id, desc, name); // skill %d: %s (%s)
  5325. clif_displaymessage(fd, atcmd_output);
  5326. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(name,message) || stristr(desc,message) ) ) {
  5327. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), skill_id, desc, name); // // skill %d: %s (%s)
  5328. }
  5329. }
  5330. if( found ) {
  5331. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  5332. clif_displaymessage(fd, atcmd_output);
  5333. }
  5334. for(i = 0; i < found; i++) { /* partials */
  5335. clif_displaymessage(fd, partials[i]);
  5336. }
  5337. return 0;
  5338. }
  5339. /*==========================================
  5340. * @useskill by [MouseJstr]
  5341. * A way of using skills without having to find them in the skills menu
  5342. *------------------------------------------*/
  5343. ACMD_FUNC(useskill)
  5344. {
  5345. map_session_data* pl_sd = nullptr;;
  5346. struct block_list *bl;
  5347. uint16 skill_id;
  5348. uint16 skill_lv;
  5349. nullpo_retr(-1, sd);
  5350. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5351. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  5352. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  5353. return -1;
  5354. }
  5355. if (!skill_id || !skill_db.find(skill_id)) {
  5356. clif_displaymessage(fd, msg_txt(sd, 198)); // This skill number doesn't exist.
  5357. return -1;
  5358. }
  5359. if (!skill_lv)
  5360. skill_lv = 1;
  5361. if(!strcmp(atcmd_player_name,"self"))
  5362. pl_sd = sd; //quick keyword
  5363. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr ){
  5364. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5365. return -1;
  5366. }
  5367. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5368. {
  5369. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5370. return -1;
  5371. }
  5372. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5373. bl = &sd->hd->bl;
  5374. else
  5375. bl = &sd->bl;
  5376. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  5377. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  5378. else
  5379. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  5380. return 0;
  5381. }
  5382. /*==========================================
  5383. * @displayskill by [Skotlex]
  5384. * Debug command to locate new skill IDs. It sends the
  5385. * three possible skill-effect packets to the area.
  5386. *------------------------------------------*/
  5387. ACMD_FUNC(displayskill)
  5388. {
  5389. t_tick tick;
  5390. uint16 skill_id;
  5391. uint16 skill_lv = 1;
  5392. uint16 type = 0;
  5393. nullpo_retr(-1, sd);
  5394. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &skill_id, &skill_lv, &type) < 1)
  5395. {
  5396. clif_displaymessage(fd, msg_txt(sd,1166));// Usage: @displayskill <skill ID> {<skill level> <type>}
  5397. clif_displaymessage(fd, msg_txt(sd,825));// Effect Types: 0: All, 1: Damage, 2: Splash Dmg, 3: No Damage, 4: Ground
  5398. return -1;
  5399. }
  5400. status_data* status = status_get_status_data(sd->bl);
  5401. tick = gettick();
  5402. if (type == 0 || type == 1)
  5403. clif_skill_damage( sd->bl, sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SINGLE );
  5404. if (type == 0 || type == 2)
  5405. clif_skill_damage( sd->bl, sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH );
  5406. if (type == 0 || type == 3)
  5407. clif_skill_nodamage(&sd->bl, sd->bl, skill_id, skill_lv);
  5408. if (type == 0 || type == 4)
  5409. clif_skill_poseffect( sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick );
  5410. return 0;
  5411. }
  5412. /*==========================================
  5413. * @displayskillcast by [Rytech]
  5414. * Debug command to view casting animations for skills.
  5415. * Can target self or the ground. Ground target can be
  5416. * useful for seeing casting circle size.
  5417. *------------------------------------------*/
  5418. ACMD_FUNC(displayskillcast)
  5419. {
  5420. uint16 skill_id;
  5421. uint16 skill_lv = 1;
  5422. uint16 cast_time = 5000;
  5423. uint16 target_type = 0;
  5424. nullpo_retr(-1, sd);
  5425. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu %6hu", &skill_id, &skill_lv, &target_type, &cast_time) < 1)
  5426. {
  5427. clif_displaymessage(fd, msg_txt(sd, 824));// Usage: @displayskillcast <skill ID> {<skill level> <ground target flag> <cast time>}
  5428. return -1;
  5429. }
  5430. if ( target_type == 1)
  5431. clif_skillcasting(&sd->bl, sd->bl.id, 0, sd->bl.x, sd->bl.y, skill_id, skill_lv, 0, cast_time);
  5432. else
  5433. clif_skillcasting(&sd->bl, sd->bl.id, sd->bl.id, 0, 0, skill_id, skill_lv, 0, cast_time);
  5434. return 0;
  5435. }
  5436. /*==========================================
  5437. * @displayskillunit by [Rytech]
  5438. * Debug command to view unit animations for skills.
  5439. *------------------------------------------*/
  5440. ACMD_FUNC(displayskillunit)
  5441. {
  5442. uint16 unit_id;
  5443. uint16 range = 0;
  5444. uint16 skill_lv = 1;
  5445. nullpo_retr(-1, sd);
  5446. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &unit_id, &skill_lv, &range) < 1)
  5447. {
  5448. clif_displaymessage(fd, msg_txt(sd, 826));// Usage: @displayskillunit <unit ID> {<skill level> <range>}
  5449. return -1;
  5450. }
  5451. clif_skill_unit_test(&sd->bl, sd->bl.x, sd->bl.y, unit_id, range, skill_lv);
  5452. return 0;
  5453. }
  5454. /*==========================================
  5455. * @skilltree by [MouseJstr]
  5456. * prints the skill tree for a player required to get to a skill
  5457. *------------------------------------------*/
  5458. ACMD_FUNC(skilltree)
  5459. {
  5460. map_session_data* pl_sd = nullptr;;
  5461. uint16 skill_id;
  5462. nullpo_retr(-1, sd);
  5463. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5464. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  5465. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  5466. return -1;
  5467. }
  5468. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5469. {
  5470. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5471. return -1;
  5472. }
  5473. int32 c = pc_mapid2jobid( pc_calc_skilltree_normalize_job( pl_sd ), pl_sd->status.sex );
  5474. 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).
  5475. clif_displaymessage(fd, atcmd_output);
  5476. auto entry = skill_tree_db.get_skill_data(c, skill_id);
  5477. if (entry == nullptr) {
  5478. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5479. return 0;
  5480. }
  5481. bool meets = true;
  5482. for (const auto &it : entry->need) {
  5483. if (pc_checkskill(sd, it.first) < it.second) {
  5484. sprintf(atcmd_output, msg_txt(sd,1170), it.second, skill_get_desc(it.first)); // Player requires level %d of skill %s.
  5485. clif_displaymessage(fd, atcmd_output);
  5486. meets = false;
  5487. }
  5488. }
  5489. if (meets) {
  5490. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5491. }
  5492. return 0;
  5493. }
  5494. // Hand a ring with partners name on it to this char
  5495. void getring (map_session_data* sd)
  5496. {
  5497. char flag = 0;
  5498. t_itemid item_id;
  5499. struct item item_tmp;
  5500. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5501. memset(&item_tmp, 0, sizeof(item_tmp));
  5502. item_tmp.nameid = item_id;
  5503. item_tmp.identify = 1;
  5504. item_tmp.card[0] = CARD0_FORGE;
  5505. item_tmp.card[2] = GetWord(sd->status.partner_id,0);
  5506. item_tmp.card[3] = GetWord(sd->status.partner_id,1);
  5507. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5508. clif_additem(sd,0,0,flag);
  5509. }
  5510. }
  5511. /*==========================================
  5512. * @marry by [MouseJstr], fixed by Lupus
  5513. * Marry two players
  5514. *------------------------------------------*/
  5515. ACMD_FUNC(marry)
  5516. {
  5517. map_session_data* pl_sd = nullptr;;
  5518. nullpo_retr(-1, sd);
  5519. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5520. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5521. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5522. return -1;
  5523. }
  5524. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  5525. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5526. return -1;
  5527. }
  5528. if (!pc_inventoryblank(sd)) {
  5529. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5530. return -1;
  5531. }
  5532. if (!pc_inventoryblank(pl_sd)) {
  5533. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5534. return -1;
  5535. }
  5536. uint32 w = 0;
  5537. if (w = itemdb_weight((sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + sd->weight > sd->max_weight) {
  5538. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5539. return -1;
  5540. }
  5541. if (w = itemdb_weight((pl_sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + pl_sd->weight > pl_sd->max_weight) {
  5542. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5543. return -1;
  5544. }
  5545. if (pc_marriage(sd, pl_sd)) {
  5546. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5547. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5548. if( pl_sd->bl.m != sd->bl.m )
  5549. clif_wedding_effect(&sd->bl);
  5550. getring(sd); // Auto-give named rings (Aru)
  5551. getring(pl_sd);
  5552. return 0;
  5553. }
  5554. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5555. return -1;
  5556. }
  5557. /*==========================================
  5558. * @divorce by [MouseJstr], fixed by [Lupus]
  5559. * divorce two players
  5560. *------------------------------------------*/
  5561. ACMD_FUNC(divorce)
  5562. {
  5563. nullpo_retr(-1, sd);
  5564. if (!pc_divorce(sd)) {
  5565. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5566. clif_displaymessage(fd, atcmd_output);
  5567. return -1;
  5568. }
  5569. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5570. clif_displaymessage(fd, atcmd_output);
  5571. return 0;
  5572. }
  5573. /*==========================================
  5574. * @changelook by [Celest]
  5575. *------------------------------------------*/
  5576. ACMD_FUNC(changelook)
  5577. {
  5578. int32 i, j = 0, k = 0;
  5579. int32 pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5580. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5581. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5582. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5583. return -1;
  5584. } else if ( i == 2 ) {
  5585. if (j < 1 || j > 8)
  5586. j = 1;
  5587. j = pos[j - 1];
  5588. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5589. k = j; // swap
  5590. j = LOOK_HEAD_TOP;
  5591. }
  5592. clif_changelook(&sd->bl,j,k);
  5593. return 0;
  5594. }
  5595. /*==========================================
  5596. * @autotrade by durf [Lupus] [Paradox924X]
  5597. * Turns on/off Autotrade for a specific player
  5598. *------------------------------------------*/
  5599. ACMD_FUNC(autotrade) {
  5600. nullpo_retr(-1, sd);
  5601. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5602. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5603. return -1;
  5604. }
  5605. if( pc_isdead(sd) ) {
  5606. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5607. return -1;
  5608. }
  5609. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5610. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5611. return -1;
  5612. }
  5613. sd->state.autotrade = 1;
  5614. if (battle_config.autotrade_monsterignore)
  5615. sd->state.block_action |= PCBLOCK_IMMUNE;
  5616. if( sd->state.vending ){
  5617. vending_update(*sd);
  5618. }else if( sd->state.buyingstore ){
  5619. buyingstore_update(*sd);
  5620. }
  5621. if( battle_config.at_timeout ) {
  5622. int32 timeout = atoi(message);
  5623. status_change_start(nullptr,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
  5624. }
  5625. if (battle_config.at_logout_event)
  5626. npc_script_event( *sd, NPCE_LOGOUT );
  5627. channel_pcquit(sd,0xF); //leave all chan
  5628. clif_authfail_fd(sd->fd, 15);
  5629. chrif_save(sd, CSAVE_AUTOTRADE);
  5630. return 0;
  5631. }
  5632. /*==========================================
  5633. * @changegm by durf (changed by Lupus)
  5634. * Changes Master of your Guild to a specified guild member
  5635. *------------------------------------------*/
  5636. ACMD_FUNC(changegm)
  5637. {
  5638. map_session_data *pl_sd;
  5639. nullpo_retr(-1, sd);
  5640. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5641. if (sd->status.guild_id == 0 || sd->guild == nullptr || strcmp(sd->guild->guild.master,sd->status.name)) {
  5642. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5643. return -1;
  5644. }
  5645. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5646. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5647. return -1;
  5648. }
  5649. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5650. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5651. return -1;
  5652. }
  5653. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr || pl_sd->status.guild_id != sd->status.guild_id) {
  5654. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5655. return -1;
  5656. }
  5657. if( !battle_config.guild_leaderchange_woe && is_agit_start() ){
  5658. #if PACKETVER >= 20151001
  5659. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_IN_SIEGE_TIME);
  5660. #else
  5661. clif_displaymessage(fd, msg_txt(sd,1513)); // Currently in WoE hours, unable to delegate Guild leader
  5662. #endif
  5663. return -1;
  5664. }
  5665. if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(nullptr),sd->guild->guild.last_leader_change) < battle_config.guild_leaderchange_delay ){
  5666. #if PACKETVER >= 20151001
  5667. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_NOT_TIME);
  5668. #else
  5669. clif_displaymessage(fd, msg_txt(sd,1514)); // You have to wait for a while before delegating a new Guild leader
  5670. #endif
  5671. return -1;
  5672. }
  5673. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5674. return 0;
  5675. }
  5676. /*==========================================
  5677. * @changeleader by Skotlex
  5678. * Changes the leader of a party.
  5679. *------------------------------------------*/
  5680. ACMD_FUNC(changeleader)
  5681. {
  5682. nullpo_retr(-1, sd);
  5683. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5684. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5685. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5686. return -1;
  5687. }
  5688. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),nullptr);
  5689. return 0;
  5690. }
  5691. /*==========================================
  5692. * @partyoption by Skotlex
  5693. * Used to change the item share setting of a party.
  5694. *------------------------------------------*/
  5695. ACMD_FUNC(partyoption)
  5696. {
  5697. struct party_data *p;
  5698. int32 mi, option;
  5699. char w1[16], w2[16];
  5700. nullpo_retr(-1, sd);
  5701. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == nullptr)
  5702. {
  5703. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5704. return -1;
  5705. }
  5706. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5707. if (mi == MAX_PARTY)
  5708. return -1; //Shouldn't happen
  5709. if (!p->party.member[mi].leader)
  5710. {
  5711. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5712. return -1;
  5713. }
  5714. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5715. {
  5716. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5717. return -1;
  5718. }
  5719. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5720. //Change item share type.
  5721. if (option != p->party.item)
  5722. party_changeoption(sd, p->party.exp, option);
  5723. else
  5724. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5725. return 0;
  5726. }
  5727. /*==========================================
  5728. * @autoloot by Upa-Kun
  5729. * Turns on/off AutoLoot for a specific player
  5730. *------------------------------------------*/
  5731. ACMD_FUNC(autoloot)
  5732. {
  5733. int32 rate;
  5734. nullpo_retr(-1, sd);
  5735. // autoloot command without value
  5736. if(!message || !*message)
  5737. {
  5738. if (sd->state.autoloot)
  5739. rate = 0;
  5740. else
  5741. rate = 10000;
  5742. } else {
  5743. double drate;
  5744. drate = atof(message);
  5745. rate = (int32)(drate*100);
  5746. }
  5747. if (rate < 0) rate = 0;
  5748. if (rate > 10000) rate = 10000;
  5749. sd->state.autoloot = rate;
  5750. if (sd->state.autoloot) {
  5751. 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.
  5752. clif_displaymessage(fd, atcmd_output);
  5753. }else
  5754. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5755. return 0;
  5756. }
  5757. /*==========================================
  5758. * @alootid
  5759. *------------------------------------------*/
  5760. ACMD_FUNC(autolootitem)
  5761. {
  5762. std::shared_ptr<item_data> item_data;
  5763. int32 i;
  5764. int32 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5765. nullpo_retr(-1, sd);
  5766. if (message && *message) {
  5767. if (message[0] == '+') {
  5768. message++;
  5769. action = 1;
  5770. }
  5771. else if (message[0] == '-') {
  5772. message++;
  5773. action = 2;
  5774. }
  5775. else if (!strcmp(message,"reset"))
  5776. action = 4;
  5777. }
  5778. if (action < 3) // add or remove
  5779. {
  5780. item_data = item_db.find( strtoul( message, nullptr, 10 ) );
  5781. if( item_data == nullptr ){
  5782. item_data = item_db.searchname( message );
  5783. }
  5784. if( item_data == nullptr ){
  5785. // No items founds in the DB with Id or Name
  5786. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5787. return -1;
  5788. }
  5789. }
  5790. switch(action) {
  5791. case 1:
  5792. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5793. if (i != AUTOLOOTITEM_SIZE) {
  5794. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5795. return -1;
  5796. }
  5797. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5798. if (i == AUTOLOOTITEM_SIZE) {
  5799. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5800. return -1;
  5801. }
  5802. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5803. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid); // Autolooting item: '%s'/'%s' {%u}
  5804. clif_displaymessage(fd, atcmd_output);
  5805. sd->state.autolooting = 1;
  5806. break;
  5807. case 2:
  5808. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5809. if (i == AUTOLOOTITEM_SIZE) {
  5810. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5811. return -1;
  5812. }
  5813. sd->state.autolootid[i] = 0;
  5814. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid); // Removed item: '%s'/'%s' {%u} from your autolootitem list.
  5815. clif_displaymessage(fd, atcmd_output);
  5816. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5817. if (i == AUTOLOOTITEM_SIZE) {
  5818. sd->state.autolooting = 0;
  5819. }
  5820. break;
  5821. case 3:
  5822. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5823. clif_displaymessage(fd, atcmd_output);
  5824. 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>".
  5825. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5826. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5827. if (i == AUTOLOOTITEM_SIZE) {
  5828. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5829. } else {
  5830. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5831. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5832. {
  5833. if (sd->state.autolootid[i] == 0)
  5834. continue;
  5835. item_data = item_db.find( sd->state.autolootid[i] );
  5836. if( item_data == nullptr ){
  5837. 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);
  5838. continue;
  5839. }
  5840. sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid);
  5841. clif_displaymessage(fd, atcmd_output);
  5842. }
  5843. }
  5844. break;
  5845. case 4:
  5846. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5847. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5848. sd->state.autolooting = 0;
  5849. break;
  5850. }
  5851. return 0;
  5852. }
  5853. /*==========================================
  5854. * @autoloottype
  5855. * Flags:
  5856. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5857. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5858. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5859. * 262144: IT_CASH
  5860. *------------------------------------------
  5861. * Credits:
  5862. * chriser
  5863. * Aleos
  5864. *------------------------------------------*/
  5865. ACMD_FUNC(autoloottype)
  5866. {
  5867. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5868. enum item_types type= IT_UNKNOWN;
  5869. int32 ITEM_MAX = 1533;
  5870. nullpo_retr(-1, sd);
  5871. if (message && *message) {
  5872. if (message[0] == '+') {
  5873. message++;
  5874. action = 1;
  5875. }
  5876. else if (message[0] == '-') {
  5877. message++;
  5878. action = 2;
  5879. }
  5880. else if (!strcmp(message,"reset"))
  5881. action = 4;
  5882. }
  5883. if (action < 3) { // add or remove
  5884. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5885. type = IT_HEALING;
  5886. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5887. type = IT_USABLE;
  5888. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5889. type = IT_ETC;
  5890. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5891. type = IT_ARMOR;
  5892. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5893. type = IT_WEAPON;
  5894. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5895. type = IT_CARD;
  5896. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5897. type = IT_PETEGG;
  5898. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5899. type = IT_PETARMOR;
  5900. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5901. type = IT_AMMO;
  5902. else {
  5903. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5904. return -1;
  5905. }
  5906. }
  5907. switch (action) {
  5908. case 1:
  5909. if (sd->state.autoloottype&(1<<type)) {
  5910. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5911. return -1;
  5912. }
  5913. if (sd->state.autoloottype == ITEM_MAX) {
  5914. 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>.
  5915. return -1;
  5916. }
  5917. sd->state.autoloottype |= (1<<type); // Stores the type
  5918. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%u}
  5919. clif_displaymessage(fd, atcmd_output);
  5920. break;
  5921. case 2:
  5922. if (!(sd->state.autoloottype&(1<<type))) {
  5923. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5924. return -1;
  5925. }
  5926. sd->state.autoloottype &= ~(1<<type);
  5927. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%u} from your autoloottype list.
  5928. clif_displaymessage(fd, atcmd_output);
  5929. break;
  5930. case 3:
  5931. 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>".
  5932. 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
  5933. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5934. if (sd->state.autoloottype == 0)
  5935. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5936. else {
  5937. uint8 i = 0;
  5938. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5939. while (i < IT_MAX) {
  5940. if (sd->state.autoloottype&(1<<i)) {
  5941. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5942. clif_displaymessage(fd, atcmd_output);
  5943. }
  5944. i++;
  5945. }
  5946. }
  5947. break;
  5948. case 4:
  5949. sd->state.autoloottype = 0;
  5950. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5951. break;
  5952. }
  5953. return 0;
  5954. }
  5955. /*==========================================
  5956. * It is made to rain.
  5957. * No longer available, keeping here just in case it's back someday. [Ind]
  5958. *------------------------------------------*/
  5959. //ACMD_FUNC(rain)
  5960. //{
  5961. // nullpo_retr(-1, sd);
  5962. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5963. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5964. // clif_weather(sd->bl.m);
  5965. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5966. // } else {
  5967. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5968. // clif_weather(sd->bl.m);
  5969. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5970. // }
  5971. // return 0;
  5972. //}
  5973. /*==========================================
  5974. * It is made to snow.
  5975. *------------------------------------------*/
  5976. ACMD_FUNC(snow)
  5977. {
  5978. nullpo_retr(-1, sd);
  5979. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5980. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5981. clif_weather(sd->bl.m);
  5982. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5983. } else {
  5984. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5985. clif_weather(sd->bl.m);
  5986. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5987. }
  5988. return 0;
  5989. }
  5990. /*==========================================
  5991. * Cherry tree snowstorm is made to fall. (Sakura)
  5992. *------------------------------------------*/
  5993. ACMD_FUNC(sakura)
  5994. {
  5995. nullpo_retr(-1, sd);
  5996. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5997. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5998. clif_weather(sd->bl.m);
  5999. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  6000. } else {
  6001. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  6002. clif_weather(sd->bl.m);
  6003. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  6004. }
  6005. return 0;
  6006. }
  6007. /*==========================================
  6008. * Clouds appear.
  6009. *------------------------------------------*/
  6010. ACMD_FUNC(clouds)
  6011. {
  6012. nullpo_retr(-1, sd);
  6013. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  6014. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  6015. clif_weather(sd->bl.m);
  6016. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  6017. } else {
  6018. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  6019. clif_weather(sd->bl.m);
  6020. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  6021. }
  6022. return 0;
  6023. }
  6024. /*==========================================
  6025. * Different type of clouds using effect 516
  6026. *------------------------------------------*/
  6027. ACMD_FUNC(clouds2)
  6028. {
  6029. nullpo_retr(-1, sd);
  6030. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  6031. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  6032. clif_weather(sd->bl.m);
  6033. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  6034. } else {
  6035. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  6036. clif_weather(sd->bl.m);
  6037. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  6038. }
  6039. return 0;
  6040. }
  6041. /*==========================================
  6042. * Fog hangs over.
  6043. *------------------------------------------*/
  6044. ACMD_FUNC(fog)
  6045. {
  6046. nullpo_retr(-1, sd);
  6047. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  6048. map_setmapflag(sd->bl.m, MF_FOG, false);
  6049. clif_weather(sd->bl.m);
  6050. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  6051. } else {
  6052. map_setmapflag(sd->bl.m, MF_FOG, true);
  6053. clif_weather(sd->bl.m);
  6054. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  6055. }
  6056. return 0;
  6057. }
  6058. /*==========================================
  6059. * Fallen leaves fall.
  6060. *------------------------------------------*/
  6061. ACMD_FUNC(leaves)
  6062. {
  6063. nullpo_retr(-1, sd);
  6064. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  6065. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6066. clif_weather(sd->bl.m);
  6067. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  6068. } else {
  6069. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  6070. clif_weather(sd->bl.m);
  6071. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  6072. }
  6073. return 0;
  6074. }
  6075. /*==========================================
  6076. * Fireworks appear.
  6077. *------------------------------------------*/
  6078. ACMD_FUNC(fireworks)
  6079. {
  6080. nullpo_retr(-1, sd);
  6081. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  6082. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6083. clif_weather(sd->bl.m);
  6084. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  6085. } else {
  6086. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  6087. clif_weather(sd->bl.m);
  6088. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  6089. }
  6090. return 0;
  6091. }
  6092. /*==========================================
  6093. * Clearing Weather Effects by Dexity
  6094. *------------------------------------------*/
  6095. ACMD_FUNC(clearweather)
  6096. {
  6097. nullpo_retr(-1, sd);
  6098. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  6099. map_setmapflag(sd->bl.m, MF_SNOW, false);
  6100. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  6101. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  6102. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  6103. map_setmapflag(sd->bl.m, MF_FOG, false);
  6104. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6105. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6106. clif_weather(sd->bl.m);
  6107. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  6108. return 0;
  6109. }
  6110. /*===============================================================
  6111. * Sound Command - plays a sound for everyone around! [Codemaster]
  6112. *---------------------------------------------------------------*/
  6113. ACMD_FUNC(sound)
  6114. {
  6115. char sound_file[100];
  6116. memset(sound_file, '\0', sizeof(sound_file));
  6117. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6118. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  6119. return -1;
  6120. }
  6121. if(strstr(sound_file, ".wav") == nullptr)
  6122. strcat(sound_file, ".wav");
  6123. clif_soundeffect( sd->bl, sound_file, 0, AREA );
  6124. return 0;
  6125. }
  6126. /*==========================================
  6127. * MOB Search
  6128. *------------------------------------------*/
  6129. ACMD_FUNC(mobsearch)
  6130. {
  6131. nullpo_retr(-1, sd);
  6132. char mob_name[100]={0};
  6133. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6134. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  6135. return -1;
  6136. }
  6137. int32 mob_id = strtol(mob_name, nullptr, 10);
  6138. if (mob_id == 0)
  6139. mob_id = mobdb_searchname(mob_name);
  6140. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6141. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6142. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  6143. clif_displaymessage(fd, atcmd_output);
  6144. return -1;
  6145. }
  6146. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6147. // strcpy(mob_name, mob->name.c_str()); // --en--
  6148. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  6149. clif_displaymessage(fd, atcmd_output);
  6150. s_mapiterator* it = mapit_geteachmob();
  6151. int32 number = 0;
  6152. for(;;)
  6153. {
  6154. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6155. if( md == nullptr )
  6156. break;// no more mobs
  6157. if( md->bl.m != sd->bl.m )
  6158. continue;
  6159. if( md->mob_id != mob_id )
  6160. continue;
  6161. ++number;
  6162. if( md->spawn_timer == INVALID_TIMER )
  6163. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  6164. else
  6165. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  6166. clif_displaymessage(fd, atcmd_output);
  6167. }
  6168. mapit_free(it);
  6169. return 0;
  6170. }
  6171. /*==========================================
  6172. * @cleanmap - cleans items on the ground
  6173. * @cleanarea - cleans items on the ground within an specified area
  6174. *------------------------------------------*/
  6175. static int32 atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  6176. {
  6177. nullpo_ret(bl);
  6178. map_clearflooritem(bl);
  6179. return 0;
  6180. }
  6181. ACMD_FUNC(cleanmap)
  6182. {
  6183. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  6184. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6185. return 0;
  6186. }
  6187. ACMD_FUNC(cleanarea)
  6188. {
  6189. int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  6190. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  6191. 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);
  6192. }
  6193. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  6194. 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);
  6195. }
  6196. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  6197. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  6198. }
  6199. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6200. return 0;
  6201. }
  6202. /*==========================================
  6203. * make a NPC/PET talk
  6204. * @npctalkc [SnakeDrak]
  6205. *------------------------------------------*/
  6206. ACMD_FUNC(npctalk)
  6207. {
  6208. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  6209. struct npc_data *nd;
  6210. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  6211. unsigned long color=0;
  6212. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6213. return -1; //no "chatting" while muted.
  6214. if(!ifcolor) {
  6215. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  6216. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  6217. return -1;
  6218. }
  6219. }
  6220. else {
  6221. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6222. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  6223. return -1;
  6224. }
  6225. }
  6226. if (!(nd = npc_name2id(name))) {
  6227. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  6228. return -1;
  6229. }
  6230. strtok(name, "#"); // discard extra name identifier if present
  6231. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6232. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  6233. else clif_disp_overhead(&nd->bl, temp);
  6234. return 0;
  6235. }
  6236. ACMD_FUNC(pettalk)
  6237. {
  6238. char mes[100],temp[CHAT_SIZE_MAX];
  6239. struct pet_data *pd;
  6240. nullpo_retr(-1, sd);
  6241. if ( battle_config.min_chat_delay ) {
  6242. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6243. return 0;
  6244. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6245. }
  6246. if(!sd->status.pet_id || !(pd=sd->pd))
  6247. {
  6248. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  6249. return -1;
  6250. }
  6251. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6252. return -1; //no "chatting" while muted.
  6253. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6254. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  6255. return -1;
  6256. }
  6257. if (message[0] == '/')
  6258. {// pet emotion processing
  6259. const char* emo[] = {
  6260. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6261. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6262. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6263. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  6264. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  6265. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  6266. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  6267. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  6268. "/whisp"
  6269. };
  6270. int32 i;
  6271. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6272. if( i == ET_DICE1 ) i = rnd_value<int>(ET_DICE1, ET_DICE6); // randomize /dice
  6273. if( i < ARRAYLENGTH(emo) )
  6274. {
  6275. if (sd->emotionlasttime + 1 >= time(nullptr)) { // not more than 1 per second
  6276. sd->emotionlasttime = time(nullptr);
  6277. return 0;
  6278. }
  6279. sd->emotionlasttime = time(nullptr);
  6280. clif_emotion(&pd->bl, i);
  6281. return 0;
  6282. }
  6283. }
  6284. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6285. clif_disp_overhead(&pd->bl, temp);
  6286. return 0;
  6287. }
  6288. /// @users - displays the number of players present on each map (and percentage)
  6289. /// #users displays on the target user instead of self
  6290. ACMD_FUNC(users)
  6291. {
  6292. char buf[CHAT_SIZE_MAX];
  6293. int32 i;
  6294. int32 users[MAX_MAPINDEX];
  6295. int32 users_all;
  6296. struct s_mapiterator* iter;
  6297. memset(users, 0, sizeof(users));
  6298. users_all = 0;
  6299. // count users on each map
  6300. iter = mapit_getallusers();
  6301. for(;;)
  6302. {
  6303. map_session_data* sd2 = (map_session_data*)mapit_next(iter);
  6304. if( sd2 == nullptr )
  6305. break;// no more users
  6306. if( sd2->mapindex >= MAX_MAPINDEX )
  6307. continue;// invalid mapindex
  6308. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6309. if( users_all < INT_MAX ) ++users_all;
  6310. }
  6311. mapit_free(iter);
  6312. // display results for each map
  6313. for( i = 0; i < MAX_MAPINDEX; ++i )
  6314. {
  6315. if( users[i] == 0 )
  6316. continue;// empty
  6317. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6318. clif_displaymessage(sd->fd, buf);
  6319. }
  6320. // display overall count
  6321. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6322. clif_displaymessage(sd->fd, buf);
  6323. return 0;
  6324. }
  6325. /*==========================================
  6326. *
  6327. *------------------------------------------*/
  6328. ACMD_FUNC(reset)
  6329. {
  6330. pc_resetstate(sd);
  6331. pc_resetskill(sd,1);
  6332. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  6333. clif_displaymessage(fd, atcmd_output);
  6334. return 0;
  6335. }
  6336. /*==========================================
  6337. *
  6338. *------------------------------------------*/
  6339. ACMD_FUNC(summon)
  6340. {
  6341. char name[NAME_LENGTH];
  6342. int32 mob_id = 0;
  6343. int32 duration = 0;
  6344. struct mob_data *md;
  6345. t_tick tick=gettick();
  6346. nullpo_retr(-1, sd);
  6347. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  6348. {
  6349. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  6350. return -1;
  6351. }
  6352. if (duration < 1)
  6353. duration =1;
  6354. else if (duration > 60)
  6355. duration =60;
  6356. if ((mob_id = atoi(name)) == 0)
  6357. mob_id = mobdb_searchname(name);
  6358. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6359. {
  6360. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6361. return -1;
  6362. }
  6363. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  6364. if(!md)
  6365. return -1;
  6366. md->master_id=sd->bl.id;
  6367. md->special_state.ai=AI_ATTACK;
  6368. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6369. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  6370. mob_spawn(md);
  6371. sc_start4(nullptr,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6372. clif_skill_poseffect( sd->bl, AM_CALLHOMUN, 1, md->bl.x, md->bl.y, tick );
  6373. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  6374. return 0;
  6375. }
  6376. /*==========================================
  6377. * @adjgroup
  6378. * Temporarily move player to another group
  6379. * Useful during beta testing to allow players to use GM commands for short periods of time
  6380. *------------------------------------------*/
  6381. ACMD_FUNC(adjgroup)
  6382. {
  6383. int32 new_group = 0;
  6384. nullpo_retr(-1, sd);
  6385. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  6386. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  6387. return -1;
  6388. }
  6389. if (!player_group_db.exists(new_group)) {
  6390. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  6391. return -1;
  6392. }
  6393. sd->group_id = new_group;
  6394. pc_group_pc_load(sd);/* update cache */
  6395. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  6396. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  6397. return 0;
  6398. }
  6399. /*==========================================
  6400. * @trade by [MouseJstr]
  6401. * Open a trade window with a remote player
  6402. *------------------------------------------*/
  6403. ACMD_FUNC(trade)
  6404. {
  6405. map_session_data* pl_sd = nullptr;;
  6406. nullpo_retr(-1, sd);
  6407. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6408. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6409. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  6410. return -1;
  6411. }
  6412. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  6413. {
  6414. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6415. return -1;
  6416. }
  6417. trade_traderequest(sd, pl_sd);
  6418. return 0;
  6419. }
  6420. /*==========================================
  6421. * @setbattleflag by [MouseJstr]
  6422. * set a battle_config flag without having to reboot
  6423. *------------------------------------------*/
  6424. ACMD_FUNC(setbattleflag)
  6425. {
  6426. char flag[128], value[128];
  6427. int32 reload = 0;
  6428. nullpo_retr(-1, sd);
  6429. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) < 2) {
  6430. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  6431. return -1;
  6432. }
  6433. if (battle_set_value(flag, value) == 0)
  6434. {
  6435. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  6436. return -1;
  6437. }
  6438. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  6439. if (reload)
  6440. mob_reload();
  6441. return 0;
  6442. }
  6443. /*==========================================
  6444. * @unmute [Valaris]
  6445. *------------------------------------------*/
  6446. ACMD_FUNC(unmute)
  6447. {
  6448. map_session_data* pl_sd = nullptr;;
  6449. nullpo_retr(-1, sd);
  6450. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6451. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6452. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6453. return -1;
  6454. }
  6455. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6456. {
  6457. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6458. return -1;
  6459. }
  6460. if(!pl_sd->sc.getSCE(SC_NOCHAT)) {
  6461. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6462. return -1;
  6463. }
  6464. pl_sd->status.manner = 0;
  6465. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6466. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6467. return 0;
  6468. }
  6469. /*==========================================
  6470. * @uptime by MC Cameri
  6471. *------------------------------------------*/
  6472. ACMD_FUNC(uptime)
  6473. {
  6474. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6475. minute = 60, days = 0, hours = 0, minutes = 0;
  6476. nullpo_retr(-1, sd);
  6477. seconds = get_uptime();
  6478. days = seconds/day;
  6479. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6480. hours = seconds/hour;
  6481. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6482. minutes = seconds/minute;
  6483. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6484. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  6485. clif_displaymessage(fd, atcmd_output);
  6486. return 0;
  6487. }
  6488. /*==========================================
  6489. * @changesex
  6490. * => Changes one's account sex. Switch from male to female or visversa
  6491. *------------------------------------------*/
  6492. ACMD_FUNC(changesex)
  6493. {
  6494. int32 i;
  6495. nullpo_retr(-1, sd);
  6496. pc_resetskill(sd,4);
  6497. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6498. for (i = 0; i < EQI_MAX; i++) {
  6499. if (sd->equip_index[i] >= 0)
  6500. pc_unequipitem(sd, sd->equip_index[i], 3);
  6501. }
  6502. chrif_changesex(sd, true);
  6503. return 0;
  6504. }
  6505. /*==========================================
  6506. * @changecharsex
  6507. * => Changes one's character sex. Switch from male to female or visversa.
  6508. *------------------------------------------*/
  6509. ACMD_FUNC(changecharsex)
  6510. {
  6511. int32 i;
  6512. nullpo_retr(-1, sd);
  6513. pc_resetskill(sd,4);
  6514. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6515. for (i = 0; i < EQI_MAX; i++) {
  6516. if (sd->equip_index[i] >= 0)
  6517. pc_unequipitem(sd, sd->equip_index[i], 3);
  6518. }
  6519. chrif_changesex(sd, false);
  6520. return 0;
  6521. }
  6522. /*================================================
  6523. * @mute - Mutes a player for a set amount of time
  6524. *------------------------------------------------*/
  6525. ACMD_FUNC(mute)
  6526. {
  6527. map_session_data* pl_sd = nullptr;;
  6528. int32 manner;
  6529. nullpo_retr(-1, sd);
  6530. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6531. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6532. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6533. return -1;
  6534. }
  6535. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6536. {
  6537. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6538. return -1;
  6539. }
  6540. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6541. {
  6542. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6543. return -1;
  6544. }
  6545. clif_manner_message(sd, 0);
  6546. clif_manner_message(pl_sd, 5);
  6547. if( pl_sd->status.manner < manner ) {
  6548. pl_sd->status.manner -= manner;
  6549. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6550. } else {
  6551. pl_sd->status.manner = 0;
  6552. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6553. }
  6554. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6555. return 0;
  6556. }
  6557. /*==========================================
  6558. * @refresh (like @jumpto <<yourself>>)
  6559. *------------------------------------------*/
  6560. ACMD_FUNC(refresh)
  6561. {
  6562. nullpo_retr(-1, sd);
  6563. clif_refresh(sd);
  6564. return 0;
  6565. }
  6566. ACMD_FUNC(refreshall)
  6567. {
  6568. map_session_data* iter_sd;
  6569. struct s_mapiterator* iter;
  6570. nullpo_retr(-1, sd);
  6571. iter = mapit_getallusers();
  6572. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6573. clif_refresh(iter_sd);
  6574. mapit_free(iter);
  6575. return 0;
  6576. }
  6577. /*==========================================
  6578. * @identify
  6579. * => GM's magnifier.
  6580. *------------------------------------------*/
  6581. ACMD_FUNC(identify)
  6582. {
  6583. int32 i,num;
  6584. nullpo_retr(-1, sd);
  6585. for(i=num=0;i<MAX_INVENTORY;i++){
  6586. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6587. num++;
  6588. }
  6589. }
  6590. if (num > 0) {
  6591. clif_item_identify_list(sd);
  6592. } else {
  6593. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6594. }
  6595. return 0;
  6596. }
  6597. /*===============================================
  6598. * @identifyall
  6599. * => Indentify all items in inventory - Akinari
  6600. *-----------------------------------------------*/
  6601. ACMD_FUNC(identifyall)
  6602. {
  6603. nullpo_retr(-1, sd);
  6604. pc_identifyall(sd, true);
  6605. return 0;
  6606. }
  6607. /*==========================================
  6608. * @gmotd (Global MOTD)
  6609. * by davidsiaw :P
  6610. *------------------------------------------*/
  6611. ACMD_FUNC(gmotd)
  6612. {
  6613. FILE* fp;
  6614. if( ( fp = fopen(motd_txt, "r") ) != nullptr )
  6615. {
  6616. char buf[CHAT_SIZE_MAX];
  6617. size_t len;
  6618. while( fgets(buf, sizeof(buf), fp) )
  6619. {
  6620. if( buf[0] == '/' && buf[1] == '/' )
  6621. {
  6622. continue;
  6623. }
  6624. len = strlen(buf);
  6625. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6626. {// strip trailing EOL characters
  6627. len--;
  6628. }
  6629. if( len )
  6630. {
  6631. buf[len] = 0;
  6632. intif_broadcast(buf, len+1, 0);
  6633. }
  6634. }
  6635. fclose(fp);
  6636. }
  6637. return 0;
  6638. }
  6639. ACMD_FUNC(misceffect)
  6640. {
  6641. int32 effect = 0;
  6642. nullpo_retr(-1, sd);
  6643. if (!message || !*message)
  6644. return -1;
  6645. if (sscanf(message, "%11d", &effect) < 1)
  6646. return -1;
  6647. if (effect < NOTIFYEFFECT_BASE_LEVEL_UP || effect > NOTIFYEFFECT_TAEKWON_BASE_LEVEL_UP)
  6648. return -1;
  6649. clif_misceffect( sd->bl, static_cast<e_notify_effect>(effect) );
  6650. return 0;
  6651. }
  6652. /*==========================================
  6653. * MAIL SYSTEM
  6654. *------------------------------------------*/
  6655. ACMD_FUNC(mail)
  6656. {
  6657. nullpo_ret(sd);
  6658. mail_openmail(sd);
  6659. return 0;
  6660. }
  6661. /*==========================================
  6662. * Show Monster DB Info v 1.0
  6663. * originally by [Lupus]
  6664. *------------------------------------------*/
  6665. ACMD_FUNC(mobinfo)
  6666. {
  6667. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6668. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6669. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6670. char atcmd_output2[CHAT_SIZE_MAX];
  6671. uint16 mob_ids[MAX_SEARCH], count;
  6672. uint16 i;
  6673. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6674. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6675. if (!message || !*message) {
  6676. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6677. return -1;
  6678. }
  6679. // If monster identifier/name argument is a name
  6680. i = util::strtoint32def(message);
  6681. if (i != 0 && (i = mobdb_checkid(i)))
  6682. {
  6683. mob_ids[0] = i;
  6684. count = 1;
  6685. } else
  6686. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6687. if (!count) {
  6688. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6689. return -1;
  6690. }
  6691. if (count >= MAX_SEARCH) {
  6692. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6693. clif_displaymessage(fd, atcmd_output);
  6694. count = MAX_SEARCH;
  6695. }
  6696. for (uint16 k = 0; k < count; k++) {
  6697. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_ids[k]);
  6698. if (mob == nullptr)
  6699. continue;
  6700. t_exp base_exp = mob->base_exp;
  6701. t_exp job_exp = mob->job_exp;
  6702. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6703. base_exp += (base_exp * battle_config.vip_base_exp_increase) / 100;
  6704. job_exp += (job_exp * battle_config.vip_job_exp_increase) / 100;
  6705. }
  6706. #ifdef RENEWAL_EXP
  6707. if( battle_config.atcommand_mobinfo_type ) {
  6708. int32 penalty = pc_level_penalty_mod( sd, PENALTY_EXP, mob );
  6709. base_exp = base_exp * penalty / 100;
  6710. job_exp = job_exp * penalty / 100;
  6711. }
  6712. #endif
  6713. // stats
  6714. if( mob->get_bosstype() == BOSSTYPE_MVP )
  6715. sprintf(atcmd_output, msg_txt(sd,1240), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->id); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6716. else
  6717. sprintf(atcmd_output, msg_txt(sd,1241), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->id); // Monster: '%s'/'%s'/'%s' (%d)
  6718. clif_displaymessage(fd, atcmd_output);
  6719. 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:%llu Job EXP:%llu HIT:%d FLEE:%d
  6720. clif_displaymessage(fd, atcmd_output);
  6721. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6722. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6723. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6724. clif_displaymessage(fd, atcmd_output);
  6725. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6726. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6727. mob->range2 , mob->range3, msize[mob->status.size],
  6728. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6729. clif_displaymessage(fd, atcmd_output);
  6730. #ifdef RENEWAL
  6731. sprintf(atcmd_output, msg_txt(sd, 827), mob->status.res, mob->status.mres);// MDEF:%d RES:%d MRES:%d
  6732. clif_displaymessage(fd, atcmd_output);
  6733. #endif
  6734. // drops
  6735. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6736. strcpy(atcmd_output, " ");
  6737. uint32 j = 0;
  6738. int32 drop_modifier = 100;
  6739. #ifdef RENEWAL_DROP
  6740. if( battle_config.atcommand_mobinfo_type ){
  6741. drop_modifier = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
  6742. }
  6743. #endif
  6744. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6745. if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].rate < 1)
  6746. continue;
  6747. std::shared_ptr<item_data> id = item_db.find(mob->dropitem[i].nameid);
  6748. if (id == nullptr)
  6749. continue;
  6750. int32 droprate = mob_getdroprate( &sd->bl, mob, mob->dropitem[i].rate, drop_modifier );
  6751. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), (float)droprate / 100);
  6752. strcat(atcmd_output, atcmd_output2);
  6753. if (++j % 3 == 0) {
  6754. clif_displaymessage(fd, atcmd_output);
  6755. strcpy(atcmd_output, " ");
  6756. }
  6757. }
  6758. if (j == 0)
  6759. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6760. else if (j % 3 != 0)
  6761. clif_displaymessage(fd, atcmd_output);
  6762. // mvp
  6763. if( mob->get_bosstype() == BOSSTYPE_MVP ){
  6764. float mvppercent, mvpremain;
  6765. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%llu
  6766. clif_displaymessage(fd, atcmd_output);
  6767. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6768. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6769. j = 0;
  6770. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6771. if (mob->mvpitem[i].nameid == 0)
  6772. continue;
  6773. std::shared_ptr<item_data> id = item_db.find(mob->mvpitem[i].nameid);
  6774. if (id == nullptr)
  6775. continue;
  6776. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6777. mvppercent = (float)mob->mvpitem[i].rate * mvpremain / 10000.0f;
  6778. if(battle_config.item_drop_mvp_mode == 0) {
  6779. mvpremain -= mvppercent;
  6780. }
  6781. if (mvppercent > 0) {
  6782. j++;
  6783. if (j == 1) {
  6784. sprintf(atcmd_output2, " %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6785. } else {
  6786. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6787. }
  6788. strcat(atcmd_output, atcmd_output2);
  6789. }
  6790. }
  6791. if (j == 0)
  6792. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6793. else
  6794. clif_displaymessage(fd, atcmd_output);
  6795. }
  6796. }
  6797. return 0;
  6798. }
  6799. /*=========================================
  6800. * @showmobs by KarLaeda
  6801. * => For 15 sec displays the mobs on minimap
  6802. *------------------------------------------*/
  6803. ACMD_FUNC(showmobs)
  6804. {
  6805. char mob_name[100];
  6806. int32 mob_id;
  6807. int32 number = 0;
  6808. struct s_mapiterator* it;
  6809. nullpo_retr(-1, sd);
  6810. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6811. return -1;
  6812. if((mob_id = strtol(mob_name, nullptr, 10)) == 0)
  6813. mob_id = mobdb_searchname(mob_name);
  6814. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6815. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6816. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6817. clif_displaymessage(fd, atcmd_output);
  6818. return 0;
  6819. }
  6820. if(status_has_mode(&mob->status,MD_STATUSIMMUNE) && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6821. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6822. return 0;
  6823. }
  6824. if(mob_id == strtol(mob_name, nullptr, 10) && !mob->jname.empty())
  6825. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6826. //strcpy(mob_name, mob->name.c_str()); // --en--
  6827. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6828. mob_name, mapindex_id2name(sd->mapindex));
  6829. clif_displaymessage(fd, atcmd_output);
  6830. it = mapit_geteachmob();
  6831. for(;;)
  6832. {
  6833. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6834. if( md == nullptr )
  6835. break;// no more mobs
  6836. if( md->bl.m != sd->bl.m )
  6837. continue;
  6838. if( mob_id != -1 && md->mob_id != mob_id )
  6839. continue;
  6840. if( md->special_state.ai || md->master_id )
  6841. continue; // hide slaves and player summoned mobs
  6842. if( md->spawn_timer != INVALID_TIMER )
  6843. continue; // hide mobs waiting for respawn
  6844. ++number;
  6845. clif_viewpoint( *sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF );
  6846. }
  6847. mapit_free(it);
  6848. return 0;
  6849. }
  6850. /*==========================================
  6851. * homunculus level up [orn]
  6852. *------------------------------------------*/
  6853. ACMD_FUNC(homlevel)
  6854. {
  6855. TBL_HOM * hd;
  6856. int32 level = 0, i = 0;
  6857. nullpo_retr(-1, sd);
  6858. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6859. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6860. return -1;
  6861. }
  6862. if ( !hom_is_active(sd->hd) ) {
  6863. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6864. return -1;
  6865. }
  6866. hd = sd->hd;
  6867. for (i = 1; i <= level && hd->exp_next; i++){
  6868. hd->homunculus.exp += hd->exp_next;
  6869. if( !hom_levelup(hd) )
  6870. break;
  6871. }
  6872. status_calc_homunculus(hd, SCO_NONE);
  6873. status_percent_heal(&hd->bl, 100, 100);
  6874. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6875. return 0;
  6876. }
  6877. /*==========================================
  6878. * homunculus evolution H [orn]
  6879. *------------------------------------------*/
  6880. ACMD_FUNC(homevolution)
  6881. {
  6882. nullpo_retr(-1, sd);
  6883. if ( !hom_is_active(sd->hd) ) {
  6884. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6885. return -1;
  6886. }
  6887. if ( !hom_evolution(sd->hd) ) {
  6888. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6889. return -1;
  6890. }
  6891. clif_homskillinfoblock( *sd->hd );
  6892. return 0;
  6893. }
  6894. ACMD_FUNC(hommutate)
  6895. {
  6896. int32 homun_id, m_class = 0, m_id;
  6897. nullpo_retr(-1, sd);
  6898. if (!hom_is_active(sd->hd)) {
  6899. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6900. return -1;
  6901. }
  6902. if (!message || !*message) {
  6903. homun_id = rnd_value<uint16>(MER_EIRA, MER_ELEANOR);
  6904. } else {
  6905. homun_id = atoi(message);
  6906. }
  6907. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6908. m_id = hom_class2mapid(homun_id);
  6909. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6910. hom_mutate(sd->hd, homun_id);
  6911. } else {
  6912. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6913. }
  6914. return 0;
  6915. }
  6916. /*==========================================
  6917. * call choosen homunculus [orn]
  6918. *------------------------------------------*/
  6919. ACMD_FUNC(makehomun)
  6920. {
  6921. int32 homunid;
  6922. nullpo_retr(-1, sd);
  6923. if ( sd->status.hom_id ) {
  6924. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6925. return -1;
  6926. }
  6927. if (!message || !*message) {
  6928. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6929. return -1;
  6930. }
  6931. homunid = atoi(message);
  6932. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6933. {
  6934. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6935. return -1;
  6936. }
  6937. hom_create_request(sd,homunid);
  6938. return 0;
  6939. }
  6940. /*==========================================
  6941. * modify homunculus intimacy [orn]
  6942. *------------------------------------------*/
  6943. ACMD_FUNC(homfriendly)
  6944. {
  6945. int32 friendly = 0;
  6946. nullpo_retr(-1, sd);
  6947. if ( !hom_is_active(sd->hd) ) {
  6948. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6949. return -1;
  6950. }
  6951. if (!message || !*message) {
  6952. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6953. return -1;
  6954. }
  6955. friendly = atoi(message);
  6956. friendly = cap_value(friendly, 0, 1000);
  6957. sd->hd->homunculus.intimacy = friendly * 100 ;
  6958. clif_send_homdata( *sd->hd, SP_INTIMATE );
  6959. return 0;
  6960. }
  6961. /*==========================================
  6962. * modify homunculus hunger [orn]
  6963. *------------------------------------------*/
  6964. ACMD_FUNC(homhungry)
  6965. {
  6966. int32 hungry = 0;
  6967. nullpo_retr(-1, sd);
  6968. if ( !hom_is_active(sd->hd) ) {
  6969. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6970. return -1;
  6971. }
  6972. if (!message || !*message) {
  6973. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6974. return -1;
  6975. }
  6976. hungry = atoi(message);
  6977. hungry = cap_value(hungry, 0, 100);
  6978. sd->hd->homunculus.hunger = hungry;
  6979. clif_send_homdata( *sd->hd, SP_HUNGRY );
  6980. return 0;
  6981. }
  6982. /*==========================================
  6983. * make the homunculus speak [orn]
  6984. *------------------------------------------*/
  6985. ACMD_FUNC(homtalk)
  6986. {
  6987. char mes[100],temp[CHAT_SIZE_MAX];
  6988. nullpo_retr(-1, sd);
  6989. if ( battle_config.min_chat_delay ) {
  6990. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6991. return 0;
  6992. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6993. }
  6994. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6995. return -1; //no "chatting" while muted.
  6996. if ( !hom_is_active(sd->hd) ) {
  6997. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6998. return -1;
  6999. }
  7000. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  7001. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  7002. return -1;
  7003. }
  7004. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  7005. clif_disp_overhead(&sd->hd->bl, temp);
  7006. return 0;
  7007. }
  7008. /*==========================================
  7009. * Show homunculus stats
  7010. *------------------------------------------*/
  7011. ACMD_FUNC(hominfo)
  7012. {
  7013. struct homun_data *hd;
  7014. nullpo_retr(-1, sd);
  7015. if ( !hom_is_active(sd->hd) ) {
  7016. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7017. return -1;
  7018. }
  7019. hd = sd->hd;
  7020. status_data* status = status_get_status_data(hd->bl);
  7021. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  7022. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  7023. status->hp, status->max_hp, status->sp, status->max_sp);
  7024. clif_displaymessage(fd, atcmd_output);
  7025. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  7026. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  7027. clif_displaymessage(fd, atcmd_output);
  7028. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  7029. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  7030. clif_displaymessage(fd, atcmd_output);
  7031. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7032. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  7033. status->str, status->agi, status->vit,
  7034. status->int_, status->dex, status->luk);
  7035. clif_displaymessage(fd, atcmd_output);
  7036. return 0;
  7037. }
  7038. ACMD_FUNC(homstats)
  7039. {
  7040. struct homun_data *hd;
  7041. std::shared_ptr<s_homunculus_db> db;
  7042. struct s_homunculus *hom;
  7043. int32 lv, min, max, evo;
  7044. nullpo_retr(-1, sd);
  7045. if ( !hom_is_active(sd->hd) ) {
  7046. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7047. return -1;
  7048. }
  7049. hd = sd->hd;
  7050. hom = &hd->homunculus;
  7051. db = hd->homunculusDB;
  7052. lv = hom->level;
  7053. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7054. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  7055. clif_displaymessage(fd, atcmd_output);
  7056. lv--; //Since the first increase is at level 2.
  7057. evo = (hom->class_ == db->evo_class);
  7058. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  7059. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  7060. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  7061. clif_displaymessage(fd, atcmd_output);
  7062. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  7063. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  7064. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  7065. clif_displaymessage(fd, atcmd_output);
  7066. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  7067. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  7068. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  7069. clif_displaymessage(fd, atcmd_output);
  7070. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  7071. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  7072. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  7073. clif_displaymessage(fd, atcmd_output);
  7074. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  7075. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  7076. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  7077. clif_displaymessage(fd, atcmd_output);
  7078. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  7079. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  7080. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  7081. clif_displaymessage(fd, atcmd_output);
  7082. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  7083. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  7084. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  7085. clif_displaymessage(fd, atcmd_output);
  7086. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  7087. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  7088. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  7089. clif_displaymessage(fd, atcmd_output);
  7090. return 0;
  7091. }
  7092. ACMD_FUNC(homshuffle)
  7093. {
  7094. nullpo_retr(-1, sd);
  7095. if(!sd->hd)
  7096. return -1; // nothing to do
  7097. if(!hom_shuffle(sd->hd))
  7098. return -1;
  7099. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  7100. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  7101. return 0;
  7102. }
  7103. /*==========================================
  7104. * Show Items DB Info v 1.0
  7105. * originally by [Lupus]
  7106. *------------------------------------------*/
  7107. ACMD_FUNC(iteminfo)
  7108. {
  7109. if (!message || !*message) {
  7110. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  7111. return -1;
  7112. }
  7113. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7114. uint16 count = 1;
  7115. t_itemid itemid = strtoul(message, nullptr, 10);
  7116. if (itemid == 0) // Entered a string
  7117. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7118. else {
  7119. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7120. count = 0;
  7121. }
  7122. if (!count) {
  7123. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7124. return -1;
  7125. }
  7126. if (count == MAX_SEARCH) {
  7127. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7128. clif_displaymessage(fd, atcmd_output);
  7129. }
  7130. for (const auto &result : item_array) {
  7131. std::shared_ptr<item_data> item_data = result.second;
  7132. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s' (%u) Type: %s | Extra Effect: %s
  7133. item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(),item_data->nameid,
  7134. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
  7135. (item_data->script==nullptr)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  7136. );
  7137. clif_displaymessage(fd, atcmd_output);
  7138. 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
  7139. clif_displaymessage(fd, atcmd_output);
  7140. if (item_data->maxchance == -1) {
  7141. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  7142. clif_displaymessage(fd, atcmd_output);
  7143. }
  7144. else if (!battle_config.atcommand_mobinfo_type) {
  7145. if (item_data->maxchance)
  7146. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  7147. else
  7148. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  7149. clif_displaymessage(fd, atcmd_output);
  7150. }
  7151. }
  7152. return 0;
  7153. }
  7154. /*==========================================
  7155. * Show who drops the item.
  7156. *------------------------------------------*/
  7157. ACMD_FUNC(whodrops)
  7158. {
  7159. if (!message || !*message) {
  7160. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  7161. return -1;
  7162. }
  7163. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7164. uint16 count = 1;
  7165. t_itemid itemid = strtoul(message, nullptr, 10);
  7166. if (itemid == 0) // Entered a string
  7167. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7168. else {
  7169. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7170. count = 0;
  7171. }
  7172. if (!count) {
  7173. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7174. return -1;
  7175. }
  7176. if (count == MAX_SEARCH) {
  7177. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7178. clif_displaymessage(fd, atcmd_output);
  7179. }
  7180. for (const auto &result : item_array) {
  7181. std::shared_ptr<item_data> id = result.second;
  7182. sprintf(atcmd_output, msg_txt(sd,1285), item_db.create_item_link( id ).c_str(), id->nameid); // Item: '%s' (ID:%u)
  7183. clif_displaymessage(fd, atcmd_output);
  7184. if (id->mob[0].chance == 0) {
  7185. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  7186. clif_displaymessage(fd, atcmd_output);
  7187. } else {
  7188. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  7189. clif_displaymessage(fd, atcmd_output);
  7190. for (uint16 j=0; j < MAX_SEARCH && id->mob[j].chance > 0; j++)
  7191. {
  7192. int32 dropchance = id->mob[j].chance;
  7193. std::shared_ptr<s_mob_db> mob = mob_db.find(id->mob[j].id);
  7194. if(!mob) continue;
  7195. #ifdef RENEWAL_DROP
  7196. if( battle_config.atcommand_mobinfo_type ) {
  7197. dropchance = dropchance * pc_level_penalty_mod( sd, PENALTY_DROP, mob ) / 100;
  7198. if (dropchance <= 0 && !battle_config.drop_rate0item)
  7199. dropchance = 1;
  7200. }
  7201. #endif
  7202. if (pc_isvip(sd)) // Display item rate increase for VIP
  7203. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  7204. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob->jname.c_str(), id->mob[j].id, dropchance/100.);
  7205. clif_displaymessage(fd, atcmd_output);
  7206. }
  7207. }
  7208. }
  7209. return 0;
  7210. }
  7211. ACMD_FUNC(whereis)
  7212. {
  7213. uint16 mob_ids[MAX_SEARCH] = {0}, count;
  7214. if (!message || !*message) {
  7215. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  7216. return -1;
  7217. }
  7218. int32 i_message = atoi(message);
  7219. if (mobdb_checkid(i_message)) {
  7220. // ID given
  7221. mob_ids[0] = i_message;
  7222. count = 1;
  7223. } else {
  7224. // Name given, get all monster associated whith this name
  7225. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  7226. }
  7227. if (count <= 0) {
  7228. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  7229. return -1;
  7230. }
  7231. if (count >= MAX_SEARCH) {
  7232. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7233. clif_displaymessage(fd, atcmd_output);
  7234. count = MAX_SEARCH;
  7235. }
  7236. for (int32 i = 0; i < count; i++) {
  7237. uint16 mob_id = mob_ids[i];
  7238. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  7239. if(!mob) continue;
  7240. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname.c_str()); // %s spawns in:
  7241. clif_displaymessage(fd, atcmd_output);
  7242. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  7243. if (spawns.size() <= 0) {
  7244. // This monster does not spawn normally.
  7245. clif_displaymessage(fd, msg_txt(sd,1290));
  7246. } else {
  7247. for(auto& spawn : spawns)
  7248. {
  7249. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  7250. if (mapid < 0)
  7251. continue;
  7252. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  7253. clif_displaymessage(fd, atcmd_output);
  7254. }
  7255. }
  7256. }
  7257. return 0;
  7258. }
  7259. ACMD_FUNC(version)
  7260. {
  7261. pc_show_version(sd);
  7262. return 0;
  7263. }
  7264. /*==========================================
  7265. * @mutearea by MouseJstr
  7266. *------------------------------------------*/
  7267. static int32 atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7268. {
  7269. int32 time, id;
  7270. map_session_data *pl_sd = (map_session_data *)bl;
  7271. if (pl_sd == nullptr)
  7272. return 0;
  7273. id = va_arg(ap, int32);
  7274. time = va_arg(ap, int32);
  7275. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  7276. pl_sd->status.manner -= time;
  7277. if (pl_sd->status.manner < 0)
  7278. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  7279. else
  7280. status_change_end(&pl_sd->bl, SC_NOCHAT);
  7281. }
  7282. return 0;
  7283. }
  7284. ACMD_FUNC(mutearea)
  7285. {
  7286. int32 time;
  7287. nullpo_ret(sd);
  7288. if (!message || !*message) {
  7289. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  7290. return -1;
  7291. }
  7292. time = atoi(message);
  7293. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  7294. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7295. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7296. return 0;
  7297. }
  7298. ACMD_FUNC(rates)
  7299. {
  7300. char buf[CHAT_SIZE_MAX];
  7301. nullpo_ret(sd);
  7302. memset(buf, '\0', sizeof(buf));
  7303. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  7304. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  7305. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  7306. clif_displaymessage(fd, buf);
  7307. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7308. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  7309. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  7310. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  7311. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  7312. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  7313. clif_displaymessage(fd, buf);
  7314. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7315. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  7316. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  7317. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  7318. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  7319. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  7320. clif_displaymessage(fd, buf);
  7321. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7322. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  7323. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  7324. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  7325. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  7326. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  7327. clif_displaymessage(fd, buf);
  7328. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  7329. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  7330. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  7331. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  7332. clif_displaymessage(fd, buf);
  7333. return 0;
  7334. }
  7335. /*==========================================
  7336. * @me by lordalfa
  7337. * => Displays the OUTPUT string on top of the Visible players Heads.
  7338. *------------------------------------------*/
  7339. ACMD_FUNC(me)
  7340. {
  7341. char tempmes[CHAT_SIZE_MAX];
  7342. nullpo_retr(-1, sd);
  7343. memset(tempmes, '\0', sizeof(tempmes));
  7344. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7345. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  7346. return -1; //no "chatting" while muted.
  7347. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  7348. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  7349. return -1;
  7350. }
  7351. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  7352. clif_disp_overhead(&sd->bl, atcmd_output);
  7353. return 0;
  7354. }
  7355. /*==========================================
  7356. * @size
  7357. * => Resize your character sprite. [Valaris]
  7358. *------------------------------------------*/
  7359. ACMD_FUNC(size)
  7360. {
  7361. int32 size = SZ_SMALL;
  7362. nullpo_retr(-1, sd);
  7363. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  7364. if(sd->state.size) {
  7365. sd->state.size = SZ_SMALL;
  7366. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  7367. }
  7368. sd->state.size = size;
  7369. if( size == SZ_MEDIUM )
  7370. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  7371. else if( size == SZ_BIG )
  7372. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  7373. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7374. return 0;
  7375. }
  7376. ACMD_FUNC(sizeall)
  7377. {
  7378. int32 size;
  7379. map_session_data *pl_sd;
  7380. struct s_mapiterator* iter;
  7381. size = atoi(message);
  7382. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7383. iter = mapit_getallusers();
  7384. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  7385. if( pl_sd->state.size != size ) {
  7386. if( pl_sd->state.size ) {
  7387. pl_sd->state.size = SZ_SMALL;
  7388. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7389. }
  7390. pl_sd->state.size = size;
  7391. if( size == SZ_MEDIUM )
  7392. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7393. else if( size == SZ_BIG )
  7394. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7395. }
  7396. }
  7397. mapit_free(iter);
  7398. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7399. return 0;
  7400. }
  7401. ACMD_FUNC(sizeguild)
  7402. {
  7403. int32 size = SZ_SMALL, i;
  7404. char guild[NAME_LENGTH];
  7405. map_session_data *pl_sd;
  7406. nullpo_retr(-1, sd);
  7407. memset(guild, '\0', sizeof(guild));
  7408. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  7409. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  7410. return -1;
  7411. }
  7412. auto g = guild_searchnameid(guild);
  7413. if (!g) {
  7414. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  7415. return -1;
  7416. }
  7417. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7418. for( i = 0; i < g->guild.max_member; i++ ) {
  7419. if( (pl_sd = g->guild.member[i].sd) && pl_sd->state.size != size ) {
  7420. if( pl_sd->state.size ) {
  7421. pl_sd->state.size = SZ_SMALL;
  7422. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7423. }
  7424. pl_sd->state.size = size;
  7425. if( size == SZ_MEDIUM )
  7426. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7427. else if( size == SZ_BIG )
  7428. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7429. }
  7430. }
  7431. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7432. return 0;
  7433. }
  7434. /*==========================================
  7435. * @monsterignore
  7436. * => Makes monsters ignore you. [Valaris]
  7437. *------------------------------------------*/
  7438. ACMD_FUNC(monsterignore)
  7439. {
  7440. nullpo_retr(-1, sd);
  7441. if (sd->state.block_action & PCBLOCK_IMMUNE) {
  7442. sd->state.block_action &= ~PCBLOCK_IMMUNE;
  7443. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  7444. } else {
  7445. sd->state.block_action |= PCBLOCK_IMMUNE;
  7446. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  7447. }
  7448. return 0;
  7449. }
  7450. /*==========================================
  7451. * @fakename
  7452. * => Gives your character a fake name. [Valaris]
  7453. *------------------------------------------*/
  7454. ACMD_FUNC(fakename)
  7455. {
  7456. nullpo_retr(-1, sd);
  7457. if( !message || !*message )
  7458. {
  7459. if( sd->fakename[0] )
  7460. {
  7461. sd->fakename[0] = '\0';
  7462. clif_name_area(&sd->bl);
  7463. if (sd->disguise)
  7464. clif_name_self(&sd->bl);
  7465. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7466. return 0;
  7467. }
  7468. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7469. return -1;
  7470. }
  7471. if( strlen(message) < 2 )
  7472. {
  7473. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7474. return -1;
  7475. }
  7476. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7477. clif_name_area(&sd->bl);
  7478. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  7479. clif_name_self(&sd->bl);
  7480. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7481. return 0;
  7482. }
  7483. /*==========================================
  7484. * Ragnarok Resources
  7485. *------------------------------------------*/
  7486. ACMD_FUNC(mapflag) {
  7487. char flag_name[50];
  7488. int16 flag = 0, i, j;
  7489. std::string buf;
  7490. nullpo_retr(-1, sd);
  7491. memset(flag_name, '\0', sizeof(flag_name));
  7492. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  7493. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7494. clif_displaymessage(sd->fd,"----------------------------------");
  7495. for( i = MF_MIN; i < MF_MAX; i++ ){
  7496. union u_mapflag_args args = {};
  7497. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  7498. clif_displaymessage(sd->fd, flag_name);
  7499. }
  7500. }
  7501. clif_displaymessage(sd->fd," ");
  7502. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7503. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7504. return 1;
  7505. }
  7506. // Check if the list of mapflags was requested
  7507. if( strcasecmp(flag_name,"available") ){
  7508. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7509. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  7510. if( mapflag != MF_INVALID ){
  7511. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  7512. MF_PVP_NIGHTMAREDROP,
  7513. MF_RESTRICTED,
  7514. MF_NOCOMMAND,
  7515. MF_BEXP,
  7516. MF_JEXP,
  7517. MF_BATTLEGROUND,
  7518. MF_SKILL_DAMAGE,
  7519. MF_SKILL_DURATION };
  7520. if (flag > 0 && util::vector_exists(disabled_mf, mapflag)) {
  7521. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  7522. clif_displaymessage(sd->fd,atcmd_output);
  7523. } else {
  7524. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  7525. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  7526. clif_displaymessage(sd->fd,atcmd_output);
  7527. }
  7528. return 0;
  7529. }else{
  7530. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  7531. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  7532. return 1;
  7533. }
  7534. }
  7535. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7536. clif_displaymessage(sd->fd,"----------------------------------");
  7537. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  7538. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  7539. buf.append(flag_name);
  7540. if( (i + 1) < MF_MAX )
  7541. buf.append(", ");
  7542. j++;
  7543. }
  7544. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  7545. clif_displaymessage(sd->fd, buf.c_str() );
  7546. buf.clear();
  7547. j = 0;
  7548. }
  7549. }
  7550. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7551. return 0;
  7552. }
  7553. /*===================================
  7554. * Remove some messages
  7555. *-----------------------------------*/
  7556. ACMD_FUNC(showexp)
  7557. {
  7558. if (sd->state.showexp) {
  7559. sd->state.showexp = 0;
  7560. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7561. return 0;
  7562. }
  7563. sd->state.showexp = 1;
  7564. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7565. return 0;
  7566. }
  7567. ACMD_FUNC(showzeny)
  7568. {
  7569. if (sd->state.showzeny) {
  7570. sd->state.showzeny = 0;
  7571. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7572. return 0;
  7573. }
  7574. sd->state.showzeny = 1;
  7575. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7576. return 0;
  7577. }
  7578. ACMD_FUNC(showdelay)
  7579. {
  7580. if (sd->state.showdelay) {
  7581. sd->state.showdelay = 0;
  7582. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7583. return 0;
  7584. }
  7585. sd->state.showdelay = 1;
  7586. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7587. return 0;
  7588. }
  7589. /*==========================================
  7590. * Duel organizing functions [LuzZza]
  7591. *
  7592. * @duel [limit|nick] - create a duel
  7593. * @invite <nick> - invite player
  7594. * @accept - accept invitation
  7595. * @reject - reject invitation
  7596. * @leave - leave duel
  7597. *------------------------------------------*/
  7598. ACMD_FUNC(invite)
  7599. {
  7600. size_t did = sd->duel_group;
  7601. map_session_data *target_sd = nullptr;
  7602. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7603. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7604. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7605. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7606. clif_displaymessage(fd, atcmd_output);
  7607. return -1;
  7608. }
  7609. if(did == 0 || !duel_exist(did) ) {
  7610. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7611. return 0;
  7612. }
  7613. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7614. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7615. return 0;
  7616. }
  7617. if((target_sd = map_nick2sd(atcmd_player_name, true)) == nullptr) {
  7618. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7619. return 0;
  7620. }
  7621. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7622. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7623. return 0;
  7624. }
  7625. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7626. {
  7627. 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.
  7628. clif_displaymessage(fd, atcmd_output);
  7629. return 0;
  7630. }
  7631. duel_invite(did, sd, target_sd);
  7632. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7633. return 0;
  7634. }
  7635. ACMD_FUNC(duel)
  7636. {
  7637. uint32 maxpl = 0;
  7638. if(sd->duel_group > 0) {
  7639. duel_showinfo(sd->duel_group, sd);
  7640. return 0;
  7641. }
  7642. if(sd->duel_invite > 0) {
  7643. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7644. return 0;
  7645. }
  7646. if(!duel_checktime(sd)) {
  7647. char output[CHAT_SIZE_MAX];
  7648. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7649. clif_displaymessage(fd, output);
  7650. return 0;
  7651. }
  7652. if( message[0] ) {
  7653. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7654. if(maxpl < 2 || maxpl > 65535) {
  7655. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7656. return 0;
  7657. }
  7658. duel_create(sd, maxpl);
  7659. } else {
  7660. map_session_data *target_sd = nullptr;
  7661. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7662. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7663. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7664. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7665. clif_displaymessage(fd, atcmd_output);
  7666. return -1;
  7667. }
  7668. target_sd = map_nick2sd(atcmd_player_name,true);
  7669. if(target_sd != nullptr) {
  7670. size_t newduel;
  7671. if((newduel = duel_create(sd, 2)) != -1) {
  7672. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7673. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7674. return 0;
  7675. }
  7676. duel_invite(newduel, sd, target_sd);
  7677. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7678. }
  7679. } else {
  7680. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7681. return 0;
  7682. }
  7683. }
  7684. } else
  7685. duel_create(sd, 0);
  7686. return 0;
  7687. }
  7688. ACMD_FUNC(leave)
  7689. {
  7690. if(sd->duel_group <= 0) {
  7691. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7692. return 0;
  7693. }
  7694. duel_leave(sd->duel_group, sd);
  7695. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7696. return 0;
  7697. }
  7698. ACMD_FUNC(accept)
  7699. {
  7700. if(!duel_checktime(sd)) {
  7701. char output[CHAT_SIZE_MAX];
  7702. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7703. clif_displaymessage(fd, output);
  7704. return 0;
  7705. }
  7706. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7707. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7708. return 0;
  7709. }
  7710. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7711. {
  7712. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7713. return 0;
  7714. }
  7715. duel_accept(sd->duel_invite, sd);
  7716. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7717. return 0;
  7718. }
  7719. ACMD_FUNC(reject)
  7720. {
  7721. if(sd->duel_invite <= 0) {
  7722. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7723. return 0;
  7724. }
  7725. duel_reject(sd->duel_invite, sd);
  7726. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7727. return 0;
  7728. }
  7729. /*===================================
  7730. * Cash Points
  7731. *-----------------------------------*/
  7732. ACMD_FUNC(cash)
  7733. {
  7734. char output[128];
  7735. int32 value;
  7736. int32 ret=0;
  7737. nullpo_retr(-1, sd);
  7738. // Since there is no cashpoint update packet we need to force updating like this
  7739. if( sd->state.cashshop_open ){
  7740. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7741. return -1;
  7742. }
  7743. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7744. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7745. return -1;
  7746. }
  7747. if( value > 0 ) {
  7748. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7749. // If this option is set, the message is already sent by pc function
  7750. if( !battle_config.cashshop_show_points ){
  7751. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7752. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7753. }
  7754. }
  7755. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7756. } else {
  7757. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7758. value = -sd->cashPoints;
  7759. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7760. // If this option is set, the message is already sent by pc function
  7761. if( !battle_config.cashshop_show_points ){
  7762. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7763. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7764. }
  7765. }
  7766. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7767. }
  7768. return 0;
  7769. }
  7770. ACMD_FUNC(points){
  7771. char output[128];
  7772. int32 value;
  7773. int32 ret=0;
  7774. nullpo_retr(-1, sd);
  7775. // Since there is no cashpoint update packet we need to force updating like this
  7776. if( sd->state.cashshop_open ){
  7777. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7778. return -1;
  7779. }
  7780. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7781. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7782. return -1;
  7783. }
  7784. if( value > 0 ) {
  7785. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7786. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7787. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7788. }
  7789. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7790. } else {
  7791. if (-value > sd->kafraPoints) //By command, if cash < value, force it to remove all
  7792. value = -sd->kafraPoints;
  7793. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7794. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7795. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7796. }
  7797. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7798. }
  7799. return 0;
  7800. }
  7801. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7802. ACMD_FUNC(clone)
  7803. {
  7804. int32 x=0,y=0,flag=0,master=0,i=0;
  7805. map_session_data *pl_sd=nullptr;
  7806. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7807. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7808. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7809. return 0;
  7810. }
  7811. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr) {
  7812. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7813. return 0;
  7814. }
  7815. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7816. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7817. return 0;
  7818. }
  7819. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7820. if (strcmpi(parent_cmd, "clone") == 0)
  7821. flag = 1;
  7822. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7823. flag = 2;
  7824. if(pc_isdead(sd)){
  7825. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7826. return 0;
  7827. }
  7828. master = sd->bl.id;
  7829. if (battle_config.atc_slave_clone_limit
  7830. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7831. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7832. return 0;
  7833. }
  7834. }
  7835. do {
  7836. x = sd->bl.x + rnd_value(-5, 5);
  7837. y = sd->bl.y + rnd_value(-5, 5);
  7838. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7839. if (i >= 10) {
  7840. x = sd->bl.x;
  7841. y = sd->bl.y;
  7842. }
  7843. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7844. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7845. return 0;
  7846. }
  7847. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7848. return 0;
  7849. }
  7850. /*=====================================
  7851. * Autorejecting Invites/Deals [LuzZza]
  7852. * Usage: @noask
  7853. *-------------------------------------*/
  7854. ACMD_FUNC(noask)
  7855. {
  7856. if(sd->state.noask) {
  7857. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7858. sd->state.noask = 0;
  7859. } else {
  7860. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7861. sd->state.noask = 1;
  7862. }
  7863. return 0;
  7864. }
  7865. /*=====================================
  7866. * Send a @request message to all GMs of lowest_gm_level.
  7867. * Usage: @request <petition>
  7868. *-------------------------------------*/
  7869. ACMD_FUNC(request)
  7870. {
  7871. if (!message || !*message) {
  7872. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7873. return -1;
  7874. }
  7875. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7876. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7877. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7878. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7879. return 0;
  7880. }
  7881. /*==========================================
  7882. * Feel (SG designated maps) Reset [HiddenDragon]
  7883. *------------------------------------------*/
  7884. ACMD_FUNC(feelreset)
  7885. {
  7886. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7887. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7888. return -1;
  7889. }
  7890. pc_resetfeel(sd);
  7891. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7892. return 0;
  7893. }
  7894. /*==========================================
  7895. * Hate (SG designated monsters) Reset
  7896. *------------------------------------------*/
  7897. ACMD_FUNC(hatereset)
  7898. {
  7899. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7900. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7901. return -1;
  7902. }
  7903. pc_resethate(sd);
  7904. clif_displaymessage(fd, msg_txt(sd,1515)); // Reset 'Hatred' monsters.
  7905. return 0;
  7906. }
  7907. /*==========================================
  7908. * AUCTION SYSTEM
  7909. *------------------------------------------*/
  7910. ACMD_FUNC(auction)
  7911. {
  7912. nullpo_ret(sd);
  7913. if (!battle_config.feature_auction) {
  7914. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7915. return 0;
  7916. }
  7917. clif_Auction_openwindow(sd);
  7918. return 0;
  7919. }
  7920. /*==========================================
  7921. * Kill Steal Protection
  7922. *------------------------------------------*/
  7923. ACMD_FUNC(ksprotection)
  7924. {
  7925. nullpo_retr(-1,sd);
  7926. if( sd->state.noks ) {
  7927. sd->state.noks = 0;
  7928. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7929. }
  7930. else
  7931. {
  7932. if( !message || !*message || !strcmpi(message, "party") )
  7933. { // Default is Party
  7934. sd->state.noks = 2;
  7935. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7936. }
  7937. else if( !strcmpi(message, "self") )
  7938. {
  7939. sd->state.noks = 1;
  7940. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7941. }
  7942. else if( !strcmpi(message, "guild") )
  7943. {
  7944. sd->state.noks = 3;
  7945. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7946. }
  7947. else
  7948. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7949. }
  7950. return 0;
  7951. }
  7952. /*==========================================
  7953. * Map Kill Steal Protection Setting
  7954. *------------------------------------------*/
  7955. ACMD_FUNC(allowks)
  7956. {
  7957. nullpo_retr(-1,sd);
  7958. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7959. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7960. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7961. } else {
  7962. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7963. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7964. }
  7965. return 0;
  7966. }
  7967. ACMD_FUNC(resetstat)
  7968. {
  7969. nullpo_retr(-1, sd);
  7970. pc_resetstate(sd);
  7971. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7972. clif_displaymessage(fd, atcmd_output);
  7973. return 0;
  7974. }
  7975. ACMD_FUNC(resetskill)
  7976. {
  7977. nullpo_retr(-1,sd);
  7978. pc_resetskill(sd,1);
  7979. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7980. clif_displaymessage(fd, atcmd_output);
  7981. return 0;
  7982. }
  7983. /*==========================================
  7984. * #storagelist: Displays the items list of a player's storage.
  7985. * #cartlist: Displays contents of target's cart.
  7986. * #itemlist: Displays contents of target's inventory.
  7987. *------------------------------------------*/
  7988. ACMD_FUNC(itemlist)
  7989. {
  7990. int32 i, j, count, counter;
  7991. const char* location;
  7992. struct item* items;
  7993. int32 size;
  7994. StringBuf buf;
  7995. nullpo_retr(-1, sd);
  7996. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7997. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7998. location = "storage";
  7999. items = sd->storage.u.items_storage;
  8000. size = sd->storage.max_amount;
  8001. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  8002. location = "cart";
  8003. items = sd->cart.u.items_cart;
  8004. size = MAX_CART;
  8005. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  8006. location = "inventory";
  8007. items = sd->inventory.u.items_inventory;
  8008. size = MAX_INVENTORY;
  8009. } else
  8010. return 1;
  8011. StringBuf_Init(&buf);
  8012. count = 0; // total slots occupied
  8013. counter = 0; // total items found
  8014. for( i = 0; i < size; ++i ) {
  8015. struct item* it = &items[i];
  8016. if( it->nameid == 0 )
  8017. continue;
  8018. std::shared_ptr<item_data> itd = item_db.find(it->nameid);
  8019. if (itd == nullptr)
  8020. continue;
  8021. counter += it->amount;
  8022. count++;
  8023. if( count == 1 ) {
  8024. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  8025. clif_displaymessage(fd, StringBuf_Value(&buf));
  8026. StringBuf_Clear(&buf);
  8027. }
  8028. StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, item_db.create_item_link( *it ).c_str(), itd->name.c_str(), it->nameid);
  8029. if( it->equip ) {
  8030. char equipstr[CHAT_SIZE_MAX];
  8031. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  8032. if( it->equip&EQP_GARMENT )
  8033. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  8034. if( it->equip&EQP_ACC_L )
  8035. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  8036. if( it->equip&EQP_ARMOR )
  8037. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  8038. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  8039. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  8040. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  8041. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  8042. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  8043. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  8044. if( it->equip&EQP_SHOES )
  8045. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  8046. if( it->equip&EQP_ACC_R )
  8047. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  8048. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  8049. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  8050. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  8051. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  8052. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  8053. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  8054. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  8055. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  8056. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  8057. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  8058. if( (it->equip&EQP_HELM) == EQP_HELM )
  8059. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  8060. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  8061. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  8062. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  8063. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  8064. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  8065. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  8066. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  8067. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  8068. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  8069. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  8070. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  8071. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  8072. if( it->equip&EQP_COSTUME_GARMENT )
  8073. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  8074. //if( it->equip&EQP_COSTUME_FLOOR )
  8075. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  8076. if( it->equip&EQP_AMMO )
  8077. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  8078. if( it->equip&EQP_SHADOW_ARMOR )
  8079. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  8080. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  8081. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  8082. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  8083. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  8084. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  8085. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  8086. if( it->equip&EQP_SHADOW_SHOES )
  8087. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  8088. if( it->equip&EQP_SHADOW_ACC_R )
  8089. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  8090. if( it->equip&EQP_SHADOW_ACC_L )
  8091. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  8092. // remove final ', '
  8093. equipstr[strlen(equipstr) - 2] = '\0';
  8094. StringBuf_AppendStr(&buf, equipstr);
  8095. }
  8096. clif_displaymessage(fd, StringBuf_Value(&buf));
  8097. StringBuf_Clear(&buf);
  8098. if( it->card[0] == CARD0_PET ) { // pet egg
  8099. if (it->card[3]&1)
  8100. StringBuf_Printf(&buf, msg_txt(sd,1348), (uint32)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  8101. else
  8102. StringBuf_Printf(&buf, msg_txt(sd,1349), (uint32)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  8103. } else if(it->card[0] == CARD0_FORGE) { // forged item
  8104. StringBuf_Printf(&buf, msg_txt(sd,1350), (uint32)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)
  8105. } else if(it->card[0] == CARD0_CREATE) { // created item
  8106. StringBuf_Printf(&buf, msg_txt(sd,1351), (uint32)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  8107. } else { // normal item
  8108. int32 counter2 = 0;
  8109. for( j = 0; j < itd->slots; ++j ) {
  8110. if( it->card[j] == 0 )
  8111. continue;
  8112. std::shared_ptr<item_data> card = item_db.find(it->card[j]);
  8113. if (card == nullptr)
  8114. continue;
  8115. counter2++;
  8116. if( counter2 == 1 )
  8117. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  8118. if( counter2 != 1 )
  8119. StringBuf_AppendStr(&buf, ", ");
  8120. StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, item_db.create_item_link( card ).c_str(), card->nameid);
  8121. }
  8122. if( counter2 > 0 )
  8123. StringBuf_AppendStr(&buf, ")");
  8124. }
  8125. if( StringBuf_Length(&buf) > 0 )
  8126. clif_displaymessage(fd, StringBuf_Value(&buf));
  8127. StringBuf_Clear(&buf);
  8128. }
  8129. if( count == 0 )
  8130. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  8131. else
  8132. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  8133. clif_displaymessage(fd, StringBuf_Value(&buf));
  8134. StringBuf_Destroy(&buf);
  8135. return 0;
  8136. }
  8137. ACMD_FUNC(stats)
  8138. {
  8139. char job_jobname[100];
  8140. char output[CHAT_SIZE_MAX];
  8141. int32 i;
  8142. struct {
  8143. const char* format;
  8144. int32 value;
  8145. } output_table[] = {
  8146. { "Base Level - %d", 0 },
  8147. { nullptr, 0 },
  8148. { "Hp - %d", 0 },
  8149. { "MaxHp - %d", 0 },
  8150. { "Sp - %d", 0 },
  8151. { "MaxSp - %d", 0 },
  8152. { "Ap - %d", 0 },
  8153. { "MaxAp - %d", 0 },
  8154. { "Str - %3d", 0 },
  8155. { "Agi - %3d", 0 },
  8156. { "Vit - %3d", 0 },
  8157. { "Int - %3d", 0 },
  8158. { "Dex - %3d", 0 },
  8159. { "Luk - %3d", 0 },
  8160. { "Pow - %3d", 0 },
  8161. { "Sta - %3d", 0 },
  8162. { "Wis - %3d", 0 },
  8163. { "Spl - %3d", 0 },
  8164. { "Con - %3d", 0 },
  8165. { "Crt - %3d", 0 },
  8166. { "Zeny - %d", 0 },
  8167. { "Free Status Points - %d", 0 },
  8168. { "Free Trait Points - %d", 0 },
  8169. { "Free Skill Points - %d", 0 },
  8170. { "JobChangeLvl (2nd) - %d", 0 },
  8171. { "JobChangeLvl (3rd) - %d", 0 },
  8172. { "JobChangeLvl (4th) - %d", 0 },
  8173. { nullptr, 0 }
  8174. };
  8175. memset(job_jobname, '\0', sizeof(job_jobname));
  8176. memset(output, '\0', sizeof(output));
  8177. //direct array initialization with variables is not standard C compliant.
  8178. output_table[0].value = sd->status.base_level;
  8179. output_table[1].format = job_jobname;
  8180. output_table[1].value = sd->status.job_level;
  8181. output_table[2].value = sd->status.hp;
  8182. output_table[3].value = sd->status.max_hp;
  8183. output_table[4].value = sd->status.sp;
  8184. output_table[5].value = sd->status.max_sp;
  8185. output_table[6].value = sd->status.ap;
  8186. output_table[7].value = sd->status.max_ap;
  8187. output_table[8].value = sd->status.str;
  8188. output_table[9].value = sd->status.agi;
  8189. output_table[10].value = sd->status.vit;
  8190. output_table[11].value = sd->status.int_;
  8191. output_table[12].value = sd->status.dex;
  8192. output_table[13].value = sd->status.luk;
  8193. output_table[14].value = sd->status.pow;
  8194. output_table[15].value = sd->status.sta;
  8195. output_table[16].value = sd->status.wis;
  8196. output_table[17].value = sd->status.spl;
  8197. output_table[18].value = sd->status.con;
  8198. output_table[19].value = sd->status.crt;
  8199. output_table[20].value = sd->status.zeny;
  8200. output_table[21].value = sd->status.status_point;
  8201. output_table[22].value = sd->status.trait_point;
  8202. output_table[23].value = sd->status.skill_point;
  8203. output_table[24].value = sd->change_level_2nd;
  8204. output_table[25].value = sd->change_level_3rd;
  8205. output_table[26].value = sd->change_level_4th;
  8206. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  8207. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  8208. clif_displaymessage(fd, output);
  8209. for (i = 0; output_table[i].format != nullptr; i++) {
  8210. sprintf(output, output_table[i].format, output_table[i].value);
  8211. clif_displaymessage(fd, output);
  8212. }
  8213. return 0;
  8214. }
  8215. ACMD_FUNC(delitem)
  8216. {
  8217. char item_name[100];
  8218. int32 amount = 0, idx;
  8219. nullpo_retr(-1, sd);
  8220. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  8221. {
  8222. 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>).
  8223. return -1;
  8224. }
  8225. std::shared_ptr<item_data> id = item_db.searchname( item_name );
  8226. if( id == nullptr ){
  8227. id = item_db.find( strtoul( item_name, nullptr, 10 ) );
  8228. }
  8229. if( id == nullptr ){
  8230. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  8231. return -1;
  8232. }
  8233. t_itemid nameid = id->nameid;
  8234. int32 total = amount;
  8235. // delete items
  8236. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  8237. {
  8238. int32 delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  8239. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  8240. {// delete pet
  8241. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  8242. }
  8243. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  8244. amount-= delamount;
  8245. }
  8246. // notify target
  8247. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  8248. clif_displaymessage(sd->fd, atcmd_output);
  8249. // notify source
  8250. if( amount == total )
  8251. {
  8252. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  8253. }
  8254. else if( amount )
  8255. {
  8256. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  8257. clif_displaymessage(fd, atcmd_output);
  8258. }
  8259. else
  8260. {
  8261. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  8262. clif_displaymessage(fd, atcmd_output);
  8263. }
  8264. return 0;
  8265. }
  8266. /*==========================================
  8267. * Custom Fonts
  8268. *------------------------------------------*/
  8269. ACMD_FUNC(font)
  8270. {
  8271. int32 font_id;
  8272. nullpo_retr(-1,sd);
  8273. font_id = atoi(message);
  8274. if( font_id == 0 ) {
  8275. if( sd->status.font ) {
  8276. sd->status.font = 0;
  8277. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  8278. clif_font(sd);
  8279. } else {
  8280. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  8281. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  8282. }
  8283. } else if( font_id < 0 || font_id > 9 )
  8284. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  8285. else if( font_id != sd->status.font ) {
  8286. sd->status.font = font_id;
  8287. clif_font(sd);
  8288. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  8289. } else
  8290. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  8291. return 0;
  8292. }
  8293. /*==========================================
  8294. * type: 1 = commands (@), 2 = charcommands (#)
  8295. *------------------------------------------*/
  8296. static void atcommand_commands_sub(map_session_data* sd, const int32 fd, AtCommandType type)
  8297. {
  8298. char line_buff[CHATBOX_SIZE];
  8299. char* cur = line_buff;
  8300. AtCommandInfo* cmd;
  8301. DBIterator *iter = db_iterator(atcommand_db);
  8302. int32 count = 0;
  8303. memset(line_buff,' ',CHATBOX_SIZE);
  8304. line_buff[CHATBOX_SIZE-1] = 0;
  8305. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  8306. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  8307. switch( type ) {
  8308. case COMMAND_CHARCOMMAND:
  8309. if( cmd->char_groups[sd->group->index] == 0 )
  8310. continue;
  8311. break;
  8312. case COMMAND_ATCOMMAND:
  8313. if( cmd->at_groups[sd->group->index] == 0 )
  8314. continue;
  8315. break;
  8316. default:
  8317. continue;
  8318. }
  8319. size_t slen = strlen( cmd->command );
  8320. // flush the text buffer if this command won't fit into it
  8321. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8322. clif_displaymessage(fd,line_buff);
  8323. cur = line_buff;
  8324. memset(line_buff,' ',CHATBOX_SIZE);
  8325. line_buff[CHATBOX_SIZE-1] = 0;
  8326. }
  8327. memcpy(cur,cmd->command,slen);
  8328. cur += slen+(10-slen%10);
  8329. count++;
  8330. }
  8331. dbi_destroy(iter);
  8332. clif_displaymessage(fd,line_buff);
  8333. if ( atcmd_binding_count ) {
  8334. int32 i, count_bind, gm_lvl = pc_get_group_level(sd);
  8335. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  8336. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  8337. size_t slen = strlen( atcmd_binding[i]->command );
  8338. if ( count_bind == 0 ) {
  8339. cur = line_buff;
  8340. memset(line_buff,' ',CHATBOX_SIZE);
  8341. line_buff[CHATBOX_SIZE-1] = 0;
  8342. clif_displaymessage(fd, "-----------------");
  8343. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  8344. }
  8345. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8346. clif_displaymessage(fd,line_buff);
  8347. cur = line_buff;
  8348. memset(line_buff,' ',CHATBOX_SIZE);
  8349. line_buff[CHATBOX_SIZE-1] = 0;
  8350. }
  8351. memcpy(cur,atcmd_binding[i]->command,slen);
  8352. cur += slen+(10-slen%10);
  8353. count_bind++;
  8354. }
  8355. }
  8356. if ( count_bind )
  8357. clif_displaymessage(fd,line_buff);// last one
  8358. count += count_bind;
  8359. }
  8360. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  8361. clif_displaymessage(fd, atcmd_output);
  8362. return;
  8363. }
  8364. /*==========================================
  8365. * @commands Lists available @ commands to you
  8366. *------------------------------------------*/
  8367. ACMD_FUNC(commands)
  8368. {
  8369. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  8370. return 0;
  8371. }
  8372. /*==========================================
  8373. * @charcommands Lists available # commands to you
  8374. *------------------------------------------*/
  8375. ACMD_FUNC(charcommands) {
  8376. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  8377. return 0;
  8378. }
  8379. /* for new mounts */
  8380. ACMD_FUNC(mount2) {
  8381. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  8382. if (!sd->sc.getSCE(SC_ALL_RIDING)) {
  8383. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  8384. sc_start(nullptr, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  8385. } else {
  8386. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  8387. status_change_end(&sd->bl, SC_ALL_RIDING);
  8388. }
  8389. return 0;
  8390. }
  8391. ACMD_FUNC(accinfo) {
  8392. char query[NAME_LENGTH];
  8393. if (!message || !*message || strlen(message) > NAME_LENGTH
  8394. || ( sscanf(message, "%23s", query) < 1))
  8395. {
  8396. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  8397. 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".
  8398. return -1;
  8399. }
  8400. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query);
  8401. return 0;
  8402. }
  8403. /**
  8404. * @set <variable name{[index]}>{ <value>}
  8405. *
  8406. * Gets or sets a value of a non server variable.
  8407. * If a value is specified it is used to set the variable's value,
  8408. * if not the variable's value is read.
  8409. * In any case it reads and displays the variable's value.
  8410. *
  8411. * Original implementation by Ind
  8412. */
  8413. ACMD_FUNC(set) {
  8414. char reg[46], val[128], name[32];
  8415. int32 toset = 0;
  8416. size_t len;
  8417. uint32 index;
  8418. bool is_str = false;
  8419. int64 uid;
  8420. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  8421. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  8422. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  8423. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  8424. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  8425. return -1;
  8426. }
  8427. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  8428. if( reg[0] == '.' ) {
  8429. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  8430. return -1;
  8431. } else if( reg[0] == '\'' ) {
  8432. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  8433. return -1;
  8434. }
  8435. // Check if the user wanted to set an array
  8436. if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
  8437. // The user did not specify array brackets, so we set the index to zero
  8438. index = 0;
  8439. }
  8440. is_str = is_string_variable(name);
  8441. if( ( len = strlen(val) ) > 1 ) {
  8442. if( val[0] == '"' && val[len-1] == '"') {
  8443. val[len-1] = '\0'; //Strip quotes.
  8444. memmove(val, val+1, len-1);
  8445. }
  8446. }
  8447. // Only set the variable if there is a value for it
  8448. if( toset >= 2 ){
  8449. if( is_str ){
  8450. setd_sub_str( nullptr, sd, name, index, val, nullptr );
  8451. }else{
  8452. setd_sub_num( nullptr, sd, name, index, strtoll( val, nullptr, 10 ), nullptr );
  8453. }
  8454. }
  8455. uid = reference_uid( add_str( name ), index );
  8456. if( is_str ) {// string variable
  8457. char* value;
  8458. switch( reg[0] ) {
  8459. case '@':
  8460. value = pc_readregstr(sd, uid);
  8461. break;
  8462. case '$':
  8463. value = mapreg_readregstr(uid);
  8464. break;
  8465. case '#':
  8466. if( reg[1] == '#' )
  8467. value = pc_readaccountreg2str(sd, uid);// global
  8468. else
  8469. value = pc_readaccountregstr(sd, uid);// local
  8470. break;
  8471. default:
  8472. value = pc_readglobalreg_str(sd, uid);
  8473. break;
  8474. }
  8475. if( value == nullptr || *value == '\0' ){// empty string
  8476. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  8477. }else{
  8478. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
  8479. }
  8480. } else {// integer variable
  8481. int64 value;
  8482. switch( reg[0] ) {
  8483. case '@':
  8484. value = pc_readreg(sd, uid);
  8485. break;
  8486. case '$':
  8487. value = mapreg_readreg(uid);
  8488. break;
  8489. case '#':
  8490. if( reg[1] == '#' )
  8491. value = pc_readaccountreg2(sd, uid);// global
  8492. else
  8493. value = pc_readaccountreg(sd, uid);// local
  8494. break;
  8495. default:
  8496. value = pc_readglobalreg(sd, uid);
  8497. break;
  8498. }
  8499. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
  8500. }
  8501. clif_displaymessage(fd, atcmd_output);
  8502. return 0;
  8503. }
  8504. ACMD_FUNC(addperm) {
  8505. int32 perm_size = ARRAYLENGTH(pc_g_permission_name);
  8506. int32 i;
  8507. if( !message || !*message ) {
  8508. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8509. clif_displaymessage(fd, atcmd_output);
  8510. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8511. for( i = 0; i < perm_size; i++ ) {
  8512. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8513. clif_displaymessage(fd, atcmd_output);
  8514. }
  8515. return -1;
  8516. }
  8517. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8518. if( i == perm_size ) {
  8519. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8520. clif_displaymessage(fd, atcmd_output);
  8521. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8522. for( i = 0; i < perm_size; i++ ) {
  8523. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8524. clif_displaymessage(fd, atcmd_output);
  8525. }
  8526. return -1;
  8527. }
  8528. if( pc_has_permission( sd, pc_g_permission_name[i].permission) ){
  8529. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8530. clif_displaymessage(fd, atcmd_output);
  8531. return -1;
  8532. }
  8533. sd->permissions.set( pc_g_permission_name[i].permission );
  8534. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8535. clif_displaymessage(fd, atcmd_output);
  8536. return 0;
  8537. }
  8538. ACMD_FUNC(rmvperm) {
  8539. int32 perm_size = ARRAYLENGTH(pc_g_permission_name);
  8540. int32 i;
  8541. if( !message || !*message ) {
  8542. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8543. clif_displaymessage(fd, atcmd_output);
  8544. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8545. for( i = 0; i < perm_size; i++ ) {
  8546. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8547. clif_displaymessage(fd, atcmd_output);
  8548. }
  8549. return -1;
  8550. }
  8551. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8552. if( i == perm_size ) {
  8553. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8554. clif_displaymessage(fd, atcmd_output);
  8555. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8556. for( i = 0; i < perm_size; i++ ) {
  8557. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8558. clif_displaymessage(fd, atcmd_output);
  8559. }
  8560. return -1;
  8561. }
  8562. if( !pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8563. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8564. clif_displaymessage(fd, atcmd_output);
  8565. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8566. clif_displaymessage(fd, atcmd_output);
  8567. for( i = 0; i < perm_size; i++ ) {
  8568. if( pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8569. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8570. clif_displaymessage(fd, atcmd_output);
  8571. }
  8572. }
  8573. return -1;
  8574. }
  8575. sd->permissions.reset( pc_g_permission_name[i].permission );
  8576. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8577. clif_displaymessage(fd, atcmd_output);
  8578. return 0;
  8579. }
  8580. ACMD_FUNC(unloadnpcfile) {
  8581. if( !message || !*message ) {
  8582. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8583. return -1;
  8584. }
  8585. if( npc_unloadfile(message) )
  8586. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8587. else {
  8588. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8589. return -1;
  8590. }
  8591. return 0;
  8592. }
  8593. ACMD_FUNC(cart) {
  8594. #define MC_CART_MDFY(idx, x) \
  8595. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8596. sd->status.skill[(idx)].lv = (x)?1:0; \
  8597. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8598. int32 val = atoi(message);
  8599. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8600. uint16 sk_idx = 0;
  8601. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8602. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8603. clif_displaymessage(fd, atcmd_output);
  8604. return -1;
  8605. }
  8606. if( val == 0 && !pc_iscarton(sd) ) {
  8607. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8608. return -1;
  8609. }
  8610. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8611. return -1;
  8612. if( need_skill ) {
  8613. MC_CART_MDFY(sk_idx,1);
  8614. }
  8615. if( !pc_setcart(sd, val) ) {
  8616. if( need_skill ) {
  8617. MC_CART_MDFY(sk_idx,0);
  8618. }
  8619. return -1;/* @cart failed */
  8620. }
  8621. if( need_skill ) {
  8622. MC_CART_MDFY(sk_idx,0);
  8623. }
  8624. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8625. return 0;
  8626. #undef MC_CART_MDFY
  8627. }
  8628. /* Channel System [Ind] */
  8629. ACMD_FUNC(join){
  8630. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8631. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8632. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8633. clif_displaymessage(fd, atcmd_output);
  8634. return -1;
  8635. }
  8636. return channel_pcjoin(sd, chname, pass);
  8637. }
  8638. /*
  8639. * Display available option for @channel command
  8640. * @command : the name of used command (for alias case)
  8641. */
  8642. static inline void atcmd_channel_help(map_session_data *sd, const char *command)
  8643. {
  8644. int32 fd = sd->fd;
  8645. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8646. bool can_create = (can_delete || channel_config.private_channel.allow);
  8647. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8648. //option create
  8649. if( can_create ) {
  8650. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8651. clif_displaymessage(fd, atcmd_output);
  8652. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8653. }
  8654. //option delete
  8655. if(can_delete){
  8656. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8657. clif_displaymessage(fd, atcmd_output);
  8658. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8659. }
  8660. //option list
  8661. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8662. clif_displaymessage(fd, atcmd_output);
  8663. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8664. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8665. clif_displaymessage(fd, atcmd_output);
  8666. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8667. if( can_create ) {
  8668. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8669. clif_displaymessage(fd, atcmd_output);
  8670. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8671. }
  8672. //option setcolor
  8673. if(can_create){
  8674. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8675. clif_displaymessage(fd, atcmd_output);
  8676. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8677. }
  8678. //option join
  8679. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8680. clif_displaymessage(fd, atcmd_output);
  8681. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8682. //option leave
  8683. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8684. clif_displaymessage(fd, atcmd_output);
  8685. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8686. //option bindto
  8687. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8688. clif_displaymessage(fd, atcmd_output);
  8689. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8690. //option unbind
  8691. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8692. clif_displaymessage(fd, atcmd_output);
  8693. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8694. //option ban/unban/banlist
  8695. if( can_create ) {
  8696. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8697. clif_displaymessage(fd, atcmd_output);
  8698. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8699. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8700. clif_displaymessage(fd, atcmd_output);
  8701. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8702. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8703. clif_displaymessage(fd, atcmd_output);
  8704. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8705. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8706. clif_displaymessage(fd, atcmd_output);
  8707. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8708. }
  8709. //option setopt
  8710. if(can_create){
  8711. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8712. clif_displaymessage(fd, atcmd_output);
  8713. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8714. }
  8715. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8716. clif_displaymessage(fd, atcmd_output);
  8717. }
  8718. ACMD_FUNC(channel) {
  8719. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8720. sub1[0] = sub2[0] = '\0';
  8721. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8722. atcmd_channel_help(sd,command);
  8723. return 0;
  8724. }
  8725. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8726. return channel_pcdelete(sd,sub1);
  8727. } else if ( strcmpi(key,"list") == 0 ) {
  8728. return channel_display_list(sd,sub1);
  8729. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8730. return channel_pccolor(sd, sub1, sub2);
  8731. } else if ( strcmpi(key,"join") == 0 ) {
  8732. return channel_pcjoin(sd, sub1, sub2);
  8733. }else if ( strcmpi(key,"leave") == 0 ) {
  8734. return channel_pcleave(sd, sub1);
  8735. } else if ( strcmpi(key,"bindto") == 0 ) {
  8736. return channel_pcbind(sd, sub1);
  8737. } else if ( strcmpi(key,"unbind") == 0 ) {
  8738. return channel_pcunbind(sd);
  8739. } else if ( strcmpi(key,"ban") == 0 ) {
  8740. return channel_pcban(sd,sub1,sub2,0);
  8741. } else if ( strcmpi(key,"kick") == 0 ) {
  8742. return channel_pckick(sd,sub1,sub2);
  8743. } else if ( strcmpi(key,"banlist") == 0 ) {
  8744. return channel_pcban(sd,sub1,nullptr,3);
  8745. } else if ( strcmpi(key,"unban") == 0 ) {
  8746. return channel_pcban(sd,sub1,sub2,1);
  8747. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8748. return channel_pcban(sd,sub1,nullptr,2);
  8749. } else {
  8750. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8751. sub3[0] = sub4[0] = '\0';
  8752. sscanf(sub2, "%19s %19s", sub3, sub4);
  8753. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8754. if (sub4[0] != '\0') {
  8755. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8756. return -1;
  8757. }
  8758. return channel_pccreate(sd,sub1,sub3);
  8759. } else if ( strcmpi(key,"setopt") == 0 ) {
  8760. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8761. }
  8762. atcmd_channel_help(sd,command);
  8763. }
  8764. return 0;
  8765. }
  8766. ACMD_FUNC(fontcolor)
  8767. {
  8768. if( !message || !*message ) {
  8769. channel_display_list(sd,"colors");
  8770. return -1;
  8771. }
  8772. if( strcmpi(message,"Normal") == 0 ) {
  8773. sd->fontcolor = 0;
  8774. } else {
  8775. unsigned char k;
  8776. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8777. if( k == channel_config.colors_count ) {
  8778. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8779. clif_displaymessage(fd, atcmd_output);
  8780. return -1;
  8781. }
  8782. sd->fontcolor = k;
  8783. }
  8784. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8785. clif_displaymessage(fd, atcmd_output);
  8786. return 0;
  8787. }
  8788. ACMD_FUNC(langtype)
  8789. {
  8790. char langstr[8];
  8791. int32 i=0, fail=0;
  8792. memset(langstr, '\0', sizeof(langstr));
  8793. if(sscanf(message, "%3s", langstr) >= 1){
  8794. int32 lang=0;
  8795. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8796. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8797. char output[100];
  8798. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8799. sd->langtype = lang;
  8800. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8801. clif_displaymessage(fd,output);
  8802. return 0;
  8803. } else if (lang != -1) { //defined langage but failed check
  8804. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8805. return -1;
  8806. }
  8807. }
  8808. //wrong or no entry
  8809. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8810. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8811. while(fail != -1){ //out of range
  8812. fail = msg_checklangtype(i,false);
  8813. if(fail == 1)
  8814. clif_displaymessage(fd,msg_langtype2langstr(i));
  8815. i++;
  8816. }
  8817. return -1;
  8818. }
  8819. #ifdef VIP_ENABLE
  8820. ACMD_FUNC(vip) {
  8821. map_session_data* pl_sd = nullptr;;
  8822. char * modif_p;
  8823. int32 vipdifftime = 0;
  8824. time_t now=time(nullptr);
  8825. nullpo_retr(-1, sd);
  8826. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8827. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8828. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8829. return -1;
  8830. }
  8831. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8832. modif_p = atcmd_output;
  8833. vipdifftime = (int32)solve_time(modif_p);
  8834. if (vipdifftime == 0) {
  8835. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8836. 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.
  8837. return -1;
  8838. }
  8839. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  8840. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8841. return -1;
  8842. }
  8843. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8844. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8845. return -1;
  8846. }
  8847. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8848. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8849. if (pl_sd->vip.time <= now) {
  8850. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8851. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8852. } else {
  8853. int32 year,month,day,hour,minute,second;
  8854. char timestr[21];
  8855. split_time((int32)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8856. 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.
  8857. clif_displaymessage(pl_sd->fd,atcmd_output);
  8858. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8859. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8860. clif_displaymessage(pl_sd->fd,atcmd_output);
  8861. if (pl_sd != sd) {
  8862. 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.
  8863. clif_displaymessage(fd,atcmd_output);
  8864. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8865. clif_displaymessage(fd,atcmd_output);
  8866. }
  8867. }
  8868. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8869. return 0;
  8870. }
  8871. /** Enable/disable rate info */
  8872. ACMD_FUNC(showrate) {
  8873. nullpo_retr(-1,sd);
  8874. if (!sd->vip.disableshowrate) {
  8875. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8876. sd->vip.disableshowrate = 1;
  8877. } else {
  8878. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8879. sd->vip.disableshowrate = 0;
  8880. }
  8881. clif_displaymessage(fd,atcmd_output);
  8882. return 0;
  8883. }
  8884. #endif
  8885. ACMD_FUNC(fullstrip) {
  8886. int32 i;
  8887. TBL_PC *tsd;
  8888. nullpo_retr(-1,sd);
  8889. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8890. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8891. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8892. return -1;
  8893. }
  8894. if((tsd=map_nick2sd(atcmd_player_name,false)) == nullptr && (tsd=map_id2sd(atoi(atcmd_player_name))) == nullptr){
  8895. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8896. return -1;
  8897. }
  8898. for( i = 0; i < EQI_MAX; i++ ) {
  8899. if( tsd->equip_index[ i ] >= 0 )
  8900. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8901. }
  8902. return 0;
  8903. }
  8904. ACMD_FUNC(changedress){
  8905. sc_type name2id[] = {
  8906. SC_WEDDING,
  8907. SC_XMAS,
  8908. SC_SUMMER,
  8909. SC_DRESSUP,
  8910. SC_HANBOK,
  8911. SC_OKTOBERFEST
  8912. };
  8913. for( sc_type type : name2id ) {
  8914. if( sd->sc.getSCE(type) ) {
  8915. status_change_end( &sd->bl, type );
  8916. // You should only be able to have one - so we cancel here
  8917. break;
  8918. }
  8919. }
  8920. return 0;
  8921. }
  8922. ACMD_FUNC(costume) {
  8923. const char* names[] = {
  8924. "Wedding",
  8925. "Xmas",
  8926. "Summer",
  8927. "Summer2",
  8928. "Hanbok",
  8929. "Oktoberfest"
  8930. };
  8931. const int32 name2id[] = {
  8932. SC_WEDDING,
  8933. SC_XMAS,
  8934. SC_SUMMER,
  8935. SC_DRESSUP,
  8936. SC_HANBOK,
  8937. SC_OKTOBERFEST
  8938. };
  8939. uint16 k = 0, len = ARRAYLENGTH(names);
  8940. if( !message || !*message ) {
  8941. for( k = 0; k < len; k++ ) {
  8942. if( sd->sc.getSCE(name2id[k]) ) {
  8943. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8944. clif_displaymessage(sd->fd, atcmd_output);
  8945. status_change_end(&sd->bl, (sc_type)name2id[k]);
  8946. return 0;
  8947. }
  8948. }
  8949. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8950. for( k = 0; k < len; k++ ) {
  8951. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8952. clif_displaymessage(sd->fd, atcmd_output);
  8953. }
  8954. return -1;
  8955. }
  8956. for( k = 0; k < len; k++ ) {
  8957. if( sd->sc.getSCE(name2id[k]) ) {
  8958. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8959. clif_displaymessage(sd->fd, atcmd_output);
  8960. return -1;
  8961. }
  8962. }
  8963. for( k = 0; k < len; k++ )
  8964. if( strcmpi(message, names[k]) == 0 )
  8965. break;
  8966. if( k == len ) {
  8967. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8968. clif_displaymessage(sd->fd, atcmd_output);
  8969. return -1;
  8970. }
  8971. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  8972. return 0;
  8973. }
  8974. /**
  8975. * Clone other player's equipments
  8976. * Usage: @cloneequip <char name/ID>
  8977. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8978. * @author [Cydh], [Antares]
  8979. */
  8980. ACMD_FUNC(cloneequip) {
  8981. map_session_data *pl_sd;
  8982. nullpo_retr(-1, sd);
  8983. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8984. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8985. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8986. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8987. clif_displaymessage(fd, atcmd_output);
  8988. return -1;
  8989. }
  8990. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8991. clif_displaymessage(fd, msg_txt(sd, 3));
  8992. return -1;
  8993. }
  8994. if (sd == pl_sd) {
  8995. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8996. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8997. clif_displaymessage(fd, atcmd_output);
  8998. return -1;
  8999. }
  9000. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  9001. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9002. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  9003. clif_displaymessage(fd, atcmd_output);
  9004. return -1;
  9005. }
  9006. else {
  9007. int8 i;
  9008. for (i = 0; i < EQI_MAX; i++) {
  9009. int16 idx;
  9010. char flag = 0;
  9011. struct item tmp_item;
  9012. if ((idx = pl_sd->equip_index[i]) < 0)
  9013. continue;
  9014. if (i == EQI_AMMO)
  9015. continue;
  9016. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  9017. continue;
  9018. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  9019. if (itemdb_isspecial(tmp_item.card[0]))
  9020. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  9021. tmp_item.bound = 0;
  9022. tmp_item.expire_time = 0;
  9023. tmp_item.unique_id = 0;
  9024. tmp_item.favorite = 0;
  9025. tmp_item.amount = 1;
  9026. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  9027. clif_additem(sd, 0, 0, flag);
  9028. else
  9029. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  9030. }
  9031. }
  9032. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9033. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  9034. clif_displaymessage(fd, atcmd_output);
  9035. return 0;
  9036. }
  9037. /**
  9038. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  9039. * Usage: @clonestat <char name/ID>
  9040. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  9041. * @author [Cydh], [Antares]
  9042. */
  9043. ACMD_FUNC(clonestat) {
  9044. map_session_data *pl_sd;
  9045. nullpo_retr(-1, sd);
  9046. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  9047. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9048. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  9049. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  9050. clif_displaymessage(fd, atcmd_output);
  9051. return -1;
  9052. }
  9053. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  9054. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  9055. return -1;
  9056. }
  9057. if (sd == pl_sd) {
  9058. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9059. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  9060. clif_displaymessage(fd, atcmd_output);
  9061. return -1;
  9062. }
  9063. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  9064. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9065. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  9066. clif_displaymessage(fd, atcmd_output);
  9067. return -1;
  9068. }
  9069. else {
  9070. uint8 i;
  9071. int16 max_status[PARAM_MAX] = {};
  9072. pc_resetstate(sd);
  9073. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE)) {
  9074. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  9075. if (i >= PARAM_POW && !(sd->class_ & JOBL_FOURTH))
  9076. continue;
  9077. max_status[i] = SHRT_MAX;
  9078. }
  9079. } else {
  9080. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  9081. if (i >= PARAM_POW && sd->class_ & JOBL_FOURTH)
  9082. continue;
  9083. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  9084. }
  9085. }
  9086. #define clonestat_check(cmd,stat)\
  9087. {\
  9088. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  9089. if (pl_sd->status.cmd > max_status[(stat)]) {\
  9090. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  9091. clif_displaymessage(fd, atcmd_output);\
  9092. sd->status.cmd = max_status[(stat)];\
  9093. }\
  9094. else\
  9095. sd->status.cmd = pl_sd->status.cmd;\
  9096. }
  9097. clonestat_check(str, PARAM_STR);
  9098. clonestat_check(agi, PARAM_AGI);
  9099. clonestat_check(vit, PARAM_VIT);
  9100. clonestat_check(int_, PARAM_INT);
  9101. clonestat_check(dex, PARAM_DEX);
  9102. clonestat_check(luk, PARAM_LUK);
  9103. for (i = PARAM_STR; i < PARAM_POW; i++) {
  9104. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  9105. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  9106. }
  9107. if (sd->class_ & JOBL_FOURTH) {
  9108. clonestat_check(pow, PARAM_POW);
  9109. clonestat_check(sta, PARAM_STA);
  9110. clonestat_check(wis, PARAM_WIS);
  9111. clonestat_check(spl, PARAM_SPL);
  9112. clonestat_check(con, PARAM_CON);
  9113. clonestat_check(crt, PARAM_CRT);
  9114. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  9115. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  9116. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  9117. }
  9118. }
  9119. status_calc_pc(sd, SCO_FORCE);
  9120. }
  9121. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9122. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  9123. clif_displaymessage(fd, atcmd_output);
  9124. #undef clonestat_check
  9125. return 0;
  9126. }
  9127. /**
  9128. * Adopt a character.
  9129. * Usage: @adopt <char name>
  9130. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  9131. */
  9132. ACMD_FUNC(adopt)
  9133. {
  9134. TBL_PC *b_sd;
  9135. enum adopt_responses response;
  9136. nullpo_retr(-1, sd);
  9137. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9138. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  9139. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  9140. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  9141. clif_displaymessage(fd, atcmd_output);
  9142. return -1;
  9143. }
  9144. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  9145. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  9146. return -1;
  9147. }
  9148. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  9149. if (response == ADOPT_ALLOWED) {
  9150. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  9151. b_sd->adopt_invite = sd->status.account_id;
  9152. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  9153. return 0;
  9154. }
  9155. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  9156. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  9157. return -1;
  9158. }
  9159. /**
  9160. * Opens the limited sale window.
  9161. * Usage: @limitedsale or client command /limitedsale on supported clients
  9162. */
  9163. ACMD_FUNC(limitedsale){
  9164. nullpo_retr(-1, sd);
  9165. clif_sale_open(sd);
  9166. return 0;
  9167. }
  9168. /**
  9169. * Displays camera information from the client.
  9170. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  9171. */
  9172. ACMD_FUNC(camerainfo){
  9173. nullpo_retr(-1, sd);
  9174. if( message == nullptr || message[0] == '\0' ){
  9175. clif_camerainfo( sd, true );
  9176. return 0;
  9177. }
  9178. float range = 0;
  9179. float rotation = 0;
  9180. float latitude = 0;
  9181. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  9182. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  9183. return -1;
  9184. }
  9185. clif_camerainfo( sd, false, range, rotation, latitude );
  9186. return 0;
  9187. }
  9188. ACMD_FUNC(resurrect) {
  9189. nullpo_retr(-1, sd);
  9190. if (!pc_revive_item(sd))
  9191. return -1;
  9192. return 0;
  9193. }
  9194. ACMD_FUNC(setquest){
  9195. int32 quest_id = 0;
  9196. nullpo_retr(-1, sd);
  9197. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9198. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9199. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9200. clif_displaymessage(fd, atcmd_output);
  9201. return -1;
  9202. }
  9203. if (!quest_search(quest_id)) {
  9204. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9205. clif_displaymessage(fd, atcmd_output);
  9206. return -1;
  9207. }
  9208. if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
  9209. sprintf(atcmd_output, msg_txt(sd,1507), quest_id); // Character already has quest %d.
  9210. clif_displaymessage(fd, atcmd_output);
  9211. return -1;
  9212. }
  9213. quest_add(sd, quest_id);
  9214. pc_show_questinfo(sd);
  9215. return 0;
  9216. }
  9217. ACMD_FUNC(erasequest) {
  9218. int32 quest_id = 0;
  9219. nullpo_retr(-1, sd);
  9220. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9221. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9222. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9223. clif_displaymessage(fd, atcmd_output);
  9224. return -1;
  9225. }
  9226. if (!quest_search(quest_id)) {
  9227. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9228. clif_displaymessage(fd, atcmd_output);
  9229. return -1;
  9230. }
  9231. if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
  9232. sprintf(atcmd_output, msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
  9233. clif_displaymessage(fd, atcmd_output);
  9234. return -1;
  9235. }
  9236. quest_delete(sd, quest_id);
  9237. pc_show_questinfo(sd);
  9238. return 0;
  9239. }
  9240. ACMD_FUNC(completequest){
  9241. int32 quest_id = 0;
  9242. nullpo_retr(-1, sd);
  9243. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9244. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9245. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9246. clif_displaymessage(fd, atcmd_output);
  9247. return -1;
  9248. }
  9249. if (!quest_search(quest_id)) {
  9250. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9251. clif_displaymessage(fd, atcmd_output);
  9252. return -1;
  9253. }
  9254. if (quest_check(sd, quest_id, HAVEQUEST) < 0)
  9255. quest_add(sd, quest_id);
  9256. if (quest_check(sd, quest_id, HAVEQUEST) < 2)
  9257. quest_update_status(sd, quest_id, Q_COMPLETE);
  9258. pc_show_questinfo(sd);
  9259. return 0;
  9260. }
  9261. ACMD_FUNC(checkquest){
  9262. int32 quest_id = 0;
  9263. nullpo_retr(-1, sd);
  9264. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9265. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9266. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9267. clif_displaymessage(fd, atcmd_output);
  9268. return -1;
  9269. }
  9270. if (!quest_search(quest_id)) {
  9271. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9272. clif_displaymessage(fd, atcmd_output);
  9273. return -1;
  9274. }
  9275. sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
  9276. clif_displaymessage(fd, atcmd_output);
  9277. sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST)); // HAVEQUEST : %d
  9278. clif_displaymessage(fd, atcmd_output);
  9279. sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING)); // HUNTING : %d
  9280. clif_displaymessage(fd, atcmd_output);
  9281. sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME)); // PLAYTIME : %d
  9282. clif_displaymessage(fd, atcmd_output);
  9283. return 0;
  9284. }
  9285. /**
  9286. * Opens the refineUI
  9287. * Usage: @refineui
  9288. */
  9289. ACMD_FUNC(refineui)
  9290. {
  9291. nullpo_retr(-1, sd);
  9292. #if PACKETVER < 20161012
  9293. clif_displaymessage(fd, msg_txt(sd, 773)); // This command requires packet version 2016-10-12 or newer.
  9294. return -1;
  9295. #else
  9296. if( !battle_config.feature_refineui ){
  9297. clif_displaymessage(fd, msg_txt(sd, 774)); // This command is disabled via configuration.
  9298. return -1;
  9299. }
  9300. if( sd->state.refineui_open ){
  9301. clif_displaymessage(fd, msg_txt(sd, 775)); // You have already opened the refine UI.
  9302. return -1;
  9303. }
  9304. clif_refineui_open(sd);
  9305. return 0;
  9306. #endif
  9307. }
  9308. ACMD_FUNC( stylist ){
  9309. nullpo_retr(-1, sd);
  9310. #if PACKETVER < 20151104
  9311. clif_displaymessage( fd, msg_txt( sd, 798 ) ); // This command requires packet version 2015-11-04 or newer.
  9312. return -1;
  9313. #else
  9314. if( !battle_config.feature_stylist ){
  9315. clif_displaymessage( fd, msg_txt( sd, 774 ) ); // This command is disabled via configuration.
  9316. return -1;
  9317. }
  9318. if( sd->state.stylist_open ){
  9319. clif_displaymessage( fd, msg_txt( sd, 799 ) ); // You have already opened the stylist UI.
  9320. return -1;
  9321. }
  9322. clif_ui_open( *sd, OUT_UI_STYLIST, 0 );
  9323. return 0;
  9324. #endif
  9325. }
  9326. /**
  9327. * Add fame point(s) to a player
  9328. * Usage: @addfame <amount>
  9329. */
  9330. ACMD_FUNC(addfame)
  9331. {
  9332. nullpo_retr(-1, sd);
  9333. int32 famepoint = 0;
  9334. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9335. if (!message || !*message || sscanf(message, "%11d", &famepoint) < 1 || famepoint == 0) {
  9336. sprintf(atcmd_output, msg_txt(sd, 1516), command); // Usage: %s <fame points>.
  9337. clif_displaymessage(fd, atcmd_output);
  9338. return -1;
  9339. }
  9340. if (!pc_addfame(*sd, famepoint)) {
  9341. sprintf(atcmd_output, msg_txt(sd, 1517), job_name(sd->status.class_)); // Cannot add fame to class '%s'.
  9342. clif_displaymessage(fd, atcmd_output);
  9343. return -1;
  9344. }
  9345. sprintf(atcmd_output, msg_txt(sd, 1518), famepoint, sd->status.name); // %d points were added to '%s'.
  9346. clif_displaymessage(fd, atcmd_output);
  9347. return 0;
  9348. }
  9349. /**
  9350. * Opens the enchantgrade UI
  9351. * Usage: @enchantgradeui
  9352. */
  9353. ACMD_FUNC( enchantgradeui ){
  9354. nullpo_retr( -1, sd );
  9355. #if !( PACKETVER_MAIN_NUM >= 20200916 || PACKETVER_RE_NUM >= 20200724 )
  9356. sprintf( atcmd_output, msg_txt( sd, 798 ), "2020-07-24" ); // This command requires packet version %s or newer.
  9357. clif_displaymessage( fd, atcmd_output );
  9358. return -1;
  9359. #else
  9360. clif_ui_open( *sd, OUT_UI_ENCHANTGRADE, 0 );
  9361. return 0;
  9362. #endif
  9363. }
  9364. ACMD_FUNC( roulette ){
  9365. nullpo_retr( -1, sd );
  9366. #if PACKETVER < 20141022
  9367. sprintf( atcmd_output, msg_txt( sd, 798 ), "2014-10-22" ); // This command requires packet version %s or newer.
  9368. clif_displaymessage( fd, atcmd_output );
  9369. return -1;
  9370. #else
  9371. if( !battle_config.feature_roulette ){
  9372. clif_displaymessage( fd, msg_txt( sd, 1497 ) ); // Roulette is disabled
  9373. return -1;
  9374. }
  9375. clif_roulette_open( sd );
  9376. return 0;
  9377. #endif
  9378. }
  9379. /**
  9380. * Replaces a card ID in an equip
  9381. * Usage: @setcard <equip position> <slot> <card_id>
  9382. */
  9383. ACMD_FUNC(setcard)
  9384. {
  9385. nullpo_retr(-1, sd);
  9386. int32 position = 0, slot, card_id;
  9387. if (!message || !*message || sscanf(message, "%11d %11d %11d", &position, &slot, &card_id) < 3) {
  9388. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9389. clif_displaymessage(fd, msg_txt(sd,1527)); // Please enter the position, the slot number and the card ID (usage: @setcard <equip position> <slot> <card_id>).
  9390. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  9391. clif_displaymessage(fd, atcmd_output);
  9392. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  9393. clif_displaymessage(fd, atcmd_output);
  9394. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  9395. clif_displaymessage(fd, atcmd_output);
  9396. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  9397. clif_displaymessage(fd, atcmd_output);
  9398. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  9399. clif_displaymessage(fd, atcmd_output);
  9400. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  9401. clif_displaymessage(fd, atcmd_output);
  9402. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  9403. clif_displaymessage(fd, atcmd_output);
  9404. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  9405. clif_displaymessage(fd, atcmd_output);
  9406. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  9407. clif_displaymessage(fd, atcmd_output);
  9408. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  9409. return -1;
  9410. }
  9411. if (position < EQP_HEAD_LOW || position > EQP_HEAD_MID) {
  9412. clif_displaymessage(fd, msg_txt(sd,1531)); // Invalid position.
  9413. return -1;
  9414. }
  9415. if (slot < 0 || slot >= MAX_SLOTS) {
  9416. clif_displaymessage(fd, msg_txt(sd,1532)); // Invalid slot number.
  9417. return -1;
  9418. }
  9419. if (card_id != 0) {
  9420. std::shared_ptr<item_data> item_data = item_db.find( card_id );
  9421. if (item_data == nullptr) {
  9422. clif_displaymessage(fd, msg_txt(sd,1530)); // Invalid card ID.
  9423. return -1;
  9424. }
  9425. if (item_data->type != IT_CARD) {
  9426. clif_displaymessage(fd, msg_txt(sd,1529)); // The item type must be a card or enchant.
  9427. return -1;
  9428. }
  9429. }
  9430. int16 i = pc_checkequip(sd, position);
  9431. if (i < 0) {
  9432. clif_displaymessage(fd, msg_txt(sd,1528)); // You are not wearing any equipment in this position.
  9433. return -1;
  9434. }
  9435. int32 current_position = sd->inventory.u.items_inventory[i].equip;
  9436. pc_unequipitem(sd, i, 3);
  9437. log_pick_pc( sd, LOG_TYPE_COMMAND, -1, &sd->inventory.u.items_inventory[i] );
  9438. sd->inventory.u.items_inventory[i].card[slot] = card_id;
  9439. log_pick_pc( sd, LOG_TYPE_COMMAND, 1, &sd->inventory.u.items_inventory[i] );
  9440. clif_delitem( *sd, i, 1, 0 );
  9441. clif_additem(sd, i, 1, 0);
  9442. pc_equipitem(sd, i, current_position);
  9443. return 0;
  9444. }
  9445. #include <custom/atcommand.inc>
  9446. /**
  9447. * Fills the reference of available commands in atcommand DBMap
  9448. **/
  9449. #define ACMD_DEF(x) { #x, atcommand_ ## x, nullptr, nullptr, 0 }
  9450. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, nullptr, nullptr, 0 }
  9451. // Define with restriction
  9452. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, nullptr, nullptr, r }
  9453. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, nullptr, nullptr, r }
  9454. void atcommand_basecommands(void) {
  9455. /**
  9456. * Command reference list, place the base of your commands here
  9457. * TODO: List all commands that causing crash
  9458. **/
  9459. AtCommandInfo atcommand_base[] = {
  9460. #include <custom/atcommand_def.inc>
  9461. ACMD_DEF(mapmove),
  9462. ACMD_DEF(where),
  9463. ACMD_DEF(jumpto),
  9464. ACMD_DEF(jump),
  9465. ACMD_DEF(who),
  9466. ACMD_DEF2("who2", who),
  9467. ACMD_DEF2("who3", who),
  9468. ACMD_DEF2("whomap", who),
  9469. ACMD_DEF2("whomap2", who),
  9470. ACMD_DEF2("whomap3", who),
  9471. ACMD_DEF(whogm),
  9472. ACMD_DEF(save),
  9473. ACMD_DEF(load),
  9474. ACMD_DEF(speed),
  9475. ACMD_DEF(storage),
  9476. ACMD_DEF(guildstorage),
  9477. ACMD_DEF(option),
  9478. ACMD_DEF(hide), // + /hide
  9479. ACMD_DEF(resetcooltime), // + /resetcooltime
  9480. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  9481. ACMD_DEF(kill),
  9482. ACMD_DEF(alive),
  9483. ACMD_DEF(kami),
  9484. ACMD_DEF(kamib),
  9485. ACMD_DEF(kamic),
  9486. ACMD_DEF(lkami),
  9487. ACMD_DEF(heal),
  9488. ACMD_DEF(healap),
  9489. ACMD_DEF(item),
  9490. ACMD_DEF(item2),
  9491. ACMD_DEF2("itembound",item),
  9492. ACMD_DEF2("itembound2",item2),
  9493. ACMD_DEF(itemreset),
  9494. ACMD_DEF(clearstorage),
  9495. ACMD_DEF(cleargstorage),
  9496. ACMD_DEF(clearcart),
  9497. ACMD_DEF(baselevelup),
  9498. ACMD_DEF(joblevelup),
  9499. ACMD_DEF(help),
  9500. ACMD_DEF(pvpoff),
  9501. ACMD_DEF(pvpon),
  9502. ACMD_DEF(gvgoff),
  9503. ACMD_DEF(gvgon),
  9504. ACMD_DEF(model),
  9505. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  9506. ACMD_DEF(monster),
  9507. ACMD_DEF2("monstersmall", monster),
  9508. ACMD_DEF2("monsterbig", monster),
  9509. ACMD_DEF(killmonster),
  9510. ACMD_DEF2("killmonster2", killmonster),
  9511. ACMD_DEF(refine),
  9512. ACMD_DEF(grade),
  9513. ACMD_DEF(produce),
  9514. ACMD_DEF(memo),
  9515. ACMD_DEF(gat),
  9516. ACMD_DEF(displaystatus),
  9517. ACMD_DEF(statuspoint),
  9518. ACMD_DEF(traitpoint),
  9519. ACMD_DEF(skillpoint),
  9520. ACMD_DEF(zeny),
  9521. ACMD_DEF2("str", param),
  9522. ACMD_DEF2("agi", param),
  9523. ACMD_DEF2("vit", param),
  9524. ACMD_DEF2("int", param),
  9525. ACMD_DEF2("dex", param),
  9526. ACMD_DEF2("luk", param),
  9527. ACMD_DEF2("pow", param),
  9528. ACMD_DEF2("sta", param),
  9529. ACMD_DEF2("wis", param),
  9530. ACMD_DEF2("spl", param),
  9531. ACMD_DEF2("con", param),
  9532. ACMD_DEF2("crt", param),
  9533. ACMD_DEF(guildlevelup),
  9534. ACMD_DEF(makeegg),
  9535. ACMD_DEF(hatch),
  9536. ACMD_DEF(petfriendly),
  9537. ACMD_DEF(pethungry),
  9538. ACMD_DEF(petrename),
  9539. ACMD_DEF(recall), // + /recall
  9540. ACMD_DEF(night),
  9541. ACMD_DEF(day),
  9542. ACMD_DEF(doom),
  9543. ACMD_DEF(doommap),
  9544. ACMD_DEF(raise),
  9545. ACMD_DEF(raisemap),
  9546. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  9547. ACMD_DEF(kickall),
  9548. ACMD_DEF(allskill),
  9549. ACMD_DEF(questskill),
  9550. ACMD_DEF(lostskill),
  9551. ACMD_DEF(spiritball),
  9552. ACMD_DEF(soulball),
  9553. ACMD_DEF(party),
  9554. ACMD_DEF(guild),
  9555. ACMD_DEF(breakguild),
  9556. ACMD_DEF(agitstart),
  9557. ACMD_DEF(agitend),
  9558. ACMD_DEF(mapexit),
  9559. ACMD_DEF(idsearch),
  9560. ACMD_DEF(broadcast), // + /b and /nb
  9561. ACMD_DEF(localbroadcast), // + /lb and /nlb
  9562. ACMD_DEF(recallall),
  9563. ACMD_DEF(reloaditemdb),
  9564. ACMD_DEF(reloadcashdb),
  9565. ACMD_DEF(reloadmobdb),
  9566. ACMD_DEF(reloadskilldb),
  9567. ACMD_DEFR(reloadscript, ATCMD_NOSCRIPT),
  9568. ACMD_DEF(reloadatcommand),
  9569. ACMD_DEF(reloadbattleconf),
  9570. ACMD_DEF(reloadstatusdb),
  9571. ACMD_DEF(reloadpcdb),
  9572. ACMD_DEF(reloadmotd),
  9573. ACMD_DEF(reloadquestdb),
  9574. ACMD_DEF(reloadmsgconf),
  9575. ACMD_DEF(reloadinstancedb),
  9576. ACMD_DEF(reloadachievementdb),
  9577. ACMD_DEF(reloadattendancedb),
  9578. ACMD_DEF(reloadbarterdb),
  9579. ACMD_DEF(reloadlogconf),
  9580. ACMD_DEF(partysharelvl),
  9581. ACMD_DEF(mapinfo),
  9582. ACMD_DEF(dye),
  9583. ACMD_DEF(hair_style),
  9584. ACMD_DEF(hair_color),
  9585. ACMD_DEF(stat_all),
  9586. ACMD_DEF(trait_all),
  9587. ACMD_DEF(char_block),
  9588. ACMD_DEF(char_ban),
  9589. ACMD_DEF(char_unblock),
  9590. ACMD_DEF(char_unban),
  9591. ACMD_DEF(mount_peco),
  9592. ACMD_DEF(guildspy),
  9593. ACMD_DEF(partyspy),
  9594. ACMD_DEF(clanspy),
  9595. ACMD_DEF(repairall),
  9596. ACMD_DEF(guildrecall),
  9597. ACMD_DEF(partyrecall),
  9598. ACMD_DEF(nuke),
  9599. ACMD_DEF(shownpc),
  9600. ACMD_DEF(hidenpc),
  9601. ACMD_DEF(loadnpc),
  9602. ACMD_DEF(unloadnpc),
  9603. ACMD_DEF(reloadnpcfile),
  9604. ACMD_DEF(servertime),
  9605. ACMD_DEF(jail),
  9606. ACMD_DEF(unjail),
  9607. ACMD_DEF(jailfor),
  9608. ACMD_DEF(jailtime),
  9609. ACMD_DEF(disguise),
  9610. ACMD_DEF(undisguise),
  9611. ACMD_DEF(email),
  9612. ACMD_DEF(effect),
  9613. ACMD_DEF(follow),
  9614. ACMD_DEF(addwarp),
  9615. ACMD_DEF(skillon),
  9616. ACMD_DEF(skilloff),
  9617. ACMD_DEF(killer),
  9618. ACMD_DEF(npcmove),
  9619. ACMD_DEF(killable),
  9620. ACMD_DEF(dropall),
  9621. ACMD_DEF(stockall),
  9622. ACMD_DEF(storeall),
  9623. ACMD_DEF(skillid),
  9624. ACMD_DEF(useskill),
  9625. ACMD_DEF(displayskill),
  9626. ACMD_DEF(displayskillcast),
  9627. ACMD_DEF(displayskillunit),
  9628. ACMD_DEF(snow),
  9629. ACMD_DEF(sakura),
  9630. ACMD_DEF(clouds),
  9631. ACMD_DEF(clouds2),
  9632. ACMD_DEF(fog),
  9633. ACMD_DEF(fireworks),
  9634. ACMD_DEF(leaves),
  9635. ACMD_DEF(summon),
  9636. ACMD_DEF(adjgroup),
  9637. ACMD_DEF(trade),
  9638. ACMD_DEF(send),
  9639. ACMD_DEF(setbattleflag),
  9640. ACMD_DEF(unmute),
  9641. ACMD_DEF(clearweather),
  9642. ACMD_DEF(uptime),
  9643. ACMD_DEF(changesex),
  9644. ACMD_DEF(changecharsex),
  9645. ACMD_DEF(mute),
  9646. ACMD_DEF(refresh),
  9647. ACMD_DEF(refreshall),
  9648. ACMD_DEF(identify),
  9649. ACMD_DEF(identifyall),
  9650. ACMD_DEF(gmotd),
  9651. ACMD_DEF(misceffect),
  9652. ACMD_DEF(mobsearch),
  9653. ACMD_DEF(cleanmap),
  9654. ACMD_DEF(cleanarea),
  9655. ACMD_DEF(npctalk),
  9656. ACMD_DEF(pettalk),
  9657. ACMD_DEF(users),
  9658. ACMD_DEF(reset),
  9659. ACMD_DEF(skilltree),
  9660. ACMD_DEF(marry),
  9661. ACMD_DEF(divorce),
  9662. ACMD_DEF(sound),
  9663. ACMD_DEF(undisguiseall),
  9664. ACMD_DEF(disguiseall),
  9665. ACMD_DEF(changelook),
  9666. ACMD_DEF(autoloot),
  9667. ACMD_DEF(autolootitem),
  9668. ACMD_DEF(autoloottype),
  9669. ACMD_DEF(mobinfo),
  9670. ACMD_DEF(exp),
  9671. ACMD_DEF(version),
  9672. ACMD_DEF(mutearea),
  9673. ACMD_DEF(rates),
  9674. ACMD_DEF(iteminfo),
  9675. ACMD_DEF(whodrops),
  9676. ACMD_DEF(whereis),
  9677. ACMD_DEF(mapflag),
  9678. ACMD_DEF(me),
  9679. ACMD_DEF(monsterignore),
  9680. ACMD_DEF(fakename),
  9681. ACMD_DEF(size),
  9682. ACMD_DEF(showexp),
  9683. ACMD_DEF(showzeny),
  9684. ACMD_DEF(showdelay),
  9685. ACMD_DEF(autotrade),
  9686. ACMD_DEF(changegm),
  9687. ACMD_DEF(changeleader),
  9688. ACMD_DEF(partyoption),
  9689. ACMD_DEF(invite),
  9690. ACMD_DEF(duel),
  9691. ACMD_DEF(leave),
  9692. ACMD_DEF(accept),
  9693. ACMD_DEF(reject),
  9694. ACMD_DEF(clone),
  9695. ACMD_DEF2("slaveclone", clone),
  9696. ACMD_DEF2("evilclone", clone),
  9697. ACMD_DEF(tonpc),
  9698. ACMD_DEF(commands),
  9699. ACMD_DEF(noask),
  9700. ACMD_DEF(request),
  9701. ACMD_DEF(homlevel),
  9702. ACMD_DEF(homevolution),
  9703. ACMD_DEF(hommutate),
  9704. ACMD_DEF(makehomun),
  9705. ACMD_DEF(homfriendly),
  9706. ACMD_DEF(homhungry),
  9707. ACMD_DEF(homtalk),
  9708. ACMD_DEF(hominfo),
  9709. ACMD_DEF(homstats),
  9710. ACMD_DEF(homshuffle),
  9711. ACMD_DEF(showmobs),
  9712. ACMD_DEF(feelreset),
  9713. ACMD_DEF(hatereset),
  9714. ACMD_DEF(auction),
  9715. ACMD_DEF(mail),
  9716. ACMD_DEF(ksprotection),
  9717. ACMD_DEF(allowks),
  9718. ACMD_DEF(cash),
  9719. ACMD_DEF(points),
  9720. ACMD_DEF(agitstart2),
  9721. ACMD_DEF(agitend2),
  9722. ACMD_DEF(resetskill),
  9723. ACMD_DEF(resetstat),
  9724. ACMD_DEF2("storagelist", itemlist),
  9725. ACMD_DEF2("cartlist", itemlist),
  9726. ACMD_DEF2("itemlist", itemlist),
  9727. ACMD_DEF(stats),
  9728. ACMD_DEF(delitem),
  9729. ACMD_DEF(charcommands),
  9730. ACMD_DEF(font),
  9731. ACMD_DEF(accinfo),
  9732. ACMD_DEF(set),
  9733. ACMD_DEF(undisguiseguild),
  9734. ACMD_DEF(disguiseguild),
  9735. ACMD_DEF(sizeall),
  9736. ACMD_DEF(sizeguild),
  9737. ACMD_DEF(addperm),
  9738. ACMD_DEF(rmvperm),
  9739. ACMD_DEF(unloadnpcfile),
  9740. ACMD_DEF(cart),
  9741. ACMD_DEF(mount2),
  9742. ACMD_DEF(join),
  9743. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  9744. ACMD_DEF(fontcolor),
  9745. ACMD_DEF(langtype),
  9746. #ifdef VIP_ENABLE
  9747. ACMD_DEF(vip),
  9748. ACMD_DEF(showrate),
  9749. #endif
  9750. ACMD_DEF(fullstrip),
  9751. ACMD_DEF(costume),
  9752. ACMD_DEF(cloneequip),
  9753. ACMD_DEF(clonestat),
  9754. ACMD_DEF(bodystyle),
  9755. ACMD_DEF(adopt),
  9756. ACMD_DEF(agitstart3),
  9757. ACMD_DEF(agitend3),
  9758. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9759. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9760. ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9761. ACMD_DEFR(resurrect, ATCMD_NOCONSOLE),
  9762. ACMD_DEF(setquest),
  9763. ACMD_DEF(erasequest),
  9764. ACMD_DEF(completequest),
  9765. ACMD_DEF(checkquest),
  9766. ACMD_DEF(refineui),
  9767. ACMD_DEFR(stylist, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9768. ACMD_DEF(addfame),
  9769. ACMD_DEFR(enchantgradeui, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9770. ACMD_DEFR(roulette, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9771. ACMD_DEF(setcard),
  9772. };
  9773. AtCommandInfo* atcommand;
  9774. int32 i;
  9775. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9776. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9777. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9778. continue;
  9779. }
  9780. CREATE(atcommand, AtCommandInfo, 1);
  9781. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9782. atcommand->func = atcommand_base[i].func;
  9783. atcommand->restriction = atcommand_base[i].restriction;
  9784. strdb_put(atcommand_db, atcommand->command, atcommand);
  9785. }
  9786. return;
  9787. }
  9788. /*==========================================
  9789. * Command lookup functions
  9790. *------------------------------------------*/
  9791. bool atcommand_exists(const char* name)
  9792. {
  9793. return strdb_exists(atcommand_db, name);
  9794. }
  9795. const char* atcommand_alias_lookup( const std::string& cmd ){
  9796. return atcommand_alias_db.checkAlias( cmd.c_str() );
  9797. }
  9798. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9799. {
  9800. if (strdb_exists(atcommand_db, name))
  9801. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9802. return nullptr;
  9803. }
  9804. /// AtCommand suggestion
  9805. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand) {
  9806. DBIterator* atcommand_iter;
  9807. AtCommandInfo* command_info = nullptr;
  9808. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9809. char* full_match[MAX_SUGGESTIONS];
  9810. char* suggestions[MAX_SUGGESTIONS];
  9811. char* match;
  9812. int32 prefix_count = 0, full_count = 0;
  9813. bool can_use;
  9814. if (!battle_config.atcommand_suggestions_enabled)
  9815. return;
  9816. atcommand_iter = db_iterator(atcommand_db);
  9817. // Build the matches
  9818. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  9819. match = strstr(command_info->command, name);
  9820. can_use = pc_can_use_command(sd, command_info->command, type);
  9821. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9822. suggestions[prefix_count] = command_info->command;
  9823. ++prefix_count;
  9824. }
  9825. if ( full_count < MAX_SUGGESTIONS && match != nullptr && match != command_info->command && can_use ) {
  9826. full_match[full_count] = command_info->command;
  9827. ++full_count;
  9828. }
  9829. }
  9830. for( auto& pair : atcommand_alias_db ){
  9831. std::shared_ptr<s_atcommand_alias_info> info = pair.second;
  9832. if( pc_can_use_command( sd, info->command->command, type ) ){
  9833. for( const std::string& alias_str : info->aliases ){
  9834. char* alias = const_cast<char *>(alias_str.c_str());
  9835. match = strstr( alias, name );
  9836. if( prefix_count < MAX_SUGGESTIONS && match == alias ){
  9837. suggestions[prefix_count] = alias;
  9838. ++prefix_count;
  9839. }
  9840. if( full_count < MAX_SUGGESTIONS && match != nullptr && match != alias ){
  9841. full_match[full_count] = alias;
  9842. ++full_count;
  9843. }
  9844. }
  9845. }
  9846. }
  9847. if ((full_count+prefix_count) > 0) {
  9848. char buffer[512];
  9849. int32 i;
  9850. // Merge full match and prefix match results
  9851. if (prefix_count < MAX_SUGGESTIONS) {
  9852. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9853. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9854. }
  9855. // Build the suggestion string
  9856. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  9857. strcat(buffer,"\n");
  9858. for(i=0; i < prefix_count; ++i) {
  9859. strcat(buffer,suggestions[i]);
  9860. strcat(buffer," ");
  9861. }
  9862. clif_displaymessage(sd->fd, buffer);
  9863. }
  9864. dbi_destroy(atcommand_iter);
  9865. }
  9866. /**
  9867. * Executes an at-command
  9868. * @param fd
  9869. * @param sd
  9870. * @param message
  9871. * @param type
  9872. * 0 : script call (atcommand)
  9873. * 1 : normal player @atcommand
  9874. * 2 : console (admin:@atcommand)
  9875. * 3 : script call (useatcmd)
  9876. */
  9877. bool is_atcommand(const int32 fd, map_session_data* sd, const char* message, int32 type)
  9878. {
  9879. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  9880. char output[CHAT_SIZE_MAX];
  9881. //Reconstructed message
  9882. char atcmd_msg[CHAT_SIZE_MAX * 2];
  9883. TBL_PC * ssd = nullptr; //sd for target
  9884. AtCommandInfo * info;
  9885. bool is_atcommand = true; // false if it's a charcommand
  9886. nullpo_retr(false, sd);
  9887. //Shouldn't happen
  9888. if ( !message || !*message )
  9889. return false;
  9890. //If cannot use atcomamnd while talking with NPC [Kichi]
  9891. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  9892. return false;
  9893. //Block NOCHAT but do not display it as a normal message
  9894. if ( sd->sc.getSCE(SC_NOCHAT) && sd->sc.getSCE(SC_NOCHAT)->val1&MANNER_NOCOMMAND )
  9895. return true;
  9896. // skip 10/11-langtype's codepage indicator, if detected
  9897. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9898. message += 3;
  9899. //Should display as a normal message
  9900. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9901. return false;
  9902. // type value 0|2 = script|console invoked: bypass restrictions
  9903. if ( type == 1 || type == 3) {
  9904. //Commands are disabled on maps flagged as 'nocommand'
  9905. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  9906. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  9907. return false;
  9908. }
  9909. }
  9910. if (*message == charcommand_symbol)
  9911. is_atcommand = false;
  9912. if (is_atcommand) { // @command
  9913. sprintf(atcmd_msg, "%s", message);
  9914. ssd = sd;
  9915. } else { // #command
  9916. char charname[NAME_LENGTH];
  9917. int32 n;
  9918. //Checks to see if #command has a name or a name + parameters.
  9919. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  9920. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  9921. ) {
  9922. if (pc_get_group_level(sd) == 0) {
  9923. if (n < 1)
  9924. return false; // No command found. Display as normal message.
  9925. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9926. if (!info || info->char_groups[sd->group->index] == 0) // If we can't use or doesn't exist: don't even display the command failed message
  9927. return false;
  9928. }
  9929. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9930. clif_displaymessage(fd, output);
  9931. return true;
  9932. }
  9933. ssd = map_nick2sd(charname,true);
  9934. if (ssd == nullptr) {
  9935. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9936. clif_displaymessage(fd, output);
  9937. return true;
  9938. }
  9939. if (n > 2)
  9940. sprintf(atcmd_msg, "%s %s", command, params);
  9941. else
  9942. sprintf(atcmd_msg, "%s", command);
  9943. }
  9944. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9945. sd->idletime = last_tick;
  9946. if (battle_config.hom_idle_no_share && sd->hd && battle_config.idletime_hom_option&IDLE_ATCOMMAND)
  9947. sd->idletime_hom = last_tick;
  9948. if (battle_config.mer_idle_no_share && sd->md && battle_config.idletime_mer_option&IDLE_ATCOMMAND)
  9949. sd->idletime_mer = last_tick;
  9950. //Clearing these to be used once more.
  9951. memset(command, '\0', sizeof(command));
  9952. memset(params, '\0', sizeof(params));
  9953. //check to see if any params exist within this command
  9954. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9955. params[0] = '\0';
  9956. if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
  9957. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9958. clif_displaymessage(fd, output);
  9959. return true;
  9960. }
  9961. // @commands (script based)
  9962. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9963. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9964. // Check if the binding isn't nullptr and there is a NPC event, level of usage met, et cetera
  9965. if( binding != nullptr && binding->npc_event[0] &&
  9966. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9967. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9968. {
  9969. // Check if self or character invoking; if self == character invoked, then self invoke.
  9970. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9971. return true;
  9972. }
  9973. }
  9974. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9975. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9976. if (info == nullptr) {
  9977. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9978. return false;
  9979. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9980. clif_displaymessage(fd, output);
  9981. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9982. return true;
  9983. }
  9984. //check restriction
  9985. if (info->restriction) {
  9986. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9987. return true;
  9988. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9989. return true;
  9990. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9991. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9992. return true;
  9993. }
  9994. // type == 1 : player invoked
  9995. if (type == 1) {
  9996. if ((is_atcommand && info->at_groups[sd->group->index] == 0) ||
  9997. (!is_atcommand && info->char_groups[sd->group->index] == 0) )
  9998. return false;
  9999. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  10000. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  10001. return true;
  10002. }
  10003. }
  10004. //Attempt to use the command
  10005. if ( (info->func(fd, ssd, command, params) != 0) )
  10006. {
  10007. sprintf(output,msg_txt(sd,154), command); // %s failed.
  10008. clif_displaymessage(fd, output);
  10009. return true;
  10010. }
  10011. //Log only if successful.
  10012. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  10013. return true;
  10014. }
  10015. void atcommand_db_load_groups(){
  10016. DBIterator *iter = db_iterator(atcommand_db);
  10017. AtCommandInfo* cmd;
  10018. size_t pc_group_max = player_group_db.size();
  10019. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  10020. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  10021. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  10022. for( auto& it : player_group_db ){
  10023. cmd->at_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_ATCOMMAND );
  10024. cmd->char_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_CHARCOMMAND );
  10025. }
  10026. }
  10027. dbi_destroy(iter);
  10028. }
  10029. void atcommand_db_clear(void) {
  10030. if (atcommand_db != nullptr) {
  10031. DBIterator *iter = db_iterator(atcommand_db);
  10032. AtCommandInfo* cmd;
  10033. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  10034. aFree(cmd->at_groups);
  10035. aFree(cmd->char_groups);
  10036. }
  10037. dbi_destroy(iter);
  10038. db_destroy(atcommand_db);
  10039. }
  10040. atcommand_alias_db.clear();
  10041. }
  10042. void atcommand_doload(void) {
  10043. atcommand_db_clear();
  10044. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  10045. atcommand_basecommands(); //fills initial atcommand_db with known commands
  10046. atcommand_alias_db.load();
  10047. }
  10048. void do_init_atcommand(void) {
  10049. atcommand_doload();
  10050. }
  10051. void do_final_atcommand(void) {
  10052. atcommand_db_clear();
  10053. }