atcommand.cpp 353 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710
  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_NORESTRICTION = 0x0,
  61. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  62. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  63. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  64. ATCMD_NOSCRIPT_PLAYERLESS = 0x8,
  65. ATCMD_NO_WITHOUT_SD = ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE|ATCMD_NOSCRIPT_PLAYERLESS,
  66. };
  67. struct AtCommandInfo {
  68. char command[ATCOMMAND_LENGTH];
  69. AtCommandFunc func;
  70. char* at_groups; /// Quick @commands "can-use" lookup
  71. char* char_groups; /// Quick @charcommands "can-use" lookup
  72. uint8 restriction; /// Restrictions see enum e_restict
  73. };
  74. struct s_atcommand_alias_info{
  75. AtCommandInfo *command;
  76. std::set<std::string> aliases;
  77. std::string help;
  78. };
  79. char atcommand_symbol = '@'; // first char of the commands
  80. char charcommand_symbol = '#';
  81. static DBMap* atcommand_db = nullptr; //name -> AtCommandInfo
  82. static AtCommandInfo* get_atcommandinfo_byname( const char* name );
  83. class AtcommandAliasDatabase : public TypesafeYamlDatabase<std::string, s_atcommand_alias_info>{
  84. private:
  85. std::unordered_map<std::string, std::string> aliases;
  86. public:
  87. AtcommandAliasDatabase() : TypesafeYamlDatabase( "ATCOMMAND_DB", 1 ){
  88. }
  89. void clear() override;
  90. const std::string getDefaultLocation() override;
  91. uint64 parseBodyNode( const ryml::NodeRef& node ) override;
  92. // Additional
  93. const char* checkAlias( const char* alias );
  94. };
  95. void AtcommandAliasDatabase::clear(){
  96. TypesafeYamlDatabase::clear();
  97. this->aliases.clear();
  98. }
  99. const std::string AtcommandAliasDatabase::getDefaultLocation(){
  100. return std::string(conf_path) + "/atcommands.yml";
  101. }
  102. uint64 AtcommandAliasDatabase::parseBodyNode( const ryml::NodeRef& node ){
  103. std::string command;
  104. if( !this->asString( node, "Command", command ) ){
  105. return 0;
  106. }
  107. AtCommandInfo* commandinfo = get_atcommandinfo_byname( command.c_str() );
  108. if( commandinfo == nullptr ){
  109. this->invalidWarning( node["Command"], "Command %s does not exist.\n", command.c_str() );
  110. return 0;
  111. }
  112. std::shared_ptr<s_atcommand_alias_info> info = this->find( command );
  113. bool exists = info != nullptr;
  114. if( !exists ){
  115. info = std::make_shared<s_atcommand_alias_info>();
  116. info->command = commandinfo;
  117. }
  118. if( this->nodeExists( node, "Help" ) ){
  119. std::string help;
  120. if( !this->asString( node, "Help", help ) ){
  121. return 0;
  122. }
  123. info->help = help;
  124. }
  125. if( this->nodeExists( node, "Aliases" ) ){
  126. const auto& aliasesNode = node["Aliases"];
  127. if( !aliasesNode.is_seq() ){
  128. this->invalidWarning( aliasesNode, "Aliases should be a sequence.\n" );
  129. return 0;
  130. }
  131. for( const auto& subNode : aliasesNode ){
  132. std::string alias;
  133. subNode >> alias;
  134. info->aliases.insert( alias );
  135. this->aliases[alias] = command;
  136. }
  137. }
  138. if( !exists ){
  139. this->put( command, info );
  140. }
  141. return 1;
  142. }
  143. const char* AtcommandAliasDatabase::checkAlias( const char* alias ){
  144. std::string alias_str( alias );
  145. std::string* command = util::umap_find( this->aliases, alias_str );
  146. if( command == nullptr ){
  147. return alias;
  148. }else{
  149. return command->c_str();
  150. }
  151. }
  152. AtcommandAliasDatabase atcommand_alias_db;
  153. static char atcmd_output[CHAT_SIZE_MAX];
  154. static char atcmd_player_name[NAME_LENGTH];
  155. const char *parent_cmd;
  156. struct atcmd_binding_data** atcmd_binding;
  157. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  158. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand); // @help
  159. static void warp_get_suggestions(map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  160. // @commands (script-based)
  161. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  162. int32 i = 0;
  163. if( *name == atcommand_symbol || *name == charcommand_symbol )
  164. name++; // for backwards compatibility
  165. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  166. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : nullptr;
  167. }
  168. /**
  169. * retrieves the help string associated with a given command.
  170. *
  171. * @param name the name of the command to retrieve help information for
  172. * @return the string associated with the command, or nullptr
  173. */
  174. static const char* atcommand_help_string( const char* command ){
  175. // remove the prefix symbol for the raw name of the command
  176. if( *command == atcommand_symbol || *command == charcommand_symbol ){
  177. command++;
  178. }
  179. // convert alias to the real command name
  180. command = atcommand_alias_db.checkAlias( command );
  181. // attempt to find the first default help command
  182. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command );
  183. // failed to find the help property in the configuration file
  184. if( info == nullptr ){
  185. return nullptr;
  186. }
  187. // push the result from the method
  188. return info->help.c_str();
  189. }
  190. /*==========================================
  191. * @send (used for testing packet sends from the client)
  192. *------------------------------------------*/
  193. ACMD_FUNC(send)
  194. {
  195. int32 len=0,type;
  196. // read message type as hex number (without the 0x)
  197. if(!message || !*message ||
  198. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  199. || sscanf(message, "%8x", &type)==1) )
  200. {
  201. int32 i;
  202. for (i = 900; i <= 903; ++i)
  203. clif_displaymessage(fd, msg_txt(sd,i));
  204. return -1;
  205. }
  206. #define PARSE_ERROR(error,p) \
  207. {\
  208. clif_displaymessage(fd, (error));\
  209. sprintf(atcmd_output, ">%s", (p));\
  210. clif_displaymessage(fd, atcmd_output);\
  211. }
  212. //define PARSE_ERROR
  213. #define CHECK_EOS(p) \
  214. if(*(p) == 0){\
  215. clif_displaymessage(fd, "Unexpected end of string");\
  216. return -1;\
  217. }
  218. //define CHECK_EOS
  219. #define SKIP_VALUE(p) \
  220. {\
  221. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  222. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  223. }
  224. //define SKIP_VALUE
  225. #define GET_VALUE(p,num) \
  226. {\
  227. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  228. PARSE_ERROR("Invalid number in:",(p));\
  229. return -1;\
  230. }\
  231. }
  232. //define GET_VALUE
  233. if (type > 0 && type < MAX_PACKET_DB) {
  234. int32 off,end;
  235. long num;
  236. if(len)
  237. {// show packet length
  238. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  239. clif_displaymessage(fd, atcmd_output);
  240. return 0;
  241. }
  242. len=packet_db[type].len;
  243. off=2;
  244. if(len == 0)
  245. {// unknown packet - ERROR
  246. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  247. clif_displaymessage(fd, atcmd_output);
  248. return -1;
  249. } else if(len == -1)
  250. {// dynamic packet
  251. len=SHRT_MAX-4; // maximum length
  252. off=4;
  253. }
  254. WFIFOHEAD(fd, len);
  255. WFIFOW(fd,0)=TOW(type);
  256. // parse packet contents
  257. SKIP_VALUE(message);
  258. while(*message != 0 && off < len){
  259. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  260. {// default (byte)
  261. GET_VALUE(message,num);
  262. WFIFOB(fd,off)=TOB(num);
  263. ++off;
  264. } else if(TOUPPER(*message) == 'B')
  265. {// byte
  266. ++message;
  267. GET_VALUE(message,num);
  268. WFIFOB(fd,off)=TOB(num);
  269. ++off;
  270. } else if(TOUPPER(*message) == 'W')
  271. {// word (2 bytes)
  272. ++message;
  273. GET_VALUE(message,num);
  274. WFIFOW(fd,off)=TOW(num);
  275. off+=2;
  276. } else if(TOUPPER(*message) == 'L')
  277. {// long word (4 bytes)
  278. ++message;
  279. GET_VALUE(message,num);
  280. WFIFOL(fd,off)=TOL(num);
  281. off+=4;
  282. } else if(TOUPPER(*message) == 'S')
  283. {// string - escapes are valid
  284. // get string length - num <= 0 means not fixed length (default)
  285. ++message;
  286. if(*message == '"'){
  287. num=0;
  288. } else {
  289. GET_VALUE(message,num);
  290. while(*message != '"')
  291. {// find start of string
  292. if(*message == 0 || ISSPACE(*message)){
  293. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  294. return -1;
  295. }
  296. ++message;
  297. }
  298. }
  299. // parse string
  300. ++message;
  301. CHECK_EOS(message);
  302. end=(num<=0? 0: min(off+((int32)num),len));
  303. for(; *message != '"' && (off < end || end == 0); ++off){
  304. if(*message == '\\'){
  305. ++message;
  306. CHECK_EOS(message);
  307. switch(*message){
  308. case 'a': num=0x07; break; // Bell
  309. case 'b': num=0x08; break; // Backspace
  310. case 't': num=0x09; break; // Horizontal tab
  311. case 'n': num=0x0A; break; // Line feed
  312. case 'v': num=0x0B; break; // Vertical tab
  313. case 'f': num=0x0C; break; // Form feed
  314. case 'r': num=0x0D; break; // Carriage return
  315. case 'e': num=0x1B; break; // Escape
  316. default: num=*message; break;
  317. case 'x': // Hexadecimal
  318. {
  319. ++message;
  320. CHECK_EOS(message);
  321. if(!ISXDIGIT(*message)){
  322. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  323. return -1;
  324. }
  325. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  326. if(ISXDIGIT(*message)){
  327. ++message;
  328. CHECK_EOS(message);
  329. num<<=8;
  330. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  331. }
  332. WFIFOB(fd,off)=TOB(num);
  333. ++message;
  334. CHECK_EOS(message);
  335. continue;
  336. }
  337. case '0':
  338. case '1':
  339. case '2':
  340. case '3':
  341. case '4':
  342. case '5':
  343. case '6':
  344. case '7': // Octal
  345. {
  346. num=*message-'0'; // 1st octal digit
  347. ++message;
  348. CHECK_EOS(message);
  349. if(ISDIGIT(*message) && *message < '8'){
  350. num<<=3;
  351. num+=*message-'0'; // 2nd octal digit
  352. ++message;
  353. CHECK_EOS(message);
  354. if(ISDIGIT(*message) && *message < '8'){
  355. num<<=3;
  356. num+=*message-'0'; // 3rd octal digit
  357. ++message;
  358. CHECK_EOS(message);
  359. }
  360. }
  361. WFIFOB(fd,off)=TOB(num);
  362. continue;
  363. }
  364. }
  365. } else
  366. num=*message;
  367. WFIFOB(fd,off)=TOB(num);
  368. ++message;
  369. CHECK_EOS(message);
  370. }//for
  371. while(*message != '"')
  372. {// ignore extra characters
  373. ++message;
  374. CHECK_EOS(message);
  375. }
  376. // terminate the string
  377. if(off < end)
  378. {// fill the rest with 0's
  379. memset(WFIFOP(fd,off),0,end-off);
  380. off=end;
  381. }
  382. } else
  383. {// unknown
  384. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  385. return -1;
  386. }
  387. SKIP_VALUE(message);
  388. }
  389. if(packet_db[type].len == -1)
  390. {// send dynamic packet
  391. WFIFOW(fd,2)=TOW(off);
  392. WFIFOSET(fd,off);
  393. } else
  394. {// send static packet
  395. if(off < len)
  396. memset(WFIFOP(fd,off),0,len-off);
  397. WFIFOSET(fd,len);
  398. }
  399. } else {
  400. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  401. return -1;
  402. }
  403. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  404. clif_displaymessage(fd, atcmd_output);
  405. return 0;
  406. #undef PARSE_ERROR
  407. #undef CHECK_EOS
  408. #undef SKIP_VALUE
  409. #undef GET_VALUE
  410. }
  411. /**
  412. * Retrieves map name suggestions for a given string.
  413. * This will first check if any map names contain the given string, and will
  414. * print out MAX_SUGGESTIONS results if any maps are found.
  415. * Otherwise, suggestions will be calculated through Levenshtein distance,
  416. * and up to 5 of the closest matches will be printed.
  417. *
  418. * @author Euphy
  419. */
  420. static void warp_get_suggestions(map_session_data* sd, const char *name) {
  421. // Minimum length for suggestions is 2 characters
  422. if( strlen( name ) < 2 ){
  423. return;
  424. }
  425. std::vector<const char*> suggestions;
  426. suggestions.reserve( MAX_SUGGESTIONS );
  427. // check for maps that contain string
  428. for (int32 i = 0; i < map_num; i++) {
  429. struct map_data *mapdata = map_getmapdata(i);
  430. // Prevent suggestion of instance mapnames
  431. if( mapdata->instance_id != 0 ){
  432. continue;
  433. }
  434. if( strstr( mapdata->name, name ) != nullptr ){
  435. suggestions.push_back( mapdata->name );
  436. if( suggestions.size() == MAX_SUGGESTIONS ){
  437. break;
  438. }
  439. }
  440. }
  441. // if no maps found, search by edit distance
  442. if( suggestions.empty() ){
  443. // Levenshtein > 4 is bad
  444. const int32 LEVENSHTEIN_MAX = 4;
  445. std::unordered_map<int32, std::vector<const char*>> maps;
  446. for (int32 i = 0; i < map_num; i++) {
  447. struct map_data *mapdata = map_getmapdata(i);
  448. // Prevent suggestion of instance mapnames
  449. if(mapdata->instance_id != 0 ){
  450. continue;
  451. }
  452. // Calculate the levenshtein distance of the two strings
  453. int32 distance = levenshtein(mapdata->name, name);
  454. // Check if it is above the maximum defined distance
  455. if( distance > LEVENSHTEIN_MAX ){
  456. continue;
  457. }
  458. std::vector<const char*>& vector = maps[distance];
  459. // Do not add more entries than required
  460. if( vector.size() == MAX_SUGGESTIONS ){
  461. continue;
  462. }
  463. vector.push_back(mapdata->name);
  464. }
  465. for( int32 distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){
  466. std::vector<const char*>& vector = maps[distance];
  467. for( const char* found_map : vector ){
  468. suggestions.push_back( found_map );
  469. if( suggestions.size() == MAX_SUGGESTIONS ){
  470. break;
  471. }
  472. }
  473. if( suggestions.size() == MAX_SUGGESTIONS ){
  474. break;
  475. }
  476. }
  477. }
  478. // If no suggestion could be made, do not output anything at all
  479. if( suggestions.empty() ){
  480. return;
  481. }
  482. char buffer[CHAT_SIZE_MAX];
  483. // build the suggestion string
  484. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  485. strcat(buffer, "\n");
  486. for( const char* suggestion : suggestions ){
  487. strcat(buffer, suggestion);
  488. strcat(buffer, " ");
  489. }
  490. clif_displaymessage(sd->fd, buffer);
  491. }
  492. /*==========================================
  493. * @rura, @warp, @mapmove
  494. *------------------------------------------*/
  495. ACMD_FUNC(mapmove)
  496. {
  497. char map_name[MAP_NAME_LENGTH_EXT];
  498. unsigned short mapindex;
  499. short x = 0, y = 0;
  500. int16 m = -1;
  501. nullpo_retr(-1, sd);
  502. memset(map_name, '\0', sizeof(map_name));
  503. if (!message || !*message ||
  504. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  505. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  506. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  507. return -1;
  508. }
  509. mapindex = mapindex_name2idx(map_name, nullptr);
  510. if (mapindex)
  511. m = map_mapindex2mapid(mapindex);
  512. if (m < 0) { // m < 0 means on different server! [Kevin]
  513. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  514. if (battle_config.warp_suggestions_enabled)
  515. warp_get_suggestions(sd, map_name);
  516. return -1;
  517. }
  518. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  519. { //This is to prevent the pc_setpos call from printing an error.
  520. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  521. if (!map_search_freecell(nullptr, m, &x, &y, 10, 10, 1))
  522. x = y = 0; //Invalid cell, use random spot.
  523. }
  524. 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))) {
  525. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  526. return -1;
  527. }
  528. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  529. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  530. return -1;
  531. }
  532. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  533. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  534. return -1;
  535. }
  536. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  537. return 0;
  538. }
  539. /*==========================================
  540. * Displays where a character is. Corrected version by Silent. [Skotlex]
  541. *------------------------------------------*/
  542. ACMD_FUNC(where)
  543. {
  544. map_session_data* pl_sd;
  545. nullpo_retr(-1, sd);
  546. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  547. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  548. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  549. return -1;
  550. }
  551. pl_sd = map_nick2sd(atcmd_player_name,true);
  552. if (pl_sd == nullptr ||
  553. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  554. (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))
  555. ) {
  556. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  557. return -1;
  558. }
  559. 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);
  560. clif_displaymessage(fd, atcmd_output);
  561. return 0;
  562. }
  563. /*==========================================
  564. *
  565. *------------------------------------------*/
  566. ACMD_FUNC(jumpto)
  567. {
  568. map_session_data* pl_sd = nullptr;;
  569. nullpo_retr(-1, sd);
  570. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  571. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  572. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  573. return -1;
  574. }
  575. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  576. {
  577. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  578. return -1;
  579. }
  580. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  581. {
  582. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  583. return -1;
  584. }
  585. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  586. {
  587. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  588. return -1;
  589. }
  590. if( pc_isdead(sd) )
  591. {
  592. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  593. return -1;
  594. }
  595. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  596. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  597. clif_displaymessage(fd, atcmd_output);
  598. return 0;
  599. }
  600. /*==========================================
  601. *
  602. *------------------------------------------*/
  603. ACMD_FUNC(jump)
  604. {
  605. short x = 0, y = 0;
  606. nullpo_retr(-1, sd);
  607. memset(atcmd_output, '\0', sizeof(atcmd_output));
  608. sscanf(message, "%6hd %6hd", &x, &y);
  609. if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  610. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  611. return -1;
  612. }
  613. if( pc_isdead(sd) )
  614. {
  615. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  616. return -1;
  617. }
  618. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  619. { //This is to prevent the pc_setpos call from printing an error.
  620. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  621. if (!map_search_freecell(nullptr, sd->bl.m, &x, &y, 10, 10, 1))
  622. x = y = 0; //Invalid cell, use random spot.
  623. }
  624. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  625. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  626. clif_displaymessage(fd, atcmd_output);
  627. return 0;
  628. }
  629. /*==========================================
  630. * Display list of online characters with
  631. * various info.
  632. *------------------------------------------*/
  633. ACMD_FUNC(who) {
  634. map_session_data* pl_sd = nullptr;;
  635. struct s_mapiterator *iter = nullptr;
  636. char player_name[NAME_LENGTH] = "";
  637. int32 count = 0;
  638. int32 level = 0;
  639. StringBuf buf;
  640. /**
  641. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  642. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  643. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  644. */
  645. int32 display_type = 1;
  646. int32 map_id = -1;
  647. nullpo_retr(-1, sd);
  648. if (strstr(command, "map") != nullptr) {
  649. char map_name[MAP_NAME_LENGTH_EXT] = "";
  650. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  651. map_id = sd->bl.m;
  652. } else {
  653. sscanf(message, "%23s", player_name);
  654. }
  655. if (strstr(command, "2") != nullptr)
  656. display_type = 2;
  657. else if (strstr(command, "3") != nullptr)
  658. display_type = 3;
  659. level = pc_get_group_level(sd);
  660. StringBuf_Init(&buf);
  661. iter = mapit_getallusers();
  662. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  663. 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
  664. if (stristr(pl_sd->status.name, player_name) == nullptr // search with no case sensitive
  665. || (map_id >= 0 && pl_sd->bl.m != map_id))
  666. continue;
  667. switch (display_type) {
  668. case 2: {
  669. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  670. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  671. StringBuf_Printf(&buf, msg_txt(sd,344),pl_sd->group->name.c_str()); // "(%s) "
  672. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  673. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  674. break;
  675. }
  676. case 3: {
  677. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  678. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  679. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  680. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  681. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  682. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  683. break;
  684. }
  685. default: {
  686. struct party_data *p = party_search(pl_sd->status.party_id);
  687. auto &g = pl_sd->guild;
  688. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  689. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  690. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  691. if (p != nullptr)
  692. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  693. if (g != nullptr)
  694. StringBuf_Printf(&buf, msg_txt(sd,346), g->guild.name); // " | Guild: '%s'"
  695. break;
  696. }
  697. }
  698. clif_displaymessage(fd, StringBuf_Value(&buf));
  699. StringBuf_Clear(&buf);
  700. count++;
  701. }
  702. }
  703. mapit_free(iter);
  704. if (map_id < 0) {
  705. if (count == 0)
  706. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  707. else if (count == 1)
  708. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  709. else
  710. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  711. } else {
  712. struct map_data *mapdata = map_getmapdata(map_id);
  713. if (count == 0)
  714. StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'.
  715. else if (count == 1)
  716. StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'.
  717. else
  718. StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'.
  719. }
  720. clif_displaymessage(fd, StringBuf_Value(&buf));
  721. StringBuf_Destroy(&buf);
  722. return 0;
  723. }
  724. /*==========================================
  725. *
  726. *------------------------------------------*/
  727. ACMD_FUNC(whogm)
  728. {
  729. map_session_data* pl_sd;
  730. struct s_mapiterator* iter;
  731. int32 j, count;
  732. int32 level;
  733. char match_text[CHAT_SIZE_MAX];
  734. char player_name[NAME_LENGTH];
  735. struct party_data *p;
  736. nullpo_retr(-1, sd);
  737. memset(atcmd_output, '\0', sizeof(atcmd_output));
  738. memset(match_text, '\0', sizeof(match_text));
  739. memset(player_name, '\0', sizeof(player_name));
  740. if (sscanf(message, "%255[^\n]", match_text) < 1)
  741. strcpy(match_text, "");
  742. for (j = 0; match_text[j]; j++)
  743. match_text[j] = TOLOWER(match_text[j]);
  744. count = 0;
  745. level = pc_get_group_level(sd);
  746. iter = mapit_getallusers();
  747. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  748. {
  749. int32 pl_level = pc_get_group_level(pl_sd);
  750. if (!pl_level)
  751. continue;
  752. if (match_text[0])
  753. {
  754. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  755. for (j = 0; player_name[j]; j++)
  756. player_name[j] = TOLOWER(player_name[j]);
  757. // search with no case sensitive
  758. if (strstr(player_name, match_text) == nullptr)
  759. continue;
  760. }
  761. if (pl_level > level) {
  762. if (pc_isinvisible(pl_sd))
  763. continue;
  764. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  765. clif_displaymessage(fd, atcmd_output);
  766. count++;
  767. continue;
  768. }
  769. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  770. pl_sd->status.name, pl_level,
  771. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  772. clif_displaymessage(fd, atcmd_output);
  773. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  774. pl_sd->status.base_level,
  775. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  776. clif_displaymessage(fd, atcmd_output);
  777. p = party_search(pl_sd->status.party_id);
  778. auto &g = pl_sd->guild;
  779. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  780. p?p->party.name:msg_txt(sd,917), g?g->guild.name:msg_txt(sd,917)); // None.
  781. clif_displaymessage(fd, atcmd_output);
  782. count++;
  783. }
  784. mapit_free(iter);
  785. if (count == 0)
  786. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  787. else if (count == 1)
  788. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  789. else {
  790. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  791. clif_displaymessage(fd, atcmd_output);
  792. }
  793. return 0;
  794. }
  795. /*==========================================
  796. *
  797. *------------------------------------------*/
  798. ACMD_FUNC(save)
  799. {
  800. nullpo_retr(-1, sd);
  801. if( map_getmapdata(sd->bl.m)->instance_id ) {
  802. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  803. return 1;
  804. }
  805. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  806. if (sd->status.pet_id > 0 && sd->pd)
  807. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  808. chrif_save(sd, CSAVE_NORMAL);
  809. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  810. return 0;
  811. }
  812. /*==========================================
  813. *
  814. *------------------------------------------*/
  815. ACMD_FUNC(load){
  816. nullpo_retr(-1, sd);
  817. uint16 mapindex = mapindex_name2id( sd->status.save_point.map );
  818. int16 m = map_mapindex2mapid( mapindex );
  819. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  820. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  821. return -1;
  822. }
  823. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  824. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  825. return -1;
  826. }
  827. pc_setpos( sd, mapindex, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT );
  828. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  829. return 0;
  830. }
  831. /*==========================================
  832. *
  833. *------------------------------------------*/
  834. ACMD_FUNC(speed)
  835. {
  836. short speed;
  837. nullpo_retr(-1, sd);
  838. memset(atcmd_output, '\0', sizeof(atcmd_output));
  839. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  840. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  841. clif_displaymessage(fd, atcmd_output);
  842. return -1;
  843. }
  844. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  845. if (speed < 0)
  846. sd->base_status.speed = DEFAULT_WALK_SPEED;
  847. else
  848. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  849. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  850. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  851. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  852. } else
  853. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  854. status_calc_bl(&sd->bl, { SCB_SPEED });
  855. return 0;
  856. }
  857. /*==========================================
  858. *
  859. *------------------------------------------*/
  860. ACMD_FUNC(storage)
  861. {
  862. nullpo_retr(-1, sd);
  863. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  864. return -1;
  865. if (storage_storageopen(sd) == 1)
  866. { //Already open.
  867. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  868. return -1;
  869. }
  870. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  871. return 0;
  872. }
  873. /*==========================================
  874. *
  875. *------------------------------------------*/
  876. ACMD_FUNC(guildstorage)
  877. {
  878. nullpo_retr(-1, sd);
  879. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  880. return -1;
  881. switch (storage_guild_storageopen(sd)) {
  882. case GSTORAGE_OPEN:
  883. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  884. break;
  885. case GSTORAGE_STORAGE_ALREADY_OPEN:
  886. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  887. return -1;
  888. case GSTORAGE_ALREADY_OPEN:
  889. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  890. return -1;
  891. case GSTORAGE_NO_GUILD:
  892. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  893. return -1;
  894. case GSTORAGE_NO_STORAGE:
  895. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  896. return -1;
  897. case GSTORAGE_NO_PERMISSION:
  898. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  899. return -1;
  900. }
  901. return 0;
  902. }
  903. /*==========================================
  904. *
  905. *------------------------------------------*/
  906. ACMD_FUNC(option)
  907. {
  908. int32 param1 = 0, param2 = 0, param3 = 0;
  909. nullpo_retr(-1, sd);
  910. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  911. {// failed to match the parameters so inform the user of the options
  912. const char* text;
  913. // attempt to find the setting information for this command
  914. text = atcommand_help_string( command );
  915. // notify the user of the requirement to enter an option
  916. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  917. if( text )
  918. {// send the help text associated with this command
  919. clif_displaymessage( fd, text );
  920. }
  921. return -1;
  922. }
  923. sd->sc.opt1 = param1;
  924. sd->sc.opt2 = param2;
  925. pc_setoption(sd, param3);
  926. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  927. return 0;
  928. }
  929. /*==========================================
  930. *
  931. *------------------------------------------*/
  932. ACMD_FUNC(hide)
  933. {
  934. nullpo_retr(-1, sd);
  935. if (pc_isinvisible(sd)) {
  936. sd->sc.option &= ~OPTION_INVISIBLE;
  937. if (sd->disguise)
  938. status_set_viewdata(&sd->bl, sd->disguise);
  939. else
  940. status_set_viewdata(&sd->bl, sd->status.class_);
  941. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  942. // increment the number of pvp players on the map
  943. map_getmapdata(sd->bl.m)->users_pvp++;
  944. if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) )
  945. {// register the player for ranking calculations
  946. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  947. }
  948. //bugreport:2266
  949. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  950. } else {
  951. sd->sc.option |= OPTION_INVISIBLE;
  952. sd->vd.class_ = JT_INVISIBLE;
  953. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  954. // decrement the number of pvp players on the map
  955. map_getmapdata(sd->bl.m)->users_pvp--;
  956. if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER )
  957. {// unregister the player for ranking
  958. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  959. sd->pvp_timer = INVALID_TIMER;
  960. }
  961. }
  962. clif_changeoption(&sd->bl);
  963. return 0;
  964. }
  965. ACMD_FUNC(resetcooltime)
  966. {
  967. nullpo_retr(-1, sd);
  968. if (!sd->scd.empty()) {
  969. for (const auto &entry : sd->scd) {
  970. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  971. clif_displaymessage( sd->fd, atcmd_output );
  972. }
  973. skill_blockpc_clear(*sd);
  974. }
  975. if( sd->hd != nullptr && hom_is_active( sd->hd ) ){
  976. for (const auto &entry : sd->hd->scd) {
  977. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  978. clif_displaymessage( sd->fd, atcmd_output );
  979. }
  980. skill_blockhomun_clear(*sd->hd);
  981. }
  982. if( sd->md != nullptr ){
  983. for( const auto &entry : sd->md->scd ){
  984. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  985. clif_displaymessage( sd->fd, atcmd_output );
  986. }
  987. skill_blockmerc_clear(*sd->md);
  988. }
  989. return 0;
  990. }
  991. /*==========================================
  992. * Changes a character's class
  993. *------------------------------------------*/
  994. ACMD_FUNC(jobchange)
  995. {
  996. int32 job = 0, upper = 0;
  997. const char* text;
  998. nullpo_retr(-1, sd);
  999. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  1000. int32 i;
  1001. bool found = false;
  1002. upper = 0;
  1003. // Normal Jobs
  1004. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  1005. if (strncmpi(message, job_name(i), 16) == 0) {
  1006. job = i;
  1007. found = true;
  1008. }
  1009. }
  1010. // High Jobs, Babys, Third, and Fourth
  1011. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  1012. if (strncmpi(message, job_name(i), 16) == 0) {
  1013. job = i;
  1014. found = true;
  1015. }
  1016. }
  1017. if (!found) {
  1018. text = atcommand_help_string(command);
  1019. if (text)
  1020. clif_displaymessage(fd, text);
  1021. return -1;
  1022. }
  1023. }
  1024. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  1025. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  1026. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE_KNIGHT2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  1027. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2
  1028. || (job >= JOB_WINDHAWK2 && job <= JOB_IMPERIAL_GUARD2) || job == JOB_SKY_EMPEROR2)
  1029. { // Deny direct transformation into dummy jobs
  1030. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  1031. return 0;
  1032. }
  1033. if (pcdb_checkid(job))
  1034. {
  1035. if (pc_jobchange(sd, job, upper))
  1036. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  1037. else {
  1038. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  1039. return -1;
  1040. }
  1041. } else {
  1042. text = atcommand_help_string(command);
  1043. if (text)
  1044. clif_displaymessage(fd, text);
  1045. return -1;
  1046. }
  1047. return 0;
  1048. }
  1049. /*==========================================
  1050. *
  1051. *------------------------------------------*/
  1052. ACMD_FUNC(kill)
  1053. {
  1054. nullpo_retr(-1, sd);
  1055. status_kill(&sd->bl);
  1056. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1057. if (fd != sd->fd)
  1058. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1059. return 0;
  1060. }
  1061. /*==========================================
  1062. *
  1063. *------------------------------------------*/
  1064. ACMD_FUNC(alive)
  1065. {
  1066. nullpo_retr(-1, sd);
  1067. if (!status_revive(&sd->bl, 100, 100))
  1068. {
  1069. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  1070. return -1;
  1071. }
  1072. clif_skill_nodamage(&sd->bl,sd->bl,ALL_RESURRECTION,4);
  1073. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1074. return 0;
  1075. }
  1076. /*==========================================
  1077. * +kamic [LuzZza]
  1078. *------------------------------------------*/
  1079. ACMD_FUNC(kami)
  1080. {
  1081. unsigned long color=0;
  1082. nullpo_retr(-1, sd);
  1083. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1084. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1085. if (!message || !*message) {
  1086. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1087. return -1;
  1088. }
  1089. sscanf(message, "%255[^\n]", atcmd_output);
  1090. if (strstr(command, "l") != nullptr)
  1091. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  1092. else
  1093. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  1094. } else {
  1095. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1096. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1097. return -1;
  1098. }
  1099. if(color > 0xFFFFFF) {
  1100. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1101. return -1;
  1102. }
  1103. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1104. }
  1105. return 0;
  1106. }
  1107. /*==========================================
  1108. *
  1109. *------------------------------------------*/
  1110. ACMD_FUNC(heal)
  1111. {
  1112. int32 hp = 0, sp = 0; // [Valaris] thanks to fov
  1113. nullpo_retr(-1, sd);
  1114. sscanf(message, "%11d %11d", &hp, &sp);
  1115. // some overflow checks
  1116. if( hp == INT_MIN ) hp++;
  1117. if( sp == INT_MIN ) sp++;
  1118. if ( hp == 0 && sp == 0 ) {
  1119. if (!status_percent_heal(&sd->bl, 100, 100))
  1120. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1121. else
  1122. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1123. return 0;
  1124. }
  1125. if ( hp > 0 && sp >= 0 ) {
  1126. if(!status_heal(&sd->bl, hp, sp, 0))
  1127. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1128. else
  1129. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1130. return 0;
  1131. }
  1132. if ( hp < 0 && sp <= 0 ) {
  1133. status_damage(nullptr, &sd->bl, -hp, -sp, 0, 0, 0);
  1134. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1135. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1136. return 0;
  1137. }
  1138. //Opposing signs.
  1139. if ( hp ) {
  1140. if (hp > 0)
  1141. status_heal(&sd->bl, hp, 0, 0);
  1142. else {
  1143. status_damage(nullptr, &sd->bl, -hp, 0, 0, 0, 0);
  1144. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1145. }
  1146. }
  1147. if ( sp ) {
  1148. if (sp > 0)
  1149. status_heal(&sd->bl, 0, sp, 0);
  1150. else
  1151. status_damage(nullptr, &sd->bl, 0, -sp, 0, 0, 0);
  1152. }
  1153. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1154. return 0;
  1155. }
  1156. /*==========================================
  1157. * Recover's AP and allows exact adjustments. [Rytech]
  1158. *------------------------------------------*/
  1159. ACMD_FUNC(healap)
  1160. {
  1161. int32 ap = 0;
  1162. nullpo_retr(-1, sd);
  1163. sscanf(message, "%11d", &ap);
  1164. // Overflow check.
  1165. if (ap == INT_MIN) ap++;
  1166. if (ap == 0) {
  1167. if (!status_percent_heal(&sd->bl, 0, 0, 100))
  1168. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1169. else
  1170. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1171. return 0;
  1172. }else if (ap > 0) {
  1173. if (!status_heal(&sd->bl, 0, 0, ap, 0))
  1174. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1175. else
  1176. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1177. return 0;
  1178. }else{
  1179. status_damage(nullptr, &sd->bl, 0, 0, -ap, 0, 0, 0);
  1180. clif_displaymessage(fd, msg_txt(sd, 822));// AP modified.
  1181. return 0;
  1182. }
  1183. }
  1184. /*==========================================
  1185. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1186. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1187. *------------------------------------------*/
  1188. ACMD_FUNC(item)
  1189. {
  1190. char item_name[100];
  1191. int32 number = 0, bound = BOUND_NONE;
  1192. char flag = 0;
  1193. char *itemlist;
  1194. nullpo_retr(-1, sd);
  1195. memset(item_name, '\0', sizeof(item_name));
  1196. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1197. if (!strcmpi(parent_cmd,"itembound")) {
  1198. if (!message || !*message || (
  1199. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1200. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1201. {
  1202. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1203. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1204. return -1;
  1205. }
  1206. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1207. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1208. return -1;
  1209. }
  1210. } else if (!message || !*message || (
  1211. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1212. sscanf(message, "%99s %11d", item_name, &number) < 1
  1213. )) {
  1214. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1215. return -1;
  1216. }
  1217. std::vector<std::shared_ptr<item_data>> items;
  1218. itemlist = strtok(item_name, ":");
  1219. while( itemlist != nullptr ){
  1220. std::shared_ptr<item_data> item = item_db.searchname( itemlist );
  1221. if( item == nullptr ){
  1222. item = item_db.find( strtoul( itemlist, nullptr, 10 ) );
  1223. }
  1224. if( item == nullptr ){
  1225. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1226. return -1;
  1227. }
  1228. items.push_back( item );
  1229. itemlist = strtok(nullptr, ":"); //next itemline
  1230. }
  1231. if (number <= 0)
  1232. number = 1;
  1233. int32 get_count = number;
  1234. // Produce items in list
  1235. for( const auto& item : items ){
  1236. t_itemid item_id = item->nameid;
  1237. //Check if it's stackable.
  1238. if( !itemdb_isstackable2( item.get() ) ){
  1239. get_count = 1;
  1240. }
  1241. for( int32 i = 0; i < number; i += get_count ){
  1242. // if not pet egg
  1243. if (!pet_create_egg(sd, item_id)) {
  1244. struct item item_tmp = {};
  1245. item_tmp.nameid = item_id;
  1246. item_tmp.identify = 1;
  1247. item_tmp.bound = bound;
  1248. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1249. clif_additem(sd, 0, 0, flag);
  1250. }
  1251. }
  1252. }
  1253. if (flag == 0)
  1254. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1255. return 0;
  1256. }
  1257. /*==========================================
  1258. *
  1259. *------------------------------------------*/
  1260. ACMD_FUNC(item2)
  1261. {
  1262. char item_name[100];
  1263. int32 number = 0, bound = BOUND_NONE;
  1264. int32 identify = 0, refine = 0, attr = 0;
  1265. int32 c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1266. nullpo_retr(-1, sd);
  1267. memset(item_name, '\0', sizeof(item_name));
  1268. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1269. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1270. if (!message || !*message || (
  1271. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1272. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1273. {
  1274. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1275. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1276. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1277. return -1;
  1278. }
  1279. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1280. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1281. return -1;
  1282. }
  1283. } else if ( !message || !*message || (
  1284. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1285. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1286. )) {
  1287. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1288. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1289. return -1;
  1290. }
  1291. if (number <= 0)
  1292. number = 1;
  1293. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  1294. if( item_data == nullptr ){
  1295. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  1296. }
  1297. if( item_data != nullptr ){
  1298. int32 loop, get_count, i;
  1299. char flag = 0;
  1300. //Check if it's stackable.
  1301. if( !itemdb_isstackable2( item_data.get() ) ){
  1302. loop = number;
  1303. get_count = 1;
  1304. }else{
  1305. loop = 1;
  1306. get_count = number;
  1307. }
  1308. if( itemdb_isequip2( item_data.get() ) ){
  1309. refine = cap_value( refine, 0, MAX_REFINE );
  1310. }else{
  1311. // All other items cannot be refined and are always identified
  1312. identify = 1;
  1313. refine = attr = 0;
  1314. }
  1315. for (i = 0; i < loop; i++) {
  1316. // if not pet egg
  1317. if (!pet_create_egg(sd, item_data->nameid)) {
  1318. struct item item_tmp = {};
  1319. item_tmp.nameid = item_data->nameid;
  1320. item_tmp.identify = identify;
  1321. item_tmp.refine = refine;
  1322. item_tmp.attribute = attr;
  1323. item_tmp.card[0] = c1;
  1324. item_tmp.card[1] = c2;
  1325. item_tmp.card[2] = c3;
  1326. item_tmp.card[3] = c4;
  1327. item_tmp.bound = bound;
  1328. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1329. clif_additem(sd, 0, 0, flag);
  1330. }
  1331. }
  1332. if (flag == 0)
  1333. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1334. } else {
  1335. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1336. return -1;
  1337. }
  1338. return 0;
  1339. }
  1340. /*==========================================
  1341. *
  1342. *------------------------------------------*/
  1343. ACMD_FUNC(itemreset)
  1344. {
  1345. int32 i;
  1346. nullpo_retr(-1, sd);
  1347. for (i = 0; i < MAX_INVENTORY; i++) {
  1348. 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])) {
  1349. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1350. }
  1351. }
  1352. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1353. return 0;
  1354. }
  1355. /*==========================================
  1356. * Atcommand @lvlup
  1357. *------------------------------------------*/
  1358. ACMD_FUNC(baselevelup)
  1359. {
  1360. int32 level=0, i=0, status_point=0, trait_point=0;
  1361. nullpo_retr(-1, sd);
  1362. level = atoi(message);
  1363. if (!message || !*message || !level) {
  1364. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1365. return -1;
  1366. }
  1367. if (level > 0) {
  1368. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1369. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1370. return -1;
  1371. } // End Addition
  1372. if ((uint32)level > pc_maxbaselv(sd) || (uint32)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1373. level = pc_maxbaselv(sd) - sd->status.base_level;
  1374. for (i = 0; i < level; i++)
  1375. {
  1376. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i);
  1377. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i);
  1378. }
  1379. sd->status.status_point += status_point;
  1380. sd->status.trait_point += trait_point;
  1381. sd->status.base_level += (uint32)level;
  1382. status_calc_pc(sd, SCO_FORCE);
  1383. status_percent_heal(&sd->bl, 100, 100);
  1384. clif_misceffect( sd->bl, NOTIFYEFFECT_BASE_LEVEL_UP );
  1385. for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) {
  1386. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j);
  1387. achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_);
  1388. }
  1389. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1390. } else {
  1391. if (sd->status.base_level == 1) {
  1392. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1393. return -1;
  1394. }
  1395. level*=-1;
  1396. if ((uint32)level >= sd->status.base_level)
  1397. level = sd->status.base_level-1;
  1398. for (i = 0; i > -level; i--)
  1399. {
  1400. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i - 1);
  1401. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i - 1);
  1402. }
  1403. if (sd->status.status_point < status_point || sd->status.trait_point < trait_point)
  1404. pc_resetstate(sd);
  1405. if (sd->status.status_point < status_point)
  1406. sd->status.status_point = 0;
  1407. else
  1408. sd->status.status_point -= status_point;
  1409. if (sd->status.trait_point < trait_point)
  1410. sd->status.trait_point = 0;
  1411. else
  1412. sd->status.trait_point -= trait_point;
  1413. sd->status.base_level -= (uint32)level;
  1414. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1415. status_calc_pc(sd, SCO_FORCE);
  1416. level*=-1;
  1417. }
  1418. sd->status.base_exp = 0;
  1419. clif_updatestatus(*sd, SP_STATUSPOINT);
  1420. clif_updatestatus(*sd, SP_TRAITPOINT);
  1421. clif_updatestatus(*sd, SP_BASELEVEL);
  1422. clif_updatestatus(*sd, SP_BASEEXP);
  1423. clif_updatestatus(*sd, SP_NEXTBASEEXP);
  1424. pc_baselevelchanged(sd);
  1425. if(sd->status.party_id)
  1426. party_send_levelup(sd);
  1427. if( level > 0 && battle_config.atcommand_levelup_events )
  1428. npc_script_event( *sd, NPCE_BASELVUP );
  1429. return 0;
  1430. }
  1431. /*==========================================
  1432. *
  1433. *------------------------------------------*/
  1434. ACMD_FUNC(joblevelup)
  1435. {
  1436. int32 level=0;
  1437. nullpo_retr(-1, sd);
  1438. level = atoi(message);
  1439. if (!message || !*message || !level) {
  1440. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1441. return -1;
  1442. }
  1443. if (level > 0) {
  1444. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1445. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1446. return -1;
  1447. }
  1448. if ((uint32)level > pc_maxjoblv(sd) || (uint32)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1449. level = pc_maxjoblv(sd) - sd->status.job_level;
  1450. sd->status.job_level += (uint32)level;
  1451. sd->status.skill_point += level;
  1452. clif_misceffect( sd->bl, NOTIFYEFFECT_JOB_LEVEL_UP );
  1453. for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++)
  1454. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i);
  1455. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1456. } else {
  1457. if (sd->status.job_level == 1) {
  1458. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1459. return -1;
  1460. }
  1461. level *=-1;
  1462. if ((uint32)level >= sd->status.job_level) // fix negative overflow
  1463. level = sd->status.job_level-1;
  1464. sd->status.job_level -= (uint32)level;
  1465. if (sd->status.skill_point < level)
  1466. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1467. if (sd->status.skill_point < level)
  1468. sd->status.skill_point = 0;
  1469. else
  1470. sd->status.skill_point -= level;
  1471. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1472. level *=-1;
  1473. }
  1474. sd->status.job_exp = 0;
  1475. clif_updatestatus(*sd, SP_JOBLEVEL);
  1476. clif_updatestatus(*sd, SP_JOBEXP);
  1477. clif_updatestatus(*sd, SP_NEXTJOBEXP);
  1478. clif_updatestatus(*sd, SP_SKILLPOINT);
  1479. status_calc_pc(sd, SCO_FORCE);
  1480. if( level > 0 && battle_config.atcommand_levelup_events )
  1481. npc_script_event( *sd, NPCE_JOBLVUP );
  1482. return 0;
  1483. }
  1484. /*==========================================
  1485. * @help
  1486. *------------------------------------------*/
  1487. ACMD_FUNC(help){
  1488. const char *command_name = nullptr;
  1489. nullpo_retr(-1, sd);
  1490. if (!message || !*message) {
  1491. command_name = "help"; // If no command_name specified, display help for @help.
  1492. } else {
  1493. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1494. ++message;
  1495. command_name = atcommand_alias_db.checkAlias(message);
  1496. }
  1497. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1498. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1499. clif_displaymessage(fd, atcmd_output);
  1500. atcommand_get_suggestions(sd, command_name, true);
  1501. return -1;
  1502. }
  1503. // attempt to find the first default help command
  1504. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_name );
  1505. const char* text = info != nullptr ? info->help.c_str() : nullptr;
  1506. if( text == nullptr ){
  1507. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1508. clif_displaymessage(fd, atcmd_output);
  1509. atcommand_get_suggestions(sd, command_name, true);
  1510. return -1;
  1511. }
  1512. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1513. clif_displaymessage(fd, atcmd_output);
  1514. { // Display aliases
  1515. StringBuf buf;
  1516. bool has_aliases = false;
  1517. StringBuf_Init(&buf);
  1518. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1519. for( const std::string& alias : info->aliases ){
  1520. StringBuf_Printf( &buf, " %s", alias.c_str() );
  1521. has_aliases = true;
  1522. }
  1523. if (has_aliases)
  1524. clif_displaymessage(fd, StringBuf_Value(&buf));
  1525. StringBuf_Destroy(&buf);
  1526. }
  1527. // Display help contents
  1528. clif_displaymessage(fd, text);
  1529. return 0;
  1530. }
  1531. /*==========================================
  1532. *
  1533. *------------------------------------------*/
  1534. ACMD_FUNC(pvpoff)
  1535. {
  1536. nullpo_retr(-1, sd);
  1537. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1538. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1539. return -1;
  1540. }
  1541. map_setmapflag(sd->bl.m, MF_PVP, false);
  1542. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1543. return 0;
  1544. }
  1545. /*==========================================
  1546. *
  1547. *------------------------------------------*/
  1548. ACMD_FUNC(pvpon)
  1549. {
  1550. nullpo_retr(-1, sd);
  1551. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1552. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1553. return -1;
  1554. }
  1555. map_setmapflag(sd->bl.m, MF_PVP, true);
  1556. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1557. return 0;
  1558. }
  1559. /*==========================================
  1560. *
  1561. *------------------------------------------*/
  1562. ACMD_FUNC(gvgoff)
  1563. {
  1564. nullpo_retr(-1, sd);
  1565. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1566. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1567. return -1;
  1568. }
  1569. map_setmapflag(sd->bl.m, MF_GVG, false);
  1570. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1571. return 0;
  1572. }
  1573. /*==========================================
  1574. *
  1575. *------------------------------------------*/
  1576. ACMD_FUNC(gvgon)
  1577. {
  1578. nullpo_retr(-1, sd);
  1579. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1580. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1581. return -1;
  1582. }
  1583. map_setmapflag(sd->bl.m, MF_GVG, true);
  1584. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1585. return 0;
  1586. }
  1587. /*==========================================
  1588. *
  1589. *------------------------------------------*/
  1590. ACMD_FUNC(model)
  1591. {
  1592. int32 hair_style = 0, hair_color = 0, cloth_color = 0;
  1593. nullpo_retr(-1, sd);
  1594. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1595. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1596. 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>).
  1597. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1598. clif_displaymessage(fd, atcmd_output);
  1599. return -1;
  1600. }
  1601. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1602. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1603. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1604. pc_changelook(sd, LOOK_HAIR, hair_style);
  1605. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1606. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1607. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1608. } else {
  1609. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1610. return -1;
  1611. }
  1612. return 0;
  1613. }
  1614. /*==========================================
  1615. * @bodystyle [Rytech]
  1616. *------------------------------------------*/
  1617. ACMD_FUNC(bodystyle)
  1618. {
  1619. int32 body_style = 0;
  1620. nullpo_retr(-1, sd);
  1621. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1622. 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) {
  1623. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1624. return -1;
  1625. }
  1626. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1627. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1628. clif_displaymessage(fd, atcmd_output);
  1629. return -1;
  1630. }
  1631. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1632. pc_changelook(sd, LOOK_BODY2, body_style);
  1633. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1634. } else {
  1635. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1636. return -1;
  1637. }
  1638. return 0;
  1639. }
  1640. /*==========================================
  1641. * @dye && @ccolor
  1642. *------------------------------------------*/
  1643. ACMD_FUNC(dye)
  1644. {
  1645. int32 cloth_color = 0;
  1646. nullpo_retr(-1, sd);
  1647. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1648. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1649. 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>).
  1650. clif_displaymessage(fd, atcmd_output);
  1651. return -1;
  1652. }
  1653. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1654. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1655. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1656. } else {
  1657. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1658. return -1;
  1659. }
  1660. return 0;
  1661. }
  1662. /*==========================================
  1663. * @hairstyle && @hstyle
  1664. *------------------------------------------*/
  1665. ACMD_FUNC(hair_style)
  1666. {
  1667. int32 hair_style = 0;
  1668. nullpo_retr(-1, sd);
  1669. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1670. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1671. 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>).
  1672. clif_displaymessage(fd, atcmd_output);
  1673. return -1;
  1674. }
  1675. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1676. pc_changelook(sd, LOOK_HAIR, hair_style);
  1677. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1678. } else {
  1679. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1680. return -1;
  1681. }
  1682. return 0;
  1683. }
  1684. /*==========================================
  1685. * @haircolor && @hcolor
  1686. *------------------------------------------*/
  1687. ACMD_FUNC(hair_color)
  1688. {
  1689. int32 hair_color = 0;
  1690. nullpo_retr(-1, sd);
  1691. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1692. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1693. 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>).
  1694. clif_displaymessage(fd, atcmd_output);
  1695. return -1;
  1696. }
  1697. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1698. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1699. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1700. } else {
  1701. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1702. return -1;
  1703. }
  1704. return 0;
  1705. }
  1706. /*==========================================
  1707. * @go [city_number or city_name] - Updated by Harbin
  1708. *------------------------------------------*/
  1709. ACMD_FUNC(go)
  1710. {
  1711. int32 i;
  1712. int32 town;
  1713. char map_name[MAP_NAME_LENGTH];
  1714. const struct {
  1715. char map[MAP_NAME_LENGTH];
  1716. int32 x, y;
  1717. } data[] = {
  1718. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1719. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1720. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1721. { MAP_PAYON, 162, 233 }, // 3=Payon
  1722. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1723. #ifdef RENEWAL
  1724. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1725. #else
  1726. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1727. #endif
  1728. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1729. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1730. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1731. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1732. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1733. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1734. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1735. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1736. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1737. #ifdef RENEWAL
  1738. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1739. #else
  1740. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1741. #endif
  1742. { MAP_JAIL, 23, 61 }, // 16=Prison
  1743. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1744. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1745. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1746. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1747. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1748. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1749. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1750. { MAP_VEINS, 216, 123 }, // 24=Veins
  1751. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1752. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1753. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1754. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1755. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1756. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1757. { MAP_MORA, 44, 151 }, // 31=Mora
  1758. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1759. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1760. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1761. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1762. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1763. };
  1764. nullpo_retr(-1, sd);
  1765. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1766. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1767. return 0;
  1768. }
  1769. memset(map_name, '\0', sizeof(map_name));
  1770. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1771. // get the number
  1772. town = atoi(message);
  1773. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1774. {// no value matched so send the list of locations
  1775. const char* text;
  1776. // attempt to find the text help string
  1777. text = atcommand_help_string( command );
  1778. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1779. if( text )
  1780. {// send the text to the client
  1781. clif_displaymessage( fd, text );
  1782. }
  1783. return -1;
  1784. }
  1785. // get possible name of the city
  1786. map_name[MAP_NAME_LENGTH-1] = '\0';
  1787. for (i = 0; map_name[i]; i++)
  1788. map_name[i] = TOLOWER(map_name[i]);
  1789. // try to identify the map name
  1790. if (strncmp(map_name, "prontera", 3) == 0) {
  1791. town = 0;
  1792. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1793. strncmp(map_name, "morroc", 4) == 0) {
  1794. town = 1;
  1795. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1796. town = 2;
  1797. } else if (strncmp(map_name, "payon", 3) == 0) {
  1798. town = 3;
  1799. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1800. town = 4;
  1801. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1802. town = 5;
  1803. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1804. town = 6;
  1805. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1806. strcmp(map_name, "christmas") == 0 ||
  1807. strncmp(map_name, "xmas", 3) == 0 ||
  1808. strncmp(map_name, "x-mas", 3) == 0) {
  1809. town = 7;
  1810. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1811. town = 8;
  1812. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1813. strncmp(map_name, "yuno", 3) == 0) {
  1814. town = 9;
  1815. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1816. town = 10;
  1817. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1818. strncmp(map_name, "gonryun", 3) == 0) {
  1819. town = 11;
  1820. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1821. town = 12;
  1822. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1823. town = 13;
  1824. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1825. town = 14;
  1826. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1827. strncmp(map_name, "startpoint", 3) == 0 ||
  1828. strncmp(map_name, "beginning", 3) == 0) {
  1829. town = 15;
  1830. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1831. strncmp(map_name, "prison", 3) == 0 ||
  1832. strncmp(map_name, "jail", 3) == 0) {
  1833. town = 16;
  1834. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1835. town = 17;
  1836. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1837. town = 18;
  1838. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1839. town = 19;
  1840. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1841. town = 20;
  1842. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1843. town = 21;
  1844. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1845. town = 22;
  1846. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1847. town = 23;
  1848. } else if (strncmp(map_name, "veins", 3) == 0) {
  1849. town = 24;
  1850. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1851. town = 25;
  1852. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1853. town = 26;
  1854. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1855. town = 27;
  1856. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1857. town = 28;
  1858. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1859. town = 29;
  1860. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1861. town = 30;
  1862. } else if (strcmp(map_name, "mora") == 0) {
  1863. town = 31;
  1864. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1865. town = 32;
  1866. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1867. town = 33;
  1868. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1869. town = 34;
  1870. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1871. town = 35;
  1872. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1873. town = 36;
  1874. }
  1875. if (town >= 0 && town < ARRAYLENGTH(data))
  1876. {
  1877. int16 m = map_mapname2mapid(data[town].map);
  1878. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1879. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1880. return -1;
  1881. }
  1882. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1883. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1884. return -1;
  1885. }
  1886. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1887. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1888. } else {
  1889. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1890. return -1;
  1891. }
  1892. } else { // if you arrive here, you have an error in town variable when reading of names
  1893. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1894. return -1;
  1895. }
  1896. return 0;
  1897. }
  1898. /*==========================================
  1899. *
  1900. *------------------------------------------*/
  1901. ACMD_FUNC(monster)
  1902. {
  1903. char name[NAME_LENGTH];
  1904. char monster[NAME_LENGTH];
  1905. char eventname[EVENT_NAME_LENGTH] = "";
  1906. int32 mob_id;
  1907. int32 number = 0;
  1908. int32 count;
  1909. int32 i, range;
  1910. short mx, my;
  1911. uint32 size;
  1912. nullpo_retr(-1, sd);
  1913. memset(name, '\0', sizeof(name));
  1914. memset(monster, '\0', sizeof(monster));
  1915. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1916. if (!message || !*message) {
  1917. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1918. return -1;
  1919. }
  1920. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1921. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1922. //All data can be left as it is.
  1923. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1924. //Here, it is possible name was not given and we are using monster for it.
  1925. if (count < 3) //Blank mob's name.
  1926. name[0] = '\0';
  1927. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1928. //All data can be left as it is.
  1929. } else if (sscanf(message, "%23s", monster) > 0) {
  1930. //As before, name may be already filled.
  1931. name[0] = '\0';
  1932. } else {
  1933. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1934. return -1;
  1935. }
  1936. // If AegisName matches exactly, summon that monster
  1937. std::shared_ptr<s_mob_db> mob = mobdb_search_aegisname(monster);
  1938. if (mob != nullptr)
  1939. mob_id = mob->id;
  1940. else {
  1941. // Otherwise, search for monster with that ID or name
  1942. // Check for ID first as this is faster; if search string is not a number it will return 0
  1943. mob_id = util::strtoint32def(monster);
  1944. if (mob_id == 0 || mobdb_checkid(mob_id) == 0)
  1945. mob_id = mobdb_searchname(monster);
  1946. }
  1947. if (mob_id == 0) {
  1948. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1949. return -1;
  1950. }
  1951. if (mob_id == MOBID_EMPERIUM) {
  1952. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1953. return -1;
  1954. }
  1955. if (number <= 0)
  1956. number = 1;
  1957. if( !name[0] )
  1958. strcpy(name, "--ja--");
  1959. // 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
  1960. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1961. number = battle_config.atc_spawn_quantity_limit;
  1962. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1963. if (strcmp(parent_cmd, "monstersmall") == 0)
  1964. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1965. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1966. size = SZ_BIG;
  1967. else
  1968. size = SZ_SMALL;
  1969. if (battle_config.etc_log)
  1970. 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);
  1971. count = 0;
  1972. range = (int32)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1973. for (i = 0; i < number; i++) {
  1974. int32 k;
  1975. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1976. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1977. if(k) {
  1978. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1979. count ++;
  1980. }
  1981. }
  1982. if (count != 0)
  1983. if (number == count)
  1984. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1985. else {
  1986. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1987. clif_displaymessage(fd, atcmd_output);
  1988. }
  1989. else {
  1990. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1991. return -1;
  1992. }
  1993. return 0;
  1994. }
  1995. /*==========================================
  1996. *
  1997. *------------------------------------------*/
  1998. static int32 atkillmonster_sub(struct block_list *bl, va_list ap)
  1999. {
  2000. struct mob_data *md;
  2001. int32 flag;
  2002. nullpo_ret(md=(struct mob_data *)bl);
  2003. flag = va_arg(ap, int32);
  2004. if (md->guardian_data)
  2005. return 0; //Do not touch WoE mobs!
  2006. if (flag)
  2007. status_zap(bl,md->status.hp, 0);
  2008. else
  2009. status_kill(bl);
  2010. return 1;
  2011. }
  2012. ACMD_FUNC(killmonster)
  2013. {
  2014. int32 map_id, drop_flag;
  2015. char map_name[MAP_NAME_LENGTH_EXT];
  2016. nullpo_retr(-1, sd);
  2017. memset(map_name, '\0', sizeof(map_name));
  2018. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2019. map_id = sd->bl.m;
  2020. else {
  2021. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2022. map_id = sd->bl.m;
  2023. }
  2024. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2025. drop_flag = strcmpi(parent_cmd, "killmonster2");
  2026. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  2027. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  2028. return 0;
  2029. }
  2030. /*==========================================
  2031. *
  2032. *------------------------------------------*/
  2033. ACMD_FUNC(refine)
  2034. {
  2035. int32 j, position = 0, refine = 0, current_position, final_refine;
  2036. int32 count;
  2037. nullpo_retr(-1, sd);
  2038. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2039. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  2040. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  2041. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2042. clif_displaymessage(fd, atcmd_output);
  2043. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2044. clif_displaymessage(fd, atcmd_output);
  2045. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2046. clif_displaymessage(fd, atcmd_output);
  2047. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2048. clif_displaymessage(fd, atcmd_output);
  2049. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2050. clif_displaymessage(fd, atcmd_output);
  2051. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2052. clif_displaymessage(fd, atcmd_output);
  2053. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2054. clif_displaymessage(fd, atcmd_output);
  2055. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2056. clif_displaymessage(fd, atcmd_output);
  2057. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2058. clif_displaymessage(fd, atcmd_output);
  2059. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2060. clif_displaymessage(fd, atcmd_output);
  2061. sprintf(atcmd_output, msg_txt(sd,1521), EQP_SHADOW_ARMOR); // %d: Shadow Armor
  2062. clif_displaymessage(fd, atcmd_output);
  2063. sprintf(atcmd_output, msg_txt(sd,1522), EQP_SHADOW_WEAPON); // %d: Shadow Weapon
  2064. clif_displaymessage(fd, atcmd_output);
  2065. sprintf(atcmd_output, msg_txt(sd,1523), EQP_SHADOW_SHIELD); // %d: Shadow Shield
  2066. clif_displaymessage(fd, atcmd_output);
  2067. sprintf(atcmd_output, msg_txt(sd,1524), EQP_SHADOW_SHOES); // %d: Shadow Shoes
  2068. clif_displaymessage(fd, atcmd_output);
  2069. sprintf(atcmd_output, msg_txt(sd,1525), EQP_SHADOW_ACC_R); // %d: Shadow Right Accessory
  2070. clif_displaymessage(fd, atcmd_output);
  2071. sprintf(atcmd_output, msg_txt(sd,1526), EQP_SHADOW_ACC_L); // %d: Shadow Left Accessory
  2072. clif_displaymessage(fd, atcmd_output);
  2073. return -1;
  2074. }
  2075. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2076. count = 0;
  2077. for (j = 0; j < EQI_MAX; j++) {
  2078. int32 i;
  2079. if ((i = sd->equip_index[j]) < 0)
  2080. continue;
  2081. if(j == EQI_AMMO)
  2082. continue;
  2083. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2084. continue;
  2085. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2086. continue;
  2087. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  2088. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  2089. sd->inventory.u.items_inventory[i].refine = final_refine;
  2090. current_position = sd->inventory.u.items_inventory[i].equip;
  2091. pc_unequipitem(sd, i, 3);
  2092. clif_refine( *sd, i, ITEMREFINING_SUCCESS );
  2093. clif_delitem( *sd, i, 1, 3 );
  2094. clif_additem(sd, i, 1, 0);
  2095. pc_equipitem(sd, i, current_position);
  2096. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2097. if( sd->inventory_data[i]->type == IT_WEAPON ){
  2098. achievement_update_objective(sd, AG_ENCHANT_SUCCESS, 2, sd->inventory_data[i]->weapon_level, sd->inventory.u.items_inventory[i].refine);
  2099. }
  2100. count++;
  2101. }
  2102. }
  2103. if (count == 0)
  2104. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2105. else if (count == 1)
  2106. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2107. else {
  2108. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2109. clif_displaymessage(fd, atcmd_output);
  2110. }
  2111. return 0;
  2112. }
  2113. /*==========================================
  2114. *
  2115. *------------------------------------------*/
  2116. ACMD_FUNC(grade)
  2117. {
  2118. int32 j, position = 0, grade = 0, current_position, final_grade;
  2119. int32 count;
  2120. nullpo_retr(-1, sd);
  2121. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2122. if (!message || !*message || sscanf(message, "%11d %11d", &position, &grade) < 2) {
  2123. clif_displaymessage(fd, msg_txt(sd,1519)); // Please enter a position and an amount (usage: @grade <equip position> <+/- amount>).
  2124. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2125. clif_displaymessage(fd, atcmd_output);
  2126. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2127. clif_displaymessage(fd, atcmd_output);
  2128. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2129. clif_displaymessage(fd, atcmd_output);
  2130. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2131. clif_displaymessage(fd, atcmd_output);
  2132. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2133. clif_displaymessage(fd, atcmd_output);
  2134. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2135. clif_displaymessage(fd, atcmd_output);
  2136. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2137. clif_displaymessage(fd, atcmd_output);
  2138. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2139. clif_displaymessage(fd, atcmd_output);
  2140. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2141. clif_displaymessage(fd, atcmd_output);
  2142. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2143. clif_displaymessage(fd, atcmd_output);
  2144. return -1;
  2145. }
  2146. grade = cap_value(grade, -MAX_ENCHANTGRADE, MAX_ENCHANTGRADE);
  2147. count = 0;
  2148. for (j = 0; j < EQI_MAX; j++) {
  2149. int32 i;
  2150. if ((i = sd->equip_index[j]) < 0)
  2151. continue;
  2152. if(j == EQI_AMMO)
  2153. continue;
  2154. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2155. continue;
  2156. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2157. continue;
  2158. final_grade = cap_value(sd->inventory.u.items_inventory[i].enchantgrade + grade, 0, MAX_ENCHANTGRADE);
  2159. if (sd->inventory.u.items_inventory[i].enchantgrade != final_grade) {
  2160. sd->inventory.u.items_inventory[i].enchantgrade = final_grade;
  2161. current_position = sd->inventory.u.items_inventory[i].equip;
  2162. pc_unequipitem(sd, i, 3);
  2163. clif_delitem( *sd, i, 1, 3 );
  2164. clif_additem(sd, i, 1, 0);
  2165. pc_equipitem(sd, i, current_position);
  2166. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2167. count++;
  2168. }
  2169. }
  2170. sprintf(atcmd_output, msg_txt(sd,1520), count); // %d items have been graded.
  2171. clif_displaymessage(fd, atcmd_output);
  2172. return 0;
  2173. }
  2174. /*==========================================
  2175. *
  2176. *------------------------------------------*/
  2177. ACMD_FUNC(produce)
  2178. {
  2179. char item_name[100];
  2180. t_itemid item_id;
  2181. int32 attribute = 0, star = 0;
  2182. nullpo_retr(-1, sd);
  2183. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2184. memset(item_name, '\0', sizeof(item_name));
  2185. if (!message || !*message || (
  2186. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2187. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2188. )) {
  2189. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2190. return -1;
  2191. }
  2192. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  2193. if( item_data == nullptr ){
  2194. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  2195. }
  2196. if( item_data == nullptr ){
  2197. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2198. return -1;
  2199. }
  2200. item_id = item_data->nameid;
  2201. if( itemdb_isequip2( item_data.get() ) ){
  2202. char flag = 0;
  2203. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2204. attribute = ATTRIBUTE_NORMAL;
  2205. if (star < MIN_STAR || star > MAX_STAR)
  2206. star = 0;
  2207. struct item tmp_item = {};
  2208. tmp_item.nameid = item_id;
  2209. tmp_item.amount = 1;
  2210. tmp_item.identify = 1;
  2211. tmp_item.card[0] = CARD0_FORGE;
  2212. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2213. ((star*5) << 8) + attribute:0;
  2214. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2215. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2216. clif_produceeffect(sd, 0, item_id);
  2217. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2218. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2219. clif_additem(sd, 0, 0, flag);
  2220. } else {
  2221. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name.c_str()); // The item (%u: '%s') is not equipable.
  2222. clif_displaymessage(fd, atcmd_output);
  2223. return -1;
  2224. }
  2225. return 0;
  2226. }
  2227. /*==========================================
  2228. *
  2229. *------------------------------------------*/
  2230. ACMD_FUNC(memo)
  2231. {
  2232. int32 position = 0;
  2233. nullpo_retr(-1, sd);
  2234. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2235. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2236. {
  2237. int32 i;
  2238. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2239. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2240. {
  2241. if( strcmp( "", sd->status.memo_point[i].map ) != 0 )
  2242. 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 );
  2243. else
  2244. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2245. clif_displaymessage(sd->fd, atcmd_output);
  2246. }
  2247. return 0;
  2248. }
  2249. if( position < 0 || position >= MAX_MEMOPOINTS )
  2250. {
  2251. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2252. clif_displaymessage(fd, atcmd_output);
  2253. return -1;
  2254. }
  2255. return !pc_memo( sd, position );
  2256. }
  2257. /*==========================================
  2258. *
  2259. *------------------------------------------*/
  2260. ACMD_FUNC(gat)
  2261. {
  2262. int32 y;
  2263. nullpo_retr(-1, sd);
  2264. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2265. for (y = 2; y >= -2; y--) {
  2266. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2267. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2268. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2269. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2270. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2271. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2272. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2273. clif_displaymessage(fd, atcmd_output);
  2274. }
  2275. return 0;
  2276. }
  2277. /*==========================================
  2278. *
  2279. *------------------------------------------*/
  2280. ACMD_FUNC(displaystatus)
  2281. {
  2282. int32 i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2283. nullpo_retr(-1, sd);
  2284. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2285. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2286. return -1;
  2287. }
  2288. if (i < 2) flag = 1;
  2289. if (i < 3) tick = 0;
  2290. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2291. return 0;
  2292. }
  2293. /*==========================================
  2294. * @stpoint (Rewritten by [Yor])
  2295. *------------------------------------------*/
  2296. ACMD_FUNC(statuspoint)
  2297. {
  2298. int32 point;
  2299. uint32 new_status_point;
  2300. if (!message || !*message || (point = atoi(message)) == 0) {
  2301. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2302. return -1;
  2303. }
  2304. if(point < 0)
  2305. {
  2306. if(sd->status.status_point < (uint32)(-point))
  2307. {
  2308. new_status_point = 0;
  2309. }
  2310. else
  2311. {
  2312. new_status_point = sd->status.status_point + point;
  2313. }
  2314. }
  2315. else if(UINT_MAX - sd->status.status_point < (uint32)point)
  2316. {
  2317. new_status_point = UINT_MAX;
  2318. }
  2319. else
  2320. {
  2321. new_status_point = sd->status.status_point + point;
  2322. }
  2323. if (new_status_point != sd->status.status_point) {
  2324. sd->status.status_point = new_status_point;
  2325. clif_updatestatus(*sd, SP_STATUSPOINT);
  2326. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2327. } else {
  2328. if (point < 0)
  2329. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2330. else
  2331. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2332. return -1;
  2333. }
  2334. return 0;
  2335. }
  2336. /*==========================================
  2337. * @trpoint
  2338. *------------------------------------------*/
  2339. ACMD_FUNC(traitpoint)
  2340. {
  2341. int32 point;
  2342. uint32 new_trait_point;
  2343. if (!message || !*message || (point = atoi(message)) == 0) {
  2344. clif_displaymessage(fd, msg_txt(sd, 820)); // Please enter a number (usage: @trpoint <number of points>).
  2345. return -1;
  2346. }
  2347. if (point < 0)
  2348. {
  2349. if (sd->status.trait_point < (uint32)(-point))
  2350. {
  2351. new_trait_point = 0;
  2352. }
  2353. else
  2354. {
  2355. new_trait_point = sd->status.trait_point + point;
  2356. }
  2357. }
  2358. else if (UINT_MAX - sd->status.trait_point < (uint32)point)
  2359. {
  2360. new_trait_point = UINT_MAX;
  2361. }
  2362. else
  2363. {
  2364. new_trait_point = sd->status.trait_point + point;
  2365. }
  2366. if (new_trait_point != sd->status.trait_point) {
  2367. sd->status.trait_point = new_trait_point;
  2368. clif_updatestatus(*sd, SP_TRAITPOINT);
  2369. clif_displaymessage(fd, msg_txt(sd, 174)); // Number of status points changed.
  2370. }
  2371. else {
  2372. if (point < 0)
  2373. clif_displaymessage(fd, msg_txt(sd, 41)); // Unable to decrease the number/value.
  2374. else
  2375. clif_displaymessage(fd, msg_txt(sd, 149)); // Unable to increase the number/value.
  2376. return -1;
  2377. }
  2378. return 0;
  2379. }
  2380. /*==========================================
  2381. * @skpoint (Rewritten by [Yor])
  2382. *------------------------------------------*/
  2383. ACMD_FUNC(skillpoint)
  2384. {
  2385. int32 point;
  2386. uint32 new_skill_point;
  2387. nullpo_retr(-1, sd);
  2388. if (!message || !*message || (point = atoi(message)) == 0) {
  2389. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2390. return -1;
  2391. }
  2392. if(point < 0)
  2393. {
  2394. if(sd->status.skill_point < (uint32)(-point))
  2395. {
  2396. new_skill_point = 0;
  2397. }
  2398. else
  2399. {
  2400. new_skill_point = sd->status.skill_point + point;
  2401. }
  2402. }
  2403. else if(UINT_MAX - sd->status.skill_point < (uint32)point)
  2404. {
  2405. new_skill_point = UINT_MAX;
  2406. }
  2407. else
  2408. {
  2409. new_skill_point = sd->status.skill_point + point;
  2410. }
  2411. if (new_skill_point != sd->status.skill_point) {
  2412. sd->status.skill_point = new_skill_point;
  2413. clif_updatestatus(*sd, SP_SKILLPOINT);
  2414. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2415. } else {
  2416. if (point < 0)
  2417. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2418. else
  2419. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2420. return -1;
  2421. }
  2422. return 0;
  2423. }
  2424. /*==========================================
  2425. * @zeny
  2426. *------------------------------------------*/
  2427. ACMD_FUNC(zeny)
  2428. {
  2429. int32 zeny=0, ret=-1;
  2430. nullpo_retr(-1, sd);
  2431. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2432. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2433. return -1;
  2434. }
  2435. if(zeny > 0){
  2436. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND)) == 1)
  2437. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2438. }
  2439. else {
  2440. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2441. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND)) == 1)
  2442. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2443. }
  2444. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2445. return 0;
  2446. }
  2447. /*==========================================
  2448. *
  2449. *------------------------------------------*/
  2450. ACMD_FUNC(param)
  2451. {
  2452. nullpo_retr(-1, sd);
  2453. uint8 stat;
  2454. int32 value = 0;
  2455. uint16 new_value, status, max_status;
  2456. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2457. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2458. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2459. return -1;
  2460. }
  2461. ARR_FIND( 0, ARRAYLENGTH(parameter_names), stat, strcmpi(command + 1, parameter_names[stat]) == 0 );
  2462. if( stat == ARRAYLENGTH(parameter_names)) { // normally impossible...
  2463. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2464. return -1;
  2465. }
  2466. if( stat < PARAM_POW ){
  2467. status = pc_getstat( sd, SP_STR + stat - PARAM_STR );
  2468. }else{
  2469. if( !( sd->class_ & JOBL_FOURTH ) ){
  2470. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2471. return -1;
  2472. }
  2473. status = pc_getstat( sd, SP_POW + stat - PARAM_POW );
  2474. }
  2475. if( pc_has_permission( sd, PC_PERM_BYPASS_MAX_STAT ) ){
  2476. max_status = SHRT_MAX;
  2477. }else{
  2478. max_status = pc_maxparameter( sd, static_cast<e_params>( stat ) );
  2479. }
  2480. if( value > 0 && status + value >= max_status ){
  2481. new_value = max_status;
  2482. }else if( value < 0 && abs( value ) >= status ){
  2483. if( stat < PARAM_POW ){
  2484. new_value = 1;
  2485. }else{
  2486. new_value = 0;
  2487. }
  2488. }else{
  2489. new_value = status + value;
  2490. }
  2491. if( new_value != status ){
  2492. if (stat < PARAM_POW) {
  2493. pc_setstat( sd, SP_STR + stat - PARAM_STR, new_value );
  2494. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + stat ) );
  2495. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + stat ) );
  2496. } else {
  2497. pc_setstat( sd, SP_POW + stat - PARAM_POW, new_value );
  2498. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + stat - PARAM_POW ) );
  2499. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + stat - PARAM_POW ) );
  2500. }
  2501. status_calc_pc(sd, SCO_FORCE);
  2502. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2503. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2504. } else {
  2505. if (value < 0)
  2506. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2507. else
  2508. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2509. return -1;
  2510. }
  2511. return 0;
  2512. }
  2513. /*==========================================
  2514. * Stat all by fritz (rewritten by [Yor])
  2515. *------------------------------------------*/
  2516. ACMD_FUNC(stat_all)
  2517. {
  2518. nullpo_retr(-1, sd);
  2519. int32 value = 0;
  2520. uint8 count, i;
  2521. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2522. for (i = PARAM_STR; i < PARAM_POW; i++)
  2523. status[i] = pc_getstat(sd, SP_STR + i);
  2524. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2525. for (i = PARAM_STR; i < PARAM_POW; i++)
  2526. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2527. value = SHRT_MAX;
  2528. } else {
  2529. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2530. for (i = PARAM_STR; i < PARAM_POW; i++)
  2531. max_status[i] = SHRT_MAX;
  2532. } else {
  2533. for (i = PARAM_STR; i < PARAM_POW; i++)
  2534. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2535. }
  2536. }
  2537. count = 0;
  2538. for (i = PARAM_STR; i < PARAM_POW; i++) {
  2539. short new_value;
  2540. if (value > 0 && status[i] + value >= max_status[i])
  2541. new_value = max_status[i];
  2542. else if (value < 0 && abs(value) >= status[i])
  2543. new_value = 1;
  2544. else
  2545. new_value = status[i] + value;
  2546. if (new_value != status[i]) {
  2547. pc_setstat( sd, SP_STR + i, new_value );
  2548. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  2549. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  2550. count++;
  2551. }
  2552. }
  2553. if (count > 0) { // if at least 1 stat modified
  2554. status_calc_pc(sd, SCO_FORCE);
  2555. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2556. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2557. } else {
  2558. if (value < 0)
  2559. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2560. else
  2561. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2562. return -1;
  2563. }
  2564. return 0;
  2565. }
  2566. /*==========================================
  2567. * Traits
  2568. *------------------------------------------*/
  2569. ACMD_FUNC(trait_all) {
  2570. nullpo_retr(-1, sd);
  2571. #ifndef RENEWAL
  2572. sprintf(atcmd_output, msg_txt(sd, 154), command); // %s failed.
  2573. clif_displaymessage(fd, atcmd_output);
  2574. return -1;
  2575. #endif
  2576. if( !( sd->class_ & JOBL_FOURTH ) ){
  2577. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2578. return -1;
  2579. }
  2580. int32 value = 0;
  2581. uint8 i;
  2582. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2583. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2584. status[i] = pc_getstat(sd, SP_POW + i - PARAM_POW);
  2585. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2586. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2587. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2588. value = SHRT_MAX;
  2589. } else {
  2590. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2591. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2592. max_status[i] = SHRT_MAX;
  2593. } else {
  2594. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2595. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2596. }
  2597. }
  2598. uint8 count = 0;
  2599. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  2600. short new_value;
  2601. if (value > 0 && status[i] + value >= max_status[i])
  2602. new_value = max_status[i];
  2603. else if (value < 0 && abs(value) >= status[i])
  2604. new_value = 0;
  2605. else
  2606. new_value = status[i] + value;
  2607. if (new_value != status[i]) {
  2608. pc_setstat( sd, SP_POW + i - PARAM_POW, new_value );
  2609. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  2610. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  2611. count++;
  2612. }
  2613. }
  2614. if (count > 0) { // if at least 1 stat modified
  2615. status_calc_pc(sd, SCO_FORCE);
  2616. clif_displaymessage(fd, msg_txt(sd, 84)); // All stats changed!
  2617. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2618. } else {
  2619. if (value < 0)
  2620. clif_displaymessage(fd, msg_txt(sd, 177)); // You cannot decrease that stat anymore.
  2621. else
  2622. clif_displaymessage(fd, msg_txt(sd, 178)); // You cannot increase that stat anymore.
  2623. return -1;
  2624. }
  2625. return 0;
  2626. }
  2627. /*==========================================
  2628. *
  2629. *------------------------------------------*/
  2630. ACMD_FUNC(guildlevelup) {
  2631. int32 level = 0;
  2632. short added_level;
  2633. nullpo_retr(-1, sd);
  2634. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2635. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2636. return -1;
  2637. }
  2638. auto &guild_info = sd->guild;
  2639. if (sd->status.guild_id <= 0 || guild_info == nullptr) {
  2640. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2641. return -1;
  2642. }
  2643. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2644. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2645. // return -1;
  2646. //}
  2647. added_level = (short)level;
  2648. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild.guild_lv))) // fix positive overflow
  2649. added_level = (short)MAX_GUILDLEVEL - guild_info->guild.guild_lv;
  2650. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild.guild_lv))) // fix negative overflow
  2651. added_level = 1 - guild_info->guild.guild_lv;
  2652. if (added_level != 0) {
  2653. intif_guild_change_basicinfo(guild_info->guild.guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2654. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2655. } else {
  2656. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2657. return -1;
  2658. }
  2659. return 0;
  2660. }
  2661. /*==========================================
  2662. *
  2663. *------------------------------------------*/
  2664. ACMD_FUNC(makeegg) {
  2665. int32 id;
  2666. nullpo_retr(-1, sd);
  2667. if (!message || !*message) {
  2668. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2669. return -1;
  2670. }
  2671. // for monster name
  2672. if ((id = mobdb_searchname(message)) != 0)
  2673. ;
  2674. else
  2675. id = atoi(message);
  2676. std::shared_ptr<s_pet_db> pet = pet_db.find(id);
  2677. if( pet == nullptr ){
  2678. t_itemid nameid;
  2679. // for egg name
  2680. std::shared_ptr<item_data> item_data = item_db.searchname( message );
  2681. if( item_data != nullptr ){
  2682. nameid = item_data->nameid;
  2683. }else{
  2684. nameid = strtoul( message, nullptr, 10 );
  2685. }
  2686. pet = pet_db_search( nameid, PET_EGG );
  2687. }
  2688. int32 res(-1);
  2689. if (pet != nullptr) {
  2690. std::shared_ptr<s_mob_db> mdb = mob_db.find(pet->class_);
  2691. if(mdb){
  2692. 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())){
  2693. res = 0;
  2694. } else {
  2695. res = -2; //char server down
  2696. }
  2697. }
  2698. }
  2699. switch(res){
  2700. case -1:
  2701. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2702. break;
  2703. case -2:
  2704. clif_displaymessage(fd, msg_txt(sd,407)); //charserver link broken
  2705. break;
  2706. }
  2707. return res;
  2708. }
  2709. /*==========================================
  2710. *
  2711. *------------------------------------------*/
  2712. ACMD_FUNC(hatch) {
  2713. nullpo_retr(-1, sd);
  2714. if (sd->status.pet_id <= 0)
  2715. clif_sendegg(sd);
  2716. else {
  2717. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2718. return -1;
  2719. }
  2720. return 0;
  2721. }
  2722. /*==========================================
  2723. *
  2724. *------------------------------------------*/
  2725. ACMD_FUNC(petfriendly) {
  2726. int32 friendly;
  2727. struct pet_data *pd;
  2728. nullpo_retr(-1, sd);
  2729. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2730. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2731. return -1;
  2732. }
  2733. pd = sd->pd;
  2734. if (!pd) {
  2735. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2736. return -1;
  2737. }
  2738. if (friendly < 0 || friendly > 1000)
  2739. {
  2740. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2741. return -1;
  2742. }
  2743. if (friendly == pd->pet.intimate) {
  2744. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2745. return -1;
  2746. }
  2747. pet_set_intimate(pd, friendly);
  2748. clif_send_petstatus(sd);
  2749. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2750. return 0;
  2751. }
  2752. /*==========================================
  2753. *
  2754. *------------------------------------------*/
  2755. ACMD_FUNC(pethungry)
  2756. {
  2757. int32 hungry;
  2758. struct pet_data *pd;
  2759. nullpo_retr(-1, sd);
  2760. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2761. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2762. return -1;
  2763. }
  2764. pd = sd->pd;
  2765. if (!sd->status.pet_id || !pd) {
  2766. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2767. return -1;
  2768. }
  2769. if (hungry < 0 || hungry > 100) {
  2770. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2771. return -1;
  2772. }
  2773. if (hungry == pd->pet.hungry) {
  2774. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2775. return -1;
  2776. }
  2777. pd->pet.hungry = hungry;
  2778. clif_send_petstatus(sd);
  2779. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2780. return 0;
  2781. }
  2782. /*==========================================
  2783. *
  2784. *------------------------------------------*/
  2785. ACMD_FUNC(petrename)
  2786. {
  2787. struct pet_data *pd;
  2788. nullpo_retr(-1, sd);
  2789. if (!sd->status.pet_id || !sd->pd) {
  2790. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2791. return -1;
  2792. }
  2793. pd = sd->pd;
  2794. if (!pd->pet.rename_flag) {
  2795. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2796. return -1;
  2797. }
  2798. pd->pet.rename_flag = 0;
  2799. intif_save_petdata(sd->status.account_id, &pd->pet);
  2800. clif_send_petstatus(sd);
  2801. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2802. return 0;
  2803. }
  2804. /*==========================================
  2805. *
  2806. *------------------------------------------*/
  2807. ACMD_FUNC(recall) {
  2808. map_session_data* pl_sd = nullptr;;
  2809. nullpo_retr(-1, sd);
  2810. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2811. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2812. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2813. return -1;
  2814. }
  2815. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  2816. {
  2817. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2818. return -1;
  2819. }
  2820. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2821. {
  2822. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to perform this action on the specified player.
  2823. return -1;
  2824. }
  2825. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2826. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2827. return -1;
  2828. }
  2829. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2830. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2831. return -1;
  2832. }
  2833. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2834. return -1;
  2835. }
  2836. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2837. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2838. return -1;
  2839. }
  2840. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2841. clif_displaymessage(fd, atcmd_output);
  2842. return 0;
  2843. }
  2844. /*==========================================
  2845. * charblock command (usage: charblock <player_name>)
  2846. * This command do a definitiv ban on a player
  2847. *------------------------------------------*/
  2848. ACMD_FUNC(char_block)
  2849. {
  2850. nullpo_retr(-1, sd);
  2851. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2852. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2853. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2854. clif_displaymessage(fd, atcmd_output);
  2855. return -1;
  2856. }
  2857. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2858. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2859. clif_displaymessage(fd, atcmd_output);
  2860. return 0;
  2861. }
  2862. /*==========================================
  2863. * accountban command (usage: ban <%time> <player_name>)
  2864. * charban command (usage: charban <%time> <player_name>)
  2865. * %time see common/timer.cpp::solve_time()
  2866. *------------------------------------------*/
  2867. ACMD_FUNC(char_ban)
  2868. {
  2869. char *modif_p, output[CHAT_SIZE_MAX];
  2870. int32 timediff = 0; //don't set this as uint32 as we may want to decrease banned time
  2871. enum chrif_req_op bantype;
  2872. nullpo_retr(-1, sd);
  2873. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2874. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2875. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2876. if (strcmpi(parent_cmd,"charban") == 0)
  2877. bantype = CHRIF_OP_BAN;
  2878. else if (strcmpi(parent_cmd,"ban") == 0)
  2879. bantype = CHRIF_OP_LOGIN_BAN;
  2880. else
  2881. return -1;
  2882. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2883. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2884. clif_displaymessage(fd, output);
  2885. return -1;
  2886. }
  2887. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2888. modif_p = atcmd_output;
  2889. timediff = (int32)solve_time(modif_p); //discard seconds
  2890. if (timediff == 0) { //allow negative ?
  2891. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2892. clif_displaymessage(fd, output);
  2893. 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.
  2894. return -1;
  2895. }
  2896. if( timediff < 0 && (
  2897. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2898. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2899. ))
  2900. {
  2901. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2902. return -1;
  2903. }
  2904. if (bantype == CHRIF_OP_BAN)
  2905. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2906. else
  2907. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2908. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2909. clif_displaymessage(fd, output);
  2910. return 0;
  2911. }
  2912. /*==========================================
  2913. * charunblock command (usage: charunblock <player_name>)
  2914. *------------------------------------------*/
  2915. ACMD_FUNC(char_unblock)
  2916. {
  2917. nullpo_retr(-1, sd);
  2918. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2919. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2920. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2921. clif_displaymessage(fd, atcmd_output);
  2922. return -1;
  2923. }
  2924. // send answer to login server via char-server
  2925. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2926. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2927. clif_displaymessage(fd, atcmd_output);
  2928. return 0;
  2929. }
  2930. /*==========================================
  2931. * acc unban command (usage: unban <player_name>)
  2932. * char unban command (usage: charunban <player_name>)
  2933. *------------------------------------------*/
  2934. ACMD_FUNC(char_unban){
  2935. enum chrif_req_op unbantype;
  2936. nullpo_retr(-1, sd);
  2937. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2938. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2939. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2940. if (strcmpi(parent_cmd,"charunban") == 0)
  2941. unbantype = CHRIF_OP_UNBAN;
  2942. else if (strcmpi(parent_cmd,"unban") == 0)
  2943. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2944. else
  2945. return -1;
  2946. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2947. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2948. clif_displaymessage(fd, atcmd_output);
  2949. return -1;
  2950. }
  2951. if (unbantype == CHRIF_OP_UNBAN)
  2952. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2953. else
  2954. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2955. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2956. clif_displaymessage(fd, atcmd_output);
  2957. return 0;
  2958. }
  2959. /*==========================================
  2960. *
  2961. *------------------------------------------*/
  2962. ACMD_FUNC(night)
  2963. {
  2964. nullpo_retr(-1, sd);
  2965. if (night_flag != 1) {
  2966. map_night_timer(night_timer_tid, 0, 0, 1);
  2967. } else {
  2968. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2969. return -1;
  2970. }
  2971. return 0;
  2972. }
  2973. /*==========================================
  2974. *
  2975. *------------------------------------------*/
  2976. ACMD_FUNC(day)
  2977. {
  2978. nullpo_retr(-1, sd);
  2979. if (night_flag != 0) {
  2980. map_day_timer(day_timer_tid, 0, 0, 1);
  2981. } else {
  2982. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2983. return -1;
  2984. }
  2985. return 0;
  2986. }
  2987. /*==========================================
  2988. *
  2989. *------------------------------------------*/
  2990. ACMD_FUNC(doom)
  2991. {
  2992. map_session_data* pl_sd;
  2993. struct s_mapiterator* iter;
  2994. nullpo_retr(-1, sd);
  2995. iter = mapit_getallusers();
  2996. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2997. {
  2998. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2999. {
  3000. status_kill(&pl_sd->bl);
  3001. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  3002. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3003. }
  3004. }
  3005. mapit_free(iter);
  3006. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3007. return 0;
  3008. }
  3009. /*==========================================
  3010. *
  3011. *------------------------------------------*/
  3012. ACMD_FUNC(doommap)
  3013. {
  3014. map_session_data* pl_sd;
  3015. struct s_mapiterator* iter;
  3016. nullpo_retr(-1, sd);
  3017. iter = mapit_getallusers();
  3018. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3019. {
  3020. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3021. {
  3022. status_kill(&pl_sd->bl);
  3023. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  3024. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3025. }
  3026. }
  3027. mapit_free(iter);
  3028. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3029. return 0;
  3030. }
  3031. /*==========================================
  3032. *
  3033. *------------------------------------------*/
  3034. static void atcommand_raise_sub(map_session_data* sd) {
  3035. status_revive(&sd->bl, 100, 100);
  3036. clif_skill_nodamage(&sd->bl,sd->bl,ALL_RESURRECTION,4);
  3037. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  3038. }
  3039. /*==========================================
  3040. *
  3041. *------------------------------------------*/
  3042. ACMD_FUNC(raise)
  3043. {
  3044. map_session_data* pl_sd;
  3045. struct s_mapiterator* iter;
  3046. nullpo_retr(-1, sd);
  3047. iter = mapit_getallusers();
  3048. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3049. if( pc_isdead(pl_sd) )
  3050. atcommand_raise_sub(pl_sd);
  3051. mapit_free(iter);
  3052. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3053. return 0;
  3054. }
  3055. /*==========================================
  3056. *
  3057. *------------------------------------------*/
  3058. ACMD_FUNC(raisemap)
  3059. {
  3060. map_session_data* pl_sd;
  3061. struct s_mapiterator* iter;
  3062. nullpo_retr(-1, sd);
  3063. iter = mapit_getallusers();
  3064. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3065. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  3066. atcommand_raise_sub(pl_sd);
  3067. mapit_free(iter);
  3068. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3069. return 0;
  3070. }
  3071. /*==========================================
  3072. *
  3073. *------------------------------------------*/
  3074. ACMD_FUNC(kick)
  3075. {
  3076. map_session_data *pl_sd;
  3077. nullpo_retr(-1, sd);
  3078. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3079. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3080. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  3081. return -1;
  3082. }
  3083. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  3084. {
  3085. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3086. return -1;
  3087. }
  3088. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  3089. {
  3090. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3091. return -1;
  3092. }
  3093. clif_GM_kick(sd, pl_sd);
  3094. return 0;
  3095. }
  3096. /*==========================================
  3097. *
  3098. *------------------------------------------*/
  3099. ACMD_FUNC(kickall)
  3100. {
  3101. map_session_data* pl_sd;
  3102. struct s_mapiterator* iter;
  3103. nullpo_retr(-1, sd);
  3104. iter = mapit_getallusers();
  3105. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3106. {
  3107. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  3108. if (sd->status.account_id != pl_sd->status.account_id)
  3109. clif_GM_kick(nullptr, pl_sd);
  3110. }
  3111. }
  3112. mapit_free(iter);
  3113. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  3114. return 0;
  3115. }
  3116. /*==========================================
  3117. *
  3118. *------------------------------------------*/
  3119. ACMD_FUNC(allskill)
  3120. {
  3121. nullpo_retr(-1, sd);
  3122. pc_allskillup(sd); // all skills
  3123. sd->status.skill_point = 0; // 0 skill points
  3124. clif_updatestatus(*sd, SP_SKILLPOINT); // update
  3125. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  3126. return 0;
  3127. }
  3128. /*==========================================
  3129. *
  3130. *------------------------------------------*/
  3131. ACMD_FUNC(questskill)
  3132. {
  3133. uint16 skill_id;
  3134. nullpo_retr(-1, sd);
  3135. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3136. {// also send a list of skills applicable to this command
  3137. const char* text;
  3138. // attempt to find the text corresponding to this command
  3139. text = atcommand_help_string( command );
  3140. // send the error message as always
  3141. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3142. if( text )
  3143. {// send the skill ID list associated with this command
  3144. clif_displaymessage( fd, text );
  3145. }
  3146. return -1;
  3147. }
  3148. if (skill_id >= MAX_SKILL_ID) {
  3149. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3150. return -1;
  3151. }
  3152. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3153. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3154. return -1;
  3155. }
  3156. if (pc_checkskill(sd, skill_id) > 0) {
  3157. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  3158. return -1;
  3159. }
  3160. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  3161. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  3162. return 0;
  3163. }
  3164. /*==========================================
  3165. *
  3166. *------------------------------------------*/
  3167. ACMD_FUNC(lostskill)
  3168. {
  3169. uint16 skill_id = 0, sk_idx = 0;
  3170. nullpo_retr(-1, sd);
  3171. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3172. {// also send a list of skills applicable to this command
  3173. const char* text;
  3174. // attempt to find the text corresponding to this command
  3175. text = atcommand_help_string( command );
  3176. // send the error message as always
  3177. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3178. if( text )
  3179. {// send the skill ID list associated with this command
  3180. clif_displaymessage( fd, text );
  3181. }
  3182. return -1;
  3183. }
  3184. if (!(sk_idx = skill_get_index(skill_id))) {
  3185. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3186. return -1;
  3187. }
  3188. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3189. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3190. return -1;
  3191. }
  3192. if (pc_checkskill(sd, skill_id) == 0) {
  3193. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  3194. return -1;
  3195. }
  3196. sd->status.skill[sk_idx].lv = 0;
  3197. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  3198. clif_deleteskill(*sd,skill_id);
  3199. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  3200. return 0;
  3201. }
  3202. /*==========================================
  3203. *
  3204. *------------------------------------------*/
  3205. ACMD_FUNC(spiritball)
  3206. {
  3207. int32 number;
  3208. nullpo_retr(-1, sd);
  3209. if( !message || !*message || ( number = atoi( message ) ) < 0 || number > MAX_SPIRITBALL ){
  3210. char msg[CHAT_SIZE_MAX];
  3211. safesnprintf( msg, sizeof( msg ), msg_txt( sd, 1028 ), MAX_SPIRITBALL ); // Please enter an amount (usage: @spiritball <number: 0-%d>).
  3212. clif_displaymessage(fd, msg);
  3213. return -1;
  3214. }
  3215. if( sd->spiritball > 0 )
  3216. pc_delspiritball(sd, sd->spiritball, 1);
  3217. sd->spiritball = number;
  3218. clif_spiritball(&sd->bl);
  3219. // no message, player can look the difference
  3220. return 0;
  3221. }
  3222. ACMD_FUNC(soulball)
  3223. {
  3224. int32 number;
  3225. nullpo_retr(-1, sd);
  3226. if (!message || !*message || (number = atoi(message)) < 0 || number > MAX_SOUL_BALL) {
  3227. char msg[CHAT_SIZE_MAX];
  3228. safesnprintf(msg, sizeof(msg), "Usage: @soulball <number: 0-%d>", MAX_SOUL_BALL);
  3229. clif_displaymessage(fd, msg);
  3230. return -1;
  3231. }
  3232. if (sd->soulball > 0)
  3233. pc_delsoulball( *sd, sd->soulball, true );
  3234. pc_addsoulball( *sd, number );
  3235. clif_soulball(sd);
  3236. return 0;
  3237. }
  3238. /*==========================================
  3239. *
  3240. *------------------------------------------*/
  3241. ACMD_FUNC(party)
  3242. {
  3243. char party[NAME_LENGTH];
  3244. nullpo_retr(-1, sd);
  3245. memset(party, '\0', sizeof(party));
  3246. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3247. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  3248. return -1;
  3249. }
  3250. party_create( *sd, party, 0, 0 );
  3251. return 0;
  3252. }
  3253. /*==========================================
  3254. *
  3255. *------------------------------------------*/
  3256. ACMD_FUNC(guild)
  3257. {
  3258. char guild[NAME_LENGTH];
  3259. int32 prev;
  3260. nullpo_retr(-1, sd);
  3261. memset(guild, '\0', sizeof(guild));
  3262. if (sd->clan) {
  3263. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  3264. return -1;
  3265. }
  3266. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3267. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  3268. return -1;
  3269. }
  3270. prev = battle_config.guild_emperium_check;
  3271. battle_config.guild_emperium_check = 0;
  3272. guild_create( *sd, guild );
  3273. battle_config.guild_emperium_check = prev;
  3274. return 0;
  3275. }
  3276. ACMD_FUNC(breakguild)
  3277. {
  3278. nullpo_retr(-1, sd);
  3279. if (sd->status.guild_id) { // Check if the player has a guild
  3280. if (sd->guild) { // Check if guild was found
  3281. if (sd->state.gmaster_flag) { // Check if player is guild master
  3282. // Break guild
  3283. int32 ret = guild_break( *sd, sd->guild->guild.name );
  3284. if (ret) { // Check if anything went wrong
  3285. return 0; // Guild was broken
  3286. } else {
  3287. return -1; // Something went wrong
  3288. }
  3289. } else { // Not guild master
  3290. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3291. return -1;
  3292. }
  3293. } else { // Guild was not found. HOW?
  3294. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3295. return -1;
  3296. }
  3297. } else { // Player does not have a guild
  3298. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3299. return -1;
  3300. }
  3301. }
  3302. /**
  3303. * Start WoE:FE
  3304. */
  3305. ACMD_FUNC(agitstart)
  3306. {
  3307. nullpo_retr(-1, sd);
  3308. if( guild_agit_start() ){
  3309. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3310. return 0;
  3311. }else{
  3312. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3313. return -1;
  3314. }
  3315. }
  3316. /**
  3317. * Start WoE:SE
  3318. */
  3319. ACMD_FUNC(agitstart2)
  3320. {
  3321. nullpo_retr(-1, sd);
  3322. if( guild_agit2_start() ){
  3323. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3324. return 0;
  3325. }else{
  3326. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3327. return -1;
  3328. }
  3329. }
  3330. /**
  3331. * Start WoE:TE
  3332. */
  3333. ACMD_FUNC(agitstart3)
  3334. {
  3335. nullpo_retr(-1, sd);
  3336. if( guild_agit3_start() ){
  3337. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3338. return 0;
  3339. }else{
  3340. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3341. return -1;
  3342. }
  3343. }
  3344. /**
  3345. * End WoE:FE
  3346. */
  3347. ACMD_FUNC(agitend)
  3348. {
  3349. nullpo_retr(-1, sd);
  3350. if( guild_agit_end() ){
  3351. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3352. return 0;
  3353. }else{
  3354. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3355. return -1;
  3356. }
  3357. }
  3358. /**
  3359. * End WoE:SE
  3360. */
  3361. ACMD_FUNC(agitend2)
  3362. {
  3363. nullpo_retr(-1, sd);
  3364. if( guild_agit2_end() ){
  3365. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3366. return 0;
  3367. }else{
  3368. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3369. return -1;
  3370. }
  3371. }
  3372. /**
  3373. * End WoE:TE
  3374. */
  3375. ACMD_FUNC(agitend3)
  3376. {
  3377. nullpo_retr(-1, sd);
  3378. if( guild_agit3_end() ){
  3379. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3380. return 0;
  3381. }else{
  3382. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3383. return -1;
  3384. }
  3385. }
  3386. /*==========================================
  3387. * @mapexit - shuts down the map server
  3388. *------------------------------------------*/
  3389. ACMD_FUNC(mapexit)
  3390. {
  3391. nullpo_retr(-1, sd);
  3392. global_core->signal_shutdown();
  3393. return 0;
  3394. }
  3395. /*==========================================
  3396. * idsearch <part_of_name>: revrited by [Yor]
  3397. *------------------------------------------*/
  3398. ACMD_FUNC(idsearch)
  3399. {
  3400. nullpo_retr(-1, sd);
  3401. char item_name[100];
  3402. memset(item_name, '\0', sizeof(item_name));
  3403. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3404. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3405. return -1;
  3406. }
  3407. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3408. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3409. clif_displaymessage(fd, atcmd_output);
  3410. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  3411. uint16 match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3412. if (match == MAX_SEARCH) {
  3413. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3414. clif_displaymessage(fd, atcmd_output);
  3415. }
  3416. for(const auto &result : item_array) {
  3417. std::shared_ptr<item_data> id = result.second;
  3418. sprintf(atcmd_output, msg_txt(sd,78), item_db.create_item_link( id ).c_str(), id->nameid); // %s: %u
  3419. clif_displaymessage(fd, atcmd_output);
  3420. }
  3421. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3422. clif_displaymessage(fd, atcmd_output);
  3423. return 0;
  3424. }
  3425. /*==========================================
  3426. * Recall All Characters Online To Your Location
  3427. *------------------------------------------*/
  3428. ACMD_FUNC(recallall)
  3429. {
  3430. map_session_data* pl_sd;
  3431. struct s_mapiterator* iter;
  3432. int32 count;
  3433. nullpo_retr(-1, sd);
  3434. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3435. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3436. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3437. return -1;
  3438. }
  3439. count = 0;
  3440. iter = mapit_getallusers();
  3441. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3442. {
  3443. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3444. {
  3445. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3446. continue; // Don't waste time warping the character to the same place.
  3447. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3448. count++;
  3449. else {
  3450. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3451. count++;
  3452. }
  3453. }
  3454. }
  3455. }
  3456. mapit_free(iter);
  3457. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3458. if (count) {
  3459. 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.
  3460. clif_displaymessage(fd, atcmd_output);
  3461. }
  3462. return 0;
  3463. }
  3464. /*==========================================
  3465. * Recall online characters of a guild to your location
  3466. *------------------------------------------*/
  3467. ACMD_FUNC(guildrecall)
  3468. {
  3469. map_session_data* pl_sd;
  3470. struct s_mapiterator* iter;
  3471. int32 count;
  3472. char guild_name[NAME_LENGTH];
  3473. nullpo_retr(-1, sd);
  3474. memset(guild_name, '\0', sizeof(guild_name));
  3475. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3476. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3477. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3478. return -1;
  3479. }
  3480. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3481. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3482. return -1;
  3483. }
  3484. auto g = guild_searchnameid(guild_name);
  3485. if (!g) {
  3486. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3487. return -1;
  3488. }
  3489. count = 0;
  3490. iter = mapit_getallusers();
  3491. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3492. {
  3493. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild.guild_id)
  3494. {
  3495. 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))
  3496. continue; // Skip GMs greater than you... or chars already on the cell
  3497. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3498. count++;
  3499. else{
  3500. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3501. count++;
  3502. }
  3503. }
  3504. }
  3505. }
  3506. mapit_free(iter);
  3507. sprintf(atcmd_output, msg_txt(sd,93), g->guild.name); // All online characters of the %s guild have been recalled to your position.
  3508. clif_displaymessage(fd, atcmd_output);
  3509. if (count) {
  3510. 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.
  3511. clif_displaymessage(fd, atcmd_output);
  3512. }
  3513. return 0;
  3514. }
  3515. /*==========================================
  3516. * Recall online characters of a party to your location
  3517. *------------------------------------------*/
  3518. ACMD_FUNC(partyrecall)
  3519. {
  3520. map_session_data* pl_sd;
  3521. struct s_mapiterator* iter;
  3522. char party_name[NAME_LENGTH];
  3523. struct party_data *p;
  3524. int32 count;
  3525. nullpo_retr(-1, sd);
  3526. memset(party_name, '\0', sizeof(party_name));
  3527. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3528. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3529. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3530. return -1;
  3531. }
  3532. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3533. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3534. return -1;
  3535. }
  3536. if ((p = party_searchname(party_name)) == nullptr && // name first to avoid error when name begin with a number
  3537. (p = party_search(atoi(message))) == nullptr)
  3538. {
  3539. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3540. return -1;
  3541. }
  3542. count = 0;
  3543. iter = mapit_getallusers();
  3544. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3545. {
  3546. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3547. {
  3548. 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))
  3549. continue; // Skip GMs greater than you... or chars already on the cell
  3550. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3551. count++;
  3552. else{
  3553. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3554. count++;
  3555. }
  3556. }
  3557. }
  3558. }
  3559. mapit_free(iter);
  3560. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3561. clif_displaymessage(fd, atcmd_output);
  3562. if (count) {
  3563. 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.
  3564. clif_displaymessage(fd, atcmd_output);
  3565. }
  3566. return 0;
  3567. }
  3568. /*==========================================
  3569. *
  3570. *------------------------------------------*/
  3571. void atcommand_doload();
  3572. ACMD_FUNC(reload) {
  3573. nullpo_retr(-1, sd);
  3574. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3575. const char* text;
  3576. text = atcommand_help_string( command );
  3577. if(text)
  3578. clif_displaymessage( fd, text );
  3579. return -1;
  3580. }
  3581. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3582. itemdb_reload();
  3583. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3584. } else if (strstr(command, "cashdb") || strncmp(message, "cashdb", 4) == 0) {
  3585. cashshop_reloaddb();
  3586. clif_displaymessage( fd, msg_txt( sd, 832 ) ); // Cash shop database has been reloaded.
  3587. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3588. mob_reload();
  3589. pet_db.reload();
  3590. hom_reload();
  3591. mercenary_db.reload();
  3592. elemental_db.reload();
  3593. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3594. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3595. skill_reload();
  3596. homunculus_db.reload();
  3597. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3598. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3599. atcommand_doload();
  3600. pc_groups_reload();
  3601. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3602. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3603. struct Battle_Config prev_config;
  3604. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3605. battle_config_read(BATTLE_CONF_FILENAME);
  3606. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3607. || prev_config.item_rate_common != battle_config.item_rate_common
  3608. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3609. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3610. || prev_config.item_rate_card != battle_config.item_rate_card
  3611. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3612. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3613. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3614. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3615. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3616. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3617. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3618. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3619. || prev_config.item_rate_use != battle_config.item_rate_use
  3620. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3621. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3622. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3623. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3624. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3625. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3626. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3627. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3628. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3629. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3630. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3631. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3632. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3633. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3634. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3635. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3636. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3637. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3638. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3639. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3640. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3641. )
  3642. { // Exp or Drop rates changed.
  3643. mob_reload(); //Needed as well so rate changes take effect.
  3644. }
  3645. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3646. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3647. status_readdb( true );
  3648. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3649. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3650. pc_readdb();
  3651. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3652. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3653. pc_read_motd();
  3654. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3655. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3656. struct s_mapiterator* iter;
  3657. map_session_data* pl_sd;
  3658. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3659. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3660. iter = mapit_getallusers();
  3661. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3662. pc_close_npc(pl_sd,1);
  3663. clif_cutin( *pl_sd, "", 255 );
  3664. pl_sd->state.block_action &= ~(PCBLOCK_ALL ^ PCBLOCK_IMMUNE);
  3665. bg_queue_leave(pl_sd);
  3666. }
  3667. mapit_free(iter);
  3668. for (auto &bg : bg_queues) {
  3669. for (auto &bg_sd : bg->teama_members)
  3670. bg_team_leave(bg_sd, false, false); // Kick Team A from battlegrounds
  3671. for (auto &bg_sd : bg->teamb_members)
  3672. bg_team_leave(bg_sd, false, false); // Kick Team B from battlegrounds
  3673. bg_queue_clear(bg, true);
  3674. }
  3675. flush_fifos();
  3676. map_reloadnpc(true); // reload config files seeking for npcs
  3677. script_reload();
  3678. npc_reload();
  3679. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3680. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3681. map_msg_reload();
  3682. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3683. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3684. if (quest_db.reload())
  3685. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3686. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3687. if (instance_db.reload())
  3688. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3689. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3690. achievement_db_reload();
  3691. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3692. } else if (strstr(command, "attendancedb") || strncmp(message, "attendancedb", 4) == 0) {
  3693. attendance_db.reload();
  3694. clif_displaymessage(fd, msg_txt(sd, 795)); // Attendance database has been reloaded.
  3695. }else if( strstr( command, "barterdb" ) || strncmp( message, "barterdb", 4 ) == 0 ){
  3696. barter_db.reload();
  3697. clif_displaymessage(fd, msg_txt(sd, 830)); // Barter database has been reloaded.
  3698. } else if (strstr(command, "logconf") || strncmp(message, "logconf", 3) == 0) {
  3699. log_config_read(LOG_CONF_NAME);
  3700. clif_displaymessage(fd, msg_txt(sd,1536)); // Log configuration has been reloaded.
  3701. }
  3702. return 0;
  3703. }
  3704. /*==========================================
  3705. * @partysharelvl <share_range> [Akinari]
  3706. * Updates char server party share level range in runtime
  3707. * Temporary - Permanent update in inter_athena.conf
  3708. *------------------------------------------*/
  3709. ACMD_FUNC(partysharelvl) {
  3710. uint32 share_lvl;
  3711. nullpo_retr(-1, sd);
  3712. if(!message || !*message) {
  3713. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3714. return -1;
  3715. } else {
  3716. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3717. }
  3718. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3719. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3720. else //Char server offline
  3721. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3722. return 0;
  3723. }
  3724. /*==========================================
  3725. * @mapinfo [0-3] <map name> by MC_Cameri
  3726. * => Shows information about the map [map name]
  3727. * 0 = no additional information
  3728. * 1 = Show users in that map and their location
  3729. * 2 = Shows NPCs in that map
  3730. * 3 = Shows the chats in that map
  3731. *------------------------------------------*/
  3732. ACMD_FUNC(mapinfo) {
  3733. map_session_data* pl_sd;
  3734. struct s_mapiterator* iter;
  3735. struct chat_data *cd = nullptr;
  3736. char direction[12];
  3737. int32 i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3738. unsigned short m_index;
  3739. char mapname[MAP_NAME_LENGTH];
  3740. nullpo_retr(-1, sd);
  3741. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3742. memset(mapname, '\0', sizeof(mapname));
  3743. memset(direction, '\0', sizeof(direction));
  3744. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3745. if (list < 0 || list > 3) {
  3746. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3747. return -1;
  3748. }
  3749. if (mapname[0] == '\0') {
  3750. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3751. m_id = map_mapindex2mapid(sd->mapindex);
  3752. } else {
  3753. m_id = map_mapname2mapid(mapname);
  3754. }
  3755. if (m_id < 0) {
  3756. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3757. return -1;
  3758. }
  3759. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3760. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3761. // count chats (for initial message)
  3762. chat_num = 0;
  3763. iter = mapit_getallusers();
  3764. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3765. if( pl_sd->mapindex == m_index ) {
  3766. if( pl_sd->state.vending )
  3767. vend_num++;
  3768. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr && cd->usersd[0] == pl_sd )
  3769. chat_num++;
  3770. }
  3771. }
  3772. mapit_free(iter);
  3773. struct map_data *mapdata = map_getmapdata(m_id);
  3774. 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
  3775. clif_displaymessage(fd, atcmd_output);
  3776. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3777. if (map_getmapflag(m_id, MF_TOWN))
  3778. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3779. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3780. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3781. clif_displaymessage(fd, atcmd_output);
  3782. }
  3783. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3784. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3785. else
  3786. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3787. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3788. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3789. clif_displaymessage(fd, atcmd_output);
  3790. }
  3791. /* Skill damage adjustment info [Cydh] */
  3792. if (mapdata->getMapFlag(MF_SKILL_DAMAGE)) {
  3793. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3794. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3795. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3796. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3797. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3798. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3799. mapdata->damage_adjust.caster);
  3800. clif_displaymessage(fd, atcmd_output);
  3801. if (!mapdata->skill_damage.empty()) {
  3802. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3803. for (const auto& skilldmg : mapdata->skill_damage) {
  3804. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3805. skill_get_name(skilldmg.first),
  3806. skilldmg.second.rate[SKILLDMG_PC],
  3807. skilldmg.second.rate[SKILLDMG_MOB],
  3808. skilldmg.second.rate[SKILLDMG_BOSS],
  3809. skilldmg.second.rate[SKILLDMG_OTHER],
  3810. skilldmg.second.caster);
  3811. clif_displaymessage(fd,atcmd_output);
  3812. }
  3813. }
  3814. }
  3815. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3816. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3817. for (const auto &it : mapdata->skill_duration) {
  3818. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3819. clif_displaymessage(fd, atcmd_output);
  3820. }
  3821. }
  3822. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3823. if (map_getmapflag(m_id, MF_PVP))
  3824. strcat(atcmd_output, " Pvp ON |");
  3825. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3826. strcat(atcmd_output, " NoGuild |");
  3827. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3828. strcat(atcmd_output, " NoParty |");
  3829. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3830. strcat(atcmd_output, " NightmareDrop |");
  3831. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3832. strcat(atcmd_output, " NoCalcRank |");
  3833. clif_displaymessage(fd, atcmd_output);
  3834. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3835. if (map_getmapflag(m_id, MF_GVG))
  3836. strcat(atcmd_output, " GvG ON |");
  3837. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3838. strcat(atcmd_output, " GvG Dungeon |");
  3839. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3840. strcat(atcmd_output, " GvG Castle |");
  3841. if (map_getmapflag(m_id, MF_GVG_TE))
  3842. strcat(atcmd_output, " GvG TE |");
  3843. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3844. strcat(atcmd_output, " GvG TE Castle |");
  3845. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3846. strcat(atcmd_output, " NoParty |");
  3847. clif_displaymessage(fd, atcmd_output);
  3848. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3849. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3850. strcat(atcmd_output, " NoTeleport |");
  3851. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3852. strcat(atcmd_output, " Monster NoTeleport |");
  3853. if (map_getmapflag(m_id, MF_NOWARP))
  3854. strcat(atcmd_output, " NoWarp |");
  3855. if (map_getmapflag(m_id, MF_NOWARPTO))
  3856. strcat(atcmd_output, " NoWarpTo |");
  3857. if (map_getmapflag(m_id, MF_NORETURN))
  3858. strcat(atcmd_output, " NoReturn |");
  3859. if (map_getmapflag(m_id, MF_NOGO))
  3860. strcat(atcmd_output, " NoGo |"); //
  3861. if (map_getmapflag(m_id, MF_NOMEMO))
  3862. strcat(atcmd_output, " NoMemo |");
  3863. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_SOURCE))
  3864. strcat(atcmd_output, " PrivateAirship_Source |");
  3865. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_DESTINATION))
  3866. strcat(atcmd_output, " PrivateAirship_Destination |");
  3867. clif_displaymessage(fd, atcmd_output);
  3868. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3869. (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
  3870. clif_displaymessage(fd, atcmd_output);
  3871. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3872. if (!mapdata->save.map)
  3873. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3874. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3875. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3876. clif_displaymessage(fd, atcmd_output);
  3877. }
  3878. else {
  3879. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3880. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3881. clif_displaymessage(fd, atcmd_output);
  3882. }
  3883. }
  3884. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3885. if (map_getmapflag(m_id, MF_SNOW))
  3886. strcat(atcmd_output, " Snow |");
  3887. if (map_getmapflag(m_id, MF_FOG))
  3888. strcat(atcmd_output, " Fog |");
  3889. if (map_getmapflag(m_id, MF_SAKURA))
  3890. strcat(atcmd_output, " Sakura |");
  3891. if (map_getmapflag(m_id, MF_CLOUDS))
  3892. strcat(atcmd_output, " Clouds |");
  3893. if (map_getmapflag(m_id, MF_CLOUDS2))
  3894. strcat(atcmd_output, " Clouds2 |");
  3895. if (map_getmapflag(m_id, MF_FIREWORKS))
  3896. strcat(atcmd_output, " Fireworks |");
  3897. if (map_getmapflag(m_id, MF_LEAVES))
  3898. strcat(atcmd_output, " Leaves |");
  3899. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3900. strcat(atcmd_output, " Displays Night |");
  3901. clif_displaymessage(fd, atcmd_output);
  3902. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3903. if (map_getmapflag(m_id, MF_NOBRANCH))
  3904. strcat(atcmd_output, " NoBranch |");
  3905. if (map_getmapflag(m_id, MF_NOTRADE))
  3906. strcat(atcmd_output, " NoTrade |");
  3907. if (map_getmapflag(m_id, MF_NOVENDING))
  3908. strcat(atcmd_output, " NoVending |");
  3909. if (map_getmapflag(m_id, MF_NOBUYINGSTORE))
  3910. strcat(atcmd_output, " NoBuyingstore |");
  3911. if (map_getmapflag(m_id, MF_NODROP))
  3912. strcat(atcmd_output, " NoDrop |");
  3913. if (map_getmapflag(m_id, MF_NOSKILL))
  3914. strcat(atcmd_output, " NoSkill |");
  3915. if (map_getmapflag(m_id, MF_NOICEWALL))
  3916. strcat(atcmd_output, " NoIcewall |");
  3917. if (map_getmapflag(m_id, MF_ALLOWKS))
  3918. strcat(atcmd_output, " AllowKS |");
  3919. if (map_getmapflag(m_id, MF_RESET))
  3920. strcat(atcmd_output, " Reset |");
  3921. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3922. strcat(atcmd_output, " HideMobHPBar |");
  3923. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3924. strcat(atcmd_output, " NoCommand |");
  3925. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3926. strcat(atcmd_output, " NoBaseEXP |");
  3927. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3928. strcat(atcmd_output, " NoJobEXP |");
  3929. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3930. strcat(atcmd_output, " NoMobLoot |");
  3931. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3932. strcat(atcmd_output, " NoMVPLoot |");
  3933. if (map_getmapflag(m_id, MF_NORENEWALEXPPENALTY))
  3934. strcat(atcmd_output, " NoRenewalExpPenalty |");
  3935. if (map_getmapflag(m_id, MF_NORENEWALDROPPENALTY))
  3936. strcat(atcmd_output, " NoRenewalDropPenalty |");
  3937. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3938. strcat(atcmd_output, " PartyLock |");
  3939. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3940. strcat(atcmd_output, " GuildLock |");
  3941. if (map_getmapflag(m_id, MF_LOADEVENT))
  3942. strcat(atcmd_output, " Loadevent |");
  3943. if (map_getmapflag(m_id, MF_NODYNAMICNPC))
  3944. strcat(atcmd_output, " NoDynamicNPC |");
  3945. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3946. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  3947. if (map_getmapflag(m_id, MF_NOUSECART))
  3948. strcat(atcmd_output, " NoUsecart |");
  3949. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  3950. strcat(atcmd_output, " NoItemConsumption |");
  3951. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  3952. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  3953. if (map_getmapflag(m_id, MF_FORCEMINEFFECT))
  3954. strcat(atcmd_output, " ForceMinEffect |");
  3955. if (map_getmapflag(m_id, MF_NOLOCKON))
  3956. strcat(atcmd_output, " NoLockOn |");
  3957. if (map_getmapflag(m_id, MF_NOTOMB))
  3958. strcat(atcmd_output, " NoTomb |");
  3959. if (map_getmapflag(m_id, MF_NOCOSTUME))
  3960. strcat(atcmd_output, " NoCostume |");
  3961. if (map_getmapflag(m_id, MF_NOBANK))
  3962. strcat(atcmd_output, " NoBank |");
  3963. if (map_getmapflag(m_id, MF_NOCASHSHOP))
  3964. strcat(atcmd_output, " NoCashShop |");
  3965. if (map_getmapflag(m_id, MF_NORODEX))
  3966. strcat(atcmd_output, " NoRODex |");
  3967. if (map_getmapflag(m_id, MF_NOPETCAPTURE))
  3968. strcat(atcmd_output, " NoPetCapture |");
  3969. clif_displaymessage(fd, atcmd_output);
  3970. switch (list) {
  3971. case 0:
  3972. // Do nothing. It's list 0, no additional display.
  3973. break;
  3974. case 1:
  3975. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3976. iter = mapit_getallusers();
  3977. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3978. {
  3979. if (pl_sd->mapindex == m_index) {
  3980. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3981. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3982. clif_displaymessage(fd, atcmd_output);
  3983. }
  3984. }
  3985. mapit_free(iter);
  3986. break;
  3987. case 2:
  3988. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3989. for (i = 0; i < mapdata->npc_num;)
  3990. {
  3991. struct npc_data *nd = mapdata->npc[i];
  3992. switch(nd->ud.dir) {
  3993. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3994. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3995. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3996. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3997. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3998. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3999. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  4000. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  4001. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  4002. }
  4003. if(strcmp(nd->name,nd->exname) == 0)
  4004. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  4005. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4006. else
  4007. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  4008. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  4009. clif_displaymessage(fd, atcmd_output);
  4010. }
  4011. break;
  4012. case 3:
  4013. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  4014. iter = mapit_getallusers();
  4015. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4016. {
  4017. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr &&
  4018. pl_sd->mapindex == m_index &&
  4019. cd->usersd[0] == pl_sd)
  4020. {
  4021. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  4022. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4023. clif_displaymessage(fd, atcmd_output);
  4024. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  4025. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  4026. clif_displaymessage(fd, atcmd_output);
  4027. }
  4028. }
  4029. mapit_free(iter);
  4030. break;
  4031. default: // normally impossible to arrive here
  4032. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  4033. return -1;
  4034. break;
  4035. }
  4036. return 0;
  4037. }
  4038. /*==========================================
  4039. *
  4040. *------------------------------------------*/
  4041. ACMD_FUNC(mount_peco)
  4042. {
  4043. nullpo_retr(-1, sd);
  4044. if (sd->disguise) {
  4045. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  4046. return -1;
  4047. }
  4048. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4049. if( !(sd->sc.option&OPTION_DRAGON) ) {
  4050. uint32 option = OPTION_DRAGON1;
  4051. if( message[0] ) {
  4052. int32 color = atoi(message);
  4053. option = ( color == 2 ? OPTION_DRAGON2 :
  4054. color == 3 ? OPTION_DRAGON3 :
  4055. color == 4 ? OPTION_DRAGON4 :
  4056. color == 5 ? OPTION_DRAGON5 :
  4057. OPTION_DRAGON1 );
  4058. }
  4059. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  4060. pc_setoption(sd, sd->sc.option|option);
  4061. } else {
  4062. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  4063. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  4064. }
  4065. return 0;
  4066. }
  4067. 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)) ) {
  4068. if( !pc_isridingwug(sd) ) {
  4069. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  4070. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  4071. } else {
  4072. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  4073. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  4074. }
  4075. return 0;
  4076. }
  4077. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4078. if( !pc_ismadogear(sd) ) {
  4079. e_mado_type type = MADO_ROBOT;
  4080. if (message[0]) {
  4081. int32 tmp = strtol(message, nullptr, 10);
  4082. switch (tmp) {
  4083. case MADO_ROBOT:
  4084. case MADO_SUIT:
  4085. type = static_cast<e_mado_type>(tmp);
  4086. break;
  4087. default:
  4088. type = MADO_ROBOT;
  4089. break;
  4090. }
  4091. }
  4092. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  4093. pc_setmadogear(sd, true, type);
  4094. } else {
  4095. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  4096. pc_setmadogear(sd, false);
  4097. }
  4098. return 0;
  4099. }
  4100. if (!pc_isriding(sd)) { // if actually no peco
  4101. if (!pc_checkskill(sd, KN_RIDING)) {
  4102. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  4103. return -1;
  4104. }
  4105. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4106. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  4107. } else {//Dismount
  4108. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4109. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  4110. }
  4111. return 0;
  4112. }
  4113. /*==========================================
  4114. *Spy Commands by Syrus22
  4115. *------------------------------------------*/
  4116. ACMD_FUNC(guildspy)
  4117. {
  4118. char guild_name[NAME_LENGTH];
  4119. nullpo_retr(-1, sd);
  4120. memset(guild_name, '\0', sizeof(guild_name));
  4121. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4122. if (!enable_spy)
  4123. {
  4124. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4125. return -1;
  4126. }
  4127. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4128. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  4129. return -1;
  4130. }
  4131. auto g = guild_searchnameid(guild_name);
  4132. if (!g) {
  4133. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  4134. return -1;
  4135. }
  4136. if (sd->guildspy == g->guild.guild_id) {
  4137. sd->guildspy = 0;
  4138. sprintf(atcmd_output, msg_txt(sd,103), g->guild.name); // No longer spying on the %s guild.
  4139. clif_displaymessage(fd, atcmd_output);
  4140. } else {
  4141. sd->guildspy = g->guild.guild_id;
  4142. sprintf(atcmd_output, msg_txt(sd,104), g->guild.name); // Spying on the %s guild.
  4143. clif_displaymessage(fd, atcmd_output);
  4144. }
  4145. return 0;
  4146. }
  4147. /*==========================================
  4148. *
  4149. *------------------------------------------*/
  4150. ACMD_FUNC(partyspy)
  4151. {
  4152. char party_name[NAME_LENGTH];
  4153. struct party_data *p;
  4154. nullpo_retr(-1, sd);
  4155. memset(party_name, '\0', sizeof(party_name));
  4156. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4157. if (!enable_spy)
  4158. {
  4159. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4160. return -1;
  4161. }
  4162. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4163. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  4164. return -1;
  4165. }
  4166. if ((p = party_searchname(party_name)) != nullptr || // name first to avoid error when name begin with a number
  4167. (p = party_search(atoi(message))) != nullptr) {
  4168. if (sd->partyspy == p->party.party_id) {
  4169. sd->partyspy = 0;
  4170. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  4171. clif_displaymessage(fd, atcmd_output);
  4172. } else {
  4173. sd->partyspy = p->party.party_id;
  4174. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  4175. clif_displaymessage(fd, atcmd_output);
  4176. }
  4177. } else {
  4178. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  4179. return -1;
  4180. }
  4181. return 0;
  4182. }
  4183. ACMD_FUNC(clanspy){
  4184. char clan_name[NAME_LENGTH];
  4185. struct clan* c;
  4186. nullpo_retr(-1, sd);
  4187. memset(clan_name, '\0', sizeof(clan_name));
  4188. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4189. if( !enable_spy ){
  4190. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  4191. return -1;
  4192. }
  4193. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  4194. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  4195. return -1;
  4196. }
  4197. if ((c = clan_searchname(clan_name)) != nullptr || // name first to avoid error when name begin with a number
  4198. (c = clan_search(atoi(message))) != nullptr) {
  4199. if (sd->clanspy == c->id) {
  4200. sd->clanspy = 0;
  4201. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  4202. clif_displaymessage(fd, atcmd_output);
  4203. }
  4204. else {
  4205. sd->clanspy = c->id;
  4206. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  4207. clif_displaymessage(fd, atcmd_output);
  4208. }
  4209. }
  4210. else {
  4211. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  4212. return -1;
  4213. }
  4214. return 0;
  4215. }
  4216. /*==========================================
  4217. * @repairall [Valaris]
  4218. *------------------------------------------*/
  4219. ACMD_FUNC(repairall)
  4220. {
  4221. int32 count, i;
  4222. nullpo_retr(-1, sd);
  4223. count = 0;
  4224. for (i = 0; i < MAX_INVENTORY; i++) {
  4225. 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])) {
  4226. sd->inventory.u.items_inventory[i].attribute = 0;
  4227. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  4228. count++;
  4229. }
  4230. }
  4231. if (count > 0) {
  4232. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  4233. clif_equiplist(sd);
  4234. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  4235. } else {
  4236. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  4237. return -1;
  4238. }
  4239. return 0;
  4240. }
  4241. /*==========================================
  4242. * @nuke [Valaris]
  4243. *------------------------------------------*/
  4244. ACMD_FUNC(nuke)
  4245. {
  4246. map_session_data *pl_sd;
  4247. nullpo_retr(-1, sd);
  4248. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4249. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4250. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  4251. return -1;
  4252. }
  4253. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != nullptr) {
  4254. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  4255. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4256. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  4257. } else {
  4258. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4259. return -1;
  4260. }
  4261. } else {
  4262. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4263. return -1;
  4264. }
  4265. return 0;
  4266. }
  4267. /*==========================================
  4268. * @tonpc
  4269. *------------------------------------------*/
  4270. ACMD_FUNC(tonpc)
  4271. {
  4272. char npcname[NPC_NAME_LENGTH];
  4273. struct npc_data *nd;
  4274. nullpo_retr(-1, sd);
  4275. memset(npcname, 0, sizeof(npcname));
  4276. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  4277. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  4278. return -1;
  4279. }
  4280. if ((nd = npc_name2id(npcname)) != nullptr) {
  4281. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  4282. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  4283. else
  4284. return -1;
  4285. } else {
  4286. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4287. return -1;
  4288. }
  4289. return 0;
  4290. }
  4291. /*==========================================
  4292. *
  4293. *------------------------------------------*/
  4294. ACMD_FUNC(shownpc)
  4295. {
  4296. char NPCname[NPC_NAME_LENGTH];
  4297. nullpo_retr(-1, sd);
  4298. memset(NPCname, '\0', sizeof(NPCname));
  4299. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4300. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  4301. return -1;
  4302. }
  4303. npc_data* nd = npc_name2id(NPCname);
  4304. if (nd) {
  4305. npc_enable(*nd, NPCVIEW_ENABLE);
  4306. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4307. } else {
  4308. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4309. return -1;
  4310. }
  4311. return 0;
  4312. }
  4313. /*==========================================
  4314. *
  4315. *------------------------------------------*/
  4316. ACMD_FUNC(hidenpc)
  4317. {
  4318. char NPCname[NPC_NAME_LENGTH];
  4319. nullpo_retr(-1, sd);
  4320. memset(NPCname, '\0', sizeof(NPCname));
  4321. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4322. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4323. return -1;
  4324. }
  4325. npc_data* nd = npc_name2id(NPCname);
  4326. if (!nd) {
  4327. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4328. return -1;
  4329. }
  4330. npc_enable(*nd, NPCVIEW_DISABLE);
  4331. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4332. return 0;
  4333. }
  4334. ACMD_FUNC(loadnpc)
  4335. {
  4336. if (!message || !*message) {
  4337. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4338. return -1;
  4339. }
  4340. if (!npc_addsrcfile(message, true)) {
  4341. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4342. return -1;
  4343. }
  4344. npc_read_event_script();
  4345. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was loaded.\n", message );
  4346. npc_event_doall_path( script_config.init_event_name, message );
  4347. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4348. return 0;
  4349. }
  4350. ACMD_FUNC(unloadnpc)
  4351. {
  4352. struct npc_data *nd;
  4353. char NPCname[NPC_NAME_LENGTH];
  4354. nullpo_retr(-1, sd);
  4355. memset(NPCname, '\0', sizeof(NPCname));
  4356. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4357. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4358. return -1;
  4359. }
  4360. if ((nd = npc_name2id(NPCname)) == nullptr) {
  4361. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4362. return -1;
  4363. }
  4364. npc_unload_duplicates(nd);
  4365. npc_unload(nd,true);
  4366. npc_read_event_script();
  4367. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4368. return 0;
  4369. }
  4370. ACMD_FUNC(reloadnpcfile) {
  4371. if (!message || !*message) {
  4372. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4373. return -1;
  4374. }
  4375. if (npc_unloadfile(message))
  4376. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4377. if (!npc_addsrcfile(message, true)) {
  4378. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4379. return -1;
  4380. }
  4381. npc_read_event_script();
  4382. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was reloaded.\n", message );
  4383. npc_event_doall_path( script_config.init_event_name, message );
  4384. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4385. return 0;
  4386. }
  4387. /*==========================================
  4388. * time in txt for time command (by [Yor])
  4389. *------------------------------------------*/
  4390. char* txt_time(t_tick duration_)
  4391. {
  4392. int32 days, hours, minutes, seconds;
  4393. char temp[CHAT_SIZE_MAX];
  4394. static char temp1[CHAT_SIZE_MAX];
  4395. memset(temp, '\0', sizeof(temp));
  4396. memset(temp1, '\0', sizeof(temp1));
  4397. // Cap it
  4398. int32 duration = (int32)duration_;
  4399. days = duration / (60 * 60 * 24);
  4400. duration = duration - (60 * 60 * 24 * days);
  4401. hours = duration / (60 * 60);
  4402. duration = duration - (60 * 60 * hours);
  4403. minutes = duration / 60;
  4404. seconds = duration - (60 * minutes);
  4405. if (days == 1)
  4406. sprintf(temp, msg_txt(nullptr,219), days); // %d day
  4407. else if (days > 1)
  4408. sprintf(temp, msg_txt(nullptr,220), days); // %d days
  4409. if (hours == 1)
  4410. sprintf(temp1, msg_txt(nullptr,221), temp, hours); // %s %d hour
  4411. else if (hours > 1)
  4412. sprintf(temp1, msg_txt(nullptr,222), temp, hours); // %s %d hours
  4413. if (minutes < 2)
  4414. sprintf(temp, msg_txt(nullptr,223), temp1, minutes); // %s %d minute
  4415. else
  4416. sprintf(temp, msg_txt(nullptr,224), temp1, minutes); // %s %d minutes
  4417. if (seconds == 1)
  4418. sprintf(temp1, msg_txt(nullptr,225), temp, seconds); // %s and %d second
  4419. else if (seconds > 1)
  4420. sprintf(temp1, msg_txt(nullptr,226), temp, seconds); // %s and %d seconds
  4421. return temp1;
  4422. }
  4423. /*==========================================
  4424. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4425. * Calculation management of GM modification (@day/@night GM commands) is done
  4426. *------------------------------------------*/
  4427. ACMD_FUNC(servertime)
  4428. {
  4429. const struct TimerData * timer_data;
  4430. time_t time_server; // variable for number of seconds (used with time() function)
  4431. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4432. char temp[CHAT_SIZE_MAX];
  4433. nullpo_retr(-1, sd);
  4434. memset(temp, '\0', sizeof(temp));
  4435. time(&time_server); // get time in seconds since 1/1/1970
  4436. datetime = localtime(&time_server); // convert seconds in structure
  4437. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4438. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4439. clif_displaymessage(fd, temp);
  4440. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4441. if (night_flag == 0)
  4442. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4443. else
  4444. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4445. } else if (battle_config.night_duration == 0)
  4446. if (night_flag == 1) { // we start with night
  4447. if ((timer_data = get_timer(day_timer_tid)) != nullptr) {
  4448. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4449. clif_displaymessage(fd, temp);
  4450. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4451. } else
  4452. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4453. } else
  4454. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4455. else if (battle_config.day_duration == 0)
  4456. if (night_flag == 0) { // we start with day
  4457. if ((timer_data = get_timer(night_timer_tid)) != nullptr) {
  4458. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4459. clif_displaymessage(fd, temp);
  4460. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4461. } else
  4462. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4463. } else
  4464. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4465. else {
  4466. const struct TimerData * timer_data2;
  4467. if (night_flag == 0) {
  4468. if ((timer_data = get_timer(night_timer_tid)) != nullptr && (timer_data2 = get_timer(day_timer_tid)) != nullptr) {
  4469. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4470. clif_displaymessage(fd, temp);
  4471. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4472. 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.
  4473. else
  4474. 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.
  4475. clif_displaymessage(fd, temp);
  4476. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4477. clif_displaymessage(fd, temp);
  4478. } else
  4479. clif_displaymessage(fd, msg_txt(sd, 231)); // Game time: The game is in permanent daylight.
  4480. } else {
  4481. if ((timer_data = get_timer(day_timer_tid)) != nullptr && (timer_data2 = get_timer(night_timer_tid)) != nullptr) {
  4482. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4483. clif_displaymessage(fd, temp);
  4484. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4485. 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.
  4486. else
  4487. 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.
  4488. clif_displaymessage(fd, temp);
  4489. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4490. clif_displaymessage(fd, temp);
  4491. } else
  4492. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4493. }
  4494. }
  4495. return 0;
  4496. }
  4497. /*==========================================
  4498. * @jail <char_name> by [Yor]
  4499. * Special warp! No check with nowarp and nowarpto flag
  4500. *------------------------------------------*/
  4501. ACMD_FUNC(jail)
  4502. {
  4503. map_session_data *pl_sd;
  4504. nullpo_retr(-1, sd);
  4505. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4506. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4507. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4508. return -1;
  4509. }
  4510. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4511. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4512. return -1;
  4513. }
  4514. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4515. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4516. return -1;
  4517. }
  4518. if (pl_sd->sc.getSCE(SC_JAILED)) {
  4519. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4520. return -1;
  4521. }
  4522. pc_jail(*pl_sd);
  4523. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4524. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4525. return 0;
  4526. }
  4527. /*==========================================
  4528. * @unjail/@discharge <char_name> by [Yor]
  4529. * Special warp! No check with nowarp and nowarpto flag
  4530. *------------------------------------------*/
  4531. ACMD_FUNC(unjail)
  4532. {
  4533. map_session_data *pl_sd;
  4534. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4535. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4536. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4537. return -1;
  4538. }
  4539. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4540. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4541. return -1;
  4542. }
  4543. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4544. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4545. return -1;
  4546. }
  4547. if (!pl_sd->sc.getSCE(SC_JAILED)) {
  4548. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4549. return -1;
  4550. }
  4551. //Reset jail time to 1 sec.
  4552. pc_jail(*pl_sd, 0);
  4553. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4554. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4555. return 0;
  4556. }
  4557. ACMD_FUNC(jailfor) {
  4558. map_session_data* pl_sd = nullptr;;
  4559. char * modif_p;
  4560. int32 jailtime = 0;
  4561. nullpo_retr(-1, sd);
  4562. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4563. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4564. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4565. return -1;
  4566. }
  4567. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4568. modif_p = atcmd_output;
  4569. jailtime = (int32)solve_time(modif_p)/60; // Change to minutes
  4570. if (jailtime == 0) {
  4571. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4572. 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.
  4573. return -1;
  4574. }
  4575. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4576. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4577. return -1;
  4578. }
  4579. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4580. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4581. return -1;
  4582. }
  4583. // Added by Coltaro
  4584. if(pl_sd->sc.getSCE(SC_JAILED) && pl_sd->sc.getSCE(SC_JAILED)->val1 != INT_MAX) { // Update the player's jail time
  4585. jailtime += pl_sd->sc.getSCE(SC_JAILED)->val1;
  4586. if (jailtime <= 0) {
  4587. jailtime = 0;
  4588. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4589. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4590. } else {
  4591. int32 year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4592. char timestr[21];
  4593. time_t now=time(nullptr);
  4594. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4595. 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
  4596. clif_displaymessage(pl_sd->fd, atcmd_output);
  4597. 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
  4598. clif_displaymessage(fd, atcmd_output);
  4599. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4600. sprintf(atcmd_output,"Release date is: %s",timestr);
  4601. clif_displaymessage(pl_sd->fd, atcmd_output);
  4602. clif_displaymessage(fd, atcmd_output);
  4603. }
  4604. } else if (jailtime < 0) {
  4605. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4606. return -1;
  4607. }
  4608. pc_jail(*pl_sd, jailtime);
  4609. return 0;
  4610. }
  4611. //By Coltaro
  4612. ACMD_FUNC(jailtime){
  4613. int32 year, month, day, hour, minute, second;
  4614. char timestr[21];
  4615. time_t now = time(nullptr);
  4616. nullpo_retr(-1, sd);
  4617. if (!sd->sc.getSCE(SC_JAILED)) {
  4618. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4619. return -1;
  4620. }
  4621. if (sd->sc.getSCE(SC_JAILED)->val1 == INT_MAX) {
  4622. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4623. return 0;
  4624. }
  4625. if (sd->sc.getSCE(SC_JAILED)->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4626. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4627. return -1;
  4628. }
  4629. // Get remaining jail time
  4630. split_time(sd->sc.getSCE(SC_JAILED)->val1*60,&year,&month,&day,&hour,&minute,&second);
  4631. 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
  4632. clif_displaymessage(fd, atcmd_output);
  4633. timestamp2string(timestr,20,now+sd->sc.getSCE(SC_JAILED)->val1*60,"%Y-%m-%d %H:%M");
  4634. sprintf(atcmd_output,"Release date is: %s",timestr);
  4635. clif_displaymessage(fd, atcmd_output);
  4636. return 0;
  4637. }
  4638. /*==========================================
  4639. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4640. *------------------------------------------*/
  4641. ACMD_FUNC(disguise)
  4642. {
  4643. int32 id = 0;
  4644. nullpo_retr(-1, sd);
  4645. if (!message || !*message) {
  4646. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4647. return -1;
  4648. }
  4649. if ((id = atoi(message)) > 0)
  4650. { //Acquired an ID
  4651. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4652. id = 0; //Invalid id for either mobs or npcs.
  4653. } else { //Acquired a Name
  4654. if ((id = mobdb_searchname(message)) == 0)
  4655. {
  4656. struct npc_data* nd = npc_name2id(message);
  4657. if (nd != nullptr)
  4658. id = nd->class_;
  4659. }
  4660. }
  4661. if (id == 0)
  4662. {
  4663. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4664. return -1;
  4665. }
  4666. if(pc_isriding(sd))
  4667. {
  4668. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4669. return -1;
  4670. }
  4671. if (sd->sc.getSCE(SC_MONSTER_TRANSFORM) || sd->sc.getSCE(SC_ACTIVE_MONSTER_TRANSFORM)) {
  4672. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4673. return -1;
  4674. }
  4675. pc_disguise(sd, id);
  4676. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4677. return 0;
  4678. }
  4679. /*==========================================
  4680. * DisguiseAll
  4681. *------------------------------------------*/
  4682. ACMD_FUNC(disguiseall)
  4683. {
  4684. int32 mob_id=0;
  4685. map_session_data *pl_sd;
  4686. struct s_mapiterator* iter;
  4687. nullpo_retr(-1, sd);
  4688. if (!message || !*message) {
  4689. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4690. return -1;
  4691. }
  4692. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4693. mob_id = atoi(message);
  4694. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4695. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4696. return -1;
  4697. }
  4698. iter = mapit_getallusers();
  4699. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4700. pc_disguise(pl_sd, mob_id);
  4701. mapit_free(iter);
  4702. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4703. return 0;
  4704. }
  4705. /*==========================================
  4706. * DisguiseGuild
  4707. *------------------------------------------*/
  4708. ACMD_FUNC(disguiseguild)
  4709. {
  4710. int32 id = 0, i;
  4711. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4712. memset(monster, '\0', sizeof(monster));
  4713. memset(guild, '\0', sizeof(guild));
  4714. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4715. 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>).
  4716. return -1;
  4717. }
  4718. if( (id = atoi(monster)) > 0 ) {
  4719. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4720. id = 0;
  4721. } else {
  4722. if( (id = mobdb_searchname(monster)) == 0 ) {
  4723. struct npc_data* nd = npc_name2id(monster);
  4724. if( nd != nullptr )
  4725. id = nd->class_;
  4726. }
  4727. }
  4728. if( id == 0 ) {
  4729. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4730. return -1;
  4731. }
  4732. auto g = guild_searchnameid(guild);
  4733. if (!g) {
  4734. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4735. return -1;
  4736. }
  4737. for( i = 0; i < g->guild.max_member; i++ ){
  4738. map_session_data *pl_sd;
  4739. if( (pl_sd = g->guild.member[i].sd) && !pc_isriding(pl_sd) )
  4740. pc_disguise(pl_sd, id);
  4741. }
  4742. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4743. return 0;
  4744. }
  4745. /*==========================================
  4746. * @undisguise by [Yor]
  4747. *------------------------------------------*/
  4748. ACMD_FUNC(undisguise)
  4749. {
  4750. nullpo_retr(-1, sd);
  4751. if (sd->disguise) {
  4752. pc_disguise(sd, 0);
  4753. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4754. } else {
  4755. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4756. return -1;
  4757. }
  4758. return 0;
  4759. }
  4760. /*==========================================
  4761. * UndisguiseAll
  4762. *------------------------------------------*/
  4763. ACMD_FUNC(undisguiseall)
  4764. {
  4765. map_session_data *pl_sd;
  4766. struct s_mapiterator* iter;
  4767. nullpo_retr(-1, sd);
  4768. iter = mapit_getallusers();
  4769. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4770. if( pl_sd->disguise )
  4771. pc_disguise(pl_sd, 0);
  4772. mapit_free(iter);
  4773. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4774. return 0;
  4775. }
  4776. /*==========================================
  4777. * UndisguiseGuild
  4778. *------------------------------------------*/
  4779. ACMD_FUNC(undisguiseguild)
  4780. {
  4781. char guild_name[NAME_LENGTH];
  4782. int32 i;
  4783. nullpo_retr(-1, sd);
  4784. memset(guild_name, '\0', sizeof(guild_name));
  4785. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4786. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4787. return -1;
  4788. }
  4789. auto g = guild_searchnameid(guild_name);
  4790. if (!g) {
  4791. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4792. return -1;
  4793. }
  4794. for(i = 0; i < g->guild.max_member; i++){
  4795. map_session_data *pl_sd;
  4796. if( (pl_sd = g->guild.member[i].sd) && pl_sd->disguise )
  4797. pc_disguise(pl_sd, 0);
  4798. }
  4799. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4800. return 0;
  4801. }
  4802. /*==========================================
  4803. * @exp by [Skotlex]
  4804. *------------------------------------------*/
  4805. ACMD_FUNC(exp)
  4806. {
  4807. char output[CHAT_SIZE_MAX];
  4808. double nextb, nextj;
  4809. nullpo_retr(-1, sd);
  4810. memset(output, '\0', sizeof(output));
  4811. nextb = (double)pc_nextbaseexp(sd);
  4812. if (nextb)
  4813. nextb = sd->status.base_exp*100.0/nextb;
  4814. nextj = (double)pc_nextjobexp(sd);
  4815. if (nextj)
  4816. nextj = sd->status.job_exp*100.0/nextj;
  4817. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4818. clif_displaymessage(fd, output);
  4819. return 0;
  4820. }
  4821. /*==========================================
  4822. * @broadcast by [Valaris]
  4823. *------------------------------------------*/
  4824. ACMD_FUNC(broadcast)
  4825. {
  4826. nullpo_retr(-1, sd);
  4827. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4828. if (!message || !*message) {
  4829. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4830. return -1;
  4831. }
  4832. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4833. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4834. return 0;
  4835. }
  4836. /*==========================================
  4837. * @localbroadcast by [Valaris]
  4838. *------------------------------------------*/
  4839. ACMD_FUNC(localbroadcast)
  4840. {
  4841. nullpo_retr(-1, sd);
  4842. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4843. if (!message || !*message) {
  4844. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4845. return -1;
  4846. }
  4847. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4848. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4849. return 0;
  4850. }
  4851. /*==========================================
  4852. * @email <actual@email> <new@email> by [Yor]
  4853. *------------------------------------------*/
  4854. ACMD_FUNC(email)
  4855. {
  4856. char actual_email[100];
  4857. char new_email[100];
  4858. nullpo_retr(-1, sd);
  4859. memset(actual_email, '\0', sizeof(actual_email));
  4860. memset(new_email, '\0', sizeof(new_email));
  4861. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4862. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4863. return -1;
  4864. }
  4865. if (e_mail_check(actual_email) == 0) {
  4866. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4867. return -1;
  4868. } else if (e_mail_check(new_email) == 0) {
  4869. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4870. return -1;
  4871. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4872. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4873. return -1;
  4874. } else if (strcmpi(actual_email, new_email) == 0) {
  4875. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4876. return -1;
  4877. }
  4878. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4879. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4880. return 0;
  4881. }
  4882. /*==========================================
  4883. *@effect
  4884. *------------------------------------------*/
  4885. ACMD_FUNC(effect)
  4886. {
  4887. int32 type = EF_NONE;
  4888. nullpo_retr(-1, sd);
  4889. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4890. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4891. return -1;
  4892. }
  4893. if( type <= EF_NONE || type >= EF_MAX ){
  4894. 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.
  4895. clif_displaymessage(fd, atcmd_output);
  4896. return -1;
  4897. }
  4898. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4899. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4900. return 0;
  4901. }
  4902. /*==========================================
  4903. * @killer by MouseJstr
  4904. * enable killing players even when not in pvp
  4905. *------------------------------------------*/
  4906. ACMD_FUNC(killer)
  4907. {
  4908. nullpo_retr(-1, sd);
  4909. sd->state.killer = !sd->state.killer;
  4910. if(sd->state.killer)
  4911. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4912. else {
  4913. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4914. pc_stop_attack(sd);
  4915. }
  4916. return 0;
  4917. }
  4918. /*==========================================
  4919. * @killable by MouseJstr
  4920. * enable other people killing you
  4921. *------------------------------------------*/
  4922. ACMD_FUNC(killable)
  4923. {
  4924. nullpo_retr(-1, sd);
  4925. sd->state.killable = !sd->state.killable;
  4926. if(sd->state.killable)
  4927. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4928. else {
  4929. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4930. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4931. }
  4932. return 0;
  4933. }
  4934. /*==========================================
  4935. * @skillon by MouseJstr
  4936. * turn skills on for the map
  4937. *------------------------------------------*/
  4938. ACMD_FUNC(skillon)
  4939. {
  4940. nullpo_retr(-1, sd);
  4941. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4942. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4943. return 0;
  4944. }
  4945. /*==========================================
  4946. * @skilloff by MouseJstr
  4947. * Turn skills off on the map
  4948. *------------------------------------------*/
  4949. ACMD_FUNC(skilloff)
  4950. {
  4951. nullpo_retr(-1, sd);
  4952. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  4953. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4954. return 0;
  4955. }
  4956. /*==========================================
  4957. * @npcmove by MouseJstr
  4958. * move a npc
  4959. *------------------------------------------*/
  4960. ACMD_FUNC(npcmove)
  4961. {
  4962. short x = 0, y = 0;
  4963. struct npc_data *nd = 0;
  4964. char npc_name[NPC_NAME_LENGTH];
  4965. nullpo_retr(-1, sd);
  4966. memset(npc_name, '\0', sizeof npc_name);
  4967. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4968. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4969. return -1;
  4970. }
  4971. if ((nd = npc_name2id(npc_name)) == nullptr)
  4972. {
  4973. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4974. return -1;
  4975. }
  4976. if ( npc_movenpc( nd, x, y ) )
  4977. { //actually failed to move
  4978. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4979. return -1; //Not on a map.
  4980. } else
  4981. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4982. return 0;
  4983. }
  4984. /*==========================================
  4985. * @addwarp by MouseJstr
  4986. * Create a new static warp point.
  4987. *------------------------------------------*/
  4988. ACMD_FUNC(addwarp)
  4989. {
  4990. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4991. short x,y;
  4992. unsigned short m;
  4993. struct npc_data* nd;
  4994. nullpo_retr(-1, sd);
  4995. memset(warpname, '\0', sizeof(warpname));
  4996. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4997. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4998. return -1;
  4999. }
  5000. m = mapindex_name2id(mapname);
  5001. if( m == 0 )
  5002. {
  5003. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  5004. clif_displaymessage(fd, atcmd_output);
  5005. return -1;
  5006. }
  5007. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  5008. if( nd == nullptr )
  5009. return -1;
  5010. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  5011. clif_displaymessage(fd, atcmd_output);
  5012. return 0;
  5013. }
  5014. /*==========================================
  5015. * @follow by [MouseJstr]
  5016. * Follow a player .. staying no more then 5 spaces away
  5017. *------------------------------------------*/
  5018. ACMD_FUNC(follow)
  5019. {
  5020. map_session_data* pl_sd = nullptr;;
  5021. nullpo_retr(-1, sd);
  5022. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5023. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5024. if (sd->followtarget == -1)
  5025. return -1;
  5026. pc_stop_following (sd);
  5027. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5028. return 0;
  5029. }
  5030. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5031. {
  5032. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5033. return -1;
  5034. }
  5035. if (sd->followtarget == pl_sd->bl.id) {
  5036. pc_stop_following (sd);
  5037. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5038. } else {
  5039. pc_follow(sd, pl_sd->bl.id);
  5040. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  5041. }
  5042. return 0;
  5043. }
  5044. /*==========================================
  5045. * @dropall by [MouseJstr] and [Xantara]
  5046. * Drops all your possession on the ground based on item type
  5047. *------------------------------------------*/
  5048. ACMD_FUNC(dropall)
  5049. {
  5050. int8 type = -1;
  5051. uint16 i, count = 0, count2 = 0;
  5052. nullpo_retr(-1, sd);
  5053. if( message[0] ) {
  5054. type = atoi(message);
  5055. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  5056. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  5057. {
  5058. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  5059. 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
  5060. return -1;
  5061. }
  5062. }
  5063. for( i = 0; i < MAX_INVENTORY; i++ ) {
  5064. if( sd->inventory.u.items_inventory[i].amount ) {
  5065. std::shared_ptr<item_data> id = item_db.find(sd->inventory.u.items_inventory[i].nameid);
  5066. if( id == nullptr ) {
  5067. 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);
  5068. continue;
  5069. }
  5070. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  5071. continue;
  5072. if( type == -1 || type == (uint8)id->type ) {
  5073. if( sd->inventory.u.items_inventory[i].equip != 0 )
  5074. pc_unequipitem(sd, i, 3);
  5075. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5076. pet_return_egg( sd, sd->pd );
  5077. }
  5078. pc_equipswitch_remove(sd, i);
  5079. int32 amount = sd->inventory.u.items_inventory[i].amount;
  5080. if(pc_dropitem(sd, i, amount))
  5081. count += amount;
  5082. else count2 += amount;
  5083. }
  5084. }
  5085. }
  5086. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  5087. clif_displaymessage(fd, atcmd_output);
  5088. return 0;
  5089. }
  5090. /*==========================================
  5091. * @stockall by [Hanashi]
  5092. * transfer items from cart to inventory
  5093. *------------------------------------------*/
  5094. ACMD_FUNC(stockall)
  5095. {
  5096. nullpo_retr(-1, sd);
  5097. if (!pc_iscarton(sd)) {
  5098. clif_displaymessage(fd, msg_txt(sd,1533)); // You do not have a cart.
  5099. return -1;
  5100. }
  5101. int8 type = -1;
  5102. if ( message[0] ) {
  5103. type = atoi(message);
  5104. switch (type) {
  5105. case -1:
  5106. case IT_HEALING:
  5107. case IT_USABLE:
  5108. case IT_ETC:
  5109. case IT_WEAPON:
  5110. case IT_ARMOR:
  5111. case IT_CARD:
  5112. case IT_PETEGG:
  5113. case IT_PETARMOR:
  5114. case IT_AMMO:
  5115. break;
  5116. default:
  5117. clif_displaymessage(fd, msg_txt(sd, 1534)); // Usage: @stockall {<type>}
  5118. 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
  5119. return -1;
  5120. }
  5121. }
  5122. int32 count = 0, count2 = 0;
  5123. for ( uint16 i = 0; i < MAX_CART; i++ ) {
  5124. if ( sd->cart.u.items_cart[i].amount > 0 ) {
  5125. std::shared_ptr<item_data> id = item_db.find(sd->cart.u.items_cart[i].nameid);
  5126. if ( id == nullptr ) {
  5127. 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);
  5128. continue;
  5129. }
  5130. if ( type == -1 || static_cast<item_types>(type) == id->type ) {
  5131. int32 amount = sd->cart.u.items_cart[i].amount;
  5132. if( pc_getitemfromcart( sd, i, amount ) ){
  5133. count += amount;
  5134. }else{
  5135. count2 += amount;
  5136. }
  5137. }
  5138. }
  5139. }
  5140. sprintf(atcmd_output, msg_txt(sd,1535), count,count2); // %d items are transferred (%d skipped)!
  5141. clif_displaymessage(fd, atcmd_output);
  5142. return 0;
  5143. }
  5144. /*==========================================
  5145. * @storeall by [MouseJstr]
  5146. * Put everything into storage
  5147. *------------------------------------------*/
  5148. ACMD_FUNC(storeall)
  5149. {
  5150. int32 i;
  5151. nullpo_retr(-1, sd);
  5152. if (sd->state.storage_flag != 1)
  5153. { //Open storage.
  5154. if( storage_storageopen(sd) == 1 ) {
  5155. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  5156. return -1;
  5157. }
  5158. }
  5159. for (i = 0; i < MAX_INVENTORY; i++) {
  5160. if (sd->inventory.u.items_inventory[i].amount) {
  5161. if(sd->inventory.u.items_inventory[i].equip != 0)
  5162. pc_unequipitem(sd, i, 3);
  5163. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5164. pet_return_egg( sd, sd->pd );
  5165. }
  5166. pc_equipswitch_remove(sd, i);
  5167. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  5168. }
  5169. }
  5170. storage_storageclose(sd);
  5171. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  5172. return 0;
  5173. }
  5174. ACMD_FUNC(clearstorage)
  5175. {
  5176. int32 i, j;
  5177. nullpo_retr(-1, sd);
  5178. if (sd->state.storage_flag == 1) {
  5179. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5180. return -1;
  5181. }
  5182. if (sd->state.storage_flag == 3) {
  5183. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5184. return -1;
  5185. }
  5186. j = sd->storage.amount;
  5187. for (i = 0; i < j; ++i) {
  5188. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  5189. }
  5190. sd->state.storage_flag = 1;
  5191. storage_storageclose(sd);
  5192. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  5193. return 0;
  5194. }
  5195. ACMD_FUNC(cleargstorage)
  5196. {
  5197. int32 i, j;
  5198. struct s_storage *gstorage;
  5199. nullpo_retr(-1, sd);
  5200. if (!sd->guild) {
  5201. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  5202. return -1;
  5203. }
  5204. if (sd->state.storage_flag == 1) {
  5205. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5206. return -1;
  5207. }
  5208. if (sd->state.storage_flag == 2) {
  5209. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  5210. return -1;
  5211. }
  5212. if (sd->state.storage_flag == 3) {
  5213. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5214. return -1;
  5215. }
  5216. gstorage = guild2storage2(sd->status.guild_id);
  5217. if (gstorage == nullptr) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  5218. return -1;
  5219. }
  5220. j = gstorage->amount;
  5221. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  5222. for (i = 0; i < j; ++i) {
  5223. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  5224. }
  5225. storage_guild_storageclose(sd);
  5226. gstorage->lock = false; // Cleaning done, release lock
  5227. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  5228. return 0;
  5229. }
  5230. ACMD_FUNC(clearcart)
  5231. {
  5232. int32 i;
  5233. nullpo_retr(-1, sd);
  5234. if (pc_iscarton(sd) == 0) {
  5235. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  5236. return -1;
  5237. }
  5238. if (sd->state.vending == 1) { //Somehow...
  5239. return -1;
  5240. }
  5241. for (i = 0; i < MAX_CART; i++) {
  5242. if (sd->cart.u.items_cart[i].nameid > 0)
  5243. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  5244. }
  5245. clif_clearcart(fd);
  5246. clif_updatestatus(*sd,SP_CARTINFO);
  5247. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  5248. return 0;
  5249. }
  5250. /*==========================================
  5251. * @skillid by [MouseJstr]
  5252. * lookup a skill by name
  5253. *------------------------------------------*/
  5254. #define MAX_SKILLID_PARTIAL_RESULTS 5
  5255. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  5256. ACMD_FUNC(skillid) {
  5257. int32 i, found = 0;
  5258. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  5259. nullpo_retr(-1, sd);
  5260. if (!message || !*message) {
  5261. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  5262. return -1;
  5263. }
  5264. size_t skillen = strlen( message );
  5265. for(const auto & skill : skill_db) {
  5266. uint16 skill_id = skill.second->nameid;
  5267. uint16 idx = skill_get_index(skill_id);
  5268. const char *name = skill.second->name;
  5269. const char *desc = skill.second->desc;
  5270. if (strnicmp(name, message, skillen) == 0 || strnicmp(desc, message, skillen) == 0) {
  5271. sprintf(atcmd_output, msg_txt(sd,1164), skill_id, desc, name); // skill %d: %s (%s)
  5272. clif_displaymessage(fd, atcmd_output);
  5273. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(name,message) || stristr(desc,message) ) ) {
  5274. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), skill_id, desc, name); // // skill %d: %s (%s)
  5275. }
  5276. }
  5277. if( found ) {
  5278. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  5279. clif_displaymessage(fd, atcmd_output);
  5280. }
  5281. for(i = 0; i < found; i++) { /* partials */
  5282. clif_displaymessage(fd, partials[i]);
  5283. }
  5284. return 0;
  5285. }
  5286. /*==========================================
  5287. * @useskill by [MouseJstr]
  5288. * A way of using skills without having to find them in the skills menu
  5289. *------------------------------------------*/
  5290. ACMD_FUNC(useskill)
  5291. {
  5292. map_session_data* pl_sd = nullptr;;
  5293. struct block_list *bl;
  5294. uint16 skill_id;
  5295. uint16 skill_lv;
  5296. nullpo_retr(-1, sd);
  5297. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5298. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  5299. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  5300. return -1;
  5301. }
  5302. if (!skill_id || !skill_db.find(skill_id)) {
  5303. clif_displaymessage(fd, msg_txt(sd, 198)); // This skill number doesn't exist.
  5304. return -1;
  5305. }
  5306. if (!skill_lv)
  5307. skill_lv = 1;
  5308. if(!strcmp(atcmd_player_name,"self"))
  5309. pl_sd = sd; //quick keyword
  5310. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr ){
  5311. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5312. return -1;
  5313. }
  5314. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5315. {
  5316. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5317. return -1;
  5318. }
  5319. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5320. bl = &sd->hd->bl;
  5321. else
  5322. bl = &sd->bl;
  5323. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  5324. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  5325. else
  5326. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  5327. return 0;
  5328. }
  5329. /*==========================================
  5330. * @displayskill by [Skotlex]
  5331. * Debug command to locate new skill IDs. It sends the
  5332. * three possible skill-effect packets to the area.
  5333. *------------------------------------------*/
  5334. ACMD_FUNC(displayskill)
  5335. {
  5336. t_tick tick;
  5337. uint16 skill_id;
  5338. uint16 skill_lv = 1;
  5339. uint16 type = 0;
  5340. nullpo_retr(-1, sd);
  5341. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &skill_id, &skill_lv, &type) < 1)
  5342. {
  5343. clif_displaymessage(fd, msg_txt(sd,1166));// Usage: @displayskill <skill ID> {<skill level> <type>}
  5344. clif_displaymessage(fd, msg_txt(sd,825));// Effect Types: 0: All, 1: Damage, 2: Splash Dmg, 3: No Damage, 4: Ground
  5345. return -1;
  5346. }
  5347. status_data* status = status_get_status_data(sd->bl);
  5348. tick = gettick();
  5349. if (type == 0 || type == 1)
  5350. clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SINGLE);
  5351. if (type == 0 || type == 2)
  5352. clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  5353. if (type == 0 || type == 3)
  5354. clif_skill_nodamage(&sd->bl, sd->bl, skill_id, skill_lv);
  5355. if (type == 0 || type == 4)
  5356. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  5357. return 0;
  5358. }
  5359. /*==========================================
  5360. * @displayskillcast by [Rytech]
  5361. * Debug command to view casting animations for skills.
  5362. * Can target self or the ground. Ground target can be
  5363. * useful for seeing casting circle size.
  5364. *------------------------------------------*/
  5365. ACMD_FUNC(displayskillcast)
  5366. {
  5367. uint16 skill_id;
  5368. uint16 skill_lv = 1;
  5369. uint16 cast_time = 5000;
  5370. uint16 target_type = 0;
  5371. nullpo_retr(-1, sd);
  5372. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu %6hu", &skill_id, &skill_lv, &target_type, &cast_time) < 1)
  5373. {
  5374. clif_displaymessage(fd, msg_txt(sd, 824));// Usage: @displayskillcast <skill ID> {<skill level> <ground target flag> <cast time>}
  5375. return -1;
  5376. }
  5377. if ( target_type == 1)
  5378. clif_skillcasting(&sd->bl, sd->bl.id, 0, sd->bl.x, sd->bl.y, skill_id, skill_lv, 0, cast_time);
  5379. else
  5380. clif_skillcasting(&sd->bl, sd->bl.id, sd->bl.id, 0, 0, skill_id, skill_lv, 0, cast_time);
  5381. return 0;
  5382. }
  5383. /*==========================================
  5384. * @displayskillunit by [Rytech]
  5385. * Debug command to view unit animations for skills.
  5386. *------------------------------------------*/
  5387. ACMD_FUNC(displayskillunit)
  5388. {
  5389. uint16 unit_id;
  5390. uint16 range = 0;
  5391. uint16 skill_lv = 1;
  5392. nullpo_retr(-1, sd);
  5393. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &unit_id, &skill_lv, &range) < 1)
  5394. {
  5395. clif_displaymessage(fd, msg_txt(sd, 826));// Usage: @displayskillunit <unit ID> {<skill level> <range>}
  5396. return -1;
  5397. }
  5398. clif_skill_unit_test(&sd->bl, sd->bl.x, sd->bl.y, unit_id, range, skill_lv);
  5399. return 0;
  5400. }
  5401. /*==========================================
  5402. * @skilltree by [MouseJstr]
  5403. * prints the skill tree for a player required to get to a skill
  5404. *------------------------------------------*/
  5405. ACMD_FUNC(skilltree)
  5406. {
  5407. map_session_data* pl_sd = nullptr;;
  5408. uint16 skill_id;
  5409. nullpo_retr(-1, sd);
  5410. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5411. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  5412. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  5413. return -1;
  5414. }
  5415. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5416. {
  5417. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5418. return -1;
  5419. }
  5420. int32 c = pc_mapid2jobid( pc_calc_skilltree_normalize_job( pl_sd ), pl_sd->status.sex );
  5421. 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).
  5422. clif_displaymessage(fd, atcmd_output);
  5423. auto entry = skill_tree_db.get_skill_data(c, skill_id);
  5424. if (entry == nullptr) {
  5425. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5426. return 0;
  5427. }
  5428. bool meets = true;
  5429. for (const auto &it : entry->need) {
  5430. if (pc_checkskill(sd, it.first) < it.second) {
  5431. sprintf(atcmd_output, msg_txt(sd,1170), it.second, skill_get_desc(it.first)); // Player requires level %d of skill %s.
  5432. clif_displaymessage(fd, atcmd_output);
  5433. meets = false;
  5434. }
  5435. }
  5436. if (meets) {
  5437. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5438. }
  5439. return 0;
  5440. }
  5441. // Hand a ring with partners name on it to this char
  5442. void getring (map_session_data* sd)
  5443. {
  5444. char flag = 0;
  5445. t_itemid item_id;
  5446. struct item item_tmp;
  5447. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5448. memset(&item_tmp, 0, sizeof(item_tmp));
  5449. item_tmp.nameid = item_id;
  5450. item_tmp.identify = 1;
  5451. item_tmp.card[0] = CARD0_FORGE;
  5452. item_tmp.card[2] = GetWord(sd->status.partner_id,0);
  5453. item_tmp.card[3] = GetWord(sd->status.partner_id,1);
  5454. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5455. clif_additem(sd,0,0,flag);
  5456. }
  5457. }
  5458. /*==========================================
  5459. * @marry by [MouseJstr], fixed by Lupus
  5460. * Marry two players
  5461. *------------------------------------------*/
  5462. ACMD_FUNC(marry)
  5463. {
  5464. map_session_data* pl_sd = nullptr;;
  5465. nullpo_retr(-1, sd);
  5466. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5467. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5468. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5469. return -1;
  5470. }
  5471. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  5472. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5473. return -1;
  5474. }
  5475. if (!pc_inventoryblank(sd)) {
  5476. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5477. return -1;
  5478. }
  5479. if (!pc_inventoryblank(pl_sd)) {
  5480. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5481. return -1;
  5482. }
  5483. uint32 w = 0;
  5484. if (w = itemdb_weight((sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + sd->weight > sd->max_weight) {
  5485. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5486. return -1;
  5487. }
  5488. if (w = itemdb_weight((pl_sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + pl_sd->weight > pl_sd->max_weight) {
  5489. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5490. return -1;
  5491. }
  5492. if (pc_marriage(sd, pl_sd)) {
  5493. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5494. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5495. if( pl_sd->bl.m != sd->bl.m )
  5496. clif_wedding_effect(&sd->bl);
  5497. getring(sd); // Auto-give named rings (Aru)
  5498. getring(pl_sd);
  5499. return 0;
  5500. }
  5501. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5502. return -1;
  5503. }
  5504. /*==========================================
  5505. * @divorce by [MouseJstr], fixed by [Lupus]
  5506. * divorce two players
  5507. *------------------------------------------*/
  5508. ACMD_FUNC(divorce)
  5509. {
  5510. nullpo_retr(-1, sd);
  5511. if (!pc_divorce(sd)) {
  5512. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5513. clif_displaymessage(fd, atcmd_output);
  5514. return -1;
  5515. }
  5516. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5517. clif_displaymessage(fd, atcmd_output);
  5518. return 0;
  5519. }
  5520. /*==========================================
  5521. * @changelook by [Celest]
  5522. *------------------------------------------*/
  5523. ACMD_FUNC(changelook)
  5524. {
  5525. int32 i, j = 0, k = 0;
  5526. int32 pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5527. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5528. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5529. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5530. return -1;
  5531. } else if ( i == 2 ) {
  5532. if (j < 1 || j > 8)
  5533. j = 1;
  5534. j = pos[j - 1];
  5535. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5536. k = j; // swap
  5537. j = LOOK_HEAD_TOP;
  5538. }
  5539. clif_changelook(&sd->bl,j,k);
  5540. return 0;
  5541. }
  5542. /*==========================================
  5543. * @autotrade by durf [Lupus] [Paradox924X]
  5544. * Turns on/off Autotrade for a specific player
  5545. *------------------------------------------*/
  5546. ACMD_FUNC(autotrade) {
  5547. nullpo_retr(-1, sd);
  5548. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5549. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5550. return -1;
  5551. }
  5552. if( pc_isdead(sd) ) {
  5553. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5554. return -1;
  5555. }
  5556. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5557. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5558. return -1;
  5559. }
  5560. sd->state.autotrade = 1;
  5561. if (battle_config.autotrade_monsterignore)
  5562. sd->state.block_action |= PCBLOCK_IMMUNE;
  5563. if( sd->state.vending ){
  5564. vending_update(*sd);
  5565. }else if( sd->state.buyingstore ){
  5566. buyingstore_update(*sd);
  5567. }
  5568. if( battle_config.at_timeout ) {
  5569. int32 timeout = atoi(message);
  5570. 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);
  5571. }
  5572. if (battle_config.at_logout_event)
  5573. npc_script_event( *sd, NPCE_LOGOUT );
  5574. channel_pcquit(sd,0xF); //leave all chan
  5575. clif_authfail_fd(sd->fd, 15);
  5576. chrif_save(sd, CSAVE_AUTOTRADE);
  5577. return 0;
  5578. }
  5579. /*==========================================
  5580. * @changegm by durf (changed by Lupus)
  5581. * Changes Master of your Guild to a specified guild member
  5582. *------------------------------------------*/
  5583. ACMD_FUNC(changegm)
  5584. {
  5585. map_session_data *pl_sd;
  5586. nullpo_retr(-1, sd);
  5587. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5588. if (sd->status.guild_id == 0 || sd->guild == nullptr || strcmp(sd->guild->guild.master,sd->status.name)) {
  5589. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5590. return -1;
  5591. }
  5592. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5593. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5594. return -1;
  5595. }
  5596. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5597. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5598. return -1;
  5599. }
  5600. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr || pl_sd->status.guild_id != sd->status.guild_id) {
  5601. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5602. return -1;
  5603. }
  5604. if( !battle_config.guild_leaderchange_woe && is_agit_start() ){
  5605. #if PACKETVER >= 20151001
  5606. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_IN_SIEGE_TIME);
  5607. #else
  5608. clif_displaymessage(fd, msg_txt(sd,1513)); // Currently in WoE hours, unable to delegate Guild leader
  5609. #endif
  5610. return -1;
  5611. }
  5612. if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(nullptr),sd->guild->guild.last_leader_change) < battle_config.guild_leaderchange_delay ){
  5613. #if PACKETVER >= 20151001
  5614. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_NOT_TIME);
  5615. #else
  5616. clif_displaymessage(fd, msg_txt(sd,1514)); // You have to wait for a while before delegating a new Guild leader
  5617. #endif
  5618. return -1;
  5619. }
  5620. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5621. return 0;
  5622. }
  5623. /*==========================================
  5624. * @changeleader by Skotlex
  5625. * Changes the leader of a party.
  5626. *------------------------------------------*/
  5627. ACMD_FUNC(changeleader)
  5628. {
  5629. nullpo_retr(-1, sd);
  5630. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5631. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5632. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5633. return -1;
  5634. }
  5635. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),nullptr);
  5636. return 0;
  5637. }
  5638. /*==========================================
  5639. * @partyoption by Skotlex
  5640. * Used to change the item share setting of a party.
  5641. *------------------------------------------*/
  5642. ACMD_FUNC(partyoption)
  5643. {
  5644. struct party_data *p;
  5645. int32 mi, option;
  5646. char w1[16], w2[16];
  5647. nullpo_retr(-1, sd);
  5648. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == nullptr)
  5649. {
  5650. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5651. return -1;
  5652. }
  5653. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5654. if (mi == MAX_PARTY)
  5655. return -1; //Shouldn't happen
  5656. if (!p->party.member[mi].leader)
  5657. {
  5658. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5659. return -1;
  5660. }
  5661. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5662. {
  5663. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5664. return -1;
  5665. }
  5666. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5667. //Change item share type.
  5668. if (option != p->party.item)
  5669. party_changeoption(sd, p->party.exp, option);
  5670. else
  5671. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5672. return 0;
  5673. }
  5674. /*==========================================
  5675. * @autoloot by Upa-Kun
  5676. * Turns on/off AutoLoot for a specific player
  5677. *------------------------------------------*/
  5678. ACMD_FUNC(autoloot)
  5679. {
  5680. int32 rate;
  5681. nullpo_retr(-1, sd);
  5682. // autoloot command without value
  5683. if(!message || !*message)
  5684. {
  5685. if (sd->state.autoloot)
  5686. rate = 0;
  5687. else
  5688. rate = 10000;
  5689. } else {
  5690. double drate;
  5691. drate = atof(message);
  5692. rate = (int32)(drate*100);
  5693. }
  5694. if (rate < 0) rate = 0;
  5695. if (rate > 10000) rate = 10000;
  5696. sd->state.autoloot = rate;
  5697. if (sd->state.autoloot) {
  5698. 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.
  5699. clif_displaymessage(fd, atcmd_output);
  5700. }else
  5701. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5702. return 0;
  5703. }
  5704. /*==========================================
  5705. * @alootid
  5706. *------------------------------------------*/
  5707. ACMD_FUNC(autolootitem)
  5708. {
  5709. std::shared_ptr<item_data> item_data;
  5710. int32 i;
  5711. int32 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5712. nullpo_retr(-1, sd);
  5713. if (message && *message) {
  5714. if (message[0] == '+') {
  5715. message++;
  5716. action = 1;
  5717. }
  5718. else if (message[0] == '-') {
  5719. message++;
  5720. action = 2;
  5721. }
  5722. else if (!strcmp(message,"reset"))
  5723. action = 4;
  5724. }
  5725. if (action < 3) // add or remove
  5726. {
  5727. item_data = item_db.find( strtoul( message, nullptr, 10 ) );
  5728. if( item_data == nullptr ){
  5729. item_data = item_db.searchname( message );
  5730. }
  5731. if( item_data == nullptr ){
  5732. // No items founds in the DB with Id or Name
  5733. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5734. return -1;
  5735. }
  5736. }
  5737. switch(action) {
  5738. case 1:
  5739. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5740. if (i != AUTOLOOTITEM_SIZE) {
  5741. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5742. return -1;
  5743. }
  5744. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5745. if (i == AUTOLOOTITEM_SIZE) {
  5746. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5747. return -1;
  5748. }
  5749. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5750. 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}
  5751. clif_displaymessage(fd, atcmd_output);
  5752. sd->state.autolooting = 1;
  5753. break;
  5754. case 2:
  5755. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5756. if (i == AUTOLOOTITEM_SIZE) {
  5757. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5758. return -1;
  5759. }
  5760. sd->state.autolootid[i] = 0;
  5761. 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.
  5762. clif_displaymessage(fd, atcmd_output);
  5763. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5764. if (i == AUTOLOOTITEM_SIZE) {
  5765. sd->state.autolooting = 0;
  5766. }
  5767. break;
  5768. case 3:
  5769. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5770. clif_displaymessage(fd, atcmd_output);
  5771. 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>".
  5772. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5773. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5774. if (i == AUTOLOOTITEM_SIZE) {
  5775. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5776. } else {
  5777. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5778. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5779. {
  5780. if (sd->state.autolootid[i] == 0)
  5781. continue;
  5782. item_data = item_db.find( sd->state.autolootid[i] );
  5783. if( item_data == nullptr ){
  5784. 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);
  5785. continue;
  5786. }
  5787. sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid);
  5788. clif_displaymessage(fd, atcmd_output);
  5789. }
  5790. }
  5791. break;
  5792. case 4:
  5793. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5794. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5795. sd->state.autolooting = 0;
  5796. break;
  5797. }
  5798. return 0;
  5799. }
  5800. /*==========================================
  5801. * @autoloottype
  5802. * Flags:
  5803. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5804. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5805. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5806. * 262144: IT_CASH
  5807. *------------------------------------------
  5808. * Credits:
  5809. * chriser
  5810. * Aleos
  5811. *------------------------------------------*/
  5812. ACMD_FUNC(autoloottype)
  5813. {
  5814. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5815. enum item_types type= IT_UNKNOWN;
  5816. int32 ITEM_MAX = 1533;
  5817. nullpo_retr(-1, sd);
  5818. if (message && *message) {
  5819. if (message[0] == '+') {
  5820. message++;
  5821. action = 1;
  5822. }
  5823. else if (message[0] == '-') {
  5824. message++;
  5825. action = 2;
  5826. }
  5827. else if (!strcmp(message,"reset"))
  5828. action = 4;
  5829. }
  5830. if (action < 3) { // add or remove
  5831. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5832. type = IT_HEALING;
  5833. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5834. type = IT_USABLE;
  5835. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5836. type = IT_ETC;
  5837. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5838. type = IT_ARMOR;
  5839. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5840. type = IT_WEAPON;
  5841. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5842. type = IT_CARD;
  5843. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5844. type = IT_PETEGG;
  5845. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5846. type = IT_PETARMOR;
  5847. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5848. type = IT_AMMO;
  5849. else {
  5850. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5851. return -1;
  5852. }
  5853. }
  5854. switch (action) {
  5855. case 1:
  5856. if (sd->state.autoloottype&(1<<type)) {
  5857. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5858. return -1;
  5859. }
  5860. if (sd->state.autoloottype == ITEM_MAX) {
  5861. 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>.
  5862. return -1;
  5863. }
  5864. sd->state.autoloottype |= (1<<type); // Stores the type
  5865. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%u}
  5866. clif_displaymessage(fd, atcmd_output);
  5867. break;
  5868. case 2:
  5869. if (!(sd->state.autoloottype&(1<<type))) {
  5870. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5871. return -1;
  5872. }
  5873. sd->state.autoloottype &= ~(1<<type);
  5874. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%u} from your autoloottype list.
  5875. clif_displaymessage(fd, atcmd_output);
  5876. break;
  5877. case 3:
  5878. 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>".
  5879. 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
  5880. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5881. if (sd->state.autoloottype == 0)
  5882. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5883. else {
  5884. uint8 i = 0;
  5885. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5886. while (i < IT_MAX) {
  5887. if (sd->state.autoloottype&(1<<i)) {
  5888. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5889. clif_displaymessage(fd, atcmd_output);
  5890. }
  5891. i++;
  5892. }
  5893. }
  5894. break;
  5895. case 4:
  5896. sd->state.autoloottype = 0;
  5897. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5898. break;
  5899. }
  5900. return 0;
  5901. }
  5902. /*==========================================
  5903. * It is made to rain.
  5904. * No longer available, keeping here just in case it's back someday. [Ind]
  5905. *------------------------------------------*/
  5906. //ACMD_FUNC(rain)
  5907. //{
  5908. // nullpo_retr(-1, sd);
  5909. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5910. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5911. // clif_weather(sd->bl.m);
  5912. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5913. // } else {
  5914. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5915. // clif_weather(sd->bl.m);
  5916. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5917. // }
  5918. // return 0;
  5919. //}
  5920. /*==========================================
  5921. * It is made to snow.
  5922. *------------------------------------------*/
  5923. ACMD_FUNC(snow)
  5924. {
  5925. nullpo_retr(-1, sd);
  5926. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5927. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5928. clif_weather(sd->bl.m);
  5929. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5930. } else {
  5931. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5932. clif_weather(sd->bl.m);
  5933. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5934. }
  5935. return 0;
  5936. }
  5937. /*==========================================
  5938. * Cherry tree snowstorm is made to fall. (Sakura)
  5939. *------------------------------------------*/
  5940. ACMD_FUNC(sakura)
  5941. {
  5942. nullpo_retr(-1, sd);
  5943. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5944. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5945. clif_weather(sd->bl.m);
  5946. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5947. } else {
  5948. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  5949. clif_weather(sd->bl.m);
  5950. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5951. }
  5952. return 0;
  5953. }
  5954. /*==========================================
  5955. * Clouds appear.
  5956. *------------------------------------------*/
  5957. ACMD_FUNC(clouds)
  5958. {
  5959. nullpo_retr(-1, sd);
  5960. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  5961. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5962. clif_weather(sd->bl.m);
  5963. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5964. } else {
  5965. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  5966. clif_weather(sd->bl.m);
  5967. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5968. }
  5969. return 0;
  5970. }
  5971. /*==========================================
  5972. * Different type of clouds using effect 516
  5973. *------------------------------------------*/
  5974. ACMD_FUNC(clouds2)
  5975. {
  5976. nullpo_retr(-1, sd);
  5977. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  5978. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5979. clif_weather(sd->bl.m);
  5980. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5981. } else {
  5982. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  5983. clif_weather(sd->bl.m);
  5984. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5985. }
  5986. return 0;
  5987. }
  5988. /*==========================================
  5989. * Fog hangs over.
  5990. *------------------------------------------*/
  5991. ACMD_FUNC(fog)
  5992. {
  5993. nullpo_retr(-1, sd);
  5994. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  5995. map_setmapflag(sd->bl.m, MF_FOG, false);
  5996. clif_weather(sd->bl.m);
  5997. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5998. } else {
  5999. map_setmapflag(sd->bl.m, MF_FOG, true);
  6000. clif_weather(sd->bl.m);
  6001. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  6002. }
  6003. return 0;
  6004. }
  6005. /*==========================================
  6006. * Fallen leaves fall.
  6007. *------------------------------------------*/
  6008. ACMD_FUNC(leaves)
  6009. {
  6010. nullpo_retr(-1, sd);
  6011. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  6012. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6013. clif_weather(sd->bl.m);
  6014. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  6015. } else {
  6016. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  6017. clif_weather(sd->bl.m);
  6018. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  6019. }
  6020. return 0;
  6021. }
  6022. /*==========================================
  6023. * Fireworks appear.
  6024. *------------------------------------------*/
  6025. ACMD_FUNC(fireworks)
  6026. {
  6027. nullpo_retr(-1, sd);
  6028. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  6029. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6030. clif_weather(sd->bl.m);
  6031. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  6032. } else {
  6033. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  6034. clif_weather(sd->bl.m);
  6035. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  6036. }
  6037. return 0;
  6038. }
  6039. /*==========================================
  6040. * Clearing Weather Effects by Dexity
  6041. *------------------------------------------*/
  6042. ACMD_FUNC(clearweather)
  6043. {
  6044. nullpo_retr(-1, sd);
  6045. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  6046. map_setmapflag(sd->bl.m, MF_SNOW, false);
  6047. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  6048. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  6049. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  6050. map_setmapflag(sd->bl.m, MF_FOG, false);
  6051. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6052. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6053. clif_weather(sd->bl.m);
  6054. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  6055. return 0;
  6056. }
  6057. /*===============================================================
  6058. * Sound Command - plays a sound for everyone around! [Codemaster]
  6059. *---------------------------------------------------------------*/
  6060. ACMD_FUNC(sound)
  6061. {
  6062. char sound_file[100];
  6063. memset(sound_file, '\0', sizeof(sound_file));
  6064. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6065. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  6066. return -1;
  6067. }
  6068. if(strstr(sound_file, ".wav") == nullptr)
  6069. strcat(sound_file, ".wav");
  6070. clif_soundeffect( sd->bl, sound_file, 0, AREA );
  6071. return 0;
  6072. }
  6073. /*==========================================
  6074. * MOB Search
  6075. *------------------------------------------*/
  6076. ACMD_FUNC(mobsearch)
  6077. {
  6078. nullpo_retr(-1, sd);
  6079. char mob_name[100]={0};
  6080. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6081. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  6082. return -1;
  6083. }
  6084. int32 mob_id = strtol(mob_name, nullptr, 10);
  6085. if (mob_id == 0)
  6086. mob_id = mobdb_searchname(mob_name);
  6087. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6088. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6089. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  6090. clif_displaymessage(fd, atcmd_output);
  6091. return -1;
  6092. }
  6093. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6094. // strcpy(mob_name, mob->name.c_str()); // --en--
  6095. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  6096. clif_displaymessage(fd, atcmd_output);
  6097. s_mapiterator* it = mapit_geteachmob();
  6098. int32 number = 0;
  6099. for(;;)
  6100. {
  6101. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6102. if( md == nullptr )
  6103. break;// no more mobs
  6104. if( md->bl.m != sd->bl.m )
  6105. continue;
  6106. if( md->mob_id != mob_id )
  6107. continue;
  6108. ++number;
  6109. if( md->spawn_timer == INVALID_TIMER )
  6110. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  6111. else
  6112. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  6113. clif_displaymessage(fd, atcmd_output);
  6114. }
  6115. mapit_free(it);
  6116. return 0;
  6117. }
  6118. /*==========================================
  6119. * @cleanmap - cleans items on the ground
  6120. * @cleanarea - cleans items on the ground within an specified area
  6121. *------------------------------------------*/
  6122. static int32 atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  6123. {
  6124. nullpo_ret(bl);
  6125. map_clearflooritem(bl);
  6126. return 0;
  6127. }
  6128. ACMD_FUNC(cleanmap)
  6129. {
  6130. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  6131. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6132. return 0;
  6133. }
  6134. ACMD_FUNC(cleanarea)
  6135. {
  6136. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  6137. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  6138. 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);
  6139. }
  6140. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  6141. 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);
  6142. }
  6143. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  6144. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  6145. }
  6146. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6147. return 0;
  6148. }
  6149. /*==========================================
  6150. * make a NPC/PET talk
  6151. * @npctalkc [SnakeDrak]
  6152. *------------------------------------------*/
  6153. ACMD_FUNC(npctalk)
  6154. {
  6155. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  6156. struct npc_data *nd;
  6157. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  6158. unsigned long color=0;
  6159. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6160. return -1; //no "chatting" while muted.
  6161. if(!ifcolor) {
  6162. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  6163. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  6164. return -1;
  6165. }
  6166. }
  6167. else {
  6168. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6169. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  6170. return -1;
  6171. }
  6172. }
  6173. if (!(nd = npc_name2id(name))) {
  6174. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  6175. return -1;
  6176. }
  6177. strtok(name, "#"); // discard extra name identifier if present
  6178. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6179. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  6180. else clif_disp_overhead(&nd->bl, temp);
  6181. return 0;
  6182. }
  6183. ACMD_FUNC(pettalk)
  6184. {
  6185. char mes[100],temp[CHAT_SIZE_MAX];
  6186. struct pet_data *pd;
  6187. nullpo_retr(-1, sd);
  6188. if ( battle_config.min_chat_delay ) {
  6189. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6190. return 0;
  6191. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6192. }
  6193. if(!sd->status.pet_id || !(pd=sd->pd))
  6194. {
  6195. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  6196. return -1;
  6197. }
  6198. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6199. return -1; //no "chatting" while muted.
  6200. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6201. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  6202. return -1;
  6203. }
  6204. if (message[0] == '/')
  6205. {// pet emotion processing
  6206. const char* emo[] = {
  6207. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6208. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6209. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6210. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  6211. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  6212. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  6213. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  6214. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  6215. "/whisp"
  6216. };
  6217. int32 i;
  6218. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6219. if( i == ET_DICE1 ) i = rnd_value<int>(ET_DICE1, ET_DICE6); // randomize /dice
  6220. if( i < ARRAYLENGTH(emo) )
  6221. {
  6222. if (sd->emotionlasttime + 1 >= time(nullptr)) { // not more than 1 per second
  6223. sd->emotionlasttime = time(nullptr);
  6224. return 0;
  6225. }
  6226. sd->emotionlasttime = time(nullptr);
  6227. clif_emotion(&pd->bl, i);
  6228. return 0;
  6229. }
  6230. }
  6231. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6232. clif_disp_overhead(&pd->bl, temp);
  6233. return 0;
  6234. }
  6235. /// @users - displays the number of players present on each map (and percentage)
  6236. /// #users displays on the target user instead of self
  6237. ACMD_FUNC(users)
  6238. {
  6239. char buf[CHAT_SIZE_MAX];
  6240. int32 i;
  6241. int32 users[MAX_MAPINDEX];
  6242. int32 users_all;
  6243. struct s_mapiterator* iter;
  6244. memset(users, 0, sizeof(users));
  6245. users_all = 0;
  6246. // count users on each map
  6247. iter = mapit_getallusers();
  6248. for(;;)
  6249. {
  6250. map_session_data* sd2 = (map_session_data*)mapit_next(iter);
  6251. if( sd2 == nullptr )
  6252. break;// no more users
  6253. if( sd2->mapindex >= MAX_MAPINDEX )
  6254. continue;// invalid mapindex
  6255. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6256. if( users_all < INT_MAX ) ++users_all;
  6257. }
  6258. mapit_free(iter);
  6259. // display results for each map
  6260. for( i = 0; i < MAX_MAPINDEX; ++i )
  6261. {
  6262. if( users[i] == 0 )
  6263. continue;// empty
  6264. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6265. clif_displaymessage(sd->fd, buf);
  6266. }
  6267. // display overall count
  6268. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6269. clif_displaymessage(sd->fd, buf);
  6270. return 0;
  6271. }
  6272. /*==========================================
  6273. *
  6274. *------------------------------------------*/
  6275. ACMD_FUNC(reset)
  6276. {
  6277. pc_resetstate(sd);
  6278. pc_resetskill(sd,1);
  6279. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  6280. clif_displaymessage(fd, atcmd_output);
  6281. return 0;
  6282. }
  6283. /*==========================================
  6284. *
  6285. *------------------------------------------*/
  6286. ACMD_FUNC(summon)
  6287. {
  6288. char name[NAME_LENGTH];
  6289. int32 mob_id = 0;
  6290. int32 duration = 0;
  6291. struct mob_data *md;
  6292. t_tick tick=gettick();
  6293. nullpo_retr(-1, sd);
  6294. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  6295. {
  6296. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  6297. return -1;
  6298. }
  6299. if (duration < 1)
  6300. duration =1;
  6301. else if (duration > 60)
  6302. duration =60;
  6303. if ((mob_id = atoi(name)) == 0)
  6304. mob_id = mobdb_searchname(name);
  6305. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6306. {
  6307. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6308. return -1;
  6309. }
  6310. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  6311. if(!md)
  6312. return -1;
  6313. md->master_id=sd->bl.id;
  6314. md->special_state.ai=AI_ATTACK;
  6315. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6316. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  6317. mob_spawn(md);
  6318. sc_start4(nullptr,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6319. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  6320. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  6321. return 0;
  6322. }
  6323. /*==========================================
  6324. * @adjgroup
  6325. * Temporarily move player to another group
  6326. * Useful during beta testing to allow players to use GM commands for short periods of time
  6327. *------------------------------------------*/
  6328. ACMD_FUNC(adjgroup)
  6329. {
  6330. int32 new_group = 0;
  6331. nullpo_retr(-1, sd);
  6332. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  6333. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  6334. return -1;
  6335. }
  6336. if (!player_group_db.exists(new_group)) {
  6337. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  6338. return -1;
  6339. }
  6340. sd->group_id = new_group;
  6341. pc_group_pc_load(sd);/* update cache */
  6342. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  6343. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  6344. return 0;
  6345. }
  6346. /*==========================================
  6347. * @trade by [MouseJstr]
  6348. * Open a trade window with a remote player
  6349. *------------------------------------------*/
  6350. ACMD_FUNC(trade)
  6351. {
  6352. map_session_data* pl_sd = nullptr;;
  6353. nullpo_retr(-1, sd);
  6354. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6355. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6356. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  6357. return -1;
  6358. }
  6359. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  6360. {
  6361. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6362. return -1;
  6363. }
  6364. trade_traderequest(sd, pl_sd);
  6365. return 0;
  6366. }
  6367. /*==========================================
  6368. * @setbattleflag by [MouseJstr]
  6369. * set a battle_config flag without having to reboot
  6370. *------------------------------------------*/
  6371. ACMD_FUNC(setbattleflag)
  6372. {
  6373. char flag[128], value[128];
  6374. int32 reload = 0;
  6375. nullpo_retr(-1, sd);
  6376. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) < 2) {
  6377. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  6378. return -1;
  6379. }
  6380. if (battle_set_value(flag, value) == 0)
  6381. {
  6382. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  6383. return -1;
  6384. }
  6385. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  6386. if (reload)
  6387. mob_reload();
  6388. return 0;
  6389. }
  6390. /*==========================================
  6391. * @unmute [Valaris]
  6392. *------------------------------------------*/
  6393. ACMD_FUNC(unmute)
  6394. {
  6395. map_session_data* pl_sd = nullptr;;
  6396. nullpo_retr(-1, sd);
  6397. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6398. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6399. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6400. return -1;
  6401. }
  6402. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6403. {
  6404. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6405. return -1;
  6406. }
  6407. if(!pl_sd->sc.getSCE(SC_NOCHAT)) {
  6408. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6409. return -1;
  6410. }
  6411. pl_sd->status.manner = 0;
  6412. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6413. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6414. return 0;
  6415. }
  6416. /*==========================================
  6417. * @uptime by MC Cameri
  6418. *------------------------------------------*/
  6419. ACMD_FUNC(uptime)
  6420. {
  6421. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6422. minute = 60, days = 0, hours = 0, minutes = 0;
  6423. nullpo_retr(-1, sd);
  6424. seconds = get_uptime();
  6425. days = seconds/day;
  6426. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6427. hours = seconds/hour;
  6428. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6429. minutes = seconds/minute;
  6430. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6431. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  6432. clif_displaymessage(fd, atcmd_output);
  6433. return 0;
  6434. }
  6435. /*==========================================
  6436. * @changesex
  6437. * => Changes one's account sex. Switch from male to female or visversa
  6438. *------------------------------------------*/
  6439. ACMD_FUNC(changesex)
  6440. {
  6441. int32 i;
  6442. nullpo_retr(-1, sd);
  6443. pc_resetskill(sd,4);
  6444. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6445. for (i = 0; i < EQI_MAX; i++) {
  6446. if (sd->equip_index[i] >= 0)
  6447. pc_unequipitem(sd, sd->equip_index[i], 3);
  6448. }
  6449. chrif_changesex(sd, true);
  6450. return 0;
  6451. }
  6452. /*==========================================
  6453. * @changecharsex
  6454. * => Changes one's character sex. Switch from male to female or visversa.
  6455. *------------------------------------------*/
  6456. ACMD_FUNC(changecharsex)
  6457. {
  6458. int32 i;
  6459. nullpo_retr(-1, sd);
  6460. pc_resetskill(sd,4);
  6461. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6462. for (i = 0; i < EQI_MAX; i++) {
  6463. if (sd->equip_index[i] >= 0)
  6464. pc_unequipitem(sd, sd->equip_index[i], 3);
  6465. }
  6466. chrif_changesex(sd, false);
  6467. return 0;
  6468. }
  6469. /*================================================
  6470. * @mute - Mutes a player for a set amount of time
  6471. *------------------------------------------------*/
  6472. ACMD_FUNC(mute)
  6473. {
  6474. map_session_data* pl_sd = nullptr;;
  6475. int32 manner;
  6476. nullpo_retr(-1, sd);
  6477. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6478. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6479. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6480. return -1;
  6481. }
  6482. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6483. {
  6484. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6485. return -1;
  6486. }
  6487. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6488. {
  6489. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6490. return -1;
  6491. }
  6492. clif_manner_message(sd, 0);
  6493. clif_manner_message(pl_sd, 5);
  6494. if( pl_sd->status.manner < manner ) {
  6495. pl_sd->status.manner -= manner;
  6496. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6497. } else {
  6498. pl_sd->status.manner = 0;
  6499. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6500. }
  6501. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6502. return 0;
  6503. }
  6504. /*==========================================
  6505. * @refresh (like @jumpto <<yourself>>)
  6506. *------------------------------------------*/
  6507. ACMD_FUNC(refresh)
  6508. {
  6509. nullpo_retr(-1, sd);
  6510. clif_refresh(sd);
  6511. return 0;
  6512. }
  6513. ACMD_FUNC(refreshall)
  6514. {
  6515. map_session_data* iter_sd;
  6516. struct s_mapiterator* iter;
  6517. nullpo_retr(-1, sd);
  6518. iter = mapit_getallusers();
  6519. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6520. clif_refresh(iter_sd);
  6521. mapit_free(iter);
  6522. return 0;
  6523. }
  6524. /*==========================================
  6525. * @identify
  6526. * => GM's magnifier.
  6527. *------------------------------------------*/
  6528. ACMD_FUNC(identify)
  6529. {
  6530. int32 i,num;
  6531. nullpo_retr(-1, sd);
  6532. for(i=num=0;i<MAX_INVENTORY;i++){
  6533. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6534. num++;
  6535. }
  6536. }
  6537. if (num > 0) {
  6538. clif_item_identify_list(sd);
  6539. } else {
  6540. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6541. }
  6542. return 0;
  6543. }
  6544. /*===============================================
  6545. * @identifyall
  6546. * => Indentify all items in inventory - Akinari
  6547. *-----------------------------------------------*/
  6548. ACMD_FUNC(identifyall)
  6549. {
  6550. nullpo_retr(-1, sd);
  6551. pc_identifyall(sd, true);
  6552. return 0;
  6553. }
  6554. /*==========================================
  6555. * @gmotd (Global MOTD)
  6556. * by davidsiaw :P
  6557. *------------------------------------------*/
  6558. ACMD_FUNC(gmotd)
  6559. {
  6560. FILE* fp;
  6561. if( ( fp = fopen(motd_txt, "r") ) != nullptr )
  6562. {
  6563. char buf[CHAT_SIZE_MAX];
  6564. size_t len;
  6565. while( fgets(buf, sizeof(buf), fp) )
  6566. {
  6567. if( buf[0] == '/' && buf[1] == '/' )
  6568. {
  6569. continue;
  6570. }
  6571. len = strlen(buf);
  6572. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6573. {// strip trailing EOL characters
  6574. len--;
  6575. }
  6576. if( len )
  6577. {
  6578. buf[len] = 0;
  6579. intif_broadcast(buf, len+1, 0);
  6580. }
  6581. }
  6582. fclose(fp);
  6583. }
  6584. return 0;
  6585. }
  6586. ACMD_FUNC(misceffect)
  6587. {
  6588. int32 effect = 0;
  6589. nullpo_retr(-1, sd);
  6590. if (!message || !*message)
  6591. return -1;
  6592. if (sscanf(message, "%11d", &effect) < 1)
  6593. return -1;
  6594. if (effect < NOTIFYEFFECT_BASE_LEVEL_UP || effect > NOTIFYEFFECT_TAEKWON_BASE_LEVEL_UP)
  6595. return -1;
  6596. clif_misceffect( sd->bl, static_cast<e_notify_effect>(effect) );
  6597. return 0;
  6598. }
  6599. /*==========================================
  6600. * MAIL SYSTEM
  6601. *------------------------------------------*/
  6602. ACMD_FUNC(mail)
  6603. {
  6604. nullpo_ret(sd);
  6605. mail_openmail(sd);
  6606. return 0;
  6607. }
  6608. /*==========================================
  6609. * Show Monster DB Info v 1.0
  6610. * originally by [Lupus]
  6611. *------------------------------------------*/
  6612. ACMD_FUNC(mobinfo)
  6613. {
  6614. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6615. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6616. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6617. char atcmd_output2[CHAT_SIZE_MAX];
  6618. uint16 mob_ids[MAX_SEARCH], count;
  6619. uint16 i;
  6620. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6621. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6622. if (!message || !*message) {
  6623. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6624. return -1;
  6625. }
  6626. // If monster identifier/name argument is a name
  6627. i = util::strtoint32def(message);
  6628. if (i != 0 && (i = mobdb_checkid(i)))
  6629. {
  6630. mob_ids[0] = i;
  6631. count = 1;
  6632. } else
  6633. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6634. if (!count) {
  6635. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6636. return -1;
  6637. }
  6638. if (count >= MAX_SEARCH) {
  6639. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6640. clif_displaymessage(fd, atcmd_output);
  6641. count = MAX_SEARCH;
  6642. }
  6643. for (uint16 k = 0; k < count; k++) {
  6644. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_ids[k]);
  6645. if (mob == nullptr)
  6646. continue;
  6647. t_exp base_exp = mob->base_exp;
  6648. t_exp job_exp = mob->job_exp;
  6649. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6650. base_exp += (base_exp * battle_config.vip_base_exp_increase) / 100;
  6651. job_exp += (job_exp * battle_config.vip_job_exp_increase) / 100;
  6652. }
  6653. #ifdef RENEWAL_EXP
  6654. if( battle_config.atcommand_mobinfo_type ) {
  6655. int32 penalty = pc_level_penalty_mod( sd, PENALTY_EXP, mob );
  6656. base_exp = base_exp * penalty / 100;
  6657. job_exp = job_exp * penalty / 100;
  6658. }
  6659. #endif
  6660. // stats
  6661. if( mob->get_bosstype() == BOSSTYPE_MVP )
  6662. 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)
  6663. else
  6664. 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)
  6665. clif_displaymessage(fd, atcmd_output);
  6666. 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
  6667. clif_displaymessage(fd, atcmd_output);
  6668. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6669. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6670. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6671. clif_displaymessage(fd, atcmd_output);
  6672. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6673. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6674. mob->range2 , mob->range3, msize[mob->status.size],
  6675. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6676. clif_displaymessage(fd, atcmd_output);
  6677. #ifdef RENEWAL
  6678. sprintf(atcmd_output, msg_txt(sd, 827), mob->status.res, mob->status.mres);// MDEF:%d RES:%d MRES:%d
  6679. clif_displaymessage(fd, atcmd_output);
  6680. #endif
  6681. // drops
  6682. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6683. strcpy(atcmd_output, " ");
  6684. uint32 j = 0;
  6685. int32 drop_modifier = 100;
  6686. #ifdef RENEWAL_DROP
  6687. if( battle_config.atcommand_mobinfo_type ){
  6688. drop_modifier = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
  6689. }
  6690. #endif
  6691. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6692. if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].rate < 1)
  6693. continue;
  6694. std::shared_ptr<item_data> id = item_db.find(mob->dropitem[i].nameid);
  6695. if (id == nullptr)
  6696. continue;
  6697. int32 droprate = mob_getdroprate( &sd->bl, mob, mob->dropitem[i].rate, drop_modifier );
  6698. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), (float)droprate / 100);
  6699. strcat(atcmd_output, atcmd_output2);
  6700. if (++j % 3 == 0) {
  6701. clif_displaymessage(fd, atcmd_output);
  6702. strcpy(atcmd_output, " ");
  6703. }
  6704. }
  6705. if (j == 0)
  6706. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6707. else if (j % 3 != 0)
  6708. clif_displaymessage(fd, atcmd_output);
  6709. // mvp
  6710. if( mob->get_bosstype() == BOSSTYPE_MVP ){
  6711. float mvppercent, mvpremain;
  6712. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%llu
  6713. clif_displaymessage(fd, atcmd_output);
  6714. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6715. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6716. j = 0;
  6717. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6718. if (mob->mvpitem[i].nameid == 0)
  6719. continue;
  6720. std::shared_ptr<item_data> id = item_db.find(mob->mvpitem[i].nameid);
  6721. if (id == nullptr)
  6722. continue;
  6723. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6724. mvppercent = (float)mob->mvpitem[i].rate * mvpremain / 10000.0f;
  6725. if(battle_config.item_drop_mvp_mode == 0) {
  6726. mvpremain -= mvppercent;
  6727. }
  6728. if (mvppercent > 0) {
  6729. j++;
  6730. if (j == 1) {
  6731. sprintf(atcmd_output2, " %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6732. } else {
  6733. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6734. }
  6735. strcat(atcmd_output, atcmd_output2);
  6736. }
  6737. }
  6738. if (j == 0)
  6739. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6740. else
  6741. clif_displaymessage(fd, atcmd_output);
  6742. }
  6743. }
  6744. return 0;
  6745. }
  6746. /*=========================================
  6747. * @showmobs by KarLaeda
  6748. * => For 15 sec displays the mobs on minimap
  6749. *------------------------------------------*/
  6750. ACMD_FUNC(showmobs)
  6751. {
  6752. char mob_name[100];
  6753. int32 mob_id;
  6754. int32 number = 0;
  6755. struct s_mapiterator* it;
  6756. nullpo_retr(-1, sd);
  6757. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6758. return -1;
  6759. if((mob_id = strtol(mob_name, nullptr, 10)) == 0)
  6760. mob_id = mobdb_searchname(mob_name);
  6761. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6762. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6763. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6764. clif_displaymessage(fd, atcmd_output);
  6765. return 0;
  6766. }
  6767. 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.
  6768. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6769. return 0;
  6770. }
  6771. if(mob_id == strtol(mob_name, nullptr, 10) && !mob->jname.empty())
  6772. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6773. //strcpy(mob_name, mob->name.c_str()); // --en--
  6774. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6775. mob_name, mapindex_id2name(sd->mapindex));
  6776. clif_displaymessage(fd, atcmd_output);
  6777. it = mapit_geteachmob();
  6778. for(;;)
  6779. {
  6780. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6781. if( md == nullptr )
  6782. break;// no more mobs
  6783. if( md->bl.m != sd->bl.m )
  6784. continue;
  6785. if( mob_id != -1 && md->mob_id != mob_id )
  6786. continue;
  6787. if( md->special_state.ai || md->master_id )
  6788. continue; // hide slaves and player summoned mobs
  6789. if( md->spawn_timer != INVALID_TIMER )
  6790. continue; // hide mobs waiting for respawn
  6791. ++number;
  6792. clif_viewpoint( *sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF );
  6793. }
  6794. mapit_free(it);
  6795. return 0;
  6796. }
  6797. /*==========================================
  6798. * homunculus level up [orn]
  6799. *------------------------------------------*/
  6800. ACMD_FUNC(homlevel)
  6801. {
  6802. TBL_HOM * hd;
  6803. int32 level = 0, i = 0;
  6804. nullpo_retr(-1, sd);
  6805. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6806. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6807. return -1;
  6808. }
  6809. if ( !hom_is_active(sd->hd) ) {
  6810. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6811. return -1;
  6812. }
  6813. hd = sd->hd;
  6814. for (i = 1; i <= level && hd->exp_next; i++){
  6815. hd->homunculus.exp += hd->exp_next;
  6816. if( !hom_levelup(hd) )
  6817. break;
  6818. }
  6819. status_calc_homunculus(hd, SCO_NONE);
  6820. status_percent_heal(&hd->bl, 100, 100);
  6821. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6822. return 0;
  6823. }
  6824. /*==========================================
  6825. * homunculus evolution H [orn]
  6826. *------------------------------------------*/
  6827. ACMD_FUNC(homevolution)
  6828. {
  6829. nullpo_retr(-1, sd);
  6830. if ( !hom_is_active(sd->hd) ) {
  6831. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6832. return -1;
  6833. }
  6834. if ( !hom_evolution(sd->hd) ) {
  6835. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6836. return -1;
  6837. }
  6838. clif_homskillinfoblock( *sd->hd );
  6839. return 0;
  6840. }
  6841. ACMD_FUNC(hommutate)
  6842. {
  6843. int32 homun_id, m_class = 0, m_id;
  6844. nullpo_retr(-1, sd);
  6845. if (!hom_is_active(sd->hd)) {
  6846. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6847. return -1;
  6848. }
  6849. if (!message || !*message) {
  6850. homun_id = rnd_value<uint16>(MER_EIRA, MER_ELEANOR);
  6851. } else {
  6852. homun_id = atoi(message);
  6853. }
  6854. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6855. m_id = hom_class2mapid(homun_id);
  6856. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6857. hom_mutate(sd->hd, homun_id);
  6858. } else {
  6859. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6860. }
  6861. return 0;
  6862. }
  6863. /*==========================================
  6864. * call choosen homunculus [orn]
  6865. *------------------------------------------*/
  6866. ACMD_FUNC(makehomun)
  6867. {
  6868. int32 homunid;
  6869. nullpo_retr(-1, sd);
  6870. if ( sd->status.hom_id ) {
  6871. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6872. return -1;
  6873. }
  6874. if (!message || !*message) {
  6875. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6876. return -1;
  6877. }
  6878. homunid = atoi(message);
  6879. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6880. {
  6881. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6882. return -1;
  6883. }
  6884. hom_create_request(sd,homunid);
  6885. return 0;
  6886. }
  6887. /*==========================================
  6888. * modify homunculus intimacy [orn]
  6889. *------------------------------------------*/
  6890. ACMD_FUNC(homfriendly)
  6891. {
  6892. int32 friendly = 0;
  6893. nullpo_retr(-1, sd);
  6894. if ( !hom_is_active(sd->hd) ) {
  6895. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6896. return -1;
  6897. }
  6898. if (!message || !*message) {
  6899. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6900. return -1;
  6901. }
  6902. friendly = atoi(message);
  6903. friendly = cap_value(friendly, 0, 1000);
  6904. sd->hd->homunculus.intimacy = friendly * 100 ;
  6905. clif_send_homdata( *sd->hd, SP_INTIMATE );
  6906. return 0;
  6907. }
  6908. /*==========================================
  6909. * modify homunculus hunger [orn]
  6910. *------------------------------------------*/
  6911. ACMD_FUNC(homhungry)
  6912. {
  6913. int32 hungry = 0;
  6914. nullpo_retr(-1, sd);
  6915. if ( !hom_is_active(sd->hd) ) {
  6916. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6917. return -1;
  6918. }
  6919. if (!message || !*message) {
  6920. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6921. return -1;
  6922. }
  6923. hungry = atoi(message);
  6924. hungry = cap_value(hungry, 0, 100);
  6925. sd->hd->homunculus.hunger = hungry;
  6926. clif_send_homdata( *sd->hd, SP_HUNGRY );
  6927. return 0;
  6928. }
  6929. /*==========================================
  6930. * make the homunculus speak [orn]
  6931. *------------------------------------------*/
  6932. ACMD_FUNC(homtalk)
  6933. {
  6934. char mes[100],temp[CHAT_SIZE_MAX];
  6935. nullpo_retr(-1, sd);
  6936. if ( battle_config.min_chat_delay ) {
  6937. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6938. return 0;
  6939. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6940. }
  6941. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6942. return -1; //no "chatting" while muted.
  6943. if ( !hom_is_active(sd->hd) ) {
  6944. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6945. return -1;
  6946. }
  6947. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6948. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6949. return -1;
  6950. }
  6951. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6952. clif_disp_overhead(&sd->hd->bl, temp);
  6953. return 0;
  6954. }
  6955. /*==========================================
  6956. * Show homunculus stats
  6957. *------------------------------------------*/
  6958. ACMD_FUNC(hominfo)
  6959. {
  6960. struct homun_data *hd;
  6961. nullpo_retr(-1, sd);
  6962. if ( !hom_is_active(sd->hd) ) {
  6963. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6964. return -1;
  6965. }
  6966. hd = sd->hd;
  6967. status_data* status = status_get_status_data(hd->bl);
  6968. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6969. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6970. status->hp, status->max_hp, status->sp, status->max_sp);
  6971. clif_displaymessage(fd, atcmd_output);
  6972. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6973. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6974. clif_displaymessage(fd, atcmd_output);
  6975. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6976. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6977. clif_displaymessage(fd, atcmd_output);
  6978. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6979. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6980. status->str, status->agi, status->vit,
  6981. status->int_, status->dex, status->luk);
  6982. clif_displaymessage(fd, atcmd_output);
  6983. return 0;
  6984. }
  6985. ACMD_FUNC(homstats)
  6986. {
  6987. struct homun_data *hd;
  6988. std::shared_ptr<s_homunculus_db> db;
  6989. struct s_homunculus *hom;
  6990. int32 lv, min, max, evo;
  6991. nullpo_retr(-1, sd);
  6992. if ( !hom_is_active(sd->hd) ) {
  6993. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6994. return -1;
  6995. }
  6996. hd = sd->hd;
  6997. hom = &hd->homunculus;
  6998. db = hd->homunculusDB;
  6999. lv = hom->level;
  7000. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7001. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  7002. clif_displaymessage(fd, atcmd_output);
  7003. lv--; //Since the first increase is at level 2.
  7004. evo = (hom->class_ == db->evo_class);
  7005. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  7006. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  7007. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  7008. clif_displaymessage(fd, atcmd_output);
  7009. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  7010. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  7011. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  7012. clif_displaymessage(fd, atcmd_output);
  7013. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  7014. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  7015. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  7016. clif_displaymessage(fd, atcmd_output);
  7017. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  7018. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  7019. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  7020. clif_displaymessage(fd, atcmd_output);
  7021. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  7022. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  7023. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  7024. clif_displaymessage(fd, atcmd_output);
  7025. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  7026. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  7027. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  7028. clif_displaymessage(fd, atcmd_output);
  7029. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  7030. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  7031. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  7032. clif_displaymessage(fd, atcmd_output);
  7033. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  7034. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  7035. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  7036. clif_displaymessage(fd, atcmd_output);
  7037. return 0;
  7038. }
  7039. ACMD_FUNC(homshuffle)
  7040. {
  7041. nullpo_retr(-1, sd);
  7042. if(!sd->hd)
  7043. return -1; // nothing to do
  7044. if(!hom_shuffle(sd->hd))
  7045. return -1;
  7046. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  7047. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  7048. return 0;
  7049. }
  7050. /*==========================================
  7051. * Show Items DB Info v 1.0
  7052. * originally by [Lupus]
  7053. *------------------------------------------*/
  7054. ACMD_FUNC(iteminfo)
  7055. {
  7056. if (!message || !*message) {
  7057. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  7058. return -1;
  7059. }
  7060. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7061. uint16 count = 1;
  7062. t_itemid itemid = strtoul(message, nullptr, 10);
  7063. if (itemid == 0) // Entered a string
  7064. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7065. else {
  7066. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7067. count = 0;
  7068. }
  7069. if (!count) {
  7070. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7071. return -1;
  7072. }
  7073. if (count == MAX_SEARCH) {
  7074. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7075. clif_displaymessage(fd, atcmd_output);
  7076. }
  7077. for (const auto &result : item_array) {
  7078. std::shared_ptr<item_data> item_data = result.second;
  7079. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s' (%u) Type: %s | Extra Effect: %s
  7080. item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(),item_data->nameid,
  7081. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
  7082. (item_data->script==nullptr)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  7083. );
  7084. clif_displaymessage(fd, atcmd_output);
  7085. 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
  7086. clif_displaymessage(fd, atcmd_output);
  7087. if (item_data->maxchance == -1) {
  7088. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  7089. clif_displaymessage(fd, atcmd_output);
  7090. }
  7091. else if (!battle_config.atcommand_mobinfo_type) {
  7092. if (item_data->maxchance)
  7093. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  7094. else
  7095. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  7096. clif_displaymessage(fd, atcmd_output);
  7097. }
  7098. }
  7099. return 0;
  7100. }
  7101. /*==========================================
  7102. * Show who drops the item.
  7103. *------------------------------------------*/
  7104. ACMD_FUNC(whodrops)
  7105. {
  7106. if (!message || !*message) {
  7107. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  7108. return -1;
  7109. }
  7110. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7111. uint16 count = 1;
  7112. t_itemid itemid = strtoul(message, nullptr, 10);
  7113. if (itemid == 0) // Entered a string
  7114. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7115. else {
  7116. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7117. count = 0;
  7118. }
  7119. if (!count) {
  7120. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7121. return -1;
  7122. }
  7123. if (count == MAX_SEARCH) {
  7124. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7125. clif_displaymessage(fd, atcmd_output);
  7126. }
  7127. for (const auto &result : item_array) {
  7128. std::shared_ptr<item_data> id = result.second;
  7129. sprintf(atcmd_output, msg_txt(sd,1285), item_db.create_item_link( id ).c_str(), id->nameid); // Item: '%s' (ID:%u)
  7130. clif_displaymessage(fd, atcmd_output);
  7131. if (id->mob[0].chance == 0) {
  7132. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  7133. clif_displaymessage(fd, atcmd_output);
  7134. } else {
  7135. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  7136. clif_displaymessage(fd, atcmd_output);
  7137. for (uint16 j=0; j < MAX_SEARCH && id->mob[j].chance > 0; j++)
  7138. {
  7139. int32 dropchance = id->mob[j].chance;
  7140. std::shared_ptr<s_mob_db> mob = mob_db.find(id->mob[j].id);
  7141. if(!mob) continue;
  7142. #ifdef RENEWAL_DROP
  7143. if( battle_config.atcommand_mobinfo_type ) {
  7144. dropchance = dropchance * pc_level_penalty_mod( sd, PENALTY_DROP, mob ) / 100;
  7145. if (dropchance <= 0 && !battle_config.drop_rate0item)
  7146. dropchance = 1;
  7147. }
  7148. #endif
  7149. if (pc_isvip(sd)) // Display item rate increase for VIP
  7150. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  7151. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob->jname.c_str(), id->mob[j].id, dropchance/100.);
  7152. clif_displaymessage(fd, atcmd_output);
  7153. }
  7154. }
  7155. }
  7156. return 0;
  7157. }
  7158. ACMD_FUNC(whereis)
  7159. {
  7160. uint16 mob_ids[MAX_SEARCH] = {0}, count;
  7161. if (!message || !*message) {
  7162. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  7163. return -1;
  7164. }
  7165. int32 i_message = atoi(message);
  7166. if (mobdb_checkid(i_message)) {
  7167. // ID given
  7168. mob_ids[0] = i_message;
  7169. count = 1;
  7170. } else {
  7171. // Name given, get all monster associated whith this name
  7172. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  7173. }
  7174. if (count <= 0) {
  7175. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  7176. return -1;
  7177. }
  7178. if (count >= MAX_SEARCH) {
  7179. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7180. clif_displaymessage(fd, atcmd_output);
  7181. count = MAX_SEARCH;
  7182. }
  7183. for (int32 i = 0; i < count; i++) {
  7184. uint16 mob_id = mob_ids[i];
  7185. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  7186. if(!mob) continue;
  7187. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname.c_str()); // %s spawns in:
  7188. clif_displaymessage(fd, atcmd_output);
  7189. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  7190. if (spawns.size() <= 0) {
  7191. // This monster does not spawn normally.
  7192. clif_displaymessage(fd, msg_txt(sd,1290));
  7193. } else {
  7194. for(auto& spawn : spawns)
  7195. {
  7196. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  7197. if (mapid < 0)
  7198. continue;
  7199. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  7200. clif_displaymessage(fd, atcmd_output);
  7201. }
  7202. }
  7203. }
  7204. return 0;
  7205. }
  7206. ACMD_FUNC(version)
  7207. {
  7208. pc_show_version(sd);
  7209. return 0;
  7210. }
  7211. /*==========================================
  7212. * @mutearea by MouseJstr
  7213. *------------------------------------------*/
  7214. static int32 atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7215. {
  7216. int32 time, id;
  7217. map_session_data *pl_sd = (map_session_data *)bl;
  7218. if (pl_sd == nullptr)
  7219. return 0;
  7220. id = va_arg(ap, int32);
  7221. time = va_arg(ap, int32);
  7222. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  7223. pl_sd->status.manner -= time;
  7224. if (pl_sd->status.manner < 0)
  7225. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  7226. else
  7227. status_change_end(&pl_sd->bl, SC_NOCHAT);
  7228. }
  7229. return 0;
  7230. }
  7231. ACMD_FUNC(mutearea)
  7232. {
  7233. int32 time;
  7234. nullpo_ret(sd);
  7235. if (!message || !*message) {
  7236. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  7237. return -1;
  7238. }
  7239. time = atoi(message);
  7240. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  7241. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7242. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7243. return 0;
  7244. }
  7245. ACMD_FUNC(rates)
  7246. {
  7247. char buf[CHAT_SIZE_MAX];
  7248. nullpo_ret(sd);
  7249. memset(buf, '\0', sizeof(buf));
  7250. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  7251. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  7252. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  7253. clif_displaymessage(fd, buf);
  7254. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7255. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  7256. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  7257. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  7258. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  7259. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  7260. clif_displaymessage(fd, buf);
  7261. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7262. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  7263. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  7264. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  7265. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  7266. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  7267. clif_displaymessage(fd, buf);
  7268. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7269. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  7270. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  7271. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  7272. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  7273. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  7274. clif_displaymessage(fd, buf);
  7275. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  7276. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  7277. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  7278. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  7279. clif_displaymessage(fd, buf);
  7280. return 0;
  7281. }
  7282. /*==========================================
  7283. * @me by lordalfa
  7284. * => Displays the OUTPUT string on top of the Visible players Heads.
  7285. *------------------------------------------*/
  7286. ACMD_FUNC(me)
  7287. {
  7288. char tempmes[CHAT_SIZE_MAX];
  7289. nullpo_retr(-1, sd);
  7290. memset(tempmes, '\0', sizeof(tempmes));
  7291. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7292. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  7293. return -1; //no "chatting" while muted.
  7294. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  7295. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  7296. return -1;
  7297. }
  7298. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  7299. clif_disp_overhead(&sd->bl, atcmd_output);
  7300. return 0;
  7301. }
  7302. /*==========================================
  7303. * @size
  7304. * => Resize your character sprite. [Valaris]
  7305. *------------------------------------------*/
  7306. ACMD_FUNC(size)
  7307. {
  7308. int32 size = SZ_SMALL;
  7309. nullpo_retr(-1, sd);
  7310. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  7311. if(sd->state.size) {
  7312. sd->state.size = SZ_SMALL;
  7313. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  7314. }
  7315. sd->state.size = size;
  7316. if( size == SZ_MEDIUM )
  7317. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  7318. else if( size == SZ_BIG )
  7319. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  7320. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7321. return 0;
  7322. }
  7323. ACMD_FUNC(sizeall)
  7324. {
  7325. int32 size;
  7326. map_session_data *pl_sd;
  7327. struct s_mapiterator* iter;
  7328. size = atoi(message);
  7329. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7330. iter = mapit_getallusers();
  7331. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  7332. if( pl_sd->state.size != size ) {
  7333. if( pl_sd->state.size ) {
  7334. pl_sd->state.size = SZ_SMALL;
  7335. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7336. }
  7337. pl_sd->state.size = size;
  7338. if( size == SZ_MEDIUM )
  7339. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7340. else if( size == SZ_BIG )
  7341. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7342. }
  7343. }
  7344. mapit_free(iter);
  7345. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7346. return 0;
  7347. }
  7348. ACMD_FUNC(sizeguild)
  7349. {
  7350. int32 size = SZ_SMALL, i;
  7351. char guild[NAME_LENGTH];
  7352. map_session_data *pl_sd;
  7353. nullpo_retr(-1, sd);
  7354. memset(guild, '\0', sizeof(guild));
  7355. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  7356. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  7357. return -1;
  7358. }
  7359. auto g = guild_searchnameid(guild);
  7360. if (!g) {
  7361. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  7362. return -1;
  7363. }
  7364. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7365. for( i = 0; i < g->guild.max_member; i++ ) {
  7366. if( (pl_sd = g->guild.member[i].sd) && pl_sd->state.size != size ) {
  7367. if( pl_sd->state.size ) {
  7368. pl_sd->state.size = SZ_SMALL;
  7369. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7370. }
  7371. pl_sd->state.size = size;
  7372. if( size == SZ_MEDIUM )
  7373. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7374. else if( size == SZ_BIG )
  7375. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7376. }
  7377. }
  7378. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7379. return 0;
  7380. }
  7381. /*==========================================
  7382. * @monsterignore
  7383. * => Makes monsters ignore you. [Valaris]
  7384. *------------------------------------------*/
  7385. ACMD_FUNC(monsterignore)
  7386. {
  7387. nullpo_retr(-1, sd);
  7388. if (sd->state.block_action & PCBLOCK_IMMUNE) {
  7389. sd->state.block_action &= ~PCBLOCK_IMMUNE;
  7390. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  7391. } else {
  7392. sd->state.block_action |= PCBLOCK_IMMUNE;
  7393. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  7394. }
  7395. return 0;
  7396. }
  7397. /*==========================================
  7398. * @fakename
  7399. * => Gives your character a fake name. [Valaris]
  7400. *------------------------------------------*/
  7401. ACMD_FUNC(fakename)
  7402. {
  7403. nullpo_retr(-1, sd);
  7404. if( !message || !*message )
  7405. {
  7406. if( sd->fakename[0] )
  7407. {
  7408. sd->fakename[0] = '\0';
  7409. clif_name_area(&sd->bl);
  7410. if (sd->disguise)
  7411. clif_name_self(&sd->bl);
  7412. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7413. return 0;
  7414. }
  7415. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7416. return -1;
  7417. }
  7418. if( strlen(message) < 2 )
  7419. {
  7420. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7421. return -1;
  7422. }
  7423. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7424. clif_name_area(&sd->bl);
  7425. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  7426. clif_name_self(&sd->bl);
  7427. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7428. return 0;
  7429. }
  7430. /*==========================================
  7431. * Ragnarok Resources
  7432. *------------------------------------------*/
  7433. ACMD_FUNC(mapflag) {
  7434. char flag_name[50];
  7435. short flag = 0, i, j;
  7436. std::string buf;
  7437. nullpo_retr(-1, sd);
  7438. memset(flag_name, '\0', sizeof(flag_name));
  7439. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  7440. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7441. clif_displaymessage(sd->fd,"----------------------------------");
  7442. for( i = MF_MIN; i < MF_MAX; i++ ){
  7443. union u_mapflag_args args = {};
  7444. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  7445. clif_displaymessage(sd->fd, flag_name);
  7446. }
  7447. }
  7448. clif_displaymessage(sd->fd," ");
  7449. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7450. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7451. return 1;
  7452. }
  7453. // Check if the list of mapflags was requested
  7454. if( strcasecmp(flag_name,"available") ){
  7455. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7456. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  7457. if( mapflag != MF_INVALID ){
  7458. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  7459. MF_PVP_NIGHTMAREDROP,
  7460. MF_RESTRICTED,
  7461. MF_NOCOMMAND,
  7462. MF_BEXP,
  7463. MF_JEXP,
  7464. MF_BATTLEGROUND,
  7465. MF_SKILL_DAMAGE,
  7466. MF_SKILL_DURATION };
  7467. if (flag > 0 && util::vector_exists(disabled_mf, mapflag)) {
  7468. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  7469. clif_displaymessage(sd->fd,atcmd_output);
  7470. } else {
  7471. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  7472. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  7473. clif_displaymessage(sd->fd,atcmd_output);
  7474. }
  7475. return 0;
  7476. }else{
  7477. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  7478. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  7479. return 1;
  7480. }
  7481. }
  7482. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7483. clif_displaymessage(sd->fd,"----------------------------------");
  7484. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  7485. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  7486. buf.append(flag_name);
  7487. if( (i + 1) < MF_MAX )
  7488. buf.append(", ");
  7489. j++;
  7490. }
  7491. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  7492. clif_displaymessage(sd->fd, buf.c_str() );
  7493. buf.clear();
  7494. j = 0;
  7495. }
  7496. }
  7497. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7498. return 0;
  7499. }
  7500. /*===================================
  7501. * Remove some messages
  7502. *-----------------------------------*/
  7503. ACMD_FUNC(showexp)
  7504. {
  7505. if (sd->state.showexp) {
  7506. sd->state.showexp = 0;
  7507. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7508. return 0;
  7509. }
  7510. sd->state.showexp = 1;
  7511. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7512. return 0;
  7513. }
  7514. ACMD_FUNC(showzeny)
  7515. {
  7516. if (sd->state.showzeny) {
  7517. sd->state.showzeny = 0;
  7518. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7519. return 0;
  7520. }
  7521. sd->state.showzeny = 1;
  7522. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7523. return 0;
  7524. }
  7525. ACMD_FUNC(showdelay)
  7526. {
  7527. if (sd->state.showdelay) {
  7528. sd->state.showdelay = 0;
  7529. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7530. return 0;
  7531. }
  7532. sd->state.showdelay = 1;
  7533. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7534. return 0;
  7535. }
  7536. /*==========================================
  7537. * Duel organizing functions [LuzZza]
  7538. *
  7539. * @duel [limit|nick] - create a duel
  7540. * @invite <nick> - invite player
  7541. * @accept - accept invitation
  7542. * @reject - reject invitation
  7543. * @leave - leave duel
  7544. *------------------------------------------*/
  7545. ACMD_FUNC(invite)
  7546. {
  7547. size_t did = sd->duel_group;
  7548. map_session_data *target_sd = nullptr;
  7549. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7550. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7551. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7552. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7553. clif_displaymessage(fd, atcmd_output);
  7554. return -1;
  7555. }
  7556. if(did == 0 || !duel_exist(did) ) {
  7557. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7558. return 0;
  7559. }
  7560. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7561. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7562. return 0;
  7563. }
  7564. if((target_sd = map_nick2sd(atcmd_player_name, true)) == nullptr) {
  7565. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7566. return 0;
  7567. }
  7568. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7569. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7570. return 0;
  7571. }
  7572. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7573. {
  7574. 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.
  7575. clif_displaymessage(fd, atcmd_output);
  7576. return 0;
  7577. }
  7578. duel_invite(did, sd, target_sd);
  7579. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7580. return 0;
  7581. }
  7582. ACMD_FUNC(duel)
  7583. {
  7584. uint32 maxpl = 0;
  7585. if(sd->duel_group > 0) {
  7586. duel_showinfo(sd->duel_group, sd);
  7587. return 0;
  7588. }
  7589. if(sd->duel_invite > 0) {
  7590. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7591. return 0;
  7592. }
  7593. if(!duel_checktime(sd)) {
  7594. char output[CHAT_SIZE_MAX];
  7595. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7596. clif_displaymessage(fd, output);
  7597. return 0;
  7598. }
  7599. if( message[0] ) {
  7600. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7601. if(maxpl < 2 || maxpl > 65535) {
  7602. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7603. return 0;
  7604. }
  7605. duel_create(sd, maxpl);
  7606. } else {
  7607. map_session_data *target_sd = nullptr;
  7608. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7609. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7610. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7611. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7612. clif_displaymessage(fd, atcmd_output);
  7613. return -1;
  7614. }
  7615. target_sd = map_nick2sd(atcmd_player_name,true);
  7616. if(target_sd != nullptr) {
  7617. size_t newduel;
  7618. if((newduel = duel_create(sd, 2)) != -1) {
  7619. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7620. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7621. return 0;
  7622. }
  7623. duel_invite(newduel, sd, target_sd);
  7624. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7625. }
  7626. } else {
  7627. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7628. return 0;
  7629. }
  7630. }
  7631. } else
  7632. duel_create(sd, 0);
  7633. return 0;
  7634. }
  7635. ACMD_FUNC(leave)
  7636. {
  7637. if(sd->duel_group <= 0) {
  7638. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7639. return 0;
  7640. }
  7641. duel_leave(sd->duel_group, sd);
  7642. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7643. return 0;
  7644. }
  7645. ACMD_FUNC(accept)
  7646. {
  7647. if(!duel_checktime(sd)) {
  7648. char output[CHAT_SIZE_MAX];
  7649. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7650. clif_displaymessage(fd, output);
  7651. return 0;
  7652. }
  7653. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7654. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7655. return 0;
  7656. }
  7657. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7658. {
  7659. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7660. return 0;
  7661. }
  7662. duel_accept(sd->duel_invite, sd);
  7663. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7664. return 0;
  7665. }
  7666. ACMD_FUNC(reject)
  7667. {
  7668. if(sd->duel_invite <= 0) {
  7669. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7670. return 0;
  7671. }
  7672. duel_reject(sd->duel_invite, sd);
  7673. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7674. return 0;
  7675. }
  7676. /*===================================
  7677. * Cash Points
  7678. *-----------------------------------*/
  7679. ACMD_FUNC(cash)
  7680. {
  7681. char output[128];
  7682. int32 value;
  7683. int32 ret=0;
  7684. nullpo_retr(-1, sd);
  7685. // Since there is no cashpoint update packet we need to force updating like this
  7686. if( sd->state.cashshop_open ){
  7687. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7688. return -1;
  7689. }
  7690. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7691. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7692. return -1;
  7693. }
  7694. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7695. if( !strcmpi(parent_cmd,"cash") )
  7696. {
  7697. if( value > 0 ) {
  7698. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7699. // If this option is set, the message is already sent by pc function
  7700. if( !battle_config.cashshop_show_points ){
  7701. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7702. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7703. }
  7704. }
  7705. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7706. } else {
  7707. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7708. value = -sd->cashPoints;
  7709. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7710. // If this option is set, the message is already sent by pc function
  7711. if( !battle_config.cashshop_show_points ){
  7712. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7713. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7714. }
  7715. }
  7716. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7717. }
  7718. }
  7719. else
  7720. { // @points
  7721. if( value > 0 ) {
  7722. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7723. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7724. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7725. }
  7726. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7727. } else {
  7728. if (-value > sd->kafraPoints) //By command, if cash < value, force it to remove all
  7729. value = -sd->kafraPoints;
  7730. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7731. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7732. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7733. }
  7734. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7735. }
  7736. }
  7737. return 0;
  7738. }
  7739. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7740. ACMD_FUNC(clone)
  7741. {
  7742. int32 x=0,y=0,flag=0,master=0,i=0;
  7743. map_session_data *pl_sd=nullptr;
  7744. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7745. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7746. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7747. return 0;
  7748. }
  7749. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr) {
  7750. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7751. return 0;
  7752. }
  7753. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7754. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7755. return 0;
  7756. }
  7757. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7758. if (strcmpi(parent_cmd, "clone") == 0)
  7759. flag = 1;
  7760. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7761. flag = 2;
  7762. if(pc_isdead(sd)){
  7763. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7764. return 0;
  7765. }
  7766. master = sd->bl.id;
  7767. if (battle_config.atc_slave_clone_limit
  7768. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7769. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7770. return 0;
  7771. }
  7772. }
  7773. do {
  7774. x = sd->bl.x + rnd_value(-5, 5);
  7775. y = sd->bl.y + rnd_value(-5, 5);
  7776. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7777. if (i >= 10) {
  7778. x = sd->bl.x;
  7779. y = sd->bl.y;
  7780. }
  7781. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7782. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7783. return 0;
  7784. }
  7785. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7786. return 0;
  7787. }
  7788. /*=====================================
  7789. * Autorejecting Invites/Deals [LuzZza]
  7790. * Usage: @noask
  7791. *-------------------------------------*/
  7792. ACMD_FUNC(noask)
  7793. {
  7794. if(sd->state.noask) {
  7795. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7796. sd->state.noask = 0;
  7797. } else {
  7798. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7799. sd->state.noask = 1;
  7800. }
  7801. return 0;
  7802. }
  7803. /*=====================================
  7804. * Send a @request message to all GMs of lowest_gm_level.
  7805. * Usage: @request <petition>
  7806. *-------------------------------------*/
  7807. ACMD_FUNC(request)
  7808. {
  7809. if (!message || !*message) {
  7810. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7811. return -1;
  7812. }
  7813. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7814. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7815. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7816. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7817. return 0;
  7818. }
  7819. /*==========================================
  7820. * Feel (SG designated maps) Reset [HiddenDragon]
  7821. *------------------------------------------*/
  7822. ACMD_FUNC(feelreset)
  7823. {
  7824. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7825. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7826. return -1;
  7827. }
  7828. pc_resetfeel(sd);
  7829. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7830. return 0;
  7831. }
  7832. /*==========================================
  7833. * Hate (SG designated monsters) Reset
  7834. *------------------------------------------*/
  7835. ACMD_FUNC(hatereset)
  7836. {
  7837. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7838. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7839. return -1;
  7840. }
  7841. pc_resethate(sd);
  7842. clif_displaymessage(fd, msg_txt(sd,1515)); // Reset 'Hatred' monsters.
  7843. return 0;
  7844. }
  7845. /*==========================================
  7846. * AUCTION SYSTEM
  7847. *------------------------------------------*/
  7848. ACMD_FUNC(auction)
  7849. {
  7850. nullpo_ret(sd);
  7851. if (!battle_config.feature_auction) {
  7852. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7853. return 0;
  7854. }
  7855. clif_Auction_openwindow(sd);
  7856. return 0;
  7857. }
  7858. /*==========================================
  7859. * Kill Steal Protection
  7860. *------------------------------------------*/
  7861. ACMD_FUNC(ksprotection)
  7862. {
  7863. nullpo_retr(-1,sd);
  7864. if( sd->state.noks ) {
  7865. sd->state.noks = 0;
  7866. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7867. }
  7868. else
  7869. {
  7870. if( !message || !*message || !strcmpi(message, "party") )
  7871. { // Default is Party
  7872. sd->state.noks = 2;
  7873. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7874. }
  7875. else if( !strcmpi(message, "self") )
  7876. {
  7877. sd->state.noks = 1;
  7878. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7879. }
  7880. else if( !strcmpi(message, "guild") )
  7881. {
  7882. sd->state.noks = 3;
  7883. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7884. }
  7885. else
  7886. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7887. }
  7888. return 0;
  7889. }
  7890. /*==========================================
  7891. * Map Kill Steal Protection Setting
  7892. *------------------------------------------*/
  7893. ACMD_FUNC(allowks)
  7894. {
  7895. nullpo_retr(-1,sd);
  7896. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7897. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7898. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7899. } else {
  7900. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7901. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7902. }
  7903. return 0;
  7904. }
  7905. ACMD_FUNC(resetstat)
  7906. {
  7907. nullpo_retr(-1, sd);
  7908. pc_resetstate(sd);
  7909. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7910. clif_displaymessage(fd, atcmd_output);
  7911. return 0;
  7912. }
  7913. ACMD_FUNC(resetskill)
  7914. {
  7915. nullpo_retr(-1,sd);
  7916. pc_resetskill(sd,1);
  7917. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7918. clif_displaymessage(fd, atcmd_output);
  7919. return 0;
  7920. }
  7921. /*==========================================
  7922. * #storagelist: Displays the items list of a player's storage.
  7923. * #cartlist: Displays contents of target's cart.
  7924. * #itemlist: Displays contents of target's inventory.
  7925. *------------------------------------------*/
  7926. ACMD_FUNC(itemlist)
  7927. {
  7928. int32 i, j, count, counter;
  7929. const char* location;
  7930. struct item* items;
  7931. int32 size;
  7932. StringBuf buf;
  7933. nullpo_retr(-1, sd);
  7934. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7935. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7936. location = "storage";
  7937. items = sd->storage.u.items_storage;
  7938. size = sd->storage.max_amount;
  7939. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7940. location = "cart";
  7941. items = sd->cart.u.items_cart;
  7942. size = MAX_CART;
  7943. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7944. location = "inventory";
  7945. items = sd->inventory.u.items_inventory;
  7946. size = MAX_INVENTORY;
  7947. } else
  7948. return 1;
  7949. StringBuf_Init(&buf);
  7950. count = 0; // total slots occupied
  7951. counter = 0; // total items found
  7952. for( i = 0; i < size; ++i ) {
  7953. struct item* it = &items[i];
  7954. if( it->nameid == 0 )
  7955. continue;
  7956. std::shared_ptr<item_data> itd = item_db.find(it->nameid);
  7957. if (itd == nullptr)
  7958. continue;
  7959. counter += it->amount;
  7960. count++;
  7961. if( count == 1 ) {
  7962. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7963. clif_displaymessage(fd, StringBuf_Value(&buf));
  7964. StringBuf_Clear(&buf);
  7965. }
  7966. StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, item_db.create_item_link( *it ).c_str(), itd->name.c_str(), it->nameid);
  7967. if( it->equip ) {
  7968. char equipstr[CHAT_SIZE_MAX];
  7969. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7970. if( it->equip&EQP_GARMENT )
  7971. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7972. if( it->equip&EQP_ACC_L )
  7973. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7974. if( it->equip&EQP_ARMOR )
  7975. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7976. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7977. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7978. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7979. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7980. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7981. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7982. if( it->equip&EQP_SHOES )
  7983. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7984. if( it->equip&EQP_ACC_R )
  7985. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7986. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7987. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7988. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7989. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7990. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7991. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7992. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7993. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7994. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7995. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7996. if( (it->equip&EQP_HELM) == EQP_HELM )
  7997. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7998. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7999. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  8000. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  8001. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  8002. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  8003. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  8004. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  8005. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  8006. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  8007. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  8008. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  8009. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  8010. if( it->equip&EQP_COSTUME_GARMENT )
  8011. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  8012. //if( it->equip&EQP_COSTUME_FLOOR )
  8013. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  8014. if( it->equip&EQP_AMMO )
  8015. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  8016. if( it->equip&EQP_SHADOW_ARMOR )
  8017. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  8018. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  8019. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  8020. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  8021. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  8022. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  8023. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  8024. if( it->equip&EQP_SHADOW_SHOES )
  8025. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  8026. if( it->equip&EQP_SHADOW_ACC_R )
  8027. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  8028. if( it->equip&EQP_SHADOW_ACC_L )
  8029. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  8030. // remove final ', '
  8031. equipstr[strlen(equipstr) - 2] = '\0';
  8032. StringBuf_AppendStr(&buf, equipstr);
  8033. }
  8034. clif_displaymessage(fd, StringBuf_Value(&buf));
  8035. StringBuf_Clear(&buf);
  8036. if( it->card[0] == CARD0_PET ) { // pet egg
  8037. if (it->card[3]&1)
  8038. StringBuf_Printf(&buf, msg_txt(sd,1348), (uint32)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  8039. else
  8040. StringBuf_Printf(&buf, msg_txt(sd,1349), (uint32)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  8041. } else if(it->card[0] == CARD0_FORGE) { // forged item
  8042. 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)
  8043. } else if(it->card[0] == CARD0_CREATE) { // created item
  8044. StringBuf_Printf(&buf, msg_txt(sd,1351), (uint32)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  8045. } else { // normal item
  8046. int32 counter2 = 0;
  8047. for( j = 0; j < itd->slots; ++j ) {
  8048. if( it->card[j] == 0 )
  8049. continue;
  8050. std::shared_ptr<item_data> card = item_db.find(it->card[j]);
  8051. if (card == nullptr)
  8052. continue;
  8053. counter2++;
  8054. if( counter2 == 1 )
  8055. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  8056. if( counter2 != 1 )
  8057. StringBuf_AppendStr(&buf, ", ");
  8058. StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, item_db.create_item_link( card ).c_str(), card->nameid);
  8059. }
  8060. if( counter2 > 0 )
  8061. StringBuf_AppendStr(&buf, ")");
  8062. }
  8063. if( StringBuf_Length(&buf) > 0 )
  8064. clif_displaymessage(fd, StringBuf_Value(&buf));
  8065. StringBuf_Clear(&buf);
  8066. }
  8067. if( count == 0 )
  8068. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  8069. else
  8070. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  8071. clif_displaymessage(fd, StringBuf_Value(&buf));
  8072. StringBuf_Destroy(&buf);
  8073. return 0;
  8074. }
  8075. ACMD_FUNC(stats)
  8076. {
  8077. char job_jobname[100];
  8078. char output[CHAT_SIZE_MAX];
  8079. int32 i;
  8080. struct {
  8081. const char* format;
  8082. int32 value;
  8083. } output_table[] = {
  8084. { "Base Level - %d", 0 },
  8085. { nullptr, 0 },
  8086. { "Hp - %d", 0 },
  8087. { "MaxHp - %d", 0 },
  8088. { "Sp - %d", 0 },
  8089. { "MaxSp - %d", 0 },
  8090. { "Ap - %d", 0 },
  8091. { "MaxAp - %d", 0 },
  8092. { "Str - %3d", 0 },
  8093. { "Agi - %3d", 0 },
  8094. { "Vit - %3d", 0 },
  8095. { "Int - %3d", 0 },
  8096. { "Dex - %3d", 0 },
  8097. { "Luk - %3d", 0 },
  8098. { "Pow - %3d", 0 },
  8099. { "Sta - %3d", 0 },
  8100. { "Wis - %3d", 0 },
  8101. { "Spl - %3d", 0 },
  8102. { "Con - %3d", 0 },
  8103. { "Crt - %3d", 0 },
  8104. { "Zeny - %d", 0 },
  8105. { "Free Status Points - %d", 0 },
  8106. { "Free Trait Points - %d", 0 },
  8107. { "Free Skill Points - %d", 0 },
  8108. { "JobChangeLvl (2nd) - %d", 0 },
  8109. { "JobChangeLvl (3rd) - %d", 0 },
  8110. { "JobChangeLvl (4th) - %d", 0 },
  8111. { nullptr, 0 }
  8112. };
  8113. memset(job_jobname, '\0', sizeof(job_jobname));
  8114. memset(output, '\0', sizeof(output));
  8115. //direct array initialization with variables is not standard C compliant.
  8116. output_table[0].value = sd->status.base_level;
  8117. output_table[1].format = job_jobname;
  8118. output_table[1].value = sd->status.job_level;
  8119. output_table[2].value = sd->status.hp;
  8120. output_table[3].value = sd->status.max_hp;
  8121. output_table[4].value = sd->status.sp;
  8122. output_table[5].value = sd->status.max_sp;
  8123. output_table[6].value = sd->status.ap;
  8124. output_table[7].value = sd->status.max_ap;
  8125. output_table[8].value = sd->status.str;
  8126. output_table[9].value = sd->status.agi;
  8127. output_table[10].value = sd->status.vit;
  8128. output_table[11].value = sd->status.int_;
  8129. output_table[12].value = sd->status.dex;
  8130. output_table[13].value = sd->status.luk;
  8131. output_table[14].value = sd->status.pow;
  8132. output_table[15].value = sd->status.sta;
  8133. output_table[16].value = sd->status.wis;
  8134. output_table[17].value = sd->status.spl;
  8135. output_table[18].value = sd->status.con;
  8136. output_table[19].value = sd->status.crt;
  8137. output_table[20].value = sd->status.zeny;
  8138. output_table[21].value = sd->status.status_point;
  8139. output_table[22].value = sd->status.trait_point;
  8140. output_table[23].value = sd->status.skill_point;
  8141. output_table[24].value = sd->change_level_2nd;
  8142. output_table[25].value = sd->change_level_3rd;
  8143. output_table[26].value = sd->change_level_4th;
  8144. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  8145. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  8146. clif_displaymessage(fd, output);
  8147. for (i = 0; output_table[i].format != nullptr; i++) {
  8148. sprintf(output, output_table[i].format, output_table[i].value);
  8149. clif_displaymessage(fd, output);
  8150. }
  8151. return 0;
  8152. }
  8153. ACMD_FUNC(delitem)
  8154. {
  8155. char item_name[100];
  8156. int32 amount = 0, idx;
  8157. nullpo_retr(-1, sd);
  8158. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  8159. {
  8160. 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>).
  8161. return -1;
  8162. }
  8163. std::shared_ptr<item_data> id = item_db.searchname( item_name );
  8164. if( id == nullptr ){
  8165. id = item_db.find( strtoul( item_name, nullptr, 10 ) );
  8166. }
  8167. if( id == nullptr ){
  8168. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  8169. return -1;
  8170. }
  8171. t_itemid nameid = id->nameid;
  8172. int32 total = amount;
  8173. // delete items
  8174. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  8175. {
  8176. int32 delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  8177. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  8178. {// delete pet
  8179. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  8180. }
  8181. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  8182. amount-= delamount;
  8183. }
  8184. // notify target
  8185. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  8186. clif_displaymessage(sd->fd, atcmd_output);
  8187. // notify source
  8188. if( amount == total )
  8189. {
  8190. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  8191. }
  8192. else if( amount )
  8193. {
  8194. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  8195. clif_displaymessage(fd, atcmd_output);
  8196. }
  8197. else
  8198. {
  8199. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  8200. clif_displaymessage(fd, atcmd_output);
  8201. }
  8202. return 0;
  8203. }
  8204. /*==========================================
  8205. * Custom Fonts
  8206. *------------------------------------------*/
  8207. ACMD_FUNC(font)
  8208. {
  8209. int32 font_id;
  8210. nullpo_retr(-1,sd);
  8211. font_id = atoi(message);
  8212. if( font_id == 0 ) {
  8213. if( sd->status.font ) {
  8214. sd->status.font = 0;
  8215. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  8216. clif_font(sd);
  8217. } else {
  8218. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  8219. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  8220. }
  8221. } else if( font_id < 0 || font_id > 9 )
  8222. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  8223. else if( font_id != sd->status.font ) {
  8224. sd->status.font = font_id;
  8225. clif_font(sd);
  8226. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  8227. } else
  8228. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  8229. return 0;
  8230. }
  8231. /*==========================================
  8232. * type: 1 = commands (@), 2 = charcommands (#)
  8233. *------------------------------------------*/
  8234. static void atcommand_commands_sub(map_session_data* sd, const int32 fd, AtCommandType type)
  8235. {
  8236. char line_buff[CHATBOX_SIZE];
  8237. char* cur = line_buff;
  8238. AtCommandInfo* cmd;
  8239. DBIterator *iter = db_iterator(atcommand_db);
  8240. int32 count = 0;
  8241. memset(line_buff,' ',CHATBOX_SIZE);
  8242. line_buff[CHATBOX_SIZE-1] = 0;
  8243. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  8244. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  8245. switch( type ) {
  8246. case COMMAND_CHARCOMMAND:
  8247. if( cmd->char_groups[sd->group->index] == 0 )
  8248. continue;
  8249. break;
  8250. case COMMAND_ATCOMMAND:
  8251. if( cmd->at_groups[sd->group->index] == 0 )
  8252. continue;
  8253. break;
  8254. default:
  8255. continue;
  8256. }
  8257. size_t slen = strlen( cmd->command );
  8258. // flush the text buffer if this command won't fit into it
  8259. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8260. clif_displaymessage(fd,line_buff);
  8261. cur = line_buff;
  8262. memset(line_buff,' ',CHATBOX_SIZE);
  8263. line_buff[CHATBOX_SIZE-1] = 0;
  8264. }
  8265. memcpy(cur,cmd->command,slen);
  8266. cur += slen+(10-slen%10);
  8267. count++;
  8268. }
  8269. dbi_destroy(iter);
  8270. clif_displaymessage(fd,line_buff);
  8271. if ( atcmd_binding_count ) {
  8272. int32 i, count_bind, gm_lvl = pc_get_group_level(sd);
  8273. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  8274. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  8275. size_t slen = strlen( atcmd_binding[i]->command );
  8276. if ( count_bind == 0 ) {
  8277. cur = line_buff;
  8278. memset(line_buff,' ',CHATBOX_SIZE);
  8279. line_buff[CHATBOX_SIZE-1] = 0;
  8280. clif_displaymessage(fd, "-----------------");
  8281. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  8282. }
  8283. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8284. clif_displaymessage(fd,line_buff);
  8285. cur = line_buff;
  8286. memset(line_buff,' ',CHATBOX_SIZE);
  8287. line_buff[CHATBOX_SIZE-1] = 0;
  8288. }
  8289. memcpy(cur,atcmd_binding[i]->command,slen);
  8290. cur += slen+(10-slen%10);
  8291. count_bind++;
  8292. }
  8293. }
  8294. if ( count_bind )
  8295. clif_displaymessage(fd,line_buff);// last one
  8296. count += count_bind;
  8297. }
  8298. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  8299. clif_displaymessage(fd, atcmd_output);
  8300. return;
  8301. }
  8302. /*==========================================
  8303. * @commands Lists available @ commands to you
  8304. *------------------------------------------*/
  8305. ACMD_FUNC(commands)
  8306. {
  8307. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  8308. return 0;
  8309. }
  8310. /*==========================================
  8311. * @charcommands Lists available # commands to you
  8312. *------------------------------------------*/
  8313. ACMD_FUNC(charcommands) {
  8314. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  8315. return 0;
  8316. }
  8317. /* for new mounts */
  8318. ACMD_FUNC(mount2) {
  8319. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  8320. if (!sd->sc.getSCE(SC_ALL_RIDING)) {
  8321. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  8322. sc_start(nullptr, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  8323. } else {
  8324. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  8325. status_change_end(&sd->bl, SC_ALL_RIDING);
  8326. }
  8327. return 0;
  8328. }
  8329. ACMD_FUNC(accinfo) {
  8330. char query[NAME_LENGTH];
  8331. char type = 0; // type = 1, get only account name
  8332. if (!message || !*message || strlen(message) > NAME_LENGTH
  8333. || ( sscanf(message, "%23s %c", query, &type) < 1))
  8334. {
  8335. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  8336. 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".
  8337. return -1;
  8338. } else if (type != 0) {
  8339. type = type-'0'; //make it int32
  8340. if (type != 1) {
  8341. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  8342. return -1;
  8343. }
  8344. }
  8345. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  8346. return 0;
  8347. }
  8348. /**
  8349. * @set <variable name{[index]}>{ <value>}
  8350. *
  8351. * Gets or sets a value of a non server variable.
  8352. * If a value is specified it is used to set the variable's value,
  8353. * if not the variable's value is read.
  8354. * In any case it reads and displays the variable's value.
  8355. *
  8356. * Original implementation by Ind
  8357. */
  8358. ACMD_FUNC(set) {
  8359. char reg[46], val[128], name[32];
  8360. int32 toset = 0;
  8361. size_t len;
  8362. uint32 index;
  8363. bool is_str = false;
  8364. int64 uid;
  8365. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  8366. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  8367. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  8368. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  8369. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  8370. return -1;
  8371. }
  8372. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  8373. if( reg[0] == '.' ) {
  8374. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  8375. return -1;
  8376. } else if( reg[0] == '\'' ) {
  8377. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  8378. return -1;
  8379. }
  8380. // Check if the user wanted to set an array
  8381. if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
  8382. // The user did not specify array brackets, so we set the index to zero
  8383. index = 0;
  8384. }
  8385. is_str = is_string_variable(name);
  8386. if( ( len = strlen(val) ) > 1 ) {
  8387. if( val[0] == '"' && val[len-1] == '"') {
  8388. val[len-1] = '\0'; //Strip quotes.
  8389. memmove(val, val+1, len-1);
  8390. }
  8391. }
  8392. // Only set the variable if there is a value for it
  8393. if( toset >= 2 ){
  8394. if( is_str ){
  8395. setd_sub_str( nullptr, sd, name, index, val, nullptr );
  8396. }else{
  8397. setd_sub_num( nullptr, sd, name, index, strtoll( val, nullptr, 10 ), nullptr );
  8398. }
  8399. }
  8400. uid = reference_uid( add_str( name ), index );
  8401. if( is_str ) {// string variable
  8402. char* value;
  8403. switch( reg[0] ) {
  8404. case '@':
  8405. value = pc_readregstr(sd, uid);
  8406. break;
  8407. case '$':
  8408. value = mapreg_readregstr(uid);
  8409. break;
  8410. case '#':
  8411. if( reg[1] == '#' )
  8412. value = pc_readaccountreg2str(sd, uid);// global
  8413. else
  8414. value = pc_readaccountregstr(sd, uid);// local
  8415. break;
  8416. default:
  8417. value = pc_readglobalreg_str(sd, uid);
  8418. break;
  8419. }
  8420. if( value == nullptr || *value == '\0' ){// empty string
  8421. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  8422. }else{
  8423. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
  8424. }
  8425. } else {// integer variable
  8426. int64 value;
  8427. switch( reg[0] ) {
  8428. case '@':
  8429. value = pc_readreg(sd, uid);
  8430. break;
  8431. case '$':
  8432. value = mapreg_readreg(uid);
  8433. break;
  8434. case '#':
  8435. if( reg[1] == '#' )
  8436. value = pc_readaccountreg2(sd, uid);// global
  8437. else
  8438. value = pc_readaccountreg(sd, uid);// local
  8439. break;
  8440. default:
  8441. value = pc_readglobalreg(sd, uid);
  8442. break;
  8443. }
  8444. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
  8445. }
  8446. clif_displaymessage(fd, atcmd_output);
  8447. return 0;
  8448. }
  8449. ACMD_FUNC(addperm) {
  8450. int32 perm_size = ARRAYLENGTH(pc_g_permission_name);
  8451. bool add;
  8452. int32 i;
  8453. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  8454. add = (strcmpi(parent_cmd, "addperm") == 0);
  8455. if( !message || !*message ) {
  8456. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8457. clif_displaymessage(fd, atcmd_output);
  8458. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8459. for( i = 0; i < perm_size; i++ ) {
  8460. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8461. clif_displaymessage(fd, atcmd_output);
  8462. }
  8463. return -1;
  8464. }
  8465. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8466. if( i == perm_size ) {
  8467. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8468. clif_displaymessage(fd, atcmd_output);
  8469. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8470. for( i = 0; i < perm_size; i++ ) {
  8471. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8472. clif_displaymessage(fd, atcmd_output);
  8473. }
  8474. return -1;
  8475. }
  8476. if( add && pc_has_permission( sd, pc_g_permission_name[i].permission) ){
  8477. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8478. clif_displaymessage(fd, atcmd_output);
  8479. return -1;
  8480. }else if( !add && !pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8481. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8482. clif_displaymessage(fd, atcmd_output);
  8483. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8484. clif_displaymessage(fd, atcmd_output);
  8485. for( i = 0; i < perm_size; i++ ) {
  8486. if( pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8487. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8488. clif_displaymessage(fd, atcmd_output);
  8489. }
  8490. }
  8491. return -1;
  8492. }
  8493. if( add ){
  8494. sd->permissions.set( pc_g_permission_name[i].permission );
  8495. }else{
  8496. sd->permissions.reset( pc_g_permission_name[i].permission );
  8497. }
  8498. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8499. clif_displaymessage(fd, atcmd_output);
  8500. return 0;
  8501. }
  8502. ACMD_FUNC(unloadnpcfile) {
  8503. if( !message || !*message ) {
  8504. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8505. return -1;
  8506. }
  8507. if( npc_unloadfile(message) )
  8508. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8509. else {
  8510. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8511. return -1;
  8512. }
  8513. return 0;
  8514. }
  8515. ACMD_FUNC(cart) {
  8516. #define MC_CART_MDFY(idx, x) \
  8517. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8518. sd->status.skill[(idx)].lv = (x)?1:0; \
  8519. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8520. int32 val = atoi(message);
  8521. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8522. uint16 sk_idx = 0;
  8523. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8524. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8525. clif_displaymessage(fd, atcmd_output);
  8526. return -1;
  8527. }
  8528. if( val == 0 && !pc_iscarton(sd) ) {
  8529. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8530. return -1;
  8531. }
  8532. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8533. return -1;
  8534. if( need_skill ) {
  8535. MC_CART_MDFY(sk_idx,1);
  8536. }
  8537. if( !pc_setcart(sd, val) ) {
  8538. if( need_skill ) {
  8539. MC_CART_MDFY(sk_idx,0);
  8540. }
  8541. return -1;/* @cart failed */
  8542. }
  8543. if( need_skill ) {
  8544. MC_CART_MDFY(sk_idx,0);
  8545. }
  8546. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8547. return 0;
  8548. #undef MC_CART_MDFY
  8549. }
  8550. /* Channel System [Ind] */
  8551. ACMD_FUNC(join){
  8552. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8553. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8554. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8555. clif_displaymessage(fd, atcmd_output);
  8556. return -1;
  8557. }
  8558. return channel_pcjoin(sd, chname, pass);
  8559. }
  8560. /*
  8561. * Display available option for @channel command
  8562. * @command : the name of used command (for alias case)
  8563. */
  8564. static inline void atcmd_channel_help(map_session_data *sd, const char *command)
  8565. {
  8566. int32 fd = sd->fd;
  8567. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8568. bool can_create = (can_delete || channel_config.private_channel.allow);
  8569. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8570. //option create
  8571. if( can_create ) {
  8572. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8573. clif_displaymessage(fd, atcmd_output);
  8574. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8575. }
  8576. //option delete
  8577. if(can_delete){
  8578. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8579. clif_displaymessage(fd, atcmd_output);
  8580. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8581. }
  8582. //option list
  8583. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8584. clif_displaymessage(fd, atcmd_output);
  8585. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8586. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8587. clif_displaymessage(fd, atcmd_output);
  8588. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8589. if( can_create ) {
  8590. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8591. clif_displaymessage(fd, atcmd_output);
  8592. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8593. }
  8594. //option setcolor
  8595. if(can_create){
  8596. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8597. clif_displaymessage(fd, atcmd_output);
  8598. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8599. }
  8600. //option join
  8601. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8602. clif_displaymessage(fd, atcmd_output);
  8603. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8604. //option leave
  8605. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8606. clif_displaymessage(fd, atcmd_output);
  8607. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8608. //option bindto
  8609. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8610. clif_displaymessage(fd, atcmd_output);
  8611. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8612. //option unbind
  8613. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8614. clif_displaymessage(fd, atcmd_output);
  8615. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8616. //option ban/unban/banlist
  8617. if( can_create ) {
  8618. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8619. clif_displaymessage(fd, atcmd_output);
  8620. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8621. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8622. clif_displaymessage(fd, atcmd_output);
  8623. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8624. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8625. clif_displaymessage(fd, atcmd_output);
  8626. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8627. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8628. clif_displaymessage(fd, atcmd_output);
  8629. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8630. }
  8631. //option setopt
  8632. if(can_create){
  8633. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8634. clif_displaymessage(fd, atcmd_output);
  8635. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8636. }
  8637. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8638. clif_displaymessage(fd, atcmd_output);
  8639. }
  8640. ACMD_FUNC(channel) {
  8641. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8642. sub1[0] = sub2[0] = '\0';
  8643. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8644. atcmd_channel_help(sd,command);
  8645. return 0;
  8646. }
  8647. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8648. return channel_pcdelete(sd,sub1);
  8649. } else if ( strcmpi(key,"list") == 0 ) {
  8650. return channel_display_list(sd,sub1);
  8651. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8652. return channel_pccolor(sd, sub1, sub2);
  8653. } else if ( strcmpi(key,"join") == 0 ) {
  8654. return channel_pcjoin(sd, sub1, sub2);
  8655. }else if ( strcmpi(key,"leave") == 0 ) {
  8656. return channel_pcleave(sd, sub1);
  8657. } else if ( strcmpi(key,"bindto") == 0 ) {
  8658. return channel_pcbind(sd, sub1);
  8659. } else if ( strcmpi(key,"unbind") == 0 ) {
  8660. return channel_pcunbind(sd);
  8661. } else if ( strcmpi(key,"ban") == 0 ) {
  8662. return channel_pcban(sd,sub1,sub2,0);
  8663. } else if ( strcmpi(key,"kick") == 0 ) {
  8664. return channel_pckick(sd,sub1,sub2);
  8665. } else if ( strcmpi(key,"banlist") == 0 ) {
  8666. return channel_pcban(sd,sub1,nullptr,3);
  8667. } else if ( strcmpi(key,"unban") == 0 ) {
  8668. return channel_pcban(sd,sub1,sub2,1);
  8669. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8670. return channel_pcban(sd,sub1,nullptr,2);
  8671. } else {
  8672. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8673. sub3[0] = sub4[0] = '\0';
  8674. sscanf(sub2, "%19s %19s", sub3, sub4);
  8675. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8676. if (sub4[0] != '\0') {
  8677. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8678. return -1;
  8679. }
  8680. return channel_pccreate(sd,sub1,sub3);
  8681. } else if ( strcmpi(key,"setopt") == 0 ) {
  8682. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8683. }
  8684. atcmd_channel_help(sd,command);
  8685. }
  8686. return 0;
  8687. }
  8688. ACMD_FUNC(fontcolor)
  8689. {
  8690. if( !message || !*message ) {
  8691. channel_display_list(sd,"colors");
  8692. return -1;
  8693. }
  8694. if( strcmpi(message,"Normal") == 0 ) {
  8695. sd->fontcolor = 0;
  8696. } else {
  8697. unsigned char k;
  8698. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8699. if( k == channel_config.colors_count ) {
  8700. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8701. clif_displaymessage(fd, atcmd_output);
  8702. return -1;
  8703. }
  8704. sd->fontcolor = k;
  8705. }
  8706. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8707. clif_displaymessage(fd, atcmd_output);
  8708. return 0;
  8709. }
  8710. ACMD_FUNC(langtype)
  8711. {
  8712. char langstr[8];
  8713. int32 i=0, fail=0;
  8714. memset(langstr, '\0', sizeof(langstr));
  8715. if(sscanf(message, "%3s", langstr) >= 1){
  8716. int32 lang=0;
  8717. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8718. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8719. char output[100];
  8720. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8721. sd->langtype = lang;
  8722. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8723. clif_displaymessage(fd,output);
  8724. return 0;
  8725. } else if (lang != -1) { //defined langage but failed check
  8726. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8727. return -1;
  8728. }
  8729. }
  8730. //wrong or no entry
  8731. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8732. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8733. while(fail != -1){ //out of range
  8734. fail = msg_checklangtype(i,false);
  8735. if(fail == 1)
  8736. clif_displaymessage(fd,msg_langtype2langstr(i));
  8737. i++;
  8738. }
  8739. return -1;
  8740. }
  8741. #ifdef VIP_ENABLE
  8742. ACMD_FUNC(vip) {
  8743. map_session_data* pl_sd = nullptr;;
  8744. char * modif_p;
  8745. int32 vipdifftime = 0;
  8746. time_t now=time(nullptr);
  8747. nullpo_retr(-1, sd);
  8748. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8749. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8750. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8751. return -1;
  8752. }
  8753. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8754. modif_p = atcmd_output;
  8755. vipdifftime = (int32)solve_time(modif_p);
  8756. if (vipdifftime == 0) {
  8757. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8758. 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.
  8759. return -1;
  8760. }
  8761. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  8762. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8763. return -1;
  8764. }
  8765. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8766. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8767. return -1;
  8768. }
  8769. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8770. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8771. if (pl_sd->vip.time <= now) {
  8772. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8773. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8774. } else {
  8775. int32 year,month,day,hour,minute,second;
  8776. char timestr[21];
  8777. split_time((int32)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8778. 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.
  8779. clif_displaymessage(pl_sd->fd,atcmd_output);
  8780. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8781. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8782. clif_displaymessage(pl_sd->fd,atcmd_output);
  8783. if (pl_sd != sd) {
  8784. 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.
  8785. clif_displaymessage(fd,atcmd_output);
  8786. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8787. clif_displaymessage(fd,atcmd_output);
  8788. }
  8789. }
  8790. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8791. return 0;
  8792. }
  8793. /** Enable/disable rate info */
  8794. ACMD_FUNC(showrate) {
  8795. nullpo_retr(-1,sd);
  8796. if (!sd->vip.disableshowrate) {
  8797. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8798. sd->vip.disableshowrate = 1;
  8799. } else {
  8800. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8801. sd->vip.disableshowrate = 0;
  8802. }
  8803. clif_displaymessage(fd,atcmd_output);
  8804. return 0;
  8805. }
  8806. #endif
  8807. ACMD_FUNC(fullstrip) {
  8808. int32 i;
  8809. TBL_PC *tsd;
  8810. nullpo_retr(-1,sd);
  8811. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8812. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8813. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8814. return -1;
  8815. }
  8816. if((tsd=map_nick2sd(atcmd_player_name,false)) == nullptr && (tsd=map_id2sd(atoi(atcmd_player_name))) == nullptr){
  8817. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8818. return -1;
  8819. }
  8820. for( i = 0; i < EQI_MAX; i++ ) {
  8821. if( tsd->equip_index[ i ] >= 0 )
  8822. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8823. }
  8824. return 0;
  8825. }
  8826. ACMD_FUNC(changedress){
  8827. sc_type name2id[] = {
  8828. SC_WEDDING,
  8829. SC_XMAS,
  8830. SC_SUMMER,
  8831. SC_DRESSUP,
  8832. SC_HANBOK,
  8833. SC_OKTOBERFEST
  8834. };
  8835. for( sc_type type : name2id ) {
  8836. if( sd->sc.getSCE(type) ) {
  8837. status_change_end( &sd->bl, type );
  8838. // You should only be able to have one - so we cancel here
  8839. break;
  8840. }
  8841. }
  8842. return 0;
  8843. }
  8844. ACMD_FUNC(costume) {
  8845. const char* names[] = {
  8846. "Wedding",
  8847. "Xmas",
  8848. "Summer",
  8849. "Summer2",
  8850. "Hanbok",
  8851. "Oktoberfest"
  8852. };
  8853. const int32 name2id[] = {
  8854. SC_WEDDING,
  8855. SC_XMAS,
  8856. SC_SUMMER,
  8857. SC_DRESSUP,
  8858. SC_HANBOK,
  8859. SC_OKTOBERFEST
  8860. };
  8861. unsigned short k = 0, len = ARRAYLENGTH(names);
  8862. if( !message || !*message ) {
  8863. for( k = 0; k < len; k++ ) {
  8864. if( sd->sc.getSCE(name2id[k]) ) {
  8865. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8866. clif_displaymessage(sd->fd, atcmd_output);
  8867. status_change_end(&sd->bl, (sc_type)name2id[k]);
  8868. return 0;
  8869. }
  8870. }
  8871. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8872. for( k = 0; k < len; k++ ) {
  8873. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8874. clif_displaymessage(sd->fd, atcmd_output);
  8875. }
  8876. return -1;
  8877. }
  8878. for( k = 0; k < len; k++ ) {
  8879. if( sd->sc.getSCE(name2id[k]) ) {
  8880. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8881. clif_displaymessage(sd->fd, atcmd_output);
  8882. return -1;
  8883. }
  8884. }
  8885. for( k = 0; k < len; k++ )
  8886. if( strcmpi(message, names[k]) == 0 )
  8887. break;
  8888. if( k == len ) {
  8889. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8890. clif_displaymessage(sd->fd, atcmd_output);
  8891. return -1;
  8892. }
  8893. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  8894. return 0;
  8895. }
  8896. /**
  8897. * Clone other player's equipments
  8898. * Usage: @cloneequip <char name/ID>
  8899. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8900. * @author [Cydh], [Antares]
  8901. */
  8902. ACMD_FUNC(cloneequip) {
  8903. map_session_data *pl_sd;
  8904. nullpo_retr(-1, sd);
  8905. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8906. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8907. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8908. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8909. clif_displaymessage(fd, atcmd_output);
  8910. return -1;
  8911. }
  8912. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8913. clif_displaymessage(fd, msg_txt(sd, 3));
  8914. return -1;
  8915. }
  8916. if (sd == pl_sd) {
  8917. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8918. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8919. clif_displaymessage(fd, atcmd_output);
  8920. return -1;
  8921. }
  8922. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8923. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8924. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8925. clif_displaymessage(fd, atcmd_output);
  8926. return -1;
  8927. }
  8928. else {
  8929. int8 i;
  8930. for (i = 0; i < EQI_MAX; i++) {
  8931. short idx;
  8932. char flag = 0;
  8933. struct item tmp_item;
  8934. if ((idx = pl_sd->equip_index[i]) < 0)
  8935. continue;
  8936. if (i == EQI_AMMO)
  8937. continue;
  8938. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8939. continue;
  8940. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8941. if (itemdb_isspecial(tmp_item.card[0]))
  8942. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8943. tmp_item.bound = 0;
  8944. tmp_item.expire_time = 0;
  8945. tmp_item.unique_id = 0;
  8946. tmp_item.favorite = 0;
  8947. tmp_item.amount = 1;
  8948. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8949. clif_additem(sd, 0, 0, flag);
  8950. else
  8951. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8952. }
  8953. }
  8954. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8955. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8956. clif_displaymessage(fd, atcmd_output);
  8957. return 0;
  8958. }
  8959. /**
  8960. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8961. * Usage: @clonestat <char name/ID>
  8962. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8963. * @author [Cydh], [Antares]
  8964. */
  8965. ACMD_FUNC(clonestat) {
  8966. map_session_data *pl_sd;
  8967. nullpo_retr(-1, sd);
  8968. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8969. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8970. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8971. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8972. clif_displaymessage(fd, atcmd_output);
  8973. return -1;
  8974. }
  8975. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8976. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8977. return -1;
  8978. }
  8979. if (sd == pl_sd) {
  8980. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8981. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8982. clif_displaymessage(fd, atcmd_output);
  8983. return -1;
  8984. }
  8985. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8986. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8987. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8988. clif_displaymessage(fd, atcmd_output);
  8989. return -1;
  8990. }
  8991. else {
  8992. uint8 i;
  8993. short max_status[PARAM_MAX] = {};
  8994. pc_resetstate(sd);
  8995. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE)) {
  8996. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  8997. if (i >= PARAM_POW && !(sd->class_ & JOBL_FOURTH))
  8998. continue;
  8999. max_status[i] = SHRT_MAX;
  9000. }
  9001. } else {
  9002. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  9003. if (i >= PARAM_POW && sd->class_ & JOBL_FOURTH)
  9004. continue;
  9005. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  9006. }
  9007. }
  9008. #define clonestat_check(cmd,stat)\
  9009. {\
  9010. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  9011. if (pl_sd->status.cmd > max_status[(stat)]) {\
  9012. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  9013. clif_displaymessage(fd, atcmd_output);\
  9014. sd->status.cmd = max_status[(stat)];\
  9015. }\
  9016. else\
  9017. sd->status.cmd = pl_sd->status.cmd;\
  9018. }
  9019. clonestat_check(str, PARAM_STR);
  9020. clonestat_check(agi, PARAM_AGI);
  9021. clonestat_check(vit, PARAM_VIT);
  9022. clonestat_check(int_, PARAM_INT);
  9023. clonestat_check(dex, PARAM_DEX);
  9024. clonestat_check(luk, PARAM_LUK);
  9025. for (i = PARAM_STR; i < PARAM_POW; i++) {
  9026. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  9027. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  9028. }
  9029. if (sd->class_ & JOBL_FOURTH) {
  9030. clonestat_check(pow, PARAM_POW);
  9031. clonestat_check(sta, PARAM_STA);
  9032. clonestat_check(wis, PARAM_WIS);
  9033. clonestat_check(spl, PARAM_SPL);
  9034. clonestat_check(con, PARAM_CON);
  9035. clonestat_check(crt, PARAM_CRT);
  9036. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  9037. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  9038. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  9039. }
  9040. }
  9041. status_calc_pc(sd, SCO_FORCE);
  9042. }
  9043. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9044. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  9045. clif_displaymessage(fd, atcmd_output);
  9046. #undef clonestat_check
  9047. return 0;
  9048. }
  9049. /**
  9050. * Adopt a character.
  9051. * Usage: @adopt <char name>
  9052. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  9053. */
  9054. ACMD_FUNC(adopt)
  9055. {
  9056. TBL_PC *b_sd;
  9057. enum adopt_responses response;
  9058. nullpo_retr(-1, sd);
  9059. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9060. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  9061. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  9062. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  9063. clif_displaymessage(fd, atcmd_output);
  9064. return -1;
  9065. }
  9066. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  9067. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  9068. return -1;
  9069. }
  9070. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  9071. if (response == ADOPT_ALLOWED) {
  9072. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  9073. b_sd->adopt_invite = sd->status.account_id;
  9074. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  9075. return 0;
  9076. }
  9077. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  9078. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  9079. return -1;
  9080. }
  9081. /**
  9082. * Opens the limited sale window.
  9083. * Usage: @limitedsale or client command /limitedsale on supported clients
  9084. */
  9085. ACMD_FUNC(limitedsale){
  9086. nullpo_retr(-1, sd);
  9087. clif_sale_open(sd);
  9088. return 0;
  9089. }
  9090. /**
  9091. * Displays camera information from the client.
  9092. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  9093. */
  9094. ACMD_FUNC(camerainfo){
  9095. nullpo_retr(-1, sd);
  9096. if( message == nullptr || message[0] == '\0' ){
  9097. clif_camerainfo( sd, true );
  9098. return 0;
  9099. }
  9100. float range = 0;
  9101. float rotation = 0;
  9102. float latitude = 0;
  9103. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  9104. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  9105. return -1;
  9106. }
  9107. clif_camerainfo( sd, false, range, rotation, latitude );
  9108. return 0;
  9109. }
  9110. ACMD_FUNC(resurrect) {
  9111. nullpo_retr(-1, sd);
  9112. if (!pc_revive_item(sd))
  9113. return -1;
  9114. return 0;
  9115. }
  9116. ACMD_FUNC(quest) {
  9117. uint8 i;
  9118. int32 quest_id = 0;
  9119. nullpo_retr(-1, sd);
  9120. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9121. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9122. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9123. clif_displaymessage(fd, atcmd_output);
  9124. return -1;
  9125. }
  9126. if (!quest_search(quest_id)) {
  9127. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9128. clif_displaymessage(fd, atcmd_output);
  9129. return -1;
  9130. }
  9131. const char* type[] = { "setquest", "erasequest", "completequest", "checkquest" };
  9132. ARR_FIND( 0, ARRAYLENGTH(type), i, strcmpi(command+1, type[i]) == 0 );
  9133. switch(i) {
  9134. case 0:
  9135. if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
  9136. sprintf(atcmd_output, msg_txt(sd,1507), quest_id); // Character already has quest %d.
  9137. clif_displaymessage(fd, atcmd_output);
  9138. return -1;
  9139. }
  9140. quest_add(sd, quest_id);
  9141. pc_show_questinfo(sd);
  9142. break;
  9143. case 1:
  9144. if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
  9145. sprintf(atcmd_output, msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
  9146. clif_displaymessage(fd, atcmd_output);
  9147. return -1;
  9148. }
  9149. quest_delete(sd, quest_id);
  9150. pc_show_questinfo(sd);
  9151. break;
  9152. case 2:
  9153. if (quest_check(sd, quest_id, HAVEQUEST) < 0)
  9154. quest_add(sd, quest_id);
  9155. if (quest_check(sd, quest_id, HAVEQUEST) < 2)
  9156. quest_update_status(sd, quest_id, Q_COMPLETE);
  9157. pc_show_questinfo(sd);
  9158. break;
  9159. case 3:
  9160. sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
  9161. clif_displaymessage(fd, atcmd_output);
  9162. sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST)); // HAVEQUEST : %d
  9163. clif_displaymessage(fd, atcmd_output);
  9164. sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING)); // HUNTING : %d
  9165. clif_displaymessage(fd, atcmd_output);
  9166. sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME)); // PLAYTIME : %d
  9167. clif_displaymessage(fd, atcmd_output);
  9168. break;
  9169. }
  9170. return 0;
  9171. }
  9172. /**
  9173. * Opens the refineUI
  9174. * Usage: @refineui
  9175. */
  9176. ACMD_FUNC(refineui)
  9177. {
  9178. nullpo_retr(-1, sd);
  9179. #if PACKETVER < 20161012
  9180. clif_displaymessage(fd, msg_txt(sd, 773)); // This command requires packet version 2016-10-12 or newer.
  9181. return -1;
  9182. #else
  9183. if( !battle_config.feature_refineui ){
  9184. clif_displaymessage(fd, msg_txt(sd, 774)); // This command is disabled via configuration.
  9185. return -1;
  9186. }
  9187. if( sd->state.refineui_open ){
  9188. clif_displaymessage(fd, msg_txt(sd, 775)); // You have already opened the refine UI.
  9189. return -1;
  9190. }
  9191. clif_refineui_open(sd);
  9192. return 0;
  9193. #endif
  9194. }
  9195. ACMD_FUNC( stylist ){
  9196. nullpo_retr(-1, sd);
  9197. #if PACKETVER < 20151104
  9198. clif_displaymessage( fd, msg_txt( sd, 798 ) ); // This command requires packet version 2015-11-04 or newer.
  9199. return -1;
  9200. #else
  9201. if( !battle_config.feature_stylist ){
  9202. clif_displaymessage( fd, msg_txt( sd, 774 ) ); // This command is disabled via configuration.
  9203. return -1;
  9204. }
  9205. if( sd->state.stylist_open ){
  9206. clif_displaymessage( fd, msg_txt( sd, 799 ) ); // You have already opened the stylist UI.
  9207. return -1;
  9208. }
  9209. clif_ui_open( *sd, OUT_UI_STYLIST, 0 );
  9210. return 0;
  9211. #endif
  9212. }
  9213. /**
  9214. * Add fame point(s) to a player
  9215. * Usage: @addfame <amount>
  9216. */
  9217. ACMD_FUNC(addfame)
  9218. {
  9219. nullpo_retr(-1, sd);
  9220. int32 famepoint = 0;
  9221. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9222. if (!message || !*message || sscanf(message, "%11d", &famepoint) < 1 || famepoint == 0) {
  9223. sprintf(atcmd_output, msg_txt(sd, 1516), command); // Usage: %s <fame points>.
  9224. clif_displaymessage(fd, atcmd_output);
  9225. return -1;
  9226. }
  9227. if (!pc_addfame(*sd, famepoint)) {
  9228. sprintf(atcmd_output, msg_txt(sd, 1517), job_name(sd->status.class_)); // Cannot add fame to class '%s'.
  9229. clif_displaymessage(fd, atcmd_output);
  9230. return -1;
  9231. }
  9232. sprintf(atcmd_output, msg_txt(sd, 1518), famepoint, sd->status.name); // %d points were added to '%s'.
  9233. clif_displaymessage(fd, atcmd_output);
  9234. return 0;
  9235. }
  9236. /**
  9237. * Opens the enchantgrade UI
  9238. * Usage: @enchantgradeui
  9239. */
  9240. ACMD_FUNC( enchantgradeui ){
  9241. nullpo_retr( -1, sd );
  9242. #if !( PACKETVER_MAIN_NUM >= 20200916 || PACKETVER_RE_NUM >= 20200724 )
  9243. sprintf( atcmd_output, msg_txt( sd, 798 ), "2020-07-24" ); // This command requires packet version %s or newer.
  9244. clif_displaymessage( fd, atcmd_output );
  9245. return -1;
  9246. #else
  9247. clif_ui_open( *sd, OUT_UI_ENCHANTGRADE, 0 );
  9248. return 0;
  9249. #endif
  9250. }
  9251. ACMD_FUNC( roulette ){
  9252. nullpo_retr( -1, sd );
  9253. #if PACKETVER < 20141022
  9254. sprintf( atcmd_output, msg_txt( sd, 798 ), "2014-10-22" ); // This command requires packet version %s or newer.
  9255. clif_displaymessage( fd, atcmd_output );
  9256. return -1;
  9257. #else
  9258. if( !battle_config.feature_roulette ){
  9259. clif_displaymessage( fd, msg_txt( sd, 1497 ) ); // Roulette is disabled
  9260. return -1;
  9261. }
  9262. clif_roulette_open( sd );
  9263. return 0;
  9264. #endif
  9265. }
  9266. /**
  9267. * Replaces a card ID in an equip
  9268. * Usage: @setcard <equip position> <slot> <card_id>
  9269. */
  9270. ACMD_FUNC(setcard)
  9271. {
  9272. nullpo_retr(-1, sd);
  9273. int32 position = 0, slot, card_id;
  9274. if (!message || !*message || sscanf(message, "%11d %11d %11d", &position, &slot, &card_id) < 3) {
  9275. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9276. 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>).
  9277. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  9278. clif_displaymessage(fd, atcmd_output);
  9279. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  9280. clif_displaymessage(fd, atcmd_output);
  9281. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  9282. clif_displaymessage(fd, atcmd_output);
  9283. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  9284. clif_displaymessage(fd, atcmd_output);
  9285. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  9286. clif_displaymessage(fd, atcmd_output);
  9287. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  9288. clif_displaymessage(fd, atcmd_output);
  9289. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  9290. clif_displaymessage(fd, atcmd_output);
  9291. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  9292. clif_displaymessage(fd, atcmd_output);
  9293. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  9294. clif_displaymessage(fd, atcmd_output);
  9295. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  9296. return -1;
  9297. }
  9298. if (position < EQP_HEAD_LOW || position > EQP_HEAD_MID) {
  9299. clif_displaymessage(fd, msg_txt(sd,1531)); // Invalid position.
  9300. return -1;
  9301. }
  9302. if (slot < 0 || slot >= MAX_SLOTS) {
  9303. clif_displaymessage(fd, msg_txt(sd,1532)); // Invalid slot number.
  9304. return -1;
  9305. }
  9306. if (card_id != 0) {
  9307. std::shared_ptr<item_data> item_data = item_db.find( card_id );
  9308. if (item_data == nullptr) {
  9309. clif_displaymessage(fd, msg_txt(sd,1530)); // Invalid card ID.
  9310. return -1;
  9311. }
  9312. if (item_data->type != IT_CARD) {
  9313. clif_displaymessage(fd, msg_txt(sd,1529)); // The item type must be a card or enchant.
  9314. return -1;
  9315. }
  9316. }
  9317. int16 i = pc_checkequip(sd, position);
  9318. if (i < 0) {
  9319. clif_displaymessage(fd, msg_txt(sd,1528)); // You are not wearing any equipment in this position.
  9320. return -1;
  9321. }
  9322. int32 current_position = sd->inventory.u.items_inventory[i].equip;
  9323. pc_unequipitem(sd, i, 3);
  9324. log_pick_pc( sd, LOG_TYPE_COMMAND, -1, &sd->inventory.u.items_inventory[i] );
  9325. sd->inventory.u.items_inventory[i].card[slot] = card_id;
  9326. log_pick_pc( sd, LOG_TYPE_COMMAND, 1, &sd->inventory.u.items_inventory[i] );
  9327. clif_delitem( *sd, i, 1, 0 );
  9328. clif_additem(sd, i, 1, 0);
  9329. pc_equipitem(sd, i, current_position);
  9330. return 0;
  9331. }
  9332. #include <custom/atcommand.inc>
  9333. /**
  9334. * Fills the reference of available commands in atcommand DBMap
  9335. **/
  9336. #define ACMD_DEF(x) { #x, atcommand_ ## x, nullptr, nullptr, ATCMD_NO_WITHOUT_SD }
  9337. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, nullptr, nullptr, ATCMD_NO_WITHOUT_SD }
  9338. // Define with restriction
  9339. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, nullptr, nullptr, r }
  9340. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, nullptr, nullptr, r }
  9341. void atcommand_basecommands(void) {
  9342. /**
  9343. * Command reference list, place the base of your commands here
  9344. **/
  9345. AtCommandInfo atcommand_base[] = {
  9346. #include <custom/atcommand_def.inc>
  9347. ACMD_DEF2("warp", mapmove),
  9348. ACMD_DEF(where),
  9349. ACMD_DEF(jumpto),
  9350. ACMD_DEF(jump),
  9351. ACMD_DEF(who),
  9352. ACMD_DEF2("who2", who),
  9353. ACMD_DEF2("who3", who),
  9354. ACMD_DEF2("whomap", who),
  9355. ACMD_DEF2("whomap2", who),
  9356. ACMD_DEF2("whomap3", who),
  9357. ACMD_DEF(whogm),
  9358. ACMD_DEF(save),
  9359. ACMD_DEF(load),
  9360. ACMD_DEF(speed),
  9361. ACMD_DEF(storage),
  9362. ACMD_DEF(guildstorage),
  9363. ACMD_DEF(option),
  9364. ACMD_DEF(hide), // + /hide
  9365. ACMD_DEF(resetcooltime), // + /resetcooltime
  9366. ACMD_DEF(jobchange),
  9367. ACMD_DEF(kill),
  9368. ACMD_DEF(alive),
  9369. ACMD_DEF(kami),
  9370. ACMD_DEF2("kamib", kami),
  9371. ACMD_DEF2("kamic", kami),
  9372. ACMD_DEF2("lkami", kami),
  9373. ACMD_DEF(heal),
  9374. ACMD_DEF(healap),
  9375. ACMD_DEF(item),
  9376. ACMD_DEF(item2),
  9377. ACMD_DEF2("itembound",item),
  9378. ACMD_DEF2("itembound2",item2),
  9379. ACMD_DEF(itemreset),
  9380. ACMD_DEF(clearstorage),
  9381. ACMD_DEF(cleargstorage),
  9382. ACMD_DEF(clearcart),
  9383. ACMD_DEF2("blvl", baselevelup),
  9384. ACMD_DEF2("jlvl", joblevelup),
  9385. ACMD_DEF(help),
  9386. ACMD_DEF(pvpoff),
  9387. ACMD_DEF(pvpon),
  9388. ACMD_DEF(gvgoff),
  9389. ACMD_DEF(gvgon),
  9390. ACMD_DEF(model),
  9391. ACMD_DEFR(go),
  9392. ACMD_DEF(monster),
  9393. ACMD_DEF2("monstersmall", monster),
  9394. ACMD_DEF2("monsterbig", monster),
  9395. ACMD_DEF(killmonster),
  9396. ACMD_DEF2("killmonster2", killmonster),
  9397. ACMD_DEF(refine),
  9398. ACMD_DEF(grade),
  9399. ACMD_DEF(produce),
  9400. ACMD_DEF(memo),
  9401. ACMD_DEF(gat),
  9402. ACMD_DEF(displaystatus),
  9403. ACMD_DEF2("stpoint", statuspoint),
  9404. ACMD_DEF2("trpoint", traitpoint),
  9405. ACMD_DEF2("skpoint", skillpoint),
  9406. ACMD_DEF(zeny),
  9407. ACMD_DEF2("str", param),
  9408. ACMD_DEF2("agi", param),
  9409. ACMD_DEF2("vit", param),
  9410. ACMD_DEF2("int", param),
  9411. ACMD_DEF2("dex", param),
  9412. ACMD_DEF2("luk", param),
  9413. ACMD_DEF2("pow", param),
  9414. ACMD_DEF2("sta", param),
  9415. ACMD_DEF2("wis", param),
  9416. ACMD_DEF2("spl", param),
  9417. ACMD_DEF2("con", param),
  9418. ACMD_DEF2("crt", param),
  9419. ACMD_DEF2("glvl", guildlevelup),
  9420. ACMD_DEF(makeegg),
  9421. ACMD_DEF(hatch),
  9422. ACMD_DEF(petfriendly),
  9423. ACMD_DEF(pethungry),
  9424. ACMD_DEF(petrename),
  9425. ACMD_DEF(recall), // + /recall
  9426. ACMD_DEF(night),
  9427. ACMD_DEF(day),
  9428. ACMD_DEF(doom),
  9429. ACMD_DEF(doommap),
  9430. ACMD_DEF(raise),
  9431. ACMD_DEF(raisemap),
  9432. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  9433. ACMD_DEF(kickall),
  9434. ACMD_DEF(allskill),
  9435. ACMD_DEF(questskill),
  9436. ACMD_DEF(lostskill),
  9437. ACMD_DEF(spiritball),
  9438. ACMD_DEF(soulball),
  9439. ACMD_DEF(party),
  9440. ACMD_DEF(guild),
  9441. ACMD_DEF(breakguild),
  9442. ACMD_DEF(agitstart),
  9443. ACMD_DEF(agitend),
  9444. ACMD_DEF(mapexit),
  9445. ACMD_DEF(idsearch),
  9446. ACMD_DEF(broadcast), // + /b and /nb
  9447. ACMD_DEF(localbroadcast), // + /lb and /nlb
  9448. ACMD_DEF(recallall),
  9449. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  9450. ACMD_DEF2R("reloaditemdb", reload, ATCMD_NOSCRIPT),
  9451. ACMD_DEF2R("reloadcashdb", reload, ATCMD_NOSCRIPT),
  9452. ACMD_DEF2R("reloadmobdb", reload, ATCMD_NOSCRIPT),
  9453. ACMD_DEF2R("reloadskilldb", reload, ATCMD_NOSCRIPT),
  9454. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  9455. ACMD_DEF2R("reloadatcommand", reload, ATCMD_NOSCRIPT),
  9456. ACMD_DEF2R("reloadbattleconf", reload, ATCMD_NOSCRIPT),
  9457. ACMD_DEF2R("reloadstatusdb", reload, ATCMD_NOSCRIPT),
  9458. ACMD_DEF2R("reloadpcdb", reload, ATCMD_NOSCRIPT),
  9459. ACMD_DEF2R("reloadmotd", reload, ATCMD_NOSCRIPT),
  9460. ACMD_DEF2R("reloadquestdb", reload, ATCMD_NOSCRIPT),
  9461. ACMD_DEF2R("reloadmsgconf", reload, ATCMD_NOSCRIPT),
  9462. ACMD_DEF2R("reloadinstancedb", reload, ATCMD_NOSCRIPT),
  9463. ACMD_DEF2R("reloadachievementdb",reload, ATCMD_NOSCRIPT),
  9464. ACMD_DEF2R("reloadattendancedb",reload, ATCMD_NOSCRIPT),
  9465. ACMD_DEF2R("reloadbarterdb",reload, ATCMD_NOSCRIPT),
  9466. ACMD_DEF(partysharelvl),
  9467. ACMD_DEF(mapinfo),
  9468. ACMD_DEF(dye),
  9469. ACMD_DEF2("hairstyle", hair_style),
  9470. ACMD_DEF2("haircolor", hair_color),
  9471. ACMD_DEF2("allstats", stat_all),
  9472. ACMD_DEF2("alltraits", trait_all),
  9473. ACMD_DEF2("block", char_block),
  9474. ACMD_DEF2("ban", char_ban),
  9475. ACMD_DEF2("unblock", char_unblock),
  9476. ACMD_DEF2("unban", char_unban),
  9477. ACMD_DEF2("charban", char_ban),
  9478. ACMD_DEF2("charunban", char_unban),
  9479. ACMD_DEF2("mount", mount_peco),
  9480. ACMD_DEF(guildspy),
  9481. ACMD_DEF(partyspy),
  9482. ACMD_DEF(clanspy),
  9483. ACMD_DEF(repairall),
  9484. ACMD_DEF(guildrecall),
  9485. ACMD_DEF(partyrecall),
  9486. ACMD_DEF(nuke),
  9487. ACMD_DEF(shownpc),
  9488. ACMD_DEF(hidenpc),
  9489. ACMD_DEF(loadnpc),
  9490. ACMD_DEF(unloadnpc),
  9491. ACMD_DEF(reloadnpcfile),
  9492. ACMD_DEF2("time", servertime),
  9493. ACMD_DEF(jail),
  9494. ACMD_DEF(unjail),
  9495. ACMD_DEF(jailfor),
  9496. ACMD_DEF(jailtime),
  9497. ACMD_DEF(disguise),
  9498. ACMD_DEF(undisguise),
  9499. ACMD_DEF(email),
  9500. ACMD_DEF(effect),
  9501. ACMD_DEF(follow),
  9502. ACMD_DEF(addwarp),
  9503. ACMD_DEF(skillon),
  9504. ACMD_DEF(skilloff),
  9505. ACMD_DEF(killer),
  9506. ACMD_DEF(npcmove),
  9507. ACMD_DEF(killable),
  9508. ACMD_DEF(dropall),
  9509. ACMD_DEF(stockall),
  9510. ACMD_DEF(storeall),
  9511. ACMD_DEF(skillid),
  9512. ACMD_DEF(useskill),
  9513. ACMD_DEF(displayskill),
  9514. ACMD_DEF(displayskillcast),
  9515. ACMD_DEF(displayskillunit),
  9516. ACMD_DEF(snow),
  9517. ACMD_DEF(sakura),
  9518. ACMD_DEF(clouds),
  9519. ACMD_DEF(clouds2),
  9520. ACMD_DEF(fog),
  9521. ACMD_DEF(fireworks),
  9522. ACMD_DEF(leaves),
  9523. ACMD_DEF(summon),
  9524. ACMD_DEF(adjgroup),
  9525. ACMD_DEF(trade),
  9526. ACMD_DEF(send),
  9527. ACMD_DEF(setbattleflag),
  9528. ACMD_DEF(unmute),
  9529. ACMD_DEF(clearweather),
  9530. ACMD_DEF(uptime),
  9531. ACMD_DEF(changesex),
  9532. ACMD_DEF(changecharsex),
  9533. ACMD_DEF(mute),
  9534. ACMD_DEF(refresh),
  9535. ACMD_DEF(refreshall),
  9536. ACMD_DEF(identify),
  9537. ACMD_DEF(identifyall),
  9538. ACMD_DEF(gmotd),
  9539. ACMD_DEF(misceffect),
  9540. ACMD_DEF(mobsearch),
  9541. ACMD_DEF(cleanmap),
  9542. ACMD_DEF(cleanarea),
  9543. ACMD_DEF(npctalk),
  9544. ACMD_DEF(pettalk),
  9545. ACMD_DEF(users),
  9546. ACMD_DEF(reset),
  9547. ACMD_DEF(skilltree),
  9548. ACMD_DEF(marry),
  9549. ACMD_DEF(divorce),
  9550. ACMD_DEF(sound),
  9551. ACMD_DEF(undisguiseall),
  9552. ACMD_DEF(disguiseall),
  9553. ACMD_DEF(changelook),
  9554. ACMD_DEF(autoloot),
  9555. ACMD_DEF2("alootid", autolootitem),
  9556. ACMD_DEF(autoloottype),
  9557. ACMD_DEF(mobinfo),
  9558. ACMD_DEF(exp),
  9559. ACMD_DEF(version),
  9560. ACMD_DEF(mutearea),
  9561. ACMD_DEF(rates),
  9562. ACMD_DEF(iteminfo),
  9563. ACMD_DEF(whodrops),
  9564. ACMD_DEF(whereis),
  9565. ACMD_DEF(mapflag),
  9566. ACMD_DEF(me),
  9567. ACMD_DEF(monsterignore),
  9568. ACMD_DEF(fakename),
  9569. ACMD_DEF(size),
  9570. ACMD_DEF(showexp),
  9571. ACMD_DEF(showzeny),
  9572. ACMD_DEF(showdelay),
  9573. ACMD_DEF(autotrade),
  9574. ACMD_DEF(changegm),
  9575. ACMD_DEF(changeleader),
  9576. ACMD_DEF(partyoption),
  9577. ACMD_DEF(invite),
  9578. ACMD_DEF(duel),
  9579. ACMD_DEF(leave),
  9580. ACMD_DEF(accept),
  9581. ACMD_DEF(reject),
  9582. ACMD_DEF(clone),
  9583. ACMD_DEF2("slaveclone", clone),
  9584. ACMD_DEF2("evilclone", clone),
  9585. ACMD_DEF(tonpc),
  9586. ACMD_DEF(commands),
  9587. ACMD_DEF(noask),
  9588. ACMD_DEF(request),
  9589. ACMD_DEF(homlevel),
  9590. ACMD_DEF(homevolution),
  9591. ACMD_DEF(hommutate),
  9592. ACMD_DEF(makehomun),
  9593. ACMD_DEF(homfriendly),
  9594. ACMD_DEF(homhungry),
  9595. ACMD_DEF(homtalk),
  9596. ACMD_DEF(hominfo),
  9597. ACMD_DEF(homstats),
  9598. ACMD_DEF(homshuffle),
  9599. ACMD_DEF(showmobs),
  9600. ACMD_DEF(feelreset),
  9601. ACMD_DEF(hatereset),
  9602. ACMD_DEF(auction),
  9603. ACMD_DEF(mail),
  9604. ACMD_DEF2("noks", ksprotection),
  9605. ACMD_DEF(allowks),
  9606. ACMD_DEF(cash),
  9607. ACMD_DEF2("points", cash),
  9608. ACMD_DEF(agitstart2),
  9609. ACMD_DEF(agitend2),
  9610. ACMD_DEF(resetskill),
  9611. ACMD_DEF(resetstat),
  9612. ACMD_DEF2("storagelist", itemlist),
  9613. ACMD_DEF2("cartlist", itemlist),
  9614. ACMD_DEF2("itemlist", itemlist),
  9615. ACMD_DEF(stats),
  9616. ACMD_DEF(delitem),
  9617. ACMD_DEF(charcommands),
  9618. ACMD_DEF(font),
  9619. ACMD_DEF(accinfo),
  9620. ACMD_DEF(set),
  9621. ACMD_DEF(undisguiseguild),
  9622. ACMD_DEF(disguiseguild),
  9623. ACMD_DEF(sizeall),
  9624. ACMD_DEF(sizeguild),
  9625. ACMD_DEF(addperm),
  9626. ACMD_DEF2("rmvperm", addperm),
  9627. ACMD_DEF(unloadnpcfile),
  9628. ACMD_DEF(cart),
  9629. ACMD_DEF(mount2),
  9630. ACMD_DEF(join),
  9631. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  9632. ACMD_DEF(fontcolor),
  9633. ACMD_DEF(langtype),
  9634. #ifdef VIP_ENABLE
  9635. ACMD_DEF(vip),
  9636. ACMD_DEF(showrate),
  9637. #endif
  9638. ACMD_DEF(fullstrip),
  9639. ACMD_DEF(costume),
  9640. ACMD_DEF(cloneequip),
  9641. ACMD_DEF(clonestat),
  9642. ACMD_DEF(bodystyle),
  9643. ACMD_DEF(adopt),
  9644. ACMD_DEF(agitstart3),
  9645. ACMD_DEF(agitend3),
  9646. ACMD_DEF(limitedsale),
  9647. ACMD_DEF(changedress),
  9648. ACMD_DEF(camerainfo),
  9649. ACMD_DEF(resurrect),
  9650. ACMD_DEF2("setquest", quest),
  9651. ACMD_DEF2("erasequest", quest),
  9652. ACMD_DEF2("completequest", quest),
  9653. ACMD_DEF2("checkquest", quest),
  9654. ACMD_DEF(refineui),
  9655. ACMD_DEF(stylist),
  9656. ACMD_DEF(addfame),
  9657. ACMD_DEF(enchantgradeui),
  9658. ACMD_DEF(roulette),
  9659. ACMD_DEF(setcard),
  9660. };
  9661. AtCommandInfo* atcommand;
  9662. int32 i;
  9663. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9664. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9665. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9666. continue;
  9667. }
  9668. CREATE(atcommand, AtCommandInfo, 1);
  9669. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9670. atcommand->func = atcommand_base[i].func;
  9671. atcommand->restriction = atcommand_base[i].restriction;
  9672. strdb_put(atcommand_db, atcommand->command, atcommand);
  9673. }
  9674. return;
  9675. }
  9676. /*==========================================
  9677. * Command lookup functions
  9678. *------------------------------------------*/
  9679. bool atcommand_exists(const char* name)
  9680. {
  9681. return strdb_exists(atcommand_db, name);
  9682. }
  9683. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9684. {
  9685. if (strdb_exists(atcommand_db, name))
  9686. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9687. return nullptr;
  9688. }
  9689. /// AtCommand suggestion
  9690. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand) {
  9691. DBIterator* atcommand_iter;
  9692. AtCommandInfo* command_info = nullptr;
  9693. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9694. char* full_match[MAX_SUGGESTIONS];
  9695. char* suggestions[MAX_SUGGESTIONS];
  9696. char* match;
  9697. int32 prefix_count = 0, full_count = 0;
  9698. bool can_use;
  9699. if (!battle_config.atcommand_suggestions_enabled)
  9700. return;
  9701. atcommand_iter = db_iterator(atcommand_db);
  9702. // Build the matches
  9703. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  9704. match = strstr(command_info->command, name);
  9705. can_use = pc_can_use_command(sd, command_info->command, type);
  9706. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9707. suggestions[prefix_count] = command_info->command;
  9708. ++prefix_count;
  9709. }
  9710. if ( full_count < MAX_SUGGESTIONS && match != nullptr && match != command_info->command && can_use ) {
  9711. full_match[full_count] = command_info->command;
  9712. ++full_count;
  9713. }
  9714. }
  9715. for( auto& pair : atcommand_alias_db ){
  9716. std::shared_ptr<s_atcommand_alias_info> info = pair.second;
  9717. if( pc_can_use_command( sd, info->command->command, type ) ){
  9718. for( const std::string& alias_str : info->aliases ){
  9719. char* alias = const_cast<char *>(alias_str.c_str());
  9720. match = strstr( alias, name );
  9721. if( prefix_count < MAX_SUGGESTIONS && match == alias ){
  9722. suggestions[prefix_count] = alias;
  9723. ++prefix_count;
  9724. }
  9725. if( full_count < MAX_SUGGESTIONS && match != nullptr && match != alias ){
  9726. full_match[full_count] = alias;
  9727. ++full_count;
  9728. }
  9729. }
  9730. }
  9731. }
  9732. if ((full_count+prefix_count) > 0) {
  9733. char buffer[512];
  9734. int32 i;
  9735. // Merge full match and prefix match results
  9736. if (prefix_count < MAX_SUGGESTIONS) {
  9737. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9738. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9739. }
  9740. // Build the suggestion string
  9741. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  9742. strcat(buffer,"\n");
  9743. for(i=0; i < prefix_count; ++i) {
  9744. strcat(buffer,suggestions[i]);
  9745. strcat(buffer," ");
  9746. }
  9747. clif_displaymessage(sd->fd, buffer);
  9748. }
  9749. dbi_destroy(atcommand_iter);
  9750. }
  9751. /**
  9752. * Executes an at-command
  9753. * @param fd
  9754. * @param sd
  9755. * @param message
  9756. * @param type
  9757. * 0 : script call (atcommand)
  9758. * 1 : normal player @atcommand
  9759. * 2 : console (admin:@atcommand)
  9760. * 3 : script call (useatcmd)
  9761. */
  9762. bool is_atcommand(const int32 fd, map_session_data* sd, const char* message, int32 type)
  9763. {
  9764. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  9765. char output[CHAT_SIZE_MAX];
  9766. //Reconstructed message
  9767. char atcmd_msg[CHAT_SIZE_MAX * 2];
  9768. TBL_PC * ssd = nullptr; //sd for target
  9769. AtCommandInfo * info;
  9770. bool is_atcommand = true; // false if it's a charcommand
  9771. nullpo_retr(false, sd);
  9772. //Shouldn't happen
  9773. if ( !message || !*message )
  9774. return false;
  9775. //If cannot use atcomamnd while talking with NPC [Kichi]
  9776. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  9777. return false;
  9778. //Block NOCHAT but do not display it as a normal message
  9779. if ( sd->sc.getSCE(SC_NOCHAT) && sd->sc.getSCE(SC_NOCHAT)->val1&MANNER_NOCOMMAND )
  9780. return true;
  9781. // skip 10/11-langtype's codepage indicator, if detected
  9782. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9783. message += 3;
  9784. //Should display as a normal message
  9785. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9786. return false;
  9787. // type value 0|2 = script|console invoked: bypass restrictions
  9788. if ( type == 1 || type == 3) {
  9789. //Commands are disabled on maps flagged as 'nocommand'
  9790. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  9791. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  9792. return false;
  9793. }
  9794. }
  9795. if (*message == charcommand_symbol)
  9796. is_atcommand = false;
  9797. if (is_atcommand) { // @command
  9798. sprintf(atcmd_msg, "%s", message);
  9799. ssd = sd;
  9800. } else { // #command
  9801. char charname[NAME_LENGTH];
  9802. int32 n;
  9803. //Checks to see if #command has a name or a name + parameters.
  9804. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  9805. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  9806. ) {
  9807. if (pc_get_group_level(sd) == 0) {
  9808. if (n < 1)
  9809. return false; // No command found. Display as normal message.
  9810. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9811. 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
  9812. return false;
  9813. }
  9814. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9815. clif_displaymessage(fd, output);
  9816. return true;
  9817. }
  9818. ssd = map_nick2sd(charname,true);
  9819. if (ssd == nullptr) {
  9820. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9821. clif_displaymessage(fd, output);
  9822. return true;
  9823. }
  9824. if (n > 2)
  9825. sprintf(atcmd_msg, "%s %s", command, params);
  9826. else
  9827. sprintf(atcmd_msg, "%s", command);
  9828. }
  9829. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9830. sd->idletime = last_tick;
  9831. if (battle_config.hom_idle_no_share && sd->hd && battle_config.idletime_hom_option&IDLE_ATCOMMAND)
  9832. sd->idletime_hom = last_tick;
  9833. if (battle_config.mer_idle_no_share && sd->md && battle_config.idletime_mer_option&IDLE_ATCOMMAND)
  9834. sd->idletime_mer = last_tick;
  9835. //Clearing these to be used once more.
  9836. memset(command, '\0', sizeof(command));
  9837. memset(params, '\0', sizeof(params));
  9838. //check to see if any params exist within this command
  9839. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9840. params[0] = '\0';
  9841. if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
  9842. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9843. clif_displaymessage(fd, output);
  9844. return true;
  9845. }
  9846. // @commands (script based)
  9847. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9848. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9849. // Check if the binding isn't nullptr and there is a NPC event, level of usage met, et cetera
  9850. if( binding != nullptr && binding->npc_event[0] &&
  9851. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9852. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9853. {
  9854. // Check if self or character invoking; if self == character invoked, then self invoke.
  9855. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9856. return true;
  9857. }
  9858. }
  9859. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9860. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9861. if (info == nullptr) {
  9862. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9863. return false;
  9864. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9865. clif_displaymessage(fd, output);
  9866. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9867. return true;
  9868. }
  9869. //check restriction
  9870. if( info->restriction != ATCMD_NORESTRICTION ){
  9871. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9872. return true;
  9873. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9874. return true;
  9875. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9876. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9877. return true;
  9878. if( info->restriction&ATCMD_NOSCRIPT_PLAYERLESS && ( type == 0 || type == 3 ) && ( sd == dummy_sd || ssd == dummy_sd ) ){
  9879. return true;
  9880. }
  9881. }
  9882. // type == 1 : player invoked
  9883. if (type == 1) {
  9884. if ((is_atcommand && info->at_groups[sd->group->index] == 0) ||
  9885. (!is_atcommand && info->char_groups[sd->group->index] == 0) )
  9886. return false;
  9887. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9888. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9889. return true;
  9890. }
  9891. }
  9892. //Attempt to use the command
  9893. if ( (info->func(fd, ssd, command, params) != 0) )
  9894. {
  9895. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9896. clif_displaymessage(fd, output);
  9897. return true;
  9898. }
  9899. //Log only if successful.
  9900. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9901. return true;
  9902. }
  9903. void atcommand_db_load_groups(){
  9904. DBIterator *iter = db_iterator(atcommand_db);
  9905. AtCommandInfo* cmd;
  9906. size_t pc_group_max = player_group_db.size();
  9907. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9908. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9909. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9910. for( auto& it : player_group_db ){
  9911. cmd->at_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_ATCOMMAND );
  9912. cmd->char_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_CHARCOMMAND );
  9913. }
  9914. }
  9915. dbi_destroy(iter);
  9916. }
  9917. void atcommand_db_clear(void) {
  9918. if (atcommand_db != nullptr) {
  9919. DBIterator *iter = db_iterator(atcommand_db);
  9920. AtCommandInfo* cmd;
  9921. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9922. aFree(cmd->at_groups);
  9923. aFree(cmd->char_groups);
  9924. }
  9925. dbi_destroy(iter);
  9926. db_destroy(atcommand_db);
  9927. }
  9928. atcommand_alias_db.clear();
  9929. }
  9930. void atcommand_doload(void) {
  9931. atcommand_db_clear();
  9932. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9933. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9934. atcommand_alias_db.load();
  9935. }
  9936. void do_init_atcommand(void) {
  9937. atcommand_doload();
  9938. }
  9939. void do_final_atcommand(void) {
  9940. atcommand_db_clear();
  9941. }