atcommand.cpp 351 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653
  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 int atcommand_ ## x (const int fd, map_session_data* sd, const char* command, const char* message)
  56. typedef struct AtCommandInfo AtCommandInfo;
  57. int atcmd_binding_count = 0;
  58. /// Atcommand restriction usage
  59. enum e_atcmd_restict {
  60. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  61. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  62. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  63. };
  64. struct AtCommandInfo {
  65. char command[ATCOMMAND_LENGTH];
  66. AtCommandFunc func;
  67. char* at_groups; /// Quick @commands "can-use" lookup
  68. char* char_groups; /// Quick @charcommands "can-use" lookup
  69. uint8 restriction; /// Restrictions see enum e_restict
  70. };
  71. struct s_atcommand_alias_info{
  72. AtCommandInfo *command;
  73. std::set<std::string> aliases;
  74. std::string help;
  75. };
  76. char atcommand_symbol = '@'; // first char of the commands
  77. char charcommand_symbol = '#';
  78. static DBMap* atcommand_db = nullptr; //name -> AtCommandInfo
  79. static AtCommandInfo* get_atcommandinfo_byname( const char* name );
  80. class AtcommandAliasDatabase : public TypesafeYamlDatabase<std::string, s_atcommand_alias_info>{
  81. private:
  82. std::unordered_map<std::string, std::string> aliases;
  83. public:
  84. AtcommandAliasDatabase() : TypesafeYamlDatabase( "ATCOMMAND_DB", 1 ){
  85. }
  86. void clear() override;
  87. const std::string getDefaultLocation() override;
  88. uint64 parseBodyNode( const ryml::NodeRef& node ) override;
  89. // Additional
  90. const char* checkAlias( const char* alias );
  91. };
  92. void AtcommandAliasDatabase::clear(){
  93. TypesafeYamlDatabase::clear();
  94. this->aliases.clear();
  95. }
  96. const std::string AtcommandAliasDatabase::getDefaultLocation(){
  97. return std::string(conf_path) + "/atcommands.yml";
  98. }
  99. uint64 AtcommandAliasDatabase::parseBodyNode( const ryml::NodeRef& node ){
  100. std::string command;
  101. if( !this->asString( node, "Command", command ) ){
  102. return 0;
  103. }
  104. AtCommandInfo* commandinfo = get_atcommandinfo_byname( command.c_str() );
  105. if( commandinfo == nullptr ){
  106. this->invalidWarning( node["Command"], "Command %s does not exist.\n", command.c_str() );
  107. return 0;
  108. }
  109. std::shared_ptr<s_atcommand_alias_info> info = this->find( command );
  110. bool exists = info != nullptr;
  111. if( !exists ){
  112. info = std::make_shared<s_atcommand_alias_info>();
  113. info->command = commandinfo;
  114. }
  115. if( this->nodeExists( node, "Help" ) ){
  116. std::string help;
  117. if( !this->asString( node, "Help", help ) ){
  118. return 0;
  119. }
  120. info->help = help;
  121. }
  122. if( this->nodeExists( node, "Aliases" ) ){
  123. const auto& aliasesNode = node["Aliases"];
  124. if( !aliasesNode.is_seq() ){
  125. this->invalidWarning( aliasesNode, "Aliases should be a sequence.\n" );
  126. return 0;
  127. }
  128. for( const auto& subNode : aliasesNode ){
  129. std::string alias;
  130. subNode >> alias;
  131. info->aliases.insert( alias );
  132. this->aliases[alias] = command;
  133. }
  134. }
  135. if( !exists ){
  136. this->put( command, info );
  137. }
  138. return 1;
  139. }
  140. const char* AtcommandAliasDatabase::checkAlias( const char* alias ){
  141. std::string alias_str( alias );
  142. std::string* command = util::umap_find( this->aliases, alias_str );
  143. if( command == nullptr ){
  144. return alias;
  145. }else{
  146. return command->c_str();
  147. }
  148. }
  149. AtcommandAliasDatabase atcommand_alias_db;
  150. static char atcmd_output[CHAT_SIZE_MAX];
  151. static char atcmd_player_name[NAME_LENGTH];
  152. const char *parent_cmd;
  153. struct atcmd_binding_data** atcmd_binding;
  154. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  155. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand); // @help
  156. static void warp_get_suggestions(map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  157. // @commands (script-based)
  158. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  159. int i = 0;
  160. if( *name == atcommand_symbol || *name == charcommand_symbol )
  161. name++; // for backwards compatibility
  162. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  163. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : nullptr;
  164. }
  165. /**
  166. * retrieves the help string associated with a given command.
  167. *
  168. * @param name the name of the command to retrieve help information for
  169. * @return the string associated with the command, or nullptr
  170. */
  171. static const char* atcommand_help_string( const char* command ){
  172. // remove the prefix symbol for the raw name of the command
  173. if( *command == atcommand_symbol || *command == charcommand_symbol ){
  174. command++;
  175. }
  176. // convert alias to the real command name
  177. command = atcommand_alias_db.checkAlias( command );
  178. // attempt to find the first default help command
  179. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command );
  180. // failed to find the help property in the configuration file
  181. if( info == nullptr ){
  182. return nullptr;
  183. }
  184. // push the result from the method
  185. return info->help.c_str();
  186. }
  187. /*==========================================
  188. * @send (used for testing packet sends from the client)
  189. *------------------------------------------*/
  190. ACMD_FUNC(send)
  191. {
  192. int len=0,type;
  193. // read message type as hex number (without the 0x)
  194. if(!message || !*message ||
  195. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  196. || sscanf(message, "%8x", &type)==1) )
  197. {
  198. int i;
  199. for (i = 900; i <= 903; ++i)
  200. clif_displaymessage(fd, msg_txt(sd,i));
  201. return -1;
  202. }
  203. #define PARSE_ERROR(error,p) \
  204. {\
  205. clif_displaymessage(fd, (error));\
  206. sprintf(atcmd_output, ">%s", (p));\
  207. clif_displaymessage(fd, atcmd_output);\
  208. }
  209. //define PARSE_ERROR
  210. #define CHECK_EOS(p) \
  211. if(*(p) == 0){\
  212. clif_displaymessage(fd, "Unexpected end of string");\
  213. return -1;\
  214. }
  215. //define CHECK_EOS
  216. #define SKIP_VALUE(p) \
  217. {\
  218. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  219. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  220. }
  221. //define SKIP_VALUE
  222. #define GET_VALUE(p,num) \
  223. {\
  224. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  225. PARSE_ERROR("Invalid number in:",(p));\
  226. return -1;\
  227. }\
  228. }
  229. //define GET_VALUE
  230. if (type > 0 && type < MAX_PACKET_DB) {
  231. int off,end;
  232. long num;
  233. if(len)
  234. {// show packet length
  235. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  236. clif_displaymessage(fd, atcmd_output);
  237. return 0;
  238. }
  239. len=packet_db[type].len;
  240. off=2;
  241. if(len == 0)
  242. {// unknown packet - ERROR
  243. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  244. clif_displaymessage(fd, atcmd_output);
  245. return -1;
  246. } else if(len == -1)
  247. {// dynamic packet
  248. len=SHRT_MAX-4; // maximum length
  249. off=4;
  250. }
  251. WFIFOHEAD(fd, len);
  252. WFIFOW(fd,0)=TOW(type);
  253. // parse packet contents
  254. SKIP_VALUE(message);
  255. while(*message != 0 && off < len){
  256. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  257. {// default (byte)
  258. GET_VALUE(message,num);
  259. WFIFOB(fd,off)=TOB(num);
  260. ++off;
  261. } else if(TOUPPER(*message) == 'B')
  262. {// byte
  263. ++message;
  264. GET_VALUE(message,num);
  265. WFIFOB(fd,off)=TOB(num);
  266. ++off;
  267. } else if(TOUPPER(*message) == 'W')
  268. {// word (2 bytes)
  269. ++message;
  270. GET_VALUE(message,num);
  271. WFIFOW(fd,off)=TOW(num);
  272. off+=2;
  273. } else if(TOUPPER(*message) == 'L')
  274. {// long word (4 bytes)
  275. ++message;
  276. GET_VALUE(message,num);
  277. WFIFOL(fd,off)=TOL(num);
  278. off+=4;
  279. } else if(TOUPPER(*message) == 'S')
  280. {// string - escapes are valid
  281. // get string length - num <= 0 means not fixed length (default)
  282. ++message;
  283. if(*message == '"'){
  284. num=0;
  285. } else {
  286. GET_VALUE(message,num);
  287. while(*message != '"')
  288. {// find start of string
  289. if(*message == 0 || ISSPACE(*message)){
  290. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  291. return -1;
  292. }
  293. ++message;
  294. }
  295. }
  296. // parse string
  297. ++message;
  298. CHECK_EOS(message);
  299. end=(num<=0? 0: min(off+((int)num),len));
  300. for(; *message != '"' && (off < end || end == 0); ++off){
  301. if(*message == '\\'){
  302. ++message;
  303. CHECK_EOS(message);
  304. switch(*message){
  305. case 'a': num=0x07; break; // Bell
  306. case 'b': num=0x08; break; // Backspace
  307. case 't': num=0x09; break; // Horizontal tab
  308. case 'n': num=0x0A; break; // Line feed
  309. case 'v': num=0x0B; break; // Vertical tab
  310. case 'f': num=0x0C; break; // Form feed
  311. case 'r': num=0x0D; break; // Carriage return
  312. case 'e': num=0x1B; break; // Escape
  313. default: num=*message; break;
  314. case 'x': // Hexadecimal
  315. {
  316. ++message;
  317. CHECK_EOS(message);
  318. if(!ISXDIGIT(*message)){
  319. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  320. return -1;
  321. }
  322. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  323. if(ISXDIGIT(*message)){
  324. ++message;
  325. CHECK_EOS(message);
  326. num<<=8;
  327. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  328. }
  329. WFIFOB(fd,off)=TOB(num);
  330. ++message;
  331. CHECK_EOS(message);
  332. continue;
  333. }
  334. case '0':
  335. case '1':
  336. case '2':
  337. case '3':
  338. case '4':
  339. case '5':
  340. case '6':
  341. case '7': // Octal
  342. {
  343. num=*message-'0'; // 1st octal digit
  344. ++message;
  345. CHECK_EOS(message);
  346. if(ISDIGIT(*message) && *message < '8'){
  347. num<<=3;
  348. num+=*message-'0'; // 2nd octal digit
  349. ++message;
  350. CHECK_EOS(message);
  351. if(ISDIGIT(*message) && *message < '8'){
  352. num<<=3;
  353. num+=*message-'0'; // 3rd octal digit
  354. ++message;
  355. CHECK_EOS(message);
  356. }
  357. }
  358. WFIFOB(fd,off)=TOB(num);
  359. continue;
  360. }
  361. }
  362. } else
  363. num=*message;
  364. WFIFOB(fd,off)=TOB(num);
  365. ++message;
  366. CHECK_EOS(message);
  367. }//for
  368. while(*message != '"')
  369. {// ignore extra characters
  370. ++message;
  371. CHECK_EOS(message);
  372. }
  373. // terminate the string
  374. if(off < end)
  375. {// fill the rest with 0's
  376. memset(WFIFOP(fd,off),0,end-off);
  377. off=end;
  378. }
  379. } else
  380. {// unknown
  381. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  382. return -1;
  383. }
  384. SKIP_VALUE(message);
  385. }
  386. if(packet_db[type].len == -1)
  387. {// send dynamic packet
  388. WFIFOW(fd,2)=TOW(off);
  389. WFIFOSET(fd,off);
  390. } else
  391. {// send static packet
  392. if(off < len)
  393. memset(WFIFOP(fd,off),0,len-off);
  394. WFIFOSET(fd,len);
  395. }
  396. } else {
  397. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  398. return -1;
  399. }
  400. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  401. clif_displaymessage(fd, atcmd_output);
  402. return 0;
  403. #undef PARSE_ERROR
  404. #undef CHECK_EOS
  405. #undef SKIP_VALUE
  406. #undef GET_VALUE
  407. }
  408. /**
  409. * Retrieves map name suggestions for a given string.
  410. * This will first check if any map names contain the given string, and will
  411. * print out MAX_SUGGESTIONS results if any maps are found.
  412. * Otherwise, suggestions will be calculated through Levenshtein distance,
  413. * and up to 5 of the closest matches will be printed.
  414. *
  415. * @author Euphy
  416. */
  417. static void warp_get_suggestions(map_session_data* sd, const char *name) {
  418. // Minimum length for suggestions is 2 characters
  419. if( strlen( name ) < 2 ){
  420. return;
  421. }
  422. std::vector<const char*> suggestions;
  423. suggestions.reserve( MAX_SUGGESTIONS );
  424. // check for maps that contain string
  425. for (int i = 0; i < map_num; i++) {
  426. struct map_data *mapdata = map_getmapdata(i);
  427. // Prevent suggestion of instance mapnames
  428. if( mapdata->instance_id != 0 ){
  429. continue;
  430. }
  431. if( strstr( mapdata->name, name ) != nullptr ){
  432. suggestions.push_back( mapdata->name );
  433. if( suggestions.size() == MAX_SUGGESTIONS ){
  434. break;
  435. }
  436. }
  437. }
  438. // if no maps found, search by edit distance
  439. if( suggestions.empty() ){
  440. // Levenshtein > 4 is bad
  441. const int LEVENSHTEIN_MAX = 4;
  442. std::unordered_map<int, std::vector<const char*>> maps;
  443. for (int i = 0; i < map_num; i++) {
  444. struct map_data *mapdata = map_getmapdata(i);
  445. // Prevent suggestion of instance mapnames
  446. if(mapdata->instance_id != 0 ){
  447. continue;
  448. }
  449. // Calculate the levenshtein distance of the two strings
  450. int distance = levenshtein(mapdata->name, name);
  451. // Check if it is above the maximum defined distance
  452. if( distance > LEVENSHTEIN_MAX ){
  453. continue;
  454. }
  455. std::vector<const char*>& vector = maps[distance];
  456. // Do not add more entries than required
  457. if( vector.size() == MAX_SUGGESTIONS ){
  458. continue;
  459. }
  460. vector.push_back(mapdata->name);
  461. }
  462. for( int distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){
  463. std::vector<const char*>& vector = maps[distance];
  464. for( const char* found_map : vector ){
  465. suggestions.push_back( found_map );
  466. if( suggestions.size() == MAX_SUGGESTIONS ){
  467. break;
  468. }
  469. }
  470. if( suggestions.size() == MAX_SUGGESTIONS ){
  471. break;
  472. }
  473. }
  474. }
  475. // If no suggestion could be made, do not output anything at all
  476. if( suggestions.empty() ){
  477. return;
  478. }
  479. char buffer[CHAT_SIZE_MAX];
  480. // build the suggestion string
  481. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  482. strcat(buffer, "\n");
  483. for( const char* suggestion : suggestions ){
  484. strcat(buffer, suggestion);
  485. strcat(buffer, " ");
  486. }
  487. clif_displaymessage(sd->fd, buffer);
  488. }
  489. /*==========================================
  490. * @rura, @warp, @mapmove
  491. *------------------------------------------*/
  492. ACMD_FUNC(mapmove)
  493. {
  494. char map_name[MAP_NAME_LENGTH_EXT];
  495. unsigned short mapindex;
  496. short x = 0, y = 0;
  497. int16 m = -1;
  498. nullpo_retr(-1, sd);
  499. memset(map_name, '\0', sizeof(map_name));
  500. if (!message || !*message ||
  501. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  502. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  503. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  504. return -1;
  505. }
  506. mapindex = mapindex_name2idx(map_name, nullptr);
  507. if (mapindex)
  508. m = map_mapindex2mapid(mapindex);
  509. if (m < 0) { // m < 0 means on different server! [Kevin]
  510. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  511. if (battle_config.warp_suggestions_enabled)
  512. warp_get_suggestions(sd, map_name);
  513. return -1;
  514. }
  515. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  516. { //This is to prevent the pc_setpos call from printing an error.
  517. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  518. if (!map_search_freecell(nullptr, m, &x, &y, 10, 10, 1))
  519. x = y = 0; //Invalid cell, use random spot.
  520. }
  521. if ((map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, pc_get_group_level(sd))) {
  522. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  523. return -1;
  524. }
  525. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  526. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  527. return -1;
  528. }
  529. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  530. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  531. return -1;
  532. }
  533. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  534. return 0;
  535. }
  536. /*==========================================
  537. * Displays where a character is. Corrected version by Silent. [Skotlex]
  538. *------------------------------------------*/
  539. ACMD_FUNC(where)
  540. {
  541. map_session_data* pl_sd;
  542. nullpo_retr(-1, sd);
  543. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  544. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  545. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  546. return -1;
  547. }
  548. pl_sd = map_nick2sd(atcmd_player_name,true);
  549. if (pl_sd == nullptr ||
  550. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  551. (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  552. ) {
  553. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  554. return -1;
  555. }
  556. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  557. clif_displaymessage(fd, atcmd_output);
  558. return 0;
  559. }
  560. /*==========================================
  561. *
  562. *------------------------------------------*/
  563. ACMD_FUNC(jumpto)
  564. {
  565. map_session_data* pl_sd = nullptr;;
  566. nullpo_retr(-1, sd);
  567. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  568. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  569. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  570. return -1;
  571. }
  572. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  573. {
  574. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  575. return -1;
  576. }
  577. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  578. {
  579. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  580. return -1;
  581. }
  582. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  583. {
  584. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  585. return -1;
  586. }
  587. if( pc_isdead(sd) )
  588. {
  589. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  590. return -1;
  591. }
  592. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  593. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  594. clif_displaymessage(fd, atcmd_output);
  595. return 0;
  596. }
  597. /*==========================================
  598. *
  599. *------------------------------------------*/
  600. ACMD_FUNC(jump)
  601. {
  602. short x = 0, y = 0;
  603. nullpo_retr(-1, sd);
  604. memset(atcmd_output, '\0', sizeof(atcmd_output));
  605. sscanf(message, "%6hd %6hd", &x, &y);
  606. if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  607. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  608. return -1;
  609. }
  610. if( pc_isdead(sd) )
  611. {
  612. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  613. return -1;
  614. }
  615. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  616. { //This is to prevent the pc_setpos call from printing an error.
  617. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  618. if (!map_search_freecell(nullptr, sd->bl.m, &x, &y, 10, 10, 1))
  619. x = y = 0; //Invalid cell, use random spot.
  620. }
  621. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  622. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  623. clif_displaymessage(fd, atcmd_output);
  624. return 0;
  625. }
  626. /*==========================================
  627. * Display list of online characters with
  628. * various info.
  629. *------------------------------------------*/
  630. ACMD_FUNC(who) {
  631. map_session_data* pl_sd = nullptr;;
  632. struct s_mapiterator *iter = nullptr;
  633. char player_name[NAME_LENGTH] = "";
  634. int count = 0;
  635. int level = 0;
  636. StringBuf buf;
  637. /**
  638. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  639. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  640. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  641. */
  642. int display_type = 1;
  643. int map_id = -1;
  644. nullpo_retr(-1, sd);
  645. if (strstr(command, "map") != nullptr) {
  646. char map_name[MAP_NAME_LENGTH_EXT] = "";
  647. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  648. map_id = sd->bl.m;
  649. } else {
  650. sscanf(message, "%23s", player_name);
  651. }
  652. if (strstr(command, "2") != nullptr)
  653. display_type = 2;
  654. else if (strstr(command, "3") != nullptr)
  655. display_type = 3;
  656. level = pc_get_group_level(sd);
  657. StringBuf_Init(&buf);
  658. iter = mapit_getallusers();
  659. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  660. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  661. if (stristr(pl_sd->status.name, player_name) == nullptr // search with no case sensitive
  662. || (map_id >= 0 && pl_sd->bl.m != map_id))
  663. continue;
  664. switch (display_type) {
  665. case 2: {
  666. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  667. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  668. StringBuf_Printf(&buf, msg_txt(sd,344),pl_sd->group->name.c_str()); // "(%s) "
  669. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  670. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  671. break;
  672. }
  673. case 3: {
  674. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  675. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  676. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  677. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  678. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  679. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  680. break;
  681. }
  682. default: {
  683. struct party_data *p = party_search(pl_sd->status.party_id);
  684. auto &g = pl_sd->guild;
  685. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  686. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  687. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  688. if (p != nullptr)
  689. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  690. if (g != nullptr)
  691. StringBuf_Printf(&buf, msg_txt(sd,346), g->guild.name); // " | Guild: '%s'"
  692. break;
  693. }
  694. }
  695. clif_displaymessage(fd, StringBuf_Value(&buf));
  696. StringBuf_Clear(&buf);
  697. count++;
  698. }
  699. }
  700. mapit_free(iter);
  701. if (map_id < 0) {
  702. if (count == 0)
  703. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  704. else if (count == 1)
  705. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  706. else
  707. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  708. } else {
  709. struct map_data *mapdata = map_getmapdata(map_id);
  710. if (count == 0)
  711. StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'.
  712. else if (count == 1)
  713. StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'.
  714. else
  715. StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'.
  716. }
  717. clif_displaymessage(fd, StringBuf_Value(&buf));
  718. StringBuf_Destroy(&buf);
  719. return 0;
  720. }
  721. /*==========================================
  722. *
  723. *------------------------------------------*/
  724. ACMD_FUNC(whogm)
  725. {
  726. map_session_data* pl_sd;
  727. struct s_mapiterator* iter;
  728. int j, count;
  729. int level;
  730. char match_text[CHAT_SIZE_MAX];
  731. char player_name[NAME_LENGTH];
  732. struct party_data *p;
  733. nullpo_retr(-1, sd);
  734. memset(atcmd_output, '\0', sizeof(atcmd_output));
  735. memset(match_text, '\0', sizeof(match_text));
  736. memset(player_name, '\0', sizeof(player_name));
  737. if (sscanf(message, "%255[^\n]", match_text) < 1)
  738. strcpy(match_text, "");
  739. for (j = 0; match_text[j]; j++)
  740. match_text[j] = TOLOWER(match_text[j]);
  741. count = 0;
  742. level = pc_get_group_level(sd);
  743. iter = mapit_getallusers();
  744. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  745. {
  746. int pl_level = pc_get_group_level(pl_sd);
  747. if (!pl_level)
  748. continue;
  749. if (match_text[0])
  750. {
  751. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  752. for (j = 0; player_name[j]; j++)
  753. player_name[j] = TOLOWER(player_name[j]);
  754. // search with no case sensitive
  755. if (strstr(player_name, match_text) == nullptr)
  756. continue;
  757. }
  758. if (pl_level > level) {
  759. if (pc_isinvisible(pl_sd))
  760. continue;
  761. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  762. clif_displaymessage(fd, atcmd_output);
  763. count++;
  764. continue;
  765. }
  766. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  767. pl_sd->status.name, pl_level,
  768. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  769. clif_displaymessage(fd, atcmd_output);
  770. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  771. pl_sd->status.base_level,
  772. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  773. clif_displaymessage(fd, atcmd_output);
  774. p = party_search(pl_sd->status.party_id);
  775. auto &g = pl_sd->guild;
  776. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  777. p?p->party.name:msg_txt(sd,917), g?g->guild.name:msg_txt(sd,917)); // None.
  778. clif_displaymessage(fd, atcmd_output);
  779. count++;
  780. }
  781. mapit_free(iter);
  782. if (count == 0)
  783. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  784. else if (count == 1)
  785. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  786. else {
  787. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  788. clif_displaymessage(fd, atcmd_output);
  789. }
  790. return 0;
  791. }
  792. /*==========================================
  793. *
  794. *------------------------------------------*/
  795. ACMD_FUNC(save)
  796. {
  797. nullpo_retr(-1, sd);
  798. if( map_getmapdata(sd->bl.m)->instance_id ) {
  799. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  800. return 1;
  801. }
  802. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  803. if (sd->status.pet_id > 0 && sd->pd)
  804. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  805. chrif_save(sd, CSAVE_NORMAL);
  806. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  807. return 0;
  808. }
  809. /*==========================================
  810. *
  811. *------------------------------------------*/
  812. ACMD_FUNC(load){
  813. nullpo_retr(-1, sd);
  814. uint16 mapindex = mapindex_name2id( sd->status.save_point.map );
  815. int16 m = map_mapindex2mapid( mapindex );
  816. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  817. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  818. return -1;
  819. }
  820. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  821. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  822. return -1;
  823. }
  824. pc_setpos( sd, mapindex, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT );
  825. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  826. return 0;
  827. }
  828. /*==========================================
  829. *
  830. *------------------------------------------*/
  831. ACMD_FUNC(speed)
  832. {
  833. short speed;
  834. nullpo_retr(-1, sd);
  835. memset(atcmd_output, '\0', sizeof(atcmd_output));
  836. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  837. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  838. clif_displaymessage(fd, atcmd_output);
  839. return -1;
  840. }
  841. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  842. if (speed < 0)
  843. sd->base_status.speed = DEFAULT_WALK_SPEED;
  844. else
  845. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  846. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  847. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  848. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  849. } else
  850. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  851. status_calc_bl(&sd->bl, { SCB_SPEED });
  852. return 0;
  853. }
  854. /*==========================================
  855. *
  856. *------------------------------------------*/
  857. ACMD_FUNC(storage)
  858. {
  859. nullpo_retr(-1, sd);
  860. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  861. return -1;
  862. if (storage_storageopen(sd) == 1)
  863. { //Already open.
  864. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  865. return -1;
  866. }
  867. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  868. return 0;
  869. }
  870. /*==========================================
  871. *
  872. *------------------------------------------*/
  873. ACMD_FUNC(guildstorage)
  874. {
  875. nullpo_retr(-1, sd);
  876. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  877. return -1;
  878. switch (storage_guild_storageopen(sd)) {
  879. case GSTORAGE_OPEN:
  880. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  881. break;
  882. case GSTORAGE_STORAGE_ALREADY_OPEN:
  883. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  884. return -1;
  885. case GSTORAGE_ALREADY_OPEN:
  886. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  887. return -1;
  888. case GSTORAGE_NO_GUILD:
  889. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  890. return -1;
  891. case GSTORAGE_NO_STORAGE:
  892. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  893. return -1;
  894. case GSTORAGE_NO_PERMISSION:
  895. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  896. return -1;
  897. }
  898. return 0;
  899. }
  900. /*==========================================
  901. *
  902. *------------------------------------------*/
  903. ACMD_FUNC(option)
  904. {
  905. int param1 = 0, param2 = 0, param3 = 0;
  906. nullpo_retr(-1, sd);
  907. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  908. {// failed to match the parameters so inform the user of the options
  909. const char* text;
  910. // attempt to find the setting information for this command
  911. text = atcommand_help_string( command );
  912. // notify the user of the requirement to enter an option
  913. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  914. if( text )
  915. {// send the help text associated with this command
  916. clif_displaymessage( fd, text );
  917. }
  918. return -1;
  919. }
  920. sd->sc.opt1 = param1;
  921. sd->sc.opt2 = param2;
  922. pc_setoption(sd, param3);
  923. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  924. return 0;
  925. }
  926. /*==========================================
  927. *
  928. *------------------------------------------*/
  929. ACMD_FUNC(hide)
  930. {
  931. nullpo_retr(-1, sd);
  932. if (pc_isinvisible(sd)) {
  933. sd->sc.option &= ~OPTION_INVISIBLE;
  934. if (sd->disguise)
  935. status_set_viewdata(&sd->bl, sd->disguise);
  936. else
  937. status_set_viewdata(&sd->bl, sd->status.class_);
  938. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  939. // increment the number of pvp players on the map
  940. map_getmapdata(sd->bl.m)->users_pvp++;
  941. if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) )
  942. {// register the player for ranking calculations
  943. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  944. }
  945. //bugreport:2266
  946. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  947. } else {
  948. sd->sc.option |= OPTION_INVISIBLE;
  949. sd->vd.class_ = JT_INVISIBLE;
  950. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  951. // decrement the number of pvp players on the map
  952. map_getmapdata(sd->bl.m)->users_pvp--;
  953. if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER )
  954. {// unregister the player for ranking
  955. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  956. sd->pvp_timer = INVALID_TIMER;
  957. }
  958. }
  959. clif_changeoption(&sd->bl);
  960. return 0;
  961. }
  962. /*==========================================
  963. * Changes a character's class
  964. *------------------------------------------*/
  965. ACMD_FUNC(jobchange)
  966. {
  967. int job = 0, upper = 0;
  968. const char* text;
  969. nullpo_retr(-1, sd);
  970. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  971. int i;
  972. bool found = false;
  973. upper = 0;
  974. // Normal Jobs
  975. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  976. if (strncmpi(message, job_name(i), 16) == 0) {
  977. job = i;
  978. found = true;
  979. }
  980. }
  981. // High Jobs, Babys, Third, and Fourth
  982. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  983. if (strncmpi(message, job_name(i), 16) == 0) {
  984. job = i;
  985. found = true;
  986. }
  987. }
  988. if (!found) {
  989. text = atcommand_help_string(command);
  990. if (text)
  991. clif_displaymessage(fd, text);
  992. return -1;
  993. }
  994. }
  995. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  996. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  997. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE_KNIGHT2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  998. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2
  999. || (job >= JOB_WINDHAWK2 && job <= JOB_IMPERIAL_GUARD2) || job == JOB_SKY_EMPEROR2)
  1000. { // Deny direct transformation into dummy jobs
  1001. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  1002. return 0;
  1003. }
  1004. if (pcdb_checkid(job))
  1005. {
  1006. if (pc_jobchange(sd, job, upper))
  1007. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  1008. else {
  1009. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  1010. return -1;
  1011. }
  1012. } else {
  1013. text = atcommand_help_string(command);
  1014. if (text)
  1015. clif_displaymessage(fd, text);
  1016. return -1;
  1017. }
  1018. return 0;
  1019. }
  1020. /*==========================================
  1021. *
  1022. *------------------------------------------*/
  1023. ACMD_FUNC(kill)
  1024. {
  1025. nullpo_retr(-1, sd);
  1026. status_kill(&sd->bl);
  1027. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1028. if (fd != sd->fd)
  1029. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1030. return 0;
  1031. }
  1032. /*==========================================
  1033. *
  1034. *------------------------------------------*/
  1035. ACMD_FUNC(alive)
  1036. {
  1037. nullpo_retr(-1, sd);
  1038. if (!status_revive(&sd->bl, 100, 100))
  1039. {
  1040. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  1041. return -1;
  1042. }
  1043. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1044. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1045. return 0;
  1046. }
  1047. /*==========================================
  1048. * +kamic [LuzZza]
  1049. *------------------------------------------*/
  1050. ACMD_FUNC(kami)
  1051. {
  1052. unsigned long color=0;
  1053. nullpo_retr(-1, sd);
  1054. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1055. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1056. if (!message || !*message) {
  1057. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1058. return -1;
  1059. }
  1060. sscanf(message, "%255[^\n]", atcmd_output);
  1061. if (strstr(command, "l") != nullptr)
  1062. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  1063. else
  1064. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  1065. } else {
  1066. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1067. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1068. return -1;
  1069. }
  1070. if(color > 0xFFFFFF) {
  1071. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1072. return -1;
  1073. }
  1074. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1075. }
  1076. return 0;
  1077. }
  1078. /*==========================================
  1079. *
  1080. *------------------------------------------*/
  1081. ACMD_FUNC(heal)
  1082. {
  1083. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1084. nullpo_retr(-1, sd);
  1085. sscanf(message, "%11d %11d", &hp, &sp);
  1086. // some overflow checks
  1087. if( hp == INT_MIN ) hp++;
  1088. if( sp == INT_MIN ) sp++;
  1089. if ( hp == 0 && sp == 0 ) {
  1090. if (!status_percent_heal(&sd->bl, 100, 100))
  1091. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1092. else
  1093. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1094. return 0;
  1095. }
  1096. if ( hp > 0 && sp >= 0 ) {
  1097. if(!status_heal(&sd->bl, hp, sp, 0))
  1098. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1099. else
  1100. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1101. return 0;
  1102. }
  1103. if ( hp < 0 && sp <= 0 ) {
  1104. status_damage(nullptr, &sd->bl, -hp, -sp, 0, 0, 0);
  1105. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1106. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1107. return 0;
  1108. }
  1109. //Opposing signs.
  1110. if ( hp ) {
  1111. if (hp > 0)
  1112. status_heal(&sd->bl, hp, 0, 0);
  1113. else {
  1114. status_damage(nullptr, &sd->bl, -hp, 0, 0, 0, 0);
  1115. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1116. }
  1117. }
  1118. if ( sp ) {
  1119. if (sp > 0)
  1120. status_heal(&sd->bl, 0, sp, 0);
  1121. else
  1122. status_damage(nullptr, &sd->bl, 0, -sp, 0, 0, 0);
  1123. }
  1124. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1125. return 0;
  1126. }
  1127. /*==========================================
  1128. * Recover's AP and allows exact adjustments. [Rytech]
  1129. *------------------------------------------*/
  1130. ACMD_FUNC(healap)
  1131. {
  1132. int ap = 0;
  1133. nullpo_retr(-1, sd);
  1134. sscanf(message, "%11d", &ap);
  1135. // Overflow check.
  1136. if (ap == INT_MIN) ap++;
  1137. if (ap == 0) {
  1138. if (!status_percent_heal(&sd->bl, 0, 0, 100))
  1139. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1140. else
  1141. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1142. return 0;
  1143. }else if (ap > 0) {
  1144. if (!status_heal(&sd->bl, 0, 0, ap, 0))
  1145. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1146. else
  1147. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1148. return 0;
  1149. }else{
  1150. status_damage(nullptr, &sd->bl, 0, 0, -ap, 0, 0, 0);
  1151. clif_displaymessage(fd, msg_txt(sd, 822));// AP modified.
  1152. return 0;
  1153. }
  1154. }
  1155. /*==========================================
  1156. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1157. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1158. *------------------------------------------*/
  1159. ACMD_FUNC(item)
  1160. {
  1161. char item_name[100];
  1162. int number = 0, bound = BOUND_NONE;
  1163. char flag = 0;
  1164. char *itemlist;
  1165. nullpo_retr(-1, sd);
  1166. memset(item_name, '\0', sizeof(item_name));
  1167. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1168. if (!strcmpi(parent_cmd,"itembound")) {
  1169. if (!message || !*message || (
  1170. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1171. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1172. {
  1173. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1174. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1175. return -1;
  1176. }
  1177. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1178. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1179. return -1;
  1180. }
  1181. } else if (!message || !*message || (
  1182. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1183. sscanf(message, "%99s %11d", item_name, &number) < 1
  1184. )) {
  1185. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1186. return -1;
  1187. }
  1188. std::vector<std::shared_ptr<item_data>> items;
  1189. itemlist = strtok(item_name, ":");
  1190. while( itemlist != nullptr ){
  1191. std::shared_ptr<item_data> item = item_db.searchname( itemlist );
  1192. if( item == nullptr ){
  1193. item = item_db.find( strtoul( itemlist, nullptr, 10 ) );
  1194. }
  1195. if( item == nullptr ){
  1196. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1197. return -1;
  1198. }
  1199. items.push_back( item );
  1200. itemlist = strtok(nullptr, ":"); //next itemline
  1201. }
  1202. if (number <= 0)
  1203. number = 1;
  1204. int get_count = number;
  1205. // Produce items in list
  1206. for( const auto& item : items ){
  1207. t_itemid item_id = item->nameid;
  1208. //Check if it's stackable.
  1209. if( !itemdb_isstackable2( item.get() ) ){
  1210. get_count = 1;
  1211. }
  1212. for( int i = 0; i < number; i += get_count ){
  1213. // if not pet egg
  1214. if (!pet_create_egg(sd, item_id)) {
  1215. struct item item_tmp = {};
  1216. item_tmp.nameid = item_id;
  1217. item_tmp.identify = 1;
  1218. item_tmp.bound = bound;
  1219. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1220. clif_additem(sd, 0, 0, flag);
  1221. }
  1222. }
  1223. }
  1224. if (flag == 0)
  1225. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1226. return 0;
  1227. }
  1228. /*==========================================
  1229. *
  1230. *------------------------------------------*/
  1231. ACMD_FUNC(item2)
  1232. {
  1233. char item_name[100];
  1234. int number = 0, bound = BOUND_NONE;
  1235. int identify = 0, refine = 0, attr = 0;
  1236. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1237. nullpo_retr(-1, sd);
  1238. memset(item_name, '\0', sizeof(item_name));
  1239. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1240. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1241. if (!message || !*message || (
  1242. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1243. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1244. {
  1245. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1246. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1247. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1248. return -1;
  1249. }
  1250. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1251. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1252. return -1;
  1253. }
  1254. } else if ( !message || !*message || (
  1255. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1256. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1257. )) {
  1258. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1259. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1260. return -1;
  1261. }
  1262. if (number <= 0)
  1263. number = 1;
  1264. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  1265. if( item_data == nullptr ){
  1266. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  1267. }
  1268. if( item_data != nullptr ){
  1269. int loop, get_count, i;
  1270. char flag = 0;
  1271. //Check if it's stackable.
  1272. if( !itemdb_isstackable2( item_data.get() ) ){
  1273. loop = number;
  1274. get_count = 1;
  1275. }else{
  1276. loop = 1;
  1277. get_count = number;
  1278. }
  1279. if( itemdb_isequip2( item_data.get() ) ){
  1280. refine = cap_value( refine, 0, MAX_REFINE );
  1281. }else{
  1282. // All other items cannot be refined and are always identified
  1283. identify = 1;
  1284. refine = attr = 0;
  1285. }
  1286. for (i = 0; i < loop; i++) {
  1287. // if not pet egg
  1288. if (!pet_create_egg(sd, item_data->nameid)) {
  1289. struct item item_tmp = {};
  1290. item_tmp.nameid = item_data->nameid;
  1291. item_tmp.identify = identify;
  1292. item_tmp.refine = refine;
  1293. item_tmp.attribute = attr;
  1294. item_tmp.card[0] = c1;
  1295. item_tmp.card[1] = c2;
  1296. item_tmp.card[2] = c3;
  1297. item_tmp.card[3] = c4;
  1298. item_tmp.bound = bound;
  1299. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1300. clif_additem(sd, 0, 0, flag);
  1301. }
  1302. }
  1303. if (flag == 0)
  1304. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1305. } else {
  1306. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1307. return -1;
  1308. }
  1309. return 0;
  1310. }
  1311. /*==========================================
  1312. *
  1313. *------------------------------------------*/
  1314. ACMD_FUNC(itemreset)
  1315. {
  1316. int i;
  1317. nullpo_retr(-1, sd);
  1318. for (i = 0; i < MAX_INVENTORY; i++) {
  1319. 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])) {
  1320. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1321. }
  1322. }
  1323. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1324. return 0;
  1325. }
  1326. /*==========================================
  1327. * Atcommand @lvlup
  1328. *------------------------------------------*/
  1329. ACMD_FUNC(baselevelup)
  1330. {
  1331. int level=0, i=0, status_point=0, trait_point=0;
  1332. nullpo_retr(-1, sd);
  1333. level = atoi(message);
  1334. if (!message || !*message || !level) {
  1335. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1336. return -1;
  1337. }
  1338. if (level > 0) {
  1339. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1340. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1341. return -1;
  1342. } // End Addition
  1343. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1344. level = pc_maxbaselv(sd) - sd->status.base_level;
  1345. for (i = 0; i < level; i++)
  1346. {
  1347. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i);
  1348. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i);
  1349. }
  1350. sd->status.status_point += status_point;
  1351. sd->status.trait_point += trait_point;
  1352. sd->status.base_level += (unsigned int)level;
  1353. status_calc_pc(sd, SCO_FORCE);
  1354. status_percent_heal(&sd->bl, 100, 100);
  1355. clif_misceffect( sd->bl, NOTIFYEFFECT_BASE_LEVEL_UP );
  1356. for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) {
  1357. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j);
  1358. achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_);
  1359. }
  1360. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1361. } else {
  1362. if (sd->status.base_level == 1) {
  1363. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1364. return -1;
  1365. }
  1366. level*=-1;
  1367. if ((unsigned int)level >= sd->status.base_level)
  1368. level = sd->status.base_level-1;
  1369. for (i = 0; i > -level; i--)
  1370. {
  1371. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i - 1);
  1372. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i - 1);
  1373. }
  1374. if (sd->status.status_point < status_point || sd->status.trait_point < trait_point)
  1375. pc_resetstate(sd);
  1376. if (sd->status.status_point < status_point)
  1377. sd->status.status_point = 0;
  1378. else
  1379. sd->status.status_point -= status_point;
  1380. if (sd->status.trait_point < trait_point)
  1381. sd->status.trait_point = 0;
  1382. else
  1383. sd->status.trait_point -= trait_point;
  1384. sd->status.base_level -= (unsigned int)level;
  1385. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1386. status_calc_pc(sd, SCO_FORCE);
  1387. level*=-1;
  1388. }
  1389. sd->status.base_exp = 0;
  1390. clif_updatestatus(*sd, SP_STATUSPOINT);
  1391. clif_updatestatus(*sd, SP_TRAITPOINT);
  1392. clif_updatestatus(*sd, SP_BASELEVEL);
  1393. clif_updatestatus(*sd, SP_BASEEXP);
  1394. clif_updatestatus(*sd, SP_NEXTBASEEXP);
  1395. pc_baselevelchanged(sd);
  1396. if(sd->status.party_id)
  1397. party_send_levelup(sd);
  1398. if( level > 0 && battle_config.atcommand_levelup_events )
  1399. npc_script_event( *sd, NPCE_BASELVUP );
  1400. return 0;
  1401. }
  1402. /*==========================================
  1403. *
  1404. *------------------------------------------*/
  1405. ACMD_FUNC(joblevelup)
  1406. {
  1407. int level=0;
  1408. nullpo_retr(-1, sd);
  1409. level = atoi(message);
  1410. if (!message || !*message || !level) {
  1411. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1412. return -1;
  1413. }
  1414. if (level > 0) {
  1415. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1416. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1417. return -1;
  1418. }
  1419. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1420. level = pc_maxjoblv(sd) - sd->status.job_level;
  1421. sd->status.job_level += (unsigned int)level;
  1422. sd->status.skill_point += level;
  1423. clif_misceffect( sd->bl, NOTIFYEFFECT_JOB_LEVEL_UP );
  1424. for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++)
  1425. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i);
  1426. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1427. } else {
  1428. if (sd->status.job_level == 1) {
  1429. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1430. return -1;
  1431. }
  1432. level *=-1;
  1433. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1434. level = sd->status.job_level-1;
  1435. sd->status.job_level -= (unsigned int)level;
  1436. if (sd->status.skill_point < level)
  1437. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1438. if (sd->status.skill_point < level)
  1439. sd->status.skill_point = 0;
  1440. else
  1441. sd->status.skill_point -= level;
  1442. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1443. level *=-1;
  1444. }
  1445. sd->status.job_exp = 0;
  1446. clif_updatestatus(*sd, SP_JOBLEVEL);
  1447. clif_updatestatus(*sd, SP_JOBEXP);
  1448. clif_updatestatus(*sd, SP_NEXTJOBEXP);
  1449. clif_updatestatus(*sd, SP_SKILLPOINT);
  1450. status_calc_pc(sd, SCO_FORCE);
  1451. if( level > 0 && battle_config.atcommand_levelup_events )
  1452. npc_script_event( *sd, NPCE_JOBLVUP );
  1453. return 0;
  1454. }
  1455. /*==========================================
  1456. * @help
  1457. *------------------------------------------*/
  1458. ACMD_FUNC(help){
  1459. const char *command_name = nullptr;
  1460. nullpo_retr(-1, sd);
  1461. if (!message || !*message) {
  1462. command_name = "help"; // If no command_name specified, display help for @help.
  1463. } else {
  1464. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1465. ++message;
  1466. command_name = atcommand_alias_db.checkAlias(message);
  1467. }
  1468. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1469. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1470. clif_displaymessage(fd, atcmd_output);
  1471. atcommand_get_suggestions(sd, command_name, true);
  1472. return -1;
  1473. }
  1474. // attempt to find the first default help command
  1475. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_name );
  1476. const char* text = info != nullptr ? info->help.c_str() : nullptr;
  1477. if( text == nullptr ){
  1478. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1479. clif_displaymessage(fd, atcmd_output);
  1480. atcommand_get_suggestions(sd, command_name, true);
  1481. return -1;
  1482. }
  1483. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1484. clif_displaymessage(fd, atcmd_output);
  1485. { // Display aliases
  1486. StringBuf buf;
  1487. bool has_aliases = false;
  1488. StringBuf_Init(&buf);
  1489. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1490. for( const std::string& alias : info->aliases ){
  1491. StringBuf_Printf( &buf, " %s", alias.c_str() );
  1492. has_aliases = true;
  1493. }
  1494. if (has_aliases)
  1495. clif_displaymessage(fd, StringBuf_Value(&buf));
  1496. StringBuf_Destroy(&buf);
  1497. }
  1498. // Display help contents
  1499. clif_displaymessage(fd, text);
  1500. return 0;
  1501. }
  1502. /*==========================================
  1503. *
  1504. *------------------------------------------*/
  1505. ACMD_FUNC(pvpoff)
  1506. {
  1507. nullpo_retr(-1, sd);
  1508. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1509. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1510. return -1;
  1511. }
  1512. map_setmapflag(sd->bl.m, MF_PVP, false);
  1513. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1514. return 0;
  1515. }
  1516. /*==========================================
  1517. *
  1518. *------------------------------------------*/
  1519. ACMD_FUNC(pvpon)
  1520. {
  1521. nullpo_retr(-1, sd);
  1522. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1523. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1524. return -1;
  1525. }
  1526. map_setmapflag(sd->bl.m, MF_PVP, true);
  1527. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1528. return 0;
  1529. }
  1530. /*==========================================
  1531. *
  1532. *------------------------------------------*/
  1533. ACMD_FUNC(gvgoff)
  1534. {
  1535. nullpo_retr(-1, sd);
  1536. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1537. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1538. return -1;
  1539. }
  1540. map_setmapflag(sd->bl.m, MF_GVG, false);
  1541. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1542. return 0;
  1543. }
  1544. /*==========================================
  1545. *
  1546. *------------------------------------------*/
  1547. ACMD_FUNC(gvgon)
  1548. {
  1549. nullpo_retr(-1, sd);
  1550. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1551. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1552. return -1;
  1553. }
  1554. map_setmapflag(sd->bl.m, MF_GVG, true);
  1555. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1556. return 0;
  1557. }
  1558. /*==========================================
  1559. *
  1560. *------------------------------------------*/
  1561. ACMD_FUNC(model)
  1562. {
  1563. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1564. nullpo_retr(-1, sd);
  1565. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1566. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1567. 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>).
  1568. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1569. clif_displaymessage(fd, atcmd_output);
  1570. return -1;
  1571. }
  1572. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1573. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1574. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1575. pc_changelook(sd, LOOK_HAIR, hair_style);
  1576. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1577. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1578. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1579. } else {
  1580. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1581. return -1;
  1582. }
  1583. return 0;
  1584. }
  1585. /*==========================================
  1586. * @bodystyle [Rytech]
  1587. *------------------------------------------*/
  1588. ACMD_FUNC(bodystyle)
  1589. {
  1590. int body_style = 0;
  1591. nullpo_retr(-1, sd);
  1592. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1593. 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) {
  1594. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1595. return -1;
  1596. }
  1597. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1598. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1599. clif_displaymessage(fd, atcmd_output);
  1600. return -1;
  1601. }
  1602. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1603. pc_changelook(sd, LOOK_BODY2, body_style);
  1604. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1605. } else {
  1606. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1607. return -1;
  1608. }
  1609. return 0;
  1610. }
  1611. /*==========================================
  1612. * @dye && @ccolor
  1613. *------------------------------------------*/
  1614. ACMD_FUNC(dye)
  1615. {
  1616. int cloth_color = 0;
  1617. nullpo_retr(-1, sd);
  1618. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1619. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1620. 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>).
  1621. clif_displaymessage(fd, atcmd_output);
  1622. return -1;
  1623. }
  1624. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1625. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1626. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1627. } else {
  1628. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1629. return -1;
  1630. }
  1631. return 0;
  1632. }
  1633. /*==========================================
  1634. * @hairstyle && @hstyle
  1635. *------------------------------------------*/
  1636. ACMD_FUNC(hair_style)
  1637. {
  1638. int hair_style = 0;
  1639. nullpo_retr(-1, sd);
  1640. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1641. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1642. 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>).
  1643. clif_displaymessage(fd, atcmd_output);
  1644. return -1;
  1645. }
  1646. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1647. pc_changelook(sd, LOOK_HAIR, hair_style);
  1648. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1649. } else {
  1650. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1651. return -1;
  1652. }
  1653. return 0;
  1654. }
  1655. /*==========================================
  1656. * @haircolor && @hcolor
  1657. *------------------------------------------*/
  1658. ACMD_FUNC(hair_color)
  1659. {
  1660. int hair_color = 0;
  1661. nullpo_retr(-1, sd);
  1662. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1663. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1664. 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>).
  1665. clif_displaymessage(fd, atcmd_output);
  1666. return -1;
  1667. }
  1668. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1669. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1670. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1671. } else {
  1672. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1673. return -1;
  1674. }
  1675. return 0;
  1676. }
  1677. /*==========================================
  1678. * @go [city_number or city_name] - Updated by Harbin
  1679. *------------------------------------------*/
  1680. ACMD_FUNC(go)
  1681. {
  1682. int i;
  1683. int town;
  1684. char map_name[MAP_NAME_LENGTH];
  1685. const struct {
  1686. char map[MAP_NAME_LENGTH];
  1687. int x, y;
  1688. } data[] = {
  1689. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1690. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1691. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1692. { MAP_PAYON, 162, 233 }, // 3=Payon
  1693. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1694. #ifdef RENEWAL
  1695. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1696. #else
  1697. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1698. #endif
  1699. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1700. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1701. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1702. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1703. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1704. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1705. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1706. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1707. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1708. #ifdef RENEWAL
  1709. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1710. #else
  1711. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1712. #endif
  1713. { MAP_JAIL, 23, 61 }, // 16=Prison
  1714. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1715. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1716. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1717. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1718. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1719. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1720. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1721. { MAP_VEINS, 216, 123 }, // 24=Veins
  1722. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1723. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1724. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1725. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1726. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1727. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1728. { MAP_MORA, 44, 151 }, // 31=Mora
  1729. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1730. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1731. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1732. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1733. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1734. };
  1735. nullpo_retr(-1, sd);
  1736. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1737. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1738. return 0;
  1739. }
  1740. memset(map_name, '\0', sizeof(map_name));
  1741. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1742. // get the number
  1743. town = atoi(message);
  1744. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1745. {// no value matched so send the list of locations
  1746. const char* text;
  1747. // attempt to find the text help string
  1748. text = atcommand_help_string( command );
  1749. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1750. if( text )
  1751. {// send the text to the client
  1752. clif_displaymessage( fd, text );
  1753. }
  1754. return -1;
  1755. }
  1756. // get possible name of the city
  1757. map_name[MAP_NAME_LENGTH-1] = '\0';
  1758. for (i = 0; map_name[i]; i++)
  1759. map_name[i] = TOLOWER(map_name[i]);
  1760. // try to identify the map name
  1761. if (strncmp(map_name, "prontera", 3) == 0) {
  1762. town = 0;
  1763. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1764. strncmp(map_name, "morroc", 4) == 0) {
  1765. town = 1;
  1766. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1767. town = 2;
  1768. } else if (strncmp(map_name, "payon", 3) == 0) {
  1769. town = 3;
  1770. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1771. town = 4;
  1772. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1773. town = 5;
  1774. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1775. town = 6;
  1776. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1777. strcmp(map_name, "christmas") == 0 ||
  1778. strncmp(map_name, "xmas", 3) == 0 ||
  1779. strncmp(map_name, "x-mas", 3) == 0) {
  1780. town = 7;
  1781. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1782. town = 8;
  1783. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1784. strncmp(map_name, "yuno", 3) == 0) {
  1785. town = 9;
  1786. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1787. town = 10;
  1788. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1789. strncmp(map_name, "gonryun", 3) == 0) {
  1790. town = 11;
  1791. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1792. town = 12;
  1793. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1794. town = 13;
  1795. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1796. town = 14;
  1797. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1798. strncmp(map_name, "startpoint", 3) == 0 ||
  1799. strncmp(map_name, "beginning", 3) == 0) {
  1800. town = 15;
  1801. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1802. strncmp(map_name, "prison", 3) == 0 ||
  1803. strncmp(map_name, "jail", 3) == 0) {
  1804. town = 16;
  1805. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1806. town = 17;
  1807. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1808. town = 18;
  1809. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1810. town = 19;
  1811. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1812. town = 20;
  1813. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1814. town = 21;
  1815. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1816. town = 22;
  1817. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1818. town = 23;
  1819. } else if (strncmp(map_name, "veins", 3) == 0) {
  1820. town = 24;
  1821. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1822. town = 25;
  1823. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1824. town = 26;
  1825. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1826. town = 27;
  1827. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1828. town = 28;
  1829. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1830. town = 29;
  1831. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1832. town = 30;
  1833. } else if (strcmp(map_name, "mora") == 0) {
  1834. town = 31;
  1835. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1836. town = 32;
  1837. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1838. town = 33;
  1839. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1840. town = 34;
  1841. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1842. town = 35;
  1843. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1844. town = 36;
  1845. }
  1846. if (town >= 0 && town < ARRAYLENGTH(data))
  1847. {
  1848. int16 m = map_mapname2mapid(data[town].map);
  1849. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1850. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1851. return -1;
  1852. }
  1853. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1854. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1855. return -1;
  1856. }
  1857. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1858. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1859. } else {
  1860. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1861. return -1;
  1862. }
  1863. } else { // if you arrive here, you have an error in town variable when reading of names
  1864. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1865. return -1;
  1866. }
  1867. return 0;
  1868. }
  1869. /*==========================================
  1870. *
  1871. *------------------------------------------*/
  1872. ACMD_FUNC(monster)
  1873. {
  1874. char name[NAME_LENGTH];
  1875. char monster[NAME_LENGTH];
  1876. char eventname[EVENT_NAME_LENGTH] = "";
  1877. int mob_id;
  1878. int number = 0;
  1879. int count;
  1880. int i, range;
  1881. short mx, my;
  1882. unsigned int size;
  1883. nullpo_retr(-1, sd);
  1884. memset(name, '\0', sizeof(name));
  1885. memset(monster, '\0', sizeof(monster));
  1886. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1887. if (!message || !*message) {
  1888. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1889. return -1;
  1890. }
  1891. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1892. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1893. //All data can be left as it is.
  1894. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1895. //Here, it is possible name was not given and we are using monster for it.
  1896. if (count < 3) //Blank mob's name.
  1897. name[0] = '\0';
  1898. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1899. //All data can be left as it is.
  1900. } else if (sscanf(message, "%23s", monster) > 0) {
  1901. //As before, name may be already filled.
  1902. name[0] = '\0';
  1903. } else {
  1904. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1905. return -1;
  1906. }
  1907. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1908. mob_id = mobdb_checkid(atoi(monster));
  1909. if (mob_id == 0) {
  1910. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1911. return -1;
  1912. }
  1913. if (mob_id == MOBID_EMPERIUM) {
  1914. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1915. return -1;
  1916. }
  1917. if (number <= 0)
  1918. number = 1;
  1919. if( !name[0] )
  1920. strcpy(name, "--ja--");
  1921. // 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
  1922. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1923. number = battle_config.atc_spawn_quantity_limit;
  1924. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1925. if (strcmp(parent_cmd, "monstersmall") == 0)
  1926. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1927. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1928. size = SZ_BIG;
  1929. else
  1930. size = SZ_SMALL;
  1931. if (battle_config.etc_log)
  1932. 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);
  1933. count = 0;
  1934. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1935. for (i = 0; i < number; i++) {
  1936. int k;
  1937. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1938. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1939. if(k) {
  1940. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1941. count ++;
  1942. }
  1943. }
  1944. if (count != 0)
  1945. if (number == count)
  1946. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1947. else {
  1948. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1949. clif_displaymessage(fd, atcmd_output);
  1950. }
  1951. else {
  1952. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1953. return -1;
  1954. }
  1955. return 0;
  1956. }
  1957. /*==========================================
  1958. *
  1959. *------------------------------------------*/
  1960. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1961. {
  1962. struct mob_data *md;
  1963. int flag;
  1964. nullpo_ret(md=(struct mob_data *)bl);
  1965. flag = va_arg(ap, int);
  1966. if (md->guardian_data)
  1967. return 0; //Do not touch WoE mobs!
  1968. if (flag)
  1969. status_zap(bl,md->status.hp, 0);
  1970. else
  1971. status_kill(bl);
  1972. return 1;
  1973. }
  1974. ACMD_FUNC(killmonster)
  1975. {
  1976. int map_id, drop_flag;
  1977. char map_name[MAP_NAME_LENGTH_EXT];
  1978. nullpo_retr(-1, sd);
  1979. memset(map_name, '\0', sizeof(map_name));
  1980. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1981. map_id = sd->bl.m;
  1982. else {
  1983. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1984. map_id = sd->bl.m;
  1985. }
  1986. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1987. drop_flag = strcmpi(parent_cmd, "killmonster2");
  1988. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1989. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1990. return 0;
  1991. }
  1992. /*==========================================
  1993. *
  1994. *------------------------------------------*/
  1995. ACMD_FUNC(refine)
  1996. {
  1997. int j, position = 0, refine = 0, current_position, final_refine;
  1998. int count;
  1999. nullpo_retr(-1, sd);
  2000. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2001. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  2002. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  2003. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2004. clif_displaymessage(fd, atcmd_output);
  2005. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2006. clif_displaymessage(fd, atcmd_output);
  2007. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2008. clif_displaymessage(fd, atcmd_output);
  2009. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2010. clif_displaymessage(fd, atcmd_output);
  2011. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2012. clif_displaymessage(fd, atcmd_output);
  2013. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2014. clif_displaymessage(fd, atcmd_output);
  2015. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2016. clif_displaymessage(fd, atcmd_output);
  2017. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2018. clif_displaymessage(fd, atcmd_output);
  2019. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2020. clif_displaymessage(fd, atcmd_output);
  2021. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2022. clif_displaymessage(fd, atcmd_output);
  2023. sprintf(atcmd_output, msg_txt(sd,1521), EQP_SHADOW_ARMOR); // %d: Shadow Armor
  2024. clif_displaymessage(fd, atcmd_output);
  2025. sprintf(atcmd_output, msg_txt(sd,1522), EQP_SHADOW_WEAPON); // %d: Shadow Weapon
  2026. clif_displaymessage(fd, atcmd_output);
  2027. sprintf(atcmd_output, msg_txt(sd,1523), EQP_SHADOW_SHIELD); // %d: Shadow Shield
  2028. clif_displaymessage(fd, atcmd_output);
  2029. sprintf(atcmd_output, msg_txt(sd,1524), EQP_SHADOW_SHOES); // %d: Shadow Shoes
  2030. clif_displaymessage(fd, atcmd_output);
  2031. sprintf(atcmd_output, msg_txt(sd,1525), EQP_SHADOW_ACC_R); // %d: Shadow Right Accessory
  2032. clif_displaymessage(fd, atcmd_output);
  2033. sprintf(atcmd_output, msg_txt(sd,1526), EQP_SHADOW_ACC_L); // %d: Shadow Left Accessory
  2034. clif_displaymessage(fd, atcmd_output);
  2035. return -1;
  2036. }
  2037. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2038. count = 0;
  2039. for (j = 0; j < EQI_MAX; j++) {
  2040. int i;
  2041. if ((i = sd->equip_index[j]) < 0)
  2042. continue;
  2043. if(j == EQI_AMMO)
  2044. continue;
  2045. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2046. continue;
  2047. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2048. continue;
  2049. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  2050. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  2051. sd->inventory.u.items_inventory[i].refine = final_refine;
  2052. current_position = sd->inventory.u.items_inventory[i].equip;
  2053. pc_unequipitem(sd, i, 3);
  2054. clif_refine( *sd, i, ITEMREFINING_SUCCESS );
  2055. clif_delitem( *sd, i, 1, 3 );
  2056. clif_additem(sd, i, 1, 0);
  2057. pc_equipitem(sd, i, current_position);
  2058. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2059. if( sd->inventory_data[i]->type == IT_WEAPON ){
  2060. achievement_update_objective(sd, AG_ENCHANT_SUCCESS, 2, sd->inventory_data[i]->weapon_level, sd->inventory.u.items_inventory[i].refine);
  2061. }
  2062. count++;
  2063. }
  2064. }
  2065. if (count == 0)
  2066. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2067. else if (count == 1)
  2068. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2069. else {
  2070. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2071. clif_displaymessage(fd, atcmd_output);
  2072. }
  2073. return 0;
  2074. }
  2075. /*==========================================
  2076. *
  2077. *------------------------------------------*/
  2078. ACMD_FUNC(grade)
  2079. {
  2080. int j, position = 0, grade = 0, current_position, final_grade;
  2081. int count;
  2082. nullpo_retr(-1, sd);
  2083. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2084. if (!message || !*message || sscanf(message, "%11d %11d", &position, &grade) < 2) {
  2085. clif_displaymessage(fd, msg_txt(sd,1519)); // Please enter a position and an amount (usage: @grade <equip position> <+/- amount>).
  2086. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2087. clif_displaymessage(fd, atcmd_output);
  2088. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2089. clif_displaymessage(fd, atcmd_output);
  2090. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2091. clif_displaymessage(fd, atcmd_output);
  2092. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2093. clif_displaymessage(fd, atcmd_output);
  2094. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2095. clif_displaymessage(fd, atcmd_output);
  2096. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2097. clif_displaymessage(fd, atcmd_output);
  2098. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2099. clif_displaymessage(fd, atcmd_output);
  2100. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2101. clif_displaymessage(fd, atcmd_output);
  2102. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2103. clif_displaymessage(fd, atcmd_output);
  2104. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2105. clif_displaymessage(fd, atcmd_output);
  2106. return -1;
  2107. }
  2108. grade = cap_value(grade, -MAX_ENCHANTGRADE, MAX_ENCHANTGRADE);
  2109. count = 0;
  2110. for (j = 0; j < EQI_MAX; j++) {
  2111. int i;
  2112. if ((i = sd->equip_index[j]) < 0)
  2113. continue;
  2114. if(j == EQI_AMMO)
  2115. continue;
  2116. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2117. continue;
  2118. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2119. continue;
  2120. final_grade = cap_value(sd->inventory.u.items_inventory[i].enchantgrade + grade, 0, MAX_ENCHANTGRADE);
  2121. if (sd->inventory.u.items_inventory[i].enchantgrade != final_grade) {
  2122. sd->inventory.u.items_inventory[i].enchantgrade = final_grade;
  2123. current_position = sd->inventory.u.items_inventory[i].equip;
  2124. pc_unequipitem(sd, i, 3);
  2125. clif_delitem( *sd, i, 1, 3 );
  2126. clif_additem(sd, i, 1, 0);
  2127. pc_equipitem(sd, i, current_position);
  2128. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2129. count++;
  2130. }
  2131. }
  2132. sprintf(atcmd_output, msg_txt(sd,1520), count); // %d items have been graded.
  2133. clif_displaymessage(fd, atcmd_output);
  2134. return 0;
  2135. }
  2136. /*==========================================
  2137. *
  2138. *------------------------------------------*/
  2139. ACMD_FUNC(produce)
  2140. {
  2141. char item_name[100];
  2142. t_itemid item_id;
  2143. int attribute = 0, star = 0;
  2144. nullpo_retr(-1, sd);
  2145. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2146. memset(item_name, '\0', sizeof(item_name));
  2147. if (!message || !*message || (
  2148. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2149. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2150. )) {
  2151. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2152. return -1;
  2153. }
  2154. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  2155. if( item_data == nullptr ){
  2156. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  2157. }
  2158. if( item_data == nullptr ){
  2159. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2160. return -1;
  2161. }
  2162. item_id = item_data->nameid;
  2163. if( itemdb_isequip2( item_data.get() ) ){
  2164. char flag = 0;
  2165. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2166. attribute = ATTRIBUTE_NORMAL;
  2167. if (star < MIN_STAR || star > MAX_STAR)
  2168. star = 0;
  2169. struct item tmp_item = {};
  2170. tmp_item.nameid = item_id;
  2171. tmp_item.amount = 1;
  2172. tmp_item.identify = 1;
  2173. tmp_item.card[0] = CARD0_FORGE;
  2174. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2175. ((star*5) << 8) + attribute:0;
  2176. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2177. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2178. clif_produceeffect(sd, 0, item_id);
  2179. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2180. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2181. clif_additem(sd, 0, 0, flag);
  2182. } else {
  2183. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name.c_str()); // The item (%u: '%s') is not equipable.
  2184. clif_displaymessage(fd, atcmd_output);
  2185. return -1;
  2186. }
  2187. return 0;
  2188. }
  2189. /*==========================================
  2190. *
  2191. *------------------------------------------*/
  2192. ACMD_FUNC(memo)
  2193. {
  2194. int position = 0;
  2195. nullpo_retr(-1, sd);
  2196. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2197. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2198. {
  2199. int i;
  2200. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2201. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2202. {
  2203. if( strcmp( "", sd->status.memo_point[i].map ) != 0 )
  2204. 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 );
  2205. else
  2206. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2207. clif_displaymessage(sd->fd, atcmd_output);
  2208. }
  2209. return 0;
  2210. }
  2211. if( position < 0 || position >= MAX_MEMOPOINTS )
  2212. {
  2213. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2214. clif_displaymessage(fd, atcmd_output);
  2215. return -1;
  2216. }
  2217. return !pc_memo( sd, position );
  2218. }
  2219. /*==========================================
  2220. *
  2221. *------------------------------------------*/
  2222. ACMD_FUNC(gat)
  2223. {
  2224. int y;
  2225. nullpo_retr(-1, sd);
  2226. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2227. for (y = 2; y >= -2; y--) {
  2228. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2229. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2230. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2231. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2232. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2233. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2234. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2235. clif_displaymessage(fd, atcmd_output);
  2236. }
  2237. return 0;
  2238. }
  2239. /*==========================================
  2240. *
  2241. *------------------------------------------*/
  2242. ACMD_FUNC(displaystatus)
  2243. {
  2244. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2245. nullpo_retr(-1, sd);
  2246. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2247. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2248. return -1;
  2249. }
  2250. if (i < 2) flag = 1;
  2251. if (i < 3) tick = 0;
  2252. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2253. return 0;
  2254. }
  2255. /*==========================================
  2256. * @stpoint (Rewritten by [Yor])
  2257. *------------------------------------------*/
  2258. ACMD_FUNC(statuspoint)
  2259. {
  2260. int point;
  2261. unsigned int new_status_point;
  2262. if (!message || !*message || (point = atoi(message)) == 0) {
  2263. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2264. return -1;
  2265. }
  2266. if(point < 0)
  2267. {
  2268. if(sd->status.status_point < (unsigned int)(-point))
  2269. {
  2270. new_status_point = 0;
  2271. }
  2272. else
  2273. {
  2274. new_status_point = sd->status.status_point + point;
  2275. }
  2276. }
  2277. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2278. {
  2279. new_status_point = UINT_MAX;
  2280. }
  2281. else
  2282. {
  2283. new_status_point = sd->status.status_point + point;
  2284. }
  2285. if (new_status_point != sd->status.status_point) {
  2286. sd->status.status_point = new_status_point;
  2287. clif_updatestatus(*sd, SP_STATUSPOINT);
  2288. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2289. } else {
  2290. if (point < 0)
  2291. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2292. else
  2293. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2294. return -1;
  2295. }
  2296. return 0;
  2297. }
  2298. /*==========================================
  2299. * @trpoint
  2300. *------------------------------------------*/
  2301. ACMD_FUNC(traitpoint)
  2302. {
  2303. int point;
  2304. unsigned int new_trait_point;
  2305. if (!message || !*message || (point = atoi(message)) == 0) {
  2306. clif_displaymessage(fd, msg_txt(sd, 820)); // Please enter a number (usage: @trpoint <number of points>).
  2307. return -1;
  2308. }
  2309. if (point < 0)
  2310. {
  2311. if (sd->status.trait_point < (unsigned int)(-point))
  2312. {
  2313. new_trait_point = 0;
  2314. }
  2315. else
  2316. {
  2317. new_trait_point = sd->status.trait_point + point;
  2318. }
  2319. }
  2320. else if (UINT_MAX - sd->status.trait_point < (unsigned int)point)
  2321. {
  2322. new_trait_point = UINT_MAX;
  2323. }
  2324. else
  2325. {
  2326. new_trait_point = sd->status.trait_point + point;
  2327. }
  2328. if (new_trait_point != sd->status.trait_point) {
  2329. sd->status.trait_point = new_trait_point;
  2330. clif_updatestatus(*sd, SP_TRAITPOINT);
  2331. clif_displaymessage(fd, msg_txt(sd, 174)); // Number of status points changed.
  2332. }
  2333. else {
  2334. if (point < 0)
  2335. clif_displaymessage(fd, msg_txt(sd, 41)); // Unable to decrease the number/value.
  2336. else
  2337. clif_displaymessage(fd, msg_txt(sd, 149)); // Unable to increase the number/value.
  2338. return -1;
  2339. }
  2340. return 0;
  2341. }
  2342. /*==========================================
  2343. * @skpoint (Rewritten by [Yor])
  2344. *------------------------------------------*/
  2345. ACMD_FUNC(skillpoint)
  2346. {
  2347. int point;
  2348. unsigned int new_skill_point;
  2349. nullpo_retr(-1, sd);
  2350. if (!message || !*message || (point = atoi(message)) == 0) {
  2351. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2352. return -1;
  2353. }
  2354. if(point < 0)
  2355. {
  2356. if(sd->status.skill_point < (unsigned int)(-point))
  2357. {
  2358. new_skill_point = 0;
  2359. }
  2360. else
  2361. {
  2362. new_skill_point = sd->status.skill_point + point;
  2363. }
  2364. }
  2365. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2366. {
  2367. new_skill_point = UINT_MAX;
  2368. }
  2369. else
  2370. {
  2371. new_skill_point = sd->status.skill_point + point;
  2372. }
  2373. if (new_skill_point != sd->status.skill_point) {
  2374. sd->status.skill_point = new_skill_point;
  2375. clif_updatestatus(*sd, SP_SKILLPOINT);
  2376. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2377. } else {
  2378. if (point < 0)
  2379. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2380. else
  2381. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2382. return -1;
  2383. }
  2384. return 0;
  2385. }
  2386. /*==========================================
  2387. * @zeny
  2388. *------------------------------------------*/
  2389. ACMD_FUNC(zeny)
  2390. {
  2391. int zeny=0, ret=-1;
  2392. nullpo_retr(-1, sd);
  2393. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2394. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2395. return -1;
  2396. }
  2397. if(zeny > 0){
  2398. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND)) == 1)
  2399. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2400. }
  2401. else {
  2402. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2403. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND)) == 1)
  2404. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2405. }
  2406. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2407. return 0;
  2408. }
  2409. /*==========================================
  2410. *
  2411. *------------------------------------------*/
  2412. ACMD_FUNC(param)
  2413. {
  2414. nullpo_retr(-1, sd);
  2415. uint8 stat;
  2416. int value = 0;
  2417. uint16 new_value, status, max_status;
  2418. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2419. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2420. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2421. return -1;
  2422. }
  2423. ARR_FIND( 0, ARRAYLENGTH(parameter_names), stat, strcmpi(command + 1, parameter_names[stat]) == 0 );
  2424. if( stat == ARRAYLENGTH(parameter_names)) { // normally impossible...
  2425. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2426. return -1;
  2427. }
  2428. if( stat < PARAM_POW ){
  2429. status = pc_getstat( sd, SP_STR + stat - PARAM_STR );
  2430. }else{
  2431. if( !( sd->class_ & JOBL_FOURTH ) ){
  2432. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2433. return -1;
  2434. }
  2435. status = pc_getstat( sd, SP_POW + stat - PARAM_POW );
  2436. }
  2437. if( pc_has_permission( sd, PC_PERM_BYPASS_MAX_STAT ) ){
  2438. max_status = SHRT_MAX;
  2439. }else{
  2440. max_status = pc_maxparameter( sd, static_cast<e_params>( stat ) );
  2441. }
  2442. if( value > 0 && status + value >= max_status ){
  2443. new_value = max_status;
  2444. }else if( value < 0 && abs( value ) >= status ){
  2445. if( stat < PARAM_POW ){
  2446. new_value = 1;
  2447. }else{
  2448. new_value = 0;
  2449. }
  2450. }else{
  2451. new_value = status + value;
  2452. }
  2453. if( new_value != status ){
  2454. if (stat < PARAM_POW) {
  2455. pc_setstat( sd, SP_STR + stat - PARAM_STR, new_value );
  2456. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + stat ) );
  2457. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + stat ) );
  2458. } else {
  2459. pc_setstat( sd, SP_POW + stat - PARAM_POW, new_value );
  2460. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + stat - PARAM_POW ) );
  2461. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + stat - PARAM_POW ) );
  2462. }
  2463. status_calc_pc(sd, SCO_FORCE);
  2464. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2465. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2466. } else {
  2467. if (value < 0)
  2468. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2469. else
  2470. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2471. return -1;
  2472. }
  2473. return 0;
  2474. }
  2475. /*==========================================
  2476. * Stat all by fritz (rewritten by [Yor])
  2477. *------------------------------------------*/
  2478. ACMD_FUNC(stat_all)
  2479. {
  2480. nullpo_retr(-1, sd);
  2481. int value = 0;
  2482. uint8 count, i;
  2483. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2484. for (i = PARAM_STR; i < PARAM_POW; i++)
  2485. status[i] = pc_getstat(sd, SP_STR + i);
  2486. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2487. for (i = PARAM_STR; i < PARAM_POW; i++)
  2488. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2489. value = SHRT_MAX;
  2490. } else {
  2491. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2492. for (i = PARAM_STR; i < PARAM_POW; i++)
  2493. max_status[i] = SHRT_MAX;
  2494. } else {
  2495. for (i = PARAM_STR; i < PARAM_POW; i++)
  2496. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2497. }
  2498. }
  2499. count = 0;
  2500. for (i = PARAM_STR; i < PARAM_POW; i++) {
  2501. short new_value;
  2502. if (value > 0 && status[i] + value >= max_status[i])
  2503. new_value = max_status[i];
  2504. else if (value < 0 && abs(value) >= status[i])
  2505. new_value = 1;
  2506. else
  2507. new_value = status[i] + value;
  2508. if (new_value != status[i]) {
  2509. pc_setstat( sd, SP_STR + i, new_value );
  2510. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  2511. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  2512. count++;
  2513. }
  2514. }
  2515. if (count > 0) { // if at least 1 stat modified
  2516. status_calc_pc(sd, SCO_FORCE);
  2517. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2518. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2519. } else {
  2520. if (value < 0)
  2521. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2522. else
  2523. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2524. return -1;
  2525. }
  2526. return 0;
  2527. }
  2528. /*==========================================
  2529. * Traits
  2530. *------------------------------------------*/
  2531. ACMD_FUNC(trait_all) {
  2532. nullpo_retr(-1, sd);
  2533. #ifndef RENEWAL
  2534. sprintf(atcmd_output, msg_txt(sd, 154), command); // %s failed.
  2535. clif_displaymessage(fd, atcmd_output);
  2536. return -1;
  2537. #endif
  2538. if( !( sd->class_ & JOBL_FOURTH ) ){
  2539. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2540. return -1;
  2541. }
  2542. int value = 0;
  2543. uint8 i;
  2544. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2545. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2546. status[i] = pc_getstat(sd, SP_POW + i - PARAM_POW);
  2547. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2548. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2549. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2550. value = SHRT_MAX;
  2551. } else {
  2552. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2553. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2554. max_status[i] = SHRT_MAX;
  2555. } else {
  2556. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2557. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2558. }
  2559. }
  2560. uint8 count = 0;
  2561. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  2562. short new_value;
  2563. if (value > 0 && status[i] + value >= max_status[i])
  2564. new_value = max_status[i];
  2565. else if (value < 0 && abs(value) >= status[i])
  2566. new_value = 0;
  2567. else
  2568. new_value = status[i] + value;
  2569. if (new_value != status[i]) {
  2570. pc_setstat( sd, SP_POW + i - PARAM_POW, new_value );
  2571. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  2572. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  2573. count++;
  2574. }
  2575. }
  2576. if (count > 0) { // if at least 1 stat modified
  2577. status_calc_pc(sd, SCO_FORCE);
  2578. clif_displaymessage(fd, msg_txt(sd, 84)); // All stats changed!
  2579. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2580. } else {
  2581. if (value < 0)
  2582. clif_displaymessage(fd, msg_txt(sd, 177)); // You cannot decrease that stat anymore.
  2583. else
  2584. clif_displaymessage(fd, msg_txt(sd, 178)); // You cannot increase that stat anymore.
  2585. return -1;
  2586. }
  2587. return 0;
  2588. }
  2589. /*==========================================
  2590. *
  2591. *------------------------------------------*/
  2592. ACMD_FUNC(guildlevelup) {
  2593. int level = 0;
  2594. short added_level;
  2595. nullpo_retr(-1, sd);
  2596. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2597. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2598. return -1;
  2599. }
  2600. auto &guild_info = sd->guild;
  2601. if (sd->status.guild_id <= 0 || guild_info == nullptr) {
  2602. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2603. return -1;
  2604. }
  2605. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2606. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2607. // return -1;
  2608. //}
  2609. added_level = (short)level;
  2610. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild.guild_lv))) // fix positive overflow
  2611. added_level = (short)MAX_GUILDLEVEL - guild_info->guild.guild_lv;
  2612. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild.guild_lv))) // fix negative overflow
  2613. added_level = 1 - guild_info->guild.guild_lv;
  2614. if (added_level != 0) {
  2615. intif_guild_change_basicinfo(guild_info->guild.guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2616. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2617. } else {
  2618. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2619. return -1;
  2620. }
  2621. return 0;
  2622. }
  2623. /*==========================================
  2624. *
  2625. *------------------------------------------*/
  2626. ACMD_FUNC(makeegg) {
  2627. int id;
  2628. nullpo_retr(-1, sd);
  2629. if (!message || !*message) {
  2630. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2631. return -1;
  2632. }
  2633. // for monster name
  2634. if ((id = mobdb_searchname(message)) != 0)
  2635. ;
  2636. else
  2637. id = atoi(message);
  2638. std::shared_ptr<s_pet_db> pet = pet_db.find(id);
  2639. if( pet == nullptr ){
  2640. t_itemid nameid;
  2641. // for egg name
  2642. std::shared_ptr<item_data> item_data = item_db.searchname( message );
  2643. if( item_data != nullptr ){
  2644. nameid = item_data->nameid;
  2645. }else{
  2646. nameid = strtoul( message, nullptr, 10 );
  2647. }
  2648. pet = pet_db_search( nameid, PET_EGG );
  2649. }
  2650. int res(-1);
  2651. if (pet != nullptr) {
  2652. std::shared_ptr<s_mob_db> mdb = mob_db.find(pet->class_);
  2653. if(mdb){
  2654. sd->catch_target_class = pet->class_;
  2655. 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())){
  2656. res = 0;
  2657. } else {
  2658. res = -2; //char server down
  2659. }
  2660. }
  2661. }
  2662. switch(res){
  2663. case -1:
  2664. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2665. break;
  2666. case -2:
  2667. clif_displaymessage(fd, msg_txt(sd,407)); //charserver link broken
  2668. break;
  2669. }
  2670. return res;
  2671. }
  2672. /*==========================================
  2673. *
  2674. *------------------------------------------*/
  2675. ACMD_FUNC(hatch) {
  2676. nullpo_retr(-1, sd);
  2677. if (sd->status.pet_id <= 0)
  2678. clif_sendegg(sd);
  2679. else {
  2680. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2681. return -1;
  2682. }
  2683. return 0;
  2684. }
  2685. /*==========================================
  2686. *
  2687. *------------------------------------------*/
  2688. ACMD_FUNC(petfriendly) {
  2689. int friendly;
  2690. struct pet_data *pd;
  2691. nullpo_retr(-1, sd);
  2692. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2693. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2694. return -1;
  2695. }
  2696. pd = sd->pd;
  2697. if (!pd) {
  2698. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2699. return -1;
  2700. }
  2701. if (friendly < 0 || friendly > 1000)
  2702. {
  2703. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2704. return -1;
  2705. }
  2706. if (friendly == pd->pet.intimate) {
  2707. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2708. return -1;
  2709. }
  2710. pet_set_intimate(pd, friendly);
  2711. clif_send_petstatus(sd);
  2712. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2713. return 0;
  2714. }
  2715. /*==========================================
  2716. *
  2717. *------------------------------------------*/
  2718. ACMD_FUNC(pethungry)
  2719. {
  2720. int hungry;
  2721. struct pet_data *pd;
  2722. nullpo_retr(-1, sd);
  2723. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2724. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2725. return -1;
  2726. }
  2727. pd = sd->pd;
  2728. if (!sd->status.pet_id || !pd) {
  2729. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2730. return -1;
  2731. }
  2732. if (hungry < 0 || hungry > 100) {
  2733. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2734. return -1;
  2735. }
  2736. if (hungry == pd->pet.hungry) {
  2737. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2738. return -1;
  2739. }
  2740. pd->pet.hungry = hungry;
  2741. clif_send_petstatus(sd);
  2742. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2743. return 0;
  2744. }
  2745. /*==========================================
  2746. *
  2747. *------------------------------------------*/
  2748. ACMD_FUNC(petrename)
  2749. {
  2750. struct pet_data *pd;
  2751. nullpo_retr(-1, sd);
  2752. if (!sd->status.pet_id || !sd->pd) {
  2753. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2754. return -1;
  2755. }
  2756. pd = sd->pd;
  2757. if (!pd->pet.rename_flag) {
  2758. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2759. return -1;
  2760. }
  2761. pd->pet.rename_flag = 0;
  2762. intif_save_petdata(sd->status.account_id, &pd->pet);
  2763. clif_send_petstatus(sd);
  2764. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2765. return 0;
  2766. }
  2767. /*==========================================
  2768. *
  2769. *------------------------------------------*/
  2770. ACMD_FUNC(recall) {
  2771. map_session_data* pl_sd = nullptr;;
  2772. nullpo_retr(-1, sd);
  2773. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2774. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2775. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2776. return -1;
  2777. }
  2778. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  2779. {
  2780. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2781. return -1;
  2782. }
  2783. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2784. {
  2785. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to perform this action on the specified player.
  2786. return -1;
  2787. }
  2788. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2789. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2790. return -1;
  2791. }
  2792. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2793. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2794. return -1;
  2795. }
  2796. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2797. return -1;
  2798. }
  2799. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2800. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2801. return -1;
  2802. }
  2803. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2804. clif_displaymessage(fd, atcmd_output);
  2805. return 0;
  2806. }
  2807. /*==========================================
  2808. * charblock command (usage: charblock <player_name>)
  2809. * This command do a definitiv ban on a player
  2810. *------------------------------------------*/
  2811. ACMD_FUNC(char_block)
  2812. {
  2813. nullpo_retr(-1, sd);
  2814. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2815. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2816. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2817. clif_displaymessage(fd, atcmd_output);
  2818. return -1;
  2819. }
  2820. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2821. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2822. clif_displaymessage(fd, atcmd_output);
  2823. return 0;
  2824. }
  2825. /*==========================================
  2826. * accountban command (usage: ban <%time> <player_name>)
  2827. * charban command (usage: charban <%time> <player_name>)
  2828. * %time see common/timer.cpp::solve_time()
  2829. *------------------------------------------*/
  2830. ACMD_FUNC(char_ban)
  2831. {
  2832. char *modif_p, output[CHAT_SIZE_MAX];
  2833. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2834. enum chrif_req_op bantype;
  2835. nullpo_retr(-1, sd);
  2836. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2837. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2838. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2839. if (strcmpi(parent_cmd,"charban") == 0)
  2840. bantype = CHRIF_OP_BAN;
  2841. else if (strcmpi(parent_cmd,"ban") == 0)
  2842. bantype = CHRIF_OP_LOGIN_BAN;
  2843. else
  2844. return -1;
  2845. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2846. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2847. clif_displaymessage(fd, output);
  2848. return -1;
  2849. }
  2850. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2851. modif_p = atcmd_output;
  2852. timediff = (int32)solve_time(modif_p); //discard seconds
  2853. if (timediff == 0) { //allow negative ?
  2854. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2855. clif_displaymessage(fd, output);
  2856. 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.
  2857. return -1;
  2858. }
  2859. if( timediff < 0 && (
  2860. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2861. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2862. ))
  2863. {
  2864. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2865. return -1;
  2866. }
  2867. if (bantype == CHRIF_OP_BAN)
  2868. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2869. else
  2870. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2871. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2872. clif_displaymessage(fd, output);
  2873. return 0;
  2874. }
  2875. /*==========================================
  2876. * charunblock command (usage: charunblock <player_name>)
  2877. *------------------------------------------*/
  2878. ACMD_FUNC(char_unblock)
  2879. {
  2880. nullpo_retr(-1, sd);
  2881. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2882. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2883. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2884. clif_displaymessage(fd, atcmd_output);
  2885. return -1;
  2886. }
  2887. // send answer to login server via char-server
  2888. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2889. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2890. clif_displaymessage(fd, atcmd_output);
  2891. return 0;
  2892. }
  2893. /*==========================================
  2894. * acc unban command (usage: unban <player_name>)
  2895. * char unban command (usage: charunban <player_name>)
  2896. *------------------------------------------*/
  2897. ACMD_FUNC(char_unban){
  2898. enum chrif_req_op unbantype;
  2899. nullpo_retr(-1, sd);
  2900. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2901. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2902. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2903. if (strcmpi(parent_cmd,"charunban") == 0)
  2904. unbantype = CHRIF_OP_UNBAN;
  2905. else if (strcmpi(parent_cmd,"unban") == 0)
  2906. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2907. else
  2908. return -1;
  2909. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2910. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2911. clif_displaymessage(fd, atcmd_output);
  2912. return -1;
  2913. }
  2914. if (unbantype == CHRIF_OP_UNBAN)
  2915. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2916. else
  2917. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2918. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2919. clif_displaymessage(fd, atcmd_output);
  2920. return 0;
  2921. }
  2922. /*==========================================
  2923. *
  2924. *------------------------------------------*/
  2925. ACMD_FUNC(night)
  2926. {
  2927. nullpo_retr(-1, sd);
  2928. if (night_flag != 1) {
  2929. map_night_timer(night_timer_tid, 0, 0, 1);
  2930. } else {
  2931. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2932. return -1;
  2933. }
  2934. return 0;
  2935. }
  2936. /*==========================================
  2937. *
  2938. *------------------------------------------*/
  2939. ACMD_FUNC(day)
  2940. {
  2941. nullpo_retr(-1, sd);
  2942. if (night_flag != 0) {
  2943. map_day_timer(day_timer_tid, 0, 0, 1);
  2944. } else {
  2945. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2946. return -1;
  2947. }
  2948. return 0;
  2949. }
  2950. /*==========================================
  2951. *
  2952. *------------------------------------------*/
  2953. ACMD_FUNC(doom)
  2954. {
  2955. map_session_data* pl_sd;
  2956. struct s_mapiterator* iter;
  2957. nullpo_retr(-1, sd);
  2958. iter = mapit_getallusers();
  2959. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2960. {
  2961. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2962. {
  2963. status_kill(&pl_sd->bl);
  2964. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2965. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2966. }
  2967. }
  2968. mapit_free(iter);
  2969. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2970. return 0;
  2971. }
  2972. /*==========================================
  2973. *
  2974. *------------------------------------------*/
  2975. ACMD_FUNC(doommap)
  2976. {
  2977. map_session_data* pl_sd;
  2978. struct s_mapiterator* iter;
  2979. nullpo_retr(-1, sd);
  2980. iter = mapit_getallusers();
  2981. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2982. {
  2983. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2984. {
  2985. status_kill(&pl_sd->bl);
  2986. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2987. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2988. }
  2989. }
  2990. mapit_free(iter);
  2991. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2992. return 0;
  2993. }
  2994. /*==========================================
  2995. *
  2996. *------------------------------------------*/
  2997. static void atcommand_raise_sub(map_session_data* sd) {
  2998. status_revive(&sd->bl, 100, 100);
  2999. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3000. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  3001. }
  3002. /*==========================================
  3003. *
  3004. *------------------------------------------*/
  3005. ACMD_FUNC(raise)
  3006. {
  3007. map_session_data* pl_sd;
  3008. struct s_mapiterator* iter;
  3009. nullpo_retr(-1, sd);
  3010. iter = mapit_getallusers();
  3011. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3012. if( pc_isdead(pl_sd) )
  3013. atcommand_raise_sub(pl_sd);
  3014. mapit_free(iter);
  3015. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3016. return 0;
  3017. }
  3018. /*==========================================
  3019. *
  3020. *------------------------------------------*/
  3021. ACMD_FUNC(raisemap)
  3022. {
  3023. map_session_data* pl_sd;
  3024. struct s_mapiterator* iter;
  3025. nullpo_retr(-1, sd);
  3026. iter = mapit_getallusers();
  3027. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3028. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  3029. atcommand_raise_sub(pl_sd);
  3030. mapit_free(iter);
  3031. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3032. return 0;
  3033. }
  3034. /*==========================================
  3035. *
  3036. *------------------------------------------*/
  3037. ACMD_FUNC(kick)
  3038. {
  3039. map_session_data *pl_sd;
  3040. nullpo_retr(-1, sd);
  3041. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3042. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3043. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  3044. return -1;
  3045. }
  3046. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  3047. {
  3048. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3049. return -1;
  3050. }
  3051. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  3052. {
  3053. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3054. return -1;
  3055. }
  3056. clif_GM_kick(sd, pl_sd);
  3057. return 0;
  3058. }
  3059. /*==========================================
  3060. *
  3061. *------------------------------------------*/
  3062. ACMD_FUNC(kickall)
  3063. {
  3064. map_session_data* pl_sd;
  3065. struct s_mapiterator* iter;
  3066. nullpo_retr(-1, sd);
  3067. iter = mapit_getallusers();
  3068. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3069. {
  3070. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  3071. if (sd->status.account_id != pl_sd->status.account_id)
  3072. clif_GM_kick(nullptr, pl_sd);
  3073. }
  3074. }
  3075. mapit_free(iter);
  3076. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  3077. return 0;
  3078. }
  3079. /*==========================================
  3080. *
  3081. *------------------------------------------*/
  3082. ACMD_FUNC(allskill)
  3083. {
  3084. nullpo_retr(-1, sd);
  3085. pc_allskillup(sd); // all skills
  3086. sd->status.skill_point = 0; // 0 skill points
  3087. clif_updatestatus(*sd, SP_SKILLPOINT); // update
  3088. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  3089. return 0;
  3090. }
  3091. /*==========================================
  3092. *
  3093. *------------------------------------------*/
  3094. ACMD_FUNC(questskill)
  3095. {
  3096. uint16 skill_id;
  3097. nullpo_retr(-1, sd);
  3098. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3099. {// also send a list of skills applicable to this command
  3100. const char* text;
  3101. // attempt to find the text corresponding to this command
  3102. text = atcommand_help_string( command );
  3103. // send the error message as always
  3104. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3105. if( text )
  3106. {// send the skill ID list associated with this command
  3107. clif_displaymessage( fd, text );
  3108. }
  3109. return -1;
  3110. }
  3111. if (skill_id >= MAX_SKILL_ID) {
  3112. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3113. return -1;
  3114. }
  3115. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3116. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3117. return -1;
  3118. }
  3119. if (pc_checkskill(sd, skill_id) > 0) {
  3120. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  3121. return -1;
  3122. }
  3123. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  3124. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  3125. return 0;
  3126. }
  3127. /*==========================================
  3128. *
  3129. *------------------------------------------*/
  3130. ACMD_FUNC(lostskill)
  3131. {
  3132. uint16 skill_id = 0, sk_idx = 0;
  3133. nullpo_retr(-1, sd);
  3134. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3135. {// also send a list of skills applicable to this command
  3136. const char* text;
  3137. // attempt to find the text corresponding to this command
  3138. text = atcommand_help_string( command );
  3139. // send the error message as always
  3140. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3141. if( text )
  3142. {// send the skill ID list associated with this command
  3143. clif_displaymessage( fd, text );
  3144. }
  3145. return -1;
  3146. }
  3147. if (!(sk_idx = skill_get_index(skill_id))) {
  3148. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3149. return -1;
  3150. }
  3151. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3152. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3153. return -1;
  3154. }
  3155. if (pc_checkskill(sd, skill_id) == 0) {
  3156. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  3157. return -1;
  3158. }
  3159. sd->status.skill[sk_idx].lv = 0;
  3160. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  3161. clif_deleteskill(sd,skill_id);
  3162. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  3163. return 0;
  3164. }
  3165. /*==========================================
  3166. *
  3167. *------------------------------------------*/
  3168. ACMD_FUNC(spiritball)
  3169. {
  3170. int number;
  3171. nullpo_retr(-1, sd);
  3172. if( !message || !*message || ( number = atoi( message ) ) < 0 || number > MAX_SPIRITBALL ){
  3173. char msg[CHAT_SIZE_MAX];
  3174. safesnprintf( msg, sizeof( msg ), msg_txt( sd, 1028 ), MAX_SPIRITBALL ); // Please enter an amount (usage: @spiritball <number: 0-%d>).
  3175. clif_displaymessage(fd, msg);
  3176. return -1;
  3177. }
  3178. if( sd->spiritball > 0 )
  3179. pc_delspiritball(sd, sd->spiritball, 1);
  3180. sd->spiritball = number;
  3181. clif_spiritball(&sd->bl);
  3182. // no message, player can look the difference
  3183. return 0;
  3184. }
  3185. ACMD_FUNC(soulball)
  3186. {
  3187. int number;
  3188. nullpo_retr(-1, sd);
  3189. if (!message || !*message || (number = atoi(message)) < 0 || number > MAX_SOUL_BALL) {
  3190. char msg[CHAT_SIZE_MAX];
  3191. safesnprintf(msg, sizeof(msg), "Usage: @soulball <number: 0-%d>", MAX_SOUL_BALL);
  3192. clif_displaymessage(fd, msg);
  3193. return -1;
  3194. }
  3195. if (sd->soulball > 0)
  3196. pc_delsoulball(sd, sd->soulball, true);
  3197. sd->soulball = number;
  3198. clif_soulball(sd);
  3199. return 0;
  3200. }
  3201. /*==========================================
  3202. *
  3203. *------------------------------------------*/
  3204. ACMD_FUNC(party)
  3205. {
  3206. char party[NAME_LENGTH];
  3207. nullpo_retr(-1, sd);
  3208. memset(party, '\0', sizeof(party));
  3209. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3210. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  3211. return -1;
  3212. }
  3213. party_create( *sd, party, 0, 0 );
  3214. return 0;
  3215. }
  3216. /*==========================================
  3217. *
  3218. *------------------------------------------*/
  3219. ACMD_FUNC(guild)
  3220. {
  3221. char guild[NAME_LENGTH];
  3222. int prev;
  3223. nullpo_retr(-1, sd);
  3224. memset(guild, '\0', sizeof(guild));
  3225. if (sd->clan) {
  3226. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  3227. return -1;
  3228. }
  3229. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3230. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  3231. return -1;
  3232. }
  3233. prev = battle_config.guild_emperium_check;
  3234. battle_config.guild_emperium_check = 0;
  3235. guild_create( *sd, guild );
  3236. battle_config.guild_emperium_check = prev;
  3237. return 0;
  3238. }
  3239. ACMD_FUNC(breakguild)
  3240. {
  3241. nullpo_retr(-1, sd);
  3242. if (sd->status.guild_id) { // Check if the player has a guild
  3243. if (sd->guild) { // Check if guild was found
  3244. if (sd->state.gmaster_flag) { // Check if player is guild master
  3245. // Break guild
  3246. int ret = guild_break( *sd, sd->guild->guild.name );
  3247. if (ret) { // Check if anything went wrong
  3248. return 0; // Guild was broken
  3249. } else {
  3250. return -1; // Something went wrong
  3251. }
  3252. } else { // Not guild master
  3253. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3254. return -1;
  3255. }
  3256. } else { // Guild was not found. HOW?
  3257. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3258. return -1;
  3259. }
  3260. } else { // Player does not have a guild
  3261. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3262. return -1;
  3263. }
  3264. }
  3265. /**
  3266. * Start WoE:FE
  3267. */
  3268. ACMD_FUNC(agitstart)
  3269. {
  3270. nullpo_retr(-1, sd);
  3271. if( guild_agit_start() ){
  3272. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3273. return 0;
  3274. }else{
  3275. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3276. return -1;
  3277. }
  3278. }
  3279. /**
  3280. * Start WoE:SE
  3281. */
  3282. ACMD_FUNC(agitstart2)
  3283. {
  3284. nullpo_retr(-1, sd);
  3285. if( guild_agit2_start() ){
  3286. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3287. return 0;
  3288. }else{
  3289. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3290. return -1;
  3291. }
  3292. }
  3293. /**
  3294. * Start WoE:TE
  3295. */
  3296. ACMD_FUNC(agitstart3)
  3297. {
  3298. nullpo_retr(-1, sd);
  3299. if( guild_agit3_start() ){
  3300. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3301. return 0;
  3302. }else{
  3303. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3304. return -1;
  3305. }
  3306. }
  3307. /**
  3308. * End WoE:FE
  3309. */
  3310. ACMD_FUNC(agitend)
  3311. {
  3312. nullpo_retr(-1, sd);
  3313. if( guild_agit_end() ){
  3314. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3315. return 0;
  3316. }else{
  3317. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3318. return -1;
  3319. }
  3320. }
  3321. /**
  3322. * End WoE:SE
  3323. */
  3324. ACMD_FUNC(agitend2)
  3325. {
  3326. nullpo_retr(-1, sd);
  3327. if( guild_agit2_end() ){
  3328. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3329. return 0;
  3330. }else{
  3331. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3332. return -1;
  3333. }
  3334. }
  3335. /**
  3336. * End WoE:TE
  3337. */
  3338. ACMD_FUNC(agitend3)
  3339. {
  3340. nullpo_retr(-1, sd);
  3341. if( guild_agit3_end() ){
  3342. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3343. return 0;
  3344. }else{
  3345. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3346. return -1;
  3347. }
  3348. }
  3349. /*==========================================
  3350. * @mapexit - shuts down the map server
  3351. *------------------------------------------*/
  3352. ACMD_FUNC(mapexit)
  3353. {
  3354. nullpo_retr(-1, sd);
  3355. global_core->signal_shutdown();
  3356. return 0;
  3357. }
  3358. /*==========================================
  3359. * idsearch <part_of_name>: revrited by [Yor]
  3360. *------------------------------------------*/
  3361. ACMD_FUNC(idsearch)
  3362. {
  3363. nullpo_retr(-1, sd);
  3364. char item_name[100];
  3365. memset(item_name, '\0', sizeof(item_name));
  3366. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3367. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3368. return -1;
  3369. }
  3370. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3371. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3372. clif_displaymessage(fd, atcmd_output);
  3373. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  3374. uint16 match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3375. if (match == MAX_SEARCH) {
  3376. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3377. clif_displaymessage(fd, atcmd_output);
  3378. }
  3379. for(const auto &result : item_array) {
  3380. std::shared_ptr<item_data> id = result.second;
  3381. sprintf(atcmd_output, msg_txt(sd,78), item_db.create_item_link( id ).c_str(), id->nameid); // %s: %u
  3382. clif_displaymessage(fd, atcmd_output);
  3383. }
  3384. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3385. clif_displaymessage(fd, atcmd_output);
  3386. return 0;
  3387. }
  3388. /*==========================================
  3389. * Recall All Characters Online To Your Location
  3390. *------------------------------------------*/
  3391. ACMD_FUNC(recallall)
  3392. {
  3393. map_session_data* pl_sd;
  3394. struct s_mapiterator* iter;
  3395. int count;
  3396. nullpo_retr(-1, sd);
  3397. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3398. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3399. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3400. return -1;
  3401. }
  3402. count = 0;
  3403. iter = mapit_getallusers();
  3404. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3405. {
  3406. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3407. {
  3408. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3409. continue; // Don't waste time warping the character to the same place.
  3410. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3411. count++;
  3412. else {
  3413. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3414. count++;
  3415. }
  3416. }
  3417. }
  3418. }
  3419. mapit_free(iter);
  3420. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3421. if (count) {
  3422. 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.
  3423. clif_displaymessage(fd, atcmd_output);
  3424. }
  3425. return 0;
  3426. }
  3427. /*==========================================
  3428. * Recall online characters of a guild to your location
  3429. *------------------------------------------*/
  3430. ACMD_FUNC(guildrecall)
  3431. {
  3432. map_session_data* pl_sd;
  3433. struct s_mapiterator* iter;
  3434. int count;
  3435. char guild_name[NAME_LENGTH];
  3436. nullpo_retr(-1, sd);
  3437. memset(guild_name, '\0', sizeof(guild_name));
  3438. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3439. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3440. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3441. return -1;
  3442. }
  3443. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3444. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3445. return -1;
  3446. }
  3447. auto g = guild_searchnameid(guild_name);
  3448. if (!g) {
  3449. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3450. return -1;
  3451. }
  3452. count = 0;
  3453. iter = mapit_getallusers();
  3454. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3455. {
  3456. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild.guild_id)
  3457. {
  3458. 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))
  3459. continue; // Skip GMs greater than you... or chars already on the cell
  3460. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3461. count++;
  3462. else{
  3463. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3464. count++;
  3465. }
  3466. }
  3467. }
  3468. }
  3469. mapit_free(iter);
  3470. sprintf(atcmd_output, msg_txt(sd,93), g->guild.name); // All online characters of the %s guild have been recalled to your position.
  3471. clif_displaymessage(fd, atcmd_output);
  3472. if (count) {
  3473. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3474. clif_displaymessage(fd, atcmd_output);
  3475. }
  3476. return 0;
  3477. }
  3478. /*==========================================
  3479. * Recall online characters of a party to your location
  3480. *------------------------------------------*/
  3481. ACMD_FUNC(partyrecall)
  3482. {
  3483. map_session_data* pl_sd;
  3484. struct s_mapiterator* iter;
  3485. char party_name[NAME_LENGTH];
  3486. struct party_data *p;
  3487. int count;
  3488. nullpo_retr(-1, sd);
  3489. memset(party_name, '\0', sizeof(party_name));
  3490. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3491. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3492. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3493. return -1;
  3494. }
  3495. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3496. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3497. return -1;
  3498. }
  3499. if ((p = party_searchname(party_name)) == nullptr && // name first to avoid error when name begin with a number
  3500. (p = party_search(atoi(message))) == nullptr)
  3501. {
  3502. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3503. return -1;
  3504. }
  3505. count = 0;
  3506. iter = mapit_getallusers();
  3507. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3508. {
  3509. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3510. {
  3511. 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))
  3512. continue; // Skip GMs greater than you... or chars already on the cell
  3513. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3514. count++;
  3515. else{
  3516. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3517. count++;
  3518. }
  3519. }
  3520. }
  3521. }
  3522. mapit_free(iter);
  3523. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3524. clif_displaymessage(fd, atcmd_output);
  3525. if (count) {
  3526. 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.
  3527. clif_displaymessage(fd, atcmd_output);
  3528. }
  3529. return 0;
  3530. }
  3531. /*==========================================
  3532. *
  3533. *------------------------------------------*/
  3534. void atcommand_doload();
  3535. ACMD_FUNC(reload) {
  3536. nullpo_retr(-1, sd);
  3537. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3538. const char* text;
  3539. text = atcommand_help_string( command );
  3540. if(text)
  3541. clif_displaymessage( fd, text );
  3542. return -1;
  3543. }
  3544. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3545. itemdb_reload();
  3546. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3547. } else if (strstr(command, "cashdb") || strncmp(message, "cashdb", 4) == 0) {
  3548. cashshop_reloaddb();
  3549. clif_displaymessage( fd, msg_txt( sd, 832 ) ); // Cash shop database has been reloaded.
  3550. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3551. mob_reload();
  3552. pet_db.reload();
  3553. hom_reload();
  3554. mercenary_db.reload();
  3555. elemental_db.reload();
  3556. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3557. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3558. skill_reload();
  3559. homunculus_db.reload();
  3560. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3561. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3562. atcommand_doload();
  3563. pc_groups_reload();
  3564. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3565. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3566. struct Battle_Config prev_config;
  3567. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3568. battle_config_read(BATTLE_CONF_FILENAME);
  3569. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3570. || prev_config.item_rate_common != battle_config.item_rate_common
  3571. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3572. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3573. || prev_config.item_rate_card != battle_config.item_rate_card
  3574. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3575. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3576. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3577. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3578. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3579. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3580. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3581. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3582. || prev_config.item_rate_use != battle_config.item_rate_use
  3583. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3584. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3585. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3586. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3587. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3588. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3589. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3590. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3591. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3592. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3593. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3594. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3595. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3596. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3597. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3598. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3599. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3600. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3601. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3602. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3603. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3604. )
  3605. { // Exp or Drop rates changed.
  3606. mob_reload(); //Needed as well so rate changes take effect.
  3607. }
  3608. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3609. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3610. status_readdb( true );
  3611. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3612. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3613. pc_readdb();
  3614. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3615. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3616. pc_read_motd();
  3617. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3618. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3619. struct s_mapiterator* iter;
  3620. map_session_data* pl_sd;
  3621. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3622. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3623. iter = mapit_getallusers();
  3624. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3625. pc_close_npc(pl_sd,1);
  3626. clif_cutin( *pl_sd, "", 255 );
  3627. pl_sd->state.block_action &= ~(PCBLOCK_ALL ^ PCBLOCK_IMMUNE);
  3628. bg_queue_leave(pl_sd);
  3629. }
  3630. mapit_free(iter);
  3631. for (auto &bg : bg_queues) {
  3632. for (auto &bg_sd : bg->teama_members)
  3633. bg_team_leave(bg_sd, false, false); // Kick Team A from battlegrounds
  3634. for (auto &bg_sd : bg->teamb_members)
  3635. bg_team_leave(bg_sd, false, false); // Kick Team B from battlegrounds
  3636. bg_queue_clear(bg, true);
  3637. }
  3638. flush_fifos();
  3639. map_reloadnpc(true); // reload config files seeking for npcs
  3640. script_reload();
  3641. npc_reload();
  3642. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3643. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3644. map_msg_reload();
  3645. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3646. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3647. if (quest_db.reload())
  3648. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3649. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3650. if (instance_db.reload())
  3651. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3652. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3653. achievement_db_reload();
  3654. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3655. } else if (strstr(command, "attendancedb") || strncmp(message, "attendancedb", 4) == 0) {
  3656. attendance_db.reload();
  3657. clif_displaymessage(fd, msg_txt(sd, 795)); // Attendance database has been reloaded.
  3658. }else if( strstr( command, "barterdb" ) || strncmp( message, "barterdb", 4 ) == 0 ){
  3659. barter_db.reload();
  3660. clif_displaymessage(fd, msg_txt(sd, 830)); // Barter database has been reloaded.
  3661. }
  3662. return 0;
  3663. }
  3664. /*==========================================
  3665. * @partysharelvl <share_range> [Akinari]
  3666. * Updates char server party share level range in runtime
  3667. * Temporary - Permanent update in inter_athena.conf
  3668. *------------------------------------------*/
  3669. ACMD_FUNC(partysharelvl) {
  3670. unsigned int share_lvl;
  3671. nullpo_retr(-1, sd);
  3672. if(!message || !*message) {
  3673. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3674. return -1;
  3675. } else {
  3676. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3677. }
  3678. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3679. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3680. else //Char server offline
  3681. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3682. return 0;
  3683. }
  3684. /*==========================================
  3685. * @mapinfo [0-3] <map name> by MC_Cameri
  3686. * => Shows information about the map [map name]
  3687. * 0 = no additional information
  3688. * 1 = Show users in that map and their location
  3689. * 2 = Shows NPCs in that map
  3690. * 3 = Shows the chats in that map
  3691. *------------------------------------------*/
  3692. ACMD_FUNC(mapinfo) {
  3693. map_session_data* pl_sd;
  3694. struct s_mapiterator* iter;
  3695. struct chat_data *cd = nullptr;
  3696. char direction[12];
  3697. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3698. unsigned short m_index;
  3699. char mapname[MAP_NAME_LENGTH];
  3700. nullpo_retr(-1, sd);
  3701. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3702. memset(mapname, '\0', sizeof(mapname));
  3703. memset(direction, '\0', sizeof(direction));
  3704. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3705. if (list < 0 || list > 3) {
  3706. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3707. return -1;
  3708. }
  3709. if (mapname[0] == '\0') {
  3710. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3711. m_id = map_mapindex2mapid(sd->mapindex);
  3712. } else {
  3713. m_id = map_mapname2mapid(mapname);
  3714. }
  3715. if (m_id < 0) {
  3716. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3717. return -1;
  3718. }
  3719. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3720. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3721. // count chats (for initial message)
  3722. chat_num = 0;
  3723. iter = mapit_getallusers();
  3724. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3725. if( pl_sd->mapindex == m_index ) {
  3726. if( pl_sd->state.vending )
  3727. vend_num++;
  3728. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr && cd->usersd[0] == pl_sd )
  3729. chat_num++;
  3730. }
  3731. }
  3732. mapit_free(iter);
  3733. struct map_data *mapdata = map_getmapdata(m_id);
  3734. 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
  3735. clif_displaymessage(fd, atcmd_output);
  3736. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3737. if (map_getmapflag(m_id, MF_TOWN))
  3738. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3739. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3740. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3741. clif_displaymessage(fd, atcmd_output);
  3742. }
  3743. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3744. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3745. else
  3746. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3747. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3748. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3749. clif_displaymessage(fd, atcmd_output);
  3750. }
  3751. /* Skill damage adjustment info [Cydh] */
  3752. if (mapdata->getMapFlag(MF_SKILL_DAMAGE)) {
  3753. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3754. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3755. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3756. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3757. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3758. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3759. mapdata->damage_adjust.caster);
  3760. clif_displaymessage(fd, atcmd_output);
  3761. if (!mapdata->skill_damage.empty()) {
  3762. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3763. for (const auto& skilldmg : mapdata->skill_damage) {
  3764. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3765. skill_get_name(skilldmg.first),
  3766. skilldmg.second.rate[SKILLDMG_PC],
  3767. skilldmg.second.rate[SKILLDMG_MOB],
  3768. skilldmg.second.rate[SKILLDMG_BOSS],
  3769. skilldmg.second.rate[SKILLDMG_OTHER],
  3770. skilldmg.second.caster);
  3771. clif_displaymessage(fd,atcmd_output);
  3772. }
  3773. }
  3774. }
  3775. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3776. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3777. for (const auto &it : mapdata->skill_duration) {
  3778. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3779. clif_displaymessage(fd, atcmd_output);
  3780. }
  3781. }
  3782. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3783. if (map_getmapflag(m_id, MF_PVP))
  3784. strcat(atcmd_output, " Pvp ON |");
  3785. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3786. strcat(atcmd_output, " NoGuild |");
  3787. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3788. strcat(atcmd_output, " NoParty |");
  3789. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3790. strcat(atcmd_output, " NightmareDrop |");
  3791. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3792. strcat(atcmd_output, " NoCalcRank |");
  3793. clif_displaymessage(fd, atcmd_output);
  3794. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3795. if (map_getmapflag(m_id, MF_GVG))
  3796. strcat(atcmd_output, " GvG ON |");
  3797. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3798. strcat(atcmd_output, " GvG Dungeon |");
  3799. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3800. strcat(atcmd_output, " GvG Castle |");
  3801. if (map_getmapflag(m_id, MF_GVG_TE))
  3802. strcat(atcmd_output, " GvG TE |");
  3803. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3804. strcat(atcmd_output, " GvG TE Castle |");
  3805. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3806. strcat(atcmd_output, " NoParty |");
  3807. clif_displaymessage(fd, atcmd_output);
  3808. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3809. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3810. strcat(atcmd_output, " NoTeleport |");
  3811. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3812. strcat(atcmd_output, " Monster NoTeleport |");
  3813. if (map_getmapflag(m_id, MF_NOWARP))
  3814. strcat(atcmd_output, " NoWarp |");
  3815. if (map_getmapflag(m_id, MF_NOWARPTO))
  3816. strcat(atcmd_output, " NoWarpTo |");
  3817. if (map_getmapflag(m_id, MF_NORETURN))
  3818. strcat(atcmd_output, " NoReturn |");
  3819. if (map_getmapflag(m_id, MF_NOGO))
  3820. strcat(atcmd_output, " NoGo |"); //
  3821. if (map_getmapflag(m_id, MF_NOMEMO))
  3822. strcat(atcmd_output, " NoMemo |");
  3823. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_SOURCE))
  3824. strcat(atcmd_output, " PrivateAirship_Source |");
  3825. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_DESTINATION))
  3826. strcat(atcmd_output, " PrivateAirship_Destination |");
  3827. clif_displaymessage(fd, atcmd_output);
  3828. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3829. (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
  3830. clif_displaymessage(fd, atcmd_output);
  3831. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3832. if (!mapdata->save.map)
  3833. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3834. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3835. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3836. clif_displaymessage(fd, atcmd_output);
  3837. }
  3838. else {
  3839. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3840. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3841. clif_displaymessage(fd, atcmd_output);
  3842. }
  3843. }
  3844. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3845. if (map_getmapflag(m_id, MF_SNOW))
  3846. strcat(atcmd_output, " Snow |");
  3847. if (map_getmapflag(m_id, MF_FOG))
  3848. strcat(atcmd_output, " Fog |");
  3849. if (map_getmapflag(m_id, MF_SAKURA))
  3850. strcat(atcmd_output, " Sakura |");
  3851. if (map_getmapflag(m_id, MF_CLOUDS))
  3852. strcat(atcmd_output, " Clouds |");
  3853. if (map_getmapflag(m_id, MF_CLOUDS2))
  3854. strcat(atcmd_output, " Clouds2 |");
  3855. if (map_getmapflag(m_id, MF_FIREWORKS))
  3856. strcat(atcmd_output, " Fireworks |");
  3857. if (map_getmapflag(m_id, MF_LEAVES))
  3858. strcat(atcmd_output, " Leaves |");
  3859. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3860. strcat(atcmd_output, " Displays Night |");
  3861. clif_displaymessage(fd, atcmd_output);
  3862. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3863. if (map_getmapflag(m_id, MF_NOBRANCH))
  3864. strcat(atcmd_output, " NoBranch |");
  3865. if (map_getmapflag(m_id, MF_NOTRADE))
  3866. strcat(atcmd_output, " NoTrade |");
  3867. if (map_getmapflag(m_id, MF_NOVENDING))
  3868. strcat(atcmd_output, " NoVending |");
  3869. if (map_getmapflag(m_id, MF_NOBUYINGSTORE))
  3870. strcat(atcmd_output, " NoBuyingstore |");
  3871. if (map_getmapflag(m_id, MF_NODROP))
  3872. strcat(atcmd_output, " NoDrop |");
  3873. if (map_getmapflag(m_id, MF_NOSKILL))
  3874. strcat(atcmd_output, " NoSkill |");
  3875. if (map_getmapflag(m_id, MF_NOICEWALL))
  3876. strcat(atcmd_output, " NoIcewall |");
  3877. if (map_getmapflag(m_id, MF_ALLOWKS))
  3878. strcat(atcmd_output, " AllowKS |");
  3879. if (map_getmapflag(m_id, MF_RESET))
  3880. strcat(atcmd_output, " Reset |");
  3881. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3882. strcat(atcmd_output, " HideMobHPBar |");
  3883. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3884. strcat(atcmd_output, " NoCommand |");
  3885. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3886. strcat(atcmd_output, " NoBaseEXP |");
  3887. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3888. strcat(atcmd_output, " NoJobEXP |");
  3889. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3890. strcat(atcmd_output, " NoMobLoot |");
  3891. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3892. strcat(atcmd_output, " NoMVPLoot |");
  3893. if (map_getmapflag(m_id, MF_NORENEWALEXPPENALTY))
  3894. strcat(atcmd_output, " NoRenewalExpPenalty |");
  3895. if (map_getmapflag(m_id, MF_NORENEWALDROPPENALTY))
  3896. strcat(atcmd_output, " NoRenewalDropPenalty |");
  3897. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3898. strcat(atcmd_output, " PartyLock |");
  3899. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3900. strcat(atcmd_output, " GuildLock |");
  3901. if (map_getmapflag(m_id, MF_LOADEVENT))
  3902. strcat(atcmd_output, " Loadevent |");
  3903. if (map_getmapflag(m_id, MF_NODYNAMICNPC))
  3904. strcat(atcmd_output, " NoDynamicNPC |");
  3905. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3906. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  3907. if (map_getmapflag(m_id, MF_NOUSECART))
  3908. strcat(atcmd_output, " NoUsecart |");
  3909. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  3910. strcat(atcmd_output, " NoItemConsumption |");
  3911. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  3912. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  3913. if (map_getmapflag(m_id, MF_FORCEMINEFFECT))
  3914. strcat(atcmd_output, " ForceMinEffect |");
  3915. if (map_getmapflag(m_id, MF_NOLOCKON))
  3916. strcat(atcmd_output, " NoLockOn |");
  3917. if (map_getmapflag(m_id, MF_NOTOMB))
  3918. strcat(atcmd_output, " NoTomb |");
  3919. if (map_getmapflag(m_id, MF_NOCOSTUME))
  3920. strcat(atcmd_output, " NoCostume |");
  3921. if (map_getmapflag(m_id, MF_NOBANK))
  3922. strcat(atcmd_output, " NoBank |");
  3923. if (map_getmapflag(m_id, MF_NOCASHSHOP))
  3924. strcat(atcmd_output, " NoCashShop |");
  3925. if (map_getmapflag(m_id, MF_NORODEX))
  3926. strcat(atcmd_output, " NoRODex |");
  3927. if (map_getmapflag(m_id, MF_NOPETCAPTURE))
  3928. strcat(atcmd_output, " NoPetCapture |");
  3929. clif_displaymessage(fd, atcmd_output);
  3930. switch (list) {
  3931. case 0:
  3932. // Do nothing. It's list 0, no additional display.
  3933. break;
  3934. case 1:
  3935. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3936. iter = mapit_getallusers();
  3937. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3938. {
  3939. if (pl_sd->mapindex == m_index) {
  3940. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3941. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3942. clif_displaymessage(fd, atcmd_output);
  3943. }
  3944. }
  3945. mapit_free(iter);
  3946. break;
  3947. case 2:
  3948. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3949. for (i = 0; i < mapdata->npc_num;)
  3950. {
  3951. struct npc_data *nd = mapdata->npc[i];
  3952. switch(nd->ud.dir) {
  3953. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3954. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3955. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3956. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3957. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3958. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3959. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3960. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3961. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3962. }
  3963. if(strcmp(nd->name,nd->exname) == 0)
  3964. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3965. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3966. else
  3967. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3968. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3969. clif_displaymessage(fd, atcmd_output);
  3970. }
  3971. break;
  3972. case 3:
  3973. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3974. iter = mapit_getallusers();
  3975. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3976. {
  3977. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr &&
  3978. pl_sd->mapindex == m_index &&
  3979. cd->usersd[0] == pl_sd)
  3980. {
  3981. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3982. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3983. clif_displaymessage(fd, atcmd_output);
  3984. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3985. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3986. clif_displaymessage(fd, atcmd_output);
  3987. }
  3988. }
  3989. mapit_free(iter);
  3990. break;
  3991. default: // normally impossible to arrive here
  3992. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3993. return -1;
  3994. break;
  3995. }
  3996. return 0;
  3997. }
  3998. /*==========================================
  3999. *
  4000. *------------------------------------------*/
  4001. ACMD_FUNC(mount_peco)
  4002. {
  4003. nullpo_retr(-1, sd);
  4004. if (sd->disguise) {
  4005. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  4006. return -1;
  4007. }
  4008. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4009. if( !(sd->sc.option&OPTION_DRAGON) ) {
  4010. unsigned int option = OPTION_DRAGON1;
  4011. if( message[0] ) {
  4012. int color = atoi(message);
  4013. option = ( color == 2 ? OPTION_DRAGON2 :
  4014. color == 3 ? OPTION_DRAGON3 :
  4015. color == 4 ? OPTION_DRAGON4 :
  4016. color == 5 ? OPTION_DRAGON5 :
  4017. OPTION_DRAGON1 );
  4018. }
  4019. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  4020. pc_setoption(sd, sd->sc.option|option);
  4021. } else {
  4022. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  4023. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  4024. }
  4025. return 0;
  4026. }
  4027. 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)) ) {
  4028. if( !pc_isridingwug(sd) ) {
  4029. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  4030. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  4031. } else {
  4032. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  4033. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  4034. }
  4035. return 0;
  4036. }
  4037. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4038. if( !pc_ismadogear(sd) ) {
  4039. e_mado_type type = MADO_ROBOT;
  4040. if (message[0]) {
  4041. int tmp = strtol(message, nullptr, 10);
  4042. switch (tmp) {
  4043. case MADO_ROBOT:
  4044. case MADO_SUIT:
  4045. type = static_cast<e_mado_type>(tmp);
  4046. break;
  4047. default:
  4048. type = MADO_ROBOT;
  4049. break;
  4050. }
  4051. }
  4052. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  4053. pc_setmadogear(sd, true, type);
  4054. } else {
  4055. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  4056. pc_setmadogear(sd, false);
  4057. }
  4058. return 0;
  4059. }
  4060. if (!pc_isriding(sd)) { // if actually no peco
  4061. if (!pc_checkskill(sd, KN_RIDING)) {
  4062. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  4063. return -1;
  4064. }
  4065. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4066. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  4067. } else {//Dismount
  4068. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4069. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  4070. }
  4071. return 0;
  4072. }
  4073. /*==========================================
  4074. *Spy Commands by Syrus22
  4075. *------------------------------------------*/
  4076. ACMD_FUNC(guildspy)
  4077. {
  4078. char guild_name[NAME_LENGTH];
  4079. nullpo_retr(-1, sd);
  4080. memset(guild_name, '\0', sizeof(guild_name));
  4081. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4082. if (!enable_spy)
  4083. {
  4084. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4085. return -1;
  4086. }
  4087. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4088. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  4089. return -1;
  4090. }
  4091. auto g = guild_searchnameid(guild_name);
  4092. if (!g) {
  4093. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  4094. return -1;
  4095. }
  4096. if (sd->guildspy == g->guild.guild_id) {
  4097. sd->guildspy = 0;
  4098. sprintf(atcmd_output, msg_txt(sd,103), g->guild.name); // No longer spying on the %s guild.
  4099. clif_displaymessage(fd, atcmd_output);
  4100. } else {
  4101. sd->guildspy = g->guild.guild_id;
  4102. sprintf(atcmd_output, msg_txt(sd,104), g->guild.name); // Spying on the %s guild.
  4103. clif_displaymessage(fd, atcmd_output);
  4104. }
  4105. return 0;
  4106. }
  4107. /*==========================================
  4108. *
  4109. *------------------------------------------*/
  4110. ACMD_FUNC(partyspy)
  4111. {
  4112. char party_name[NAME_LENGTH];
  4113. struct party_data *p;
  4114. nullpo_retr(-1, sd);
  4115. memset(party_name, '\0', sizeof(party_name));
  4116. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4117. if (!enable_spy)
  4118. {
  4119. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4120. return -1;
  4121. }
  4122. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4123. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  4124. return -1;
  4125. }
  4126. if ((p = party_searchname(party_name)) != nullptr || // name first to avoid error when name begin with a number
  4127. (p = party_search(atoi(message))) != nullptr) {
  4128. if (sd->partyspy == p->party.party_id) {
  4129. sd->partyspy = 0;
  4130. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  4131. clif_displaymessage(fd, atcmd_output);
  4132. } else {
  4133. sd->partyspy = p->party.party_id;
  4134. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  4135. clif_displaymessage(fd, atcmd_output);
  4136. }
  4137. } else {
  4138. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  4139. return -1;
  4140. }
  4141. return 0;
  4142. }
  4143. ACMD_FUNC(clanspy){
  4144. char clan_name[NAME_LENGTH];
  4145. struct clan* c;
  4146. nullpo_retr(-1, sd);
  4147. memset(clan_name, '\0', sizeof(clan_name));
  4148. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4149. if( !enable_spy ){
  4150. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  4151. return -1;
  4152. }
  4153. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  4154. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  4155. return -1;
  4156. }
  4157. if ((c = clan_searchname(clan_name)) != nullptr || // name first to avoid error when name begin with a number
  4158. (c = clan_search(atoi(message))) != nullptr) {
  4159. if (sd->clanspy == c->id) {
  4160. sd->clanspy = 0;
  4161. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  4162. clif_displaymessage(fd, atcmd_output);
  4163. }
  4164. else {
  4165. sd->clanspy = c->id;
  4166. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  4167. clif_displaymessage(fd, atcmd_output);
  4168. }
  4169. }
  4170. else {
  4171. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  4172. return -1;
  4173. }
  4174. return 0;
  4175. }
  4176. /*==========================================
  4177. * @repairall [Valaris]
  4178. *------------------------------------------*/
  4179. ACMD_FUNC(repairall)
  4180. {
  4181. int count, i;
  4182. nullpo_retr(-1, sd);
  4183. count = 0;
  4184. for (i = 0; i < MAX_INVENTORY; i++) {
  4185. 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])) {
  4186. sd->inventory.u.items_inventory[i].attribute = 0;
  4187. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  4188. count++;
  4189. }
  4190. }
  4191. if (count > 0) {
  4192. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  4193. clif_equiplist(sd);
  4194. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  4195. } else {
  4196. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  4197. return -1;
  4198. }
  4199. return 0;
  4200. }
  4201. /*==========================================
  4202. * @nuke [Valaris]
  4203. *------------------------------------------*/
  4204. ACMD_FUNC(nuke)
  4205. {
  4206. map_session_data *pl_sd;
  4207. nullpo_retr(-1, sd);
  4208. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4209. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4210. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  4211. return -1;
  4212. }
  4213. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != nullptr) {
  4214. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  4215. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4216. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  4217. } else {
  4218. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4219. return -1;
  4220. }
  4221. } else {
  4222. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4223. return -1;
  4224. }
  4225. return 0;
  4226. }
  4227. /*==========================================
  4228. * @tonpc
  4229. *------------------------------------------*/
  4230. ACMD_FUNC(tonpc)
  4231. {
  4232. char npcname[NPC_NAME_LENGTH];
  4233. struct npc_data *nd;
  4234. nullpo_retr(-1, sd);
  4235. memset(npcname, 0, sizeof(npcname));
  4236. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  4237. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  4238. return -1;
  4239. }
  4240. if ((nd = npc_name2id(npcname)) != nullptr) {
  4241. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  4242. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  4243. else
  4244. return -1;
  4245. } else {
  4246. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4247. return -1;
  4248. }
  4249. return 0;
  4250. }
  4251. /*==========================================
  4252. *
  4253. *------------------------------------------*/
  4254. ACMD_FUNC(shownpc)
  4255. {
  4256. char NPCname[NPC_NAME_LENGTH];
  4257. nullpo_retr(-1, sd);
  4258. memset(NPCname, '\0', sizeof(NPCname));
  4259. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4260. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  4261. return -1;
  4262. }
  4263. npc_data* nd = npc_name2id(NPCname);
  4264. if (nd) {
  4265. npc_enable(*nd, NPCVIEW_ENABLE);
  4266. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4267. } else {
  4268. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4269. return -1;
  4270. }
  4271. return 0;
  4272. }
  4273. /*==========================================
  4274. *
  4275. *------------------------------------------*/
  4276. ACMD_FUNC(hidenpc)
  4277. {
  4278. char NPCname[NPC_NAME_LENGTH];
  4279. nullpo_retr(-1, sd);
  4280. memset(NPCname, '\0', sizeof(NPCname));
  4281. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4282. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4283. return -1;
  4284. }
  4285. npc_data* nd = npc_name2id(NPCname);
  4286. if (!nd) {
  4287. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4288. return -1;
  4289. }
  4290. npc_enable(*nd, NPCVIEW_DISABLE);
  4291. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4292. return 0;
  4293. }
  4294. ACMD_FUNC(loadnpc)
  4295. {
  4296. if (!message || !*message) {
  4297. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4298. return -1;
  4299. }
  4300. if (!npc_addsrcfile(message, true)) {
  4301. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4302. return -1;
  4303. }
  4304. npc_read_event_script();
  4305. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was loaded.\n", message );
  4306. npc_event_doall_path( script_config.init_event_name, message );
  4307. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4308. return 0;
  4309. }
  4310. ACMD_FUNC(unloadnpc)
  4311. {
  4312. struct npc_data *nd;
  4313. char NPCname[NPC_NAME_LENGTH];
  4314. nullpo_retr(-1, sd);
  4315. memset(NPCname, '\0', sizeof(NPCname));
  4316. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4317. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4318. return -1;
  4319. }
  4320. if ((nd = npc_name2id(NPCname)) == nullptr) {
  4321. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4322. return -1;
  4323. }
  4324. npc_unload_duplicates(nd);
  4325. npc_unload(nd,true);
  4326. npc_read_event_script();
  4327. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4328. return 0;
  4329. }
  4330. ACMD_FUNC(reloadnpcfile) {
  4331. if (!message || !*message) {
  4332. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4333. return -1;
  4334. }
  4335. if (npc_unloadfile(message))
  4336. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4337. if (!npc_addsrcfile(message, true)) {
  4338. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4339. return -1;
  4340. }
  4341. npc_read_event_script();
  4342. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was reloaded.\n", message );
  4343. npc_event_doall_path( script_config.init_event_name, message );
  4344. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4345. return 0;
  4346. }
  4347. /*==========================================
  4348. * time in txt for time command (by [Yor])
  4349. *------------------------------------------*/
  4350. char* txt_time(t_tick duration_)
  4351. {
  4352. int days, hours, minutes, seconds;
  4353. char temp[CHAT_SIZE_MAX];
  4354. static char temp1[CHAT_SIZE_MAX];
  4355. memset(temp, '\0', sizeof(temp));
  4356. memset(temp1, '\0', sizeof(temp1));
  4357. // Cap it
  4358. int duration = (int)duration_;
  4359. days = duration / (60 * 60 * 24);
  4360. duration = duration - (60 * 60 * 24 * days);
  4361. hours = duration / (60 * 60);
  4362. duration = duration - (60 * 60 * hours);
  4363. minutes = duration / 60;
  4364. seconds = duration - (60 * minutes);
  4365. if (days == 1)
  4366. sprintf(temp, msg_txt(nullptr,219), days); // %d day
  4367. else if (days > 1)
  4368. sprintf(temp, msg_txt(nullptr,220), days); // %d days
  4369. if (hours == 1)
  4370. sprintf(temp1, msg_txt(nullptr,221), temp, hours); // %s %d hour
  4371. else if (hours > 1)
  4372. sprintf(temp1, msg_txt(nullptr,222), temp, hours); // %s %d hours
  4373. if (minutes < 2)
  4374. sprintf(temp, msg_txt(nullptr,223), temp1, minutes); // %s %d minute
  4375. else
  4376. sprintf(temp, msg_txt(nullptr,224), temp1, minutes); // %s %d minutes
  4377. if (seconds == 1)
  4378. sprintf(temp1, msg_txt(nullptr,225), temp, seconds); // %s and %d second
  4379. else if (seconds > 1)
  4380. sprintf(temp1, msg_txt(nullptr,226), temp, seconds); // %s and %d seconds
  4381. return temp1;
  4382. }
  4383. /*==========================================
  4384. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4385. * Calculation management of GM modification (@day/@night GM commands) is done
  4386. *------------------------------------------*/
  4387. ACMD_FUNC(servertime)
  4388. {
  4389. const struct TimerData * timer_data;
  4390. time_t time_server; // variable for number of seconds (used with time() function)
  4391. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4392. char temp[CHAT_SIZE_MAX];
  4393. nullpo_retr(-1, sd);
  4394. memset(temp, '\0', sizeof(temp));
  4395. time(&time_server); // get time in seconds since 1/1/1970
  4396. datetime = localtime(&time_server); // convert seconds in structure
  4397. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4398. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4399. clif_displaymessage(fd, temp);
  4400. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4401. if (night_flag == 0)
  4402. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4403. else
  4404. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4405. } else if (battle_config.night_duration == 0)
  4406. if (night_flag == 1) { // we start with night
  4407. if ((timer_data = get_timer(day_timer_tid)) != nullptr) {
  4408. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4409. clif_displaymessage(fd, temp);
  4410. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4411. } else
  4412. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4413. } else
  4414. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4415. else if (battle_config.day_duration == 0)
  4416. if (night_flag == 0) { // we start with day
  4417. if ((timer_data = get_timer(night_timer_tid)) != nullptr) {
  4418. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4419. clif_displaymessage(fd, temp);
  4420. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4421. } else
  4422. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4423. } else
  4424. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4425. else {
  4426. const struct TimerData * timer_data2;
  4427. if (night_flag == 0) {
  4428. if ((timer_data = get_timer(night_timer_tid)) != nullptr && (timer_data2 = get_timer(day_timer_tid)) != nullptr) {
  4429. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4430. clif_displaymessage(fd, temp);
  4431. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4432. 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.
  4433. else
  4434. 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.
  4435. clif_displaymessage(fd, temp);
  4436. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4437. clif_displaymessage(fd, temp);
  4438. } else
  4439. clif_displaymessage(fd, msg_txt(sd, 231)); // Game time: The game is in permanent daylight.
  4440. } else {
  4441. if ((timer_data = get_timer(day_timer_tid)) != nullptr && (timer_data2 = get_timer(night_timer_tid)) != nullptr) {
  4442. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4443. clif_displaymessage(fd, temp);
  4444. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4445. 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.
  4446. else
  4447. 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.
  4448. clif_displaymessage(fd, temp);
  4449. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4450. clif_displaymessage(fd, temp);
  4451. } else
  4452. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4453. }
  4454. }
  4455. return 0;
  4456. }
  4457. /*==========================================
  4458. * @jail <char_name> by [Yor]
  4459. * Special warp! No check with nowarp and nowarpto flag
  4460. *------------------------------------------*/
  4461. ACMD_FUNC(jail)
  4462. {
  4463. map_session_data *pl_sd;
  4464. nullpo_retr(-1, sd);
  4465. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4466. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4467. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4468. return -1;
  4469. }
  4470. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4471. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4472. return -1;
  4473. }
  4474. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4475. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4476. return -1;
  4477. }
  4478. if (pl_sd->sc.getSCE(SC_JAILED)) {
  4479. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4480. return -1;
  4481. }
  4482. pc_jail(*pl_sd);
  4483. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4484. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4485. return 0;
  4486. }
  4487. /*==========================================
  4488. * @unjail/@discharge <char_name> by [Yor]
  4489. * Special warp! No check with nowarp and nowarpto flag
  4490. *------------------------------------------*/
  4491. ACMD_FUNC(unjail)
  4492. {
  4493. map_session_data *pl_sd;
  4494. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4495. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4496. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4497. return -1;
  4498. }
  4499. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4500. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4501. return -1;
  4502. }
  4503. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4504. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4505. return -1;
  4506. }
  4507. if (!pl_sd->sc.getSCE(SC_JAILED)) {
  4508. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4509. return -1;
  4510. }
  4511. //Reset jail time to 1 sec.
  4512. pc_jail(*pl_sd, 0);
  4513. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4514. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4515. return 0;
  4516. }
  4517. ACMD_FUNC(jailfor) {
  4518. map_session_data* pl_sd = nullptr;;
  4519. char * modif_p;
  4520. int jailtime = 0;
  4521. nullpo_retr(-1, sd);
  4522. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4523. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4524. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4525. return -1;
  4526. }
  4527. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4528. modif_p = atcmd_output;
  4529. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4530. if (jailtime == 0) {
  4531. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4532. 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.
  4533. return -1;
  4534. }
  4535. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4536. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4537. return -1;
  4538. }
  4539. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4540. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4541. return -1;
  4542. }
  4543. // Added by Coltaro
  4544. if(pl_sd->sc.getSCE(SC_JAILED) && pl_sd->sc.getSCE(SC_JAILED)->val1 != INT_MAX) { // Update the player's jail time
  4545. jailtime += pl_sd->sc.getSCE(SC_JAILED)->val1;
  4546. if (jailtime <= 0) {
  4547. jailtime = 0;
  4548. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4549. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4550. } else {
  4551. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4552. char timestr[21];
  4553. time_t now=time(nullptr);
  4554. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4555. 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
  4556. clif_displaymessage(pl_sd->fd, atcmd_output);
  4557. 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
  4558. clif_displaymessage(fd, atcmd_output);
  4559. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4560. sprintf(atcmd_output,"Release date is: %s",timestr);
  4561. clif_displaymessage(pl_sd->fd, atcmd_output);
  4562. clif_displaymessage(fd, atcmd_output);
  4563. }
  4564. } else if (jailtime < 0) {
  4565. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4566. return -1;
  4567. }
  4568. pc_jail(*pl_sd, jailtime);
  4569. return 0;
  4570. }
  4571. //By Coltaro
  4572. ACMD_FUNC(jailtime){
  4573. int year, month, day, hour, minute, second;
  4574. char timestr[21];
  4575. time_t now = time(nullptr);
  4576. nullpo_retr(-1, sd);
  4577. if (!sd->sc.getSCE(SC_JAILED)) {
  4578. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4579. return -1;
  4580. }
  4581. if (sd->sc.getSCE(SC_JAILED)->val1 == INT_MAX) {
  4582. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4583. return 0;
  4584. }
  4585. if (sd->sc.getSCE(SC_JAILED)->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4586. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4587. return -1;
  4588. }
  4589. // Get remaining jail time
  4590. split_time(sd->sc.getSCE(SC_JAILED)->val1*60,&year,&month,&day,&hour,&minute,&second);
  4591. 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
  4592. clif_displaymessage(fd, atcmd_output);
  4593. timestamp2string(timestr,20,now+sd->sc.getSCE(SC_JAILED)->val1*60,"%Y-%m-%d %H:%M");
  4594. sprintf(atcmd_output,"Release date is: %s",timestr);
  4595. clif_displaymessage(fd, atcmd_output);
  4596. return 0;
  4597. }
  4598. /*==========================================
  4599. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4600. *------------------------------------------*/
  4601. ACMD_FUNC(disguise)
  4602. {
  4603. int id = 0;
  4604. nullpo_retr(-1, sd);
  4605. if (!message || !*message) {
  4606. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4607. return -1;
  4608. }
  4609. if ((id = atoi(message)) > 0)
  4610. { //Acquired an ID
  4611. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4612. id = 0; //Invalid id for either mobs or npcs.
  4613. } else { //Acquired a Name
  4614. if ((id = mobdb_searchname(message)) == 0)
  4615. {
  4616. struct npc_data* nd = npc_name2id(message);
  4617. if (nd != nullptr)
  4618. id = nd->class_;
  4619. }
  4620. }
  4621. if (id == 0)
  4622. {
  4623. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4624. return -1;
  4625. }
  4626. if(pc_isriding(sd))
  4627. {
  4628. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4629. return -1;
  4630. }
  4631. if (sd->sc.getSCE(SC_MONSTER_TRANSFORM) || sd->sc.getSCE(SC_ACTIVE_MONSTER_TRANSFORM)) {
  4632. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4633. return -1;
  4634. }
  4635. pc_disguise(sd, id);
  4636. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4637. return 0;
  4638. }
  4639. /*==========================================
  4640. * DisguiseAll
  4641. *------------------------------------------*/
  4642. ACMD_FUNC(disguiseall)
  4643. {
  4644. int mob_id=0;
  4645. map_session_data *pl_sd;
  4646. struct s_mapiterator* iter;
  4647. nullpo_retr(-1, sd);
  4648. if (!message || !*message) {
  4649. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4650. return -1;
  4651. }
  4652. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4653. mob_id = atoi(message);
  4654. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4655. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4656. return -1;
  4657. }
  4658. iter = mapit_getallusers();
  4659. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4660. pc_disguise(pl_sd, mob_id);
  4661. mapit_free(iter);
  4662. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4663. return 0;
  4664. }
  4665. /*==========================================
  4666. * DisguiseGuild
  4667. *------------------------------------------*/
  4668. ACMD_FUNC(disguiseguild)
  4669. {
  4670. int id = 0, i;
  4671. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4672. memset(monster, '\0', sizeof(monster));
  4673. memset(guild, '\0', sizeof(guild));
  4674. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4675. 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>).
  4676. return -1;
  4677. }
  4678. if( (id = atoi(monster)) > 0 ) {
  4679. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4680. id = 0;
  4681. } else {
  4682. if( (id = mobdb_searchname(monster)) == 0 ) {
  4683. struct npc_data* nd = npc_name2id(monster);
  4684. if( nd != nullptr )
  4685. id = nd->class_;
  4686. }
  4687. }
  4688. if( id == 0 ) {
  4689. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4690. return -1;
  4691. }
  4692. auto g = guild_searchnameid(guild);
  4693. if (!g) {
  4694. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4695. return -1;
  4696. }
  4697. for( i = 0; i < g->guild.max_member; i++ ){
  4698. map_session_data *pl_sd;
  4699. if( (pl_sd = g->guild.member[i].sd) && !pc_isriding(pl_sd) )
  4700. pc_disguise(pl_sd, id);
  4701. }
  4702. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4703. return 0;
  4704. }
  4705. /*==========================================
  4706. * @undisguise by [Yor]
  4707. *------------------------------------------*/
  4708. ACMD_FUNC(undisguise)
  4709. {
  4710. nullpo_retr(-1, sd);
  4711. if (sd->disguise) {
  4712. pc_disguise(sd, 0);
  4713. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4714. } else {
  4715. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4716. return -1;
  4717. }
  4718. return 0;
  4719. }
  4720. /*==========================================
  4721. * UndisguiseAll
  4722. *------------------------------------------*/
  4723. ACMD_FUNC(undisguiseall)
  4724. {
  4725. map_session_data *pl_sd;
  4726. struct s_mapiterator* iter;
  4727. nullpo_retr(-1, sd);
  4728. iter = mapit_getallusers();
  4729. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4730. if( pl_sd->disguise )
  4731. pc_disguise(pl_sd, 0);
  4732. mapit_free(iter);
  4733. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4734. return 0;
  4735. }
  4736. /*==========================================
  4737. * UndisguiseGuild
  4738. *------------------------------------------*/
  4739. ACMD_FUNC(undisguiseguild)
  4740. {
  4741. char guild_name[NAME_LENGTH];
  4742. int i;
  4743. nullpo_retr(-1, sd);
  4744. memset(guild_name, '\0', sizeof(guild_name));
  4745. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4746. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4747. return -1;
  4748. }
  4749. auto g = guild_searchnameid(guild_name);
  4750. if (!g) {
  4751. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4752. return -1;
  4753. }
  4754. for(i = 0; i < g->guild.max_member; i++){
  4755. map_session_data *pl_sd;
  4756. if( (pl_sd = g->guild.member[i].sd) && pl_sd->disguise )
  4757. pc_disguise(pl_sd, 0);
  4758. }
  4759. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4760. return 0;
  4761. }
  4762. /*==========================================
  4763. * @exp by [Skotlex]
  4764. *------------------------------------------*/
  4765. ACMD_FUNC(exp)
  4766. {
  4767. char output[CHAT_SIZE_MAX];
  4768. double nextb, nextj;
  4769. nullpo_retr(-1, sd);
  4770. memset(output, '\0', sizeof(output));
  4771. nextb = (double)pc_nextbaseexp(sd);
  4772. if (nextb)
  4773. nextb = sd->status.base_exp*100.0/nextb;
  4774. nextj = (double)pc_nextjobexp(sd);
  4775. if (nextj)
  4776. nextj = sd->status.job_exp*100.0/nextj;
  4777. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4778. clif_displaymessage(fd, output);
  4779. return 0;
  4780. }
  4781. /*==========================================
  4782. * @broadcast by [Valaris]
  4783. *------------------------------------------*/
  4784. ACMD_FUNC(broadcast)
  4785. {
  4786. nullpo_retr(-1, sd);
  4787. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4788. if (!message || !*message) {
  4789. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4790. return -1;
  4791. }
  4792. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4793. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4794. return 0;
  4795. }
  4796. /*==========================================
  4797. * @localbroadcast by [Valaris]
  4798. *------------------------------------------*/
  4799. ACMD_FUNC(localbroadcast)
  4800. {
  4801. nullpo_retr(-1, sd);
  4802. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4803. if (!message || !*message) {
  4804. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4805. return -1;
  4806. }
  4807. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4808. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4809. return 0;
  4810. }
  4811. /*==========================================
  4812. * @email <actual@email> <new@email> by [Yor]
  4813. *------------------------------------------*/
  4814. ACMD_FUNC(email)
  4815. {
  4816. char actual_email[100];
  4817. char new_email[100];
  4818. nullpo_retr(-1, sd);
  4819. memset(actual_email, '\0', sizeof(actual_email));
  4820. memset(new_email, '\0', sizeof(new_email));
  4821. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4822. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4823. return -1;
  4824. }
  4825. if (e_mail_check(actual_email) == 0) {
  4826. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4827. return -1;
  4828. } else if (e_mail_check(new_email) == 0) {
  4829. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4830. return -1;
  4831. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4832. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4833. return -1;
  4834. } else if (strcmpi(actual_email, new_email) == 0) {
  4835. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4836. return -1;
  4837. }
  4838. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4839. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4840. return 0;
  4841. }
  4842. /*==========================================
  4843. *@effect
  4844. *------------------------------------------*/
  4845. ACMD_FUNC(effect)
  4846. {
  4847. int type = EF_NONE;
  4848. nullpo_retr(-1, sd);
  4849. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4850. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4851. return -1;
  4852. }
  4853. if( type <= EF_NONE || type >= EF_MAX ){
  4854. 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.
  4855. clif_displaymessage(fd, atcmd_output);
  4856. return -1;
  4857. }
  4858. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4859. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4860. return 0;
  4861. }
  4862. /*==========================================
  4863. * @killer by MouseJstr
  4864. * enable killing players even when not in pvp
  4865. *------------------------------------------*/
  4866. ACMD_FUNC(killer)
  4867. {
  4868. nullpo_retr(-1, sd);
  4869. sd->state.killer = !sd->state.killer;
  4870. if(sd->state.killer)
  4871. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4872. else {
  4873. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4874. pc_stop_attack(sd);
  4875. }
  4876. return 0;
  4877. }
  4878. /*==========================================
  4879. * @killable by MouseJstr
  4880. * enable other people killing you
  4881. *------------------------------------------*/
  4882. ACMD_FUNC(killable)
  4883. {
  4884. nullpo_retr(-1, sd);
  4885. sd->state.killable = !sd->state.killable;
  4886. if(sd->state.killable)
  4887. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4888. else {
  4889. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4890. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4891. }
  4892. return 0;
  4893. }
  4894. /*==========================================
  4895. * @skillon by MouseJstr
  4896. * turn skills on for the map
  4897. *------------------------------------------*/
  4898. ACMD_FUNC(skillon)
  4899. {
  4900. nullpo_retr(-1, sd);
  4901. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4902. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4903. return 0;
  4904. }
  4905. /*==========================================
  4906. * @skilloff by MouseJstr
  4907. * Turn skills off on the map
  4908. *------------------------------------------*/
  4909. ACMD_FUNC(skilloff)
  4910. {
  4911. nullpo_retr(-1, sd);
  4912. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  4913. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4914. return 0;
  4915. }
  4916. /*==========================================
  4917. * @npcmove by MouseJstr
  4918. * move a npc
  4919. *------------------------------------------*/
  4920. ACMD_FUNC(npcmove)
  4921. {
  4922. short x = 0, y = 0;
  4923. struct npc_data *nd = 0;
  4924. char npc_name[NPC_NAME_LENGTH];
  4925. nullpo_retr(-1, sd);
  4926. memset(npc_name, '\0', sizeof npc_name);
  4927. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4928. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4929. return -1;
  4930. }
  4931. if ((nd = npc_name2id(npc_name)) == nullptr)
  4932. {
  4933. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4934. return -1;
  4935. }
  4936. if ( npc_movenpc( nd, x, y ) )
  4937. { //actually failed to move
  4938. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4939. return -1; //Not on a map.
  4940. } else
  4941. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4942. return 0;
  4943. }
  4944. /*==========================================
  4945. * @addwarp by MouseJstr
  4946. * Create a new static warp point.
  4947. *------------------------------------------*/
  4948. ACMD_FUNC(addwarp)
  4949. {
  4950. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4951. short x,y;
  4952. unsigned short m;
  4953. struct npc_data* nd;
  4954. nullpo_retr(-1, sd);
  4955. memset(warpname, '\0', sizeof(warpname));
  4956. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4957. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4958. return -1;
  4959. }
  4960. m = mapindex_name2id(mapname);
  4961. if( m == 0 )
  4962. {
  4963. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4964. clif_displaymessage(fd, atcmd_output);
  4965. return -1;
  4966. }
  4967. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4968. if( nd == nullptr )
  4969. return -1;
  4970. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4971. clif_displaymessage(fd, atcmd_output);
  4972. return 0;
  4973. }
  4974. /*==========================================
  4975. * @follow by [MouseJstr]
  4976. * Follow a player .. staying no more then 5 spaces away
  4977. *------------------------------------------*/
  4978. ACMD_FUNC(follow)
  4979. {
  4980. map_session_data* pl_sd = nullptr;;
  4981. nullpo_retr(-1, sd);
  4982. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4983. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4984. if (sd->followtarget == -1)
  4985. return -1;
  4986. pc_stop_following (sd);
  4987. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4988. return 0;
  4989. }
  4990. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  4991. {
  4992. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4993. return -1;
  4994. }
  4995. if (sd->followtarget == pl_sd->bl.id) {
  4996. pc_stop_following (sd);
  4997. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4998. } else {
  4999. pc_follow(sd, pl_sd->bl.id);
  5000. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  5001. }
  5002. return 0;
  5003. }
  5004. /*==========================================
  5005. * @dropall by [MouseJstr] and [Xantara]
  5006. * Drops all your possession on the ground based on item type
  5007. *------------------------------------------*/
  5008. ACMD_FUNC(dropall)
  5009. {
  5010. int8 type = -1;
  5011. uint16 i, count = 0, count2 = 0;
  5012. nullpo_retr(-1, sd);
  5013. if( message[0] ) {
  5014. type = atoi(message);
  5015. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  5016. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  5017. {
  5018. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  5019. 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
  5020. return -1;
  5021. }
  5022. }
  5023. for( i = 0; i < MAX_INVENTORY; i++ ) {
  5024. if( sd->inventory.u.items_inventory[i].amount ) {
  5025. std::shared_ptr<item_data> id = item_db.find(sd->inventory.u.items_inventory[i].nameid);
  5026. if( id == nullptr ) {
  5027. 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);
  5028. continue;
  5029. }
  5030. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  5031. continue;
  5032. if( type == -1 || type == (uint8)id->type ) {
  5033. if( sd->inventory.u.items_inventory[i].equip != 0 )
  5034. pc_unequipitem(sd, i, 3);
  5035. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5036. pet_return_egg( sd, sd->pd );
  5037. }
  5038. pc_equipswitch_remove(sd, i);
  5039. int amount = sd->inventory.u.items_inventory[i].amount;
  5040. if(pc_dropitem(sd, i, amount))
  5041. count += amount;
  5042. else count2 += amount;
  5043. }
  5044. }
  5045. }
  5046. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  5047. clif_displaymessage(fd, atcmd_output);
  5048. return 0;
  5049. }
  5050. /*==========================================
  5051. * @stockall by [Hanashi]
  5052. * transfer items from cart to inventory
  5053. *------------------------------------------*/
  5054. ACMD_FUNC(stockall)
  5055. {
  5056. nullpo_retr(-1, sd);
  5057. if (!pc_iscarton(sd)) {
  5058. clif_displaymessage(fd, msg_txt(sd,1533)); // You do not have a cart.
  5059. return -1;
  5060. }
  5061. int8 type = -1;
  5062. if ( message[0] ) {
  5063. type = atoi(message);
  5064. switch (type) {
  5065. case -1:
  5066. case IT_HEALING:
  5067. case IT_USABLE:
  5068. case IT_ETC:
  5069. case IT_WEAPON:
  5070. case IT_ARMOR:
  5071. case IT_CARD:
  5072. case IT_PETEGG:
  5073. case IT_PETARMOR:
  5074. case IT_AMMO:
  5075. break;
  5076. default:
  5077. clif_displaymessage(fd, msg_txt(sd, 1534)); // Usage: @stockall {<type>}
  5078. 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
  5079. return -1;
  5080. }
  5081. }
  5082. uint16 count = 0, count2 = 0;
  5083. for ( uint16 i = 0; i < MAX_CART; i++ ) {
  5084. if ( sd->cart.u.items_cart[i].amount > 0 ) {
  5085. std::shared_ptr<item_data> id = item_db.find(sd->cart.u.items_cart[i].nameid);
  5086. if ( id == nullptr ) {
  5087. 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);
  5088. continue;
  5089. }
  5090. if ( type == -1 || static_cast<item_types>(type) == id->type ) {
  5091. if (pc_getitemfromcart(sd, i, sd->cart.u.items_cart[i].amount))
  5092. count += sd->cart.u.items_cart[i].amount;
  5093. else
  5094. count2 += sd->cart.u.items_cart[i].amount;
  5095. }
  5096. }
  5097. }
  5098. sprintf(atcmd_output, msg_txt(sd,1535), count,count2); // %d items are transferred (%d skipped)!
  5099. clif_displaymessage(fd, atcmd_output);
  5100. return 0;
  5101. }
  5102. /*==========================================
  5103. * @storeall by [MouseJstr]
  5104. * Put everything into storage
  5105. *------------------------------------------*/
  5106. ACMD_FUNC(storeall)
  5107. {
  5108. int i;
  5109. nullpo_retr(-1, sd);
  5110. if (sd->state.storage_flag != 1)
  5111. { //Open storage.
  5112. if( storage_storageopen(sd) == 1 ) {
  5113. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  5114. return -1;
  5115. }
  5116. }
  5117. for (i = 0; i < MAX_INVENTORY; i++) {
  5118. if (sd->inventory.u.items_inventory[i].amount) {
  5119. if(sd->inventory.u.items_inventory[i].equip != 0)
  5120. pc_unequipitem(sd, i, 3);
  5121. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5122. pet_return_egg( sd, sd->pd );
  5123. }
  5124. pc_equipswitch_remove(sd, i);
  5125. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  5126. }
  5127. }
  5128. storage_storageclose(sd);
  5129. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  5130. return 0;
  5131. }
  5132. ACMD_FUNC(clearstorage)
  5133. {
  5134. int i, j;
  5135. nullpo_retr(-1, sd);
  5136. if (sd->state.storage_flag == 1) {
  5137. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5138. return -1;
  5139. }
  5140. if (sd->state.storage_flag == 3) {
  5141. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5142. return -1;
  5143. }
  5144. j = sd->storage.amount;
  5145. for (i = 0; i < j; ++i) {
  5146. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  5147. }
  5148. sd->state.storage_flag = 1;
  5149. storage_storageclose(sd);
  5150. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  5151. return 0;
  5152. }
  5153. ACMD_FUNC(cleargstorage)
  5154. {
  5155. int i, j;
  5156. struct s_storage *gstorage;
  5157. nullpo_retr(-1, sd);
  5158. if (!sd->guild) {
  5159. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  5160. return -1;
  5161. }
  5162. if (sd->state.storage_flag == 1) {
  5163. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5164. return -1;
  5165. }
  5166. if (sd->state.storage_flag == 2) {
  5167. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  5168. return -1;
  5169. }
  5170. if (sd->state.storage_flag == 3) {
  5171. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5172. return -1;
  5173. }
  5174. gstorage = guild2storage2(sd->status.guild_id);
  5175. if (gstorage == nullptr) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  5176. return -1;
  5177. }
  5178. j = gstorage->amount;
  5179. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  5180. for (i = 0; i < j; ++i) {
  5181. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  5182. }
  5183. storage_guild_storageclose(sd);
  5184. gstorage->lock = false; // Cleaning done, release lock
  5185. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  5186. return 0;
  5187. }
  5188. ACMD_FUNC(clearcart)
  5189. {
  5190. int i;
  5191. nullpo_retr(-1, sd);
  5192. if (pc_iscarton(sd) == 0) {
  5193. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  5194. return -1;
  5195. }
  5196. if (sd->state.vending == 1) { //Somehow...
  5197. return -1;
  5198. }
  5199. for (i = 0; i < MAX_CART; i++) {
  5200. if (sd->cart.u.items_cart[i].nameid > 0)
  5201. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  5202. }
  5203. clif_clearcart(fd);
  5204. clif_updatestatus(*sd,SP_CARTINFO);
  5205. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  5206. return 0;
  5207. }
  5208. /*==========================================
  5209. * @skillid by [MouseJstr]
  5210. * lookup a skill by name
  5211. *------------------------------------------*/
  5212. #define MAX_SKILLID_PARTIAL_RESULTS 5
  5213. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  5214. ACMD_FUNC(skillid) {
  5215. int i, found = 0;
  5216. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  5217. nullpo_retr(-1, sd);
  5218. if (!message || !*message) {
  5219. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  5220. return -1;
  5221. }
  5222. size_t skillen = strlen( message );
  5223. for(const auto & skill : skill_db) {
  5224. uint16 skill_id = skill.second->nameid;
  5225. uint16 idx = skill_get_index(skill_id);
  5226. const char *name = skill.second->name;
  5227. const char *desc = skill.second->desc;
  5228. if (strnicmp(name, message, skillen) == 0 || strnicmp(desc, message, skillen) == 0) {
  5229. sprintf(atcmd_output, msg_txt(sd,1164), skill_id, desc, name); // skill %d: %s (%s)
  5230. clif_displaymessage(fd, atcmd_output);
  5231. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(name,message) || stristr(desc,message) ) ) {
  5232. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), skill_id, desc, name); // // skill %d: %s (%s)
  5233. }
  5234. }
  5235. if( found ) {
  5236. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  5237. clif_displaymessage(fd, atcmd_output);
  5238. }
  5239. for(i = 0; i < found; i++) { /* partials */
  5240. clif_displaymessage(fd, partials[i]);
  5241. }
  5242. return 0;
  5243. }
  5244. /*==========================================
  5245. * @useskill by [MouseJstr]
  5246. * A way of using skills without having to find them in the skills menu
  5247. *------------------------------------------*/
  5248. ACMD_FUNC(useskill)
  5249. {
  5250. map_session_data* pl_sd = nullptr;;
  5251. struct block_list *bl;
  5252. uint16 skill_id;
  5253. uint16 skill_lv;
  5254. nullpo_retr(-1, sd);
  5255. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5256. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  5257. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  5258. return -1;
  5259. }
  5260. if (!skill_id || !skill_db.find(skill_id)) {
  5261. clif_displaymessage(fd, msg_txt(sd, 198)); // This skill number doesn't exist.
  5262. return -1;
  5263. }
  5264. if (!skill_lv)
  5265. skill_lv = 1;
  5266. if(!strcmp(atcmd_player_name,"self"))
  5267. pl_sd = sd; //quick keyword
  5268. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr ){
  5269. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5270. return -1;
  5271. }
  5272. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5273. {
  5274. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5275. return -1;
  5276. }
  5277. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5278. bl = &sd->hd->bl;
  5279. else
  5280. bl = &sd->bl;
  5281. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  5282. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  5283. else
  5284. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  5285. return 0;
  5286. }
  5287. /*==========================================
  5288. * @displayskill by [Skotlex]
  5289. * Debug command to locate new skill IDs. It sends the
  5290. * three possible skill-effect packets to the area.
  5291. *------------------------------------------*/
  5292. ACMD_FUNC(displayskill)
  5293. {
  5294. t_tick tick;
  5295. uint16 skill_id;
  5296. uint16 skill_lv = 1;
  5297. uint16 type = 0;
  5298. nullpo_retr(-1, sd);
  5299. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &skill_id, &skill_lv, &type) < 1)
  5300. {
  5301. clif_displaymessage(fd, msg_txt(sd,1166));// Usage: @displayskill <skill ID> {<skill level> <type>}
  5302. clif_displaymessage(fd, msg_txt(sd,825));// Effect Types: 0: All, 1: Damage, 2: Splash Dmg, 3: No Damage, 4: Ground
  5303. return -1;
  5304. }
  5305. status_data* status = status_get_status_data(sd->bl);
  5306. tick = gettick();
  5307. if (type == 0 || type == 1)
  5308. clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SINGLE);
  5309. if (type == 0 || type == 2)
  5310. clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  5311. if (type == 0 || type == 3)
  5312. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  5313. if (type == 0 || type == 4)
  5314. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  5315. return 0;
  5316. }
  5317. /*==========================================
  5318. * @displayskillcast by [Rytech]
  5319. * Debug command to view casting animations for skills.
  5320. * Can target self or the ground. Ground target can be
  5321. * useful for seeing casting circle size.
  5322. *------------------------------------------*/
  5323. ACMD_FUNC(displayskillcast)
  5324. {
  5325. uint16 skill_id;
  5326. uint16 skill_lv = 1;
  5327. uint16 cast_time = 5000;
  5328. uint16 target_type = 0;
  5329. nullpo_retr(-1, sd);
  5330. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu %6hu", &skill_id, &skill_lv, &target_type, &cast_time) < 1)
  5331. {
  5332. clif_displaymessage(fd, msg_txt(sd, 824));// Usage: @displayskillcast <skill ID> {<skill level> <ground target flag> <cast time>}
  5333. return -1;
  5334. }
  5335. if ( target_type == 1)
  5336. clif_skillcasting(&sd->bl, sd->bl.id, 0, sd->bl.x, sd->bl.y, skill_id, skill_lv, 0, cast_time);
  5337. else
  5338. clif_skillcasting(&sd->bl, sd->bl.id, sd->bl.id, 0, 0, skill_id, skill_lv, 0, cast_time);
  5339. return 0;
  5340. }
  5341. /*==========================================
  5342. * @displayskillunit by [Rytech]
  5343. * Debug command to view unit animations for skills.
  5344. *------------------------------------------*/
  5345. ACMD_FUNC(displayskillunit)
  5346. {
  5347. uint16 unit_id;
  5348. uint16 range = 0;
  5349. uint16 skill_lv = 1;
  5350. nullpo_retr(-1, sd);
  5351. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &unit_id, &skill_lv, &range) < 1)
  5352. {
  5353. clif_displaymessage(fd, msg_txt(sd, 826));// Usage: @displayskillunit <unit ID> {<skill level> <range>}
  5354. return -1;
  5355. }
  5356. clif_skill_unit_test(&sd->bl, sd->bl.x, sd->bl.y, unit_id, range, skill_lv);
  5357. return 0;
  5358. }
  5359. /*==========================================
  5360. * @skilltree by [MouseJstr]
  5361. * prints the skill tree for a player required to get to a skill
  5362. *------------------------------------------*/
  5363. ACMD_FUNC(skilltree)
  5364. {
  5365. map_session_data* pl_sd = nullptr;;
  5366. uint16 skill_id;
  5367. nullpo_retr(-1, sd);
  5368. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5369. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  5370. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  5371. return -1;
  5372. }
  5373. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5374. {
  5375. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5376. return -1;
  5377. }
  5378. int c = pc_mapid2jobid( pc_calc_skilltree_normalize_job( pl_sd ), pl_sd->status.sex );
  5379. 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).
  5380. clif_displaymessage(fd, atcmd_output);
  5381. auto entry = skill_tree_db.get_skill_data(c, skill_id);
  5382. if (entry == nullptr) {
  5383. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5384. return 0;
  5385. }
  5386. bool meets = true;
  5387. for (const auto &it : entry->need) {
  5388. if (pc_checkskill(sd, it.first) < it.second) {
  5389. sprintf(atcmd_output, msg_txt(sd,1170), it.second, skill_get_desc(it.first)); // Player requires level %d of skill %s.
  5390. clif_displaymessage(fd, atcmd_output);
  5391. meets = false;
  5392. }
  5393. }
  5394. if (meets) {
  5395. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5396. }
  5397. return 0;
  5398. }
  5399. // Hand a ring with partners name on it to this char
  5400. void getring (map_session_data* sd)
  5401. {
  5402. char flag = 0;
  5403. t_itemid item_id;
  5404. struct item item_tmp;
  5405. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5406. memset(&item_tmp, 0, sizeof(item_tmp));
  5407. item_tmp.nameid = item_id;
  5408. item_tmp.identify = 1;
  5409. item_tmp.card[0] = CARD0_FORGE;
  5410. item_tmp.card[2] = GetWord(sd->status.partner_id,0);
  5411. item_tmp.card[3] = GetWord(sd->status.partner_id,1);
  5412. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5413. clif_additem(sd,0,0,flag);
  5414. }
  5415. }
  5416. /*==========================================
  5417. * @marry by [MouseJstr], fixed by Lupus
  5418. * Marry two players
  5419. *------------------------------------------*/
  5420. ACMD_FUNC(marry)
  5421. {
  5422. map_session_data* pl_sd = nullptr;;
  5423. nullpo_retr(-1, sd);
  5424. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5425. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5426. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5427. return -1;
  5428. }
  5429. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  5430. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5431. return -1;
  5432. }
  5433. if (!pc_inventoryblank(sd)) {
  5434. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5435. return -1;
  5436. }
  5437. if (!pc_inventoryblank(pl_sd)) {
  5438. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5439. return -1;
  5440. }
  5441. uint32 w = 0;
  5442. if (w = itemdb_weight((sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + sd->weight > sd->max_weight) {
  5443. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5444. return -1;
  5445. }
  5446. if (w = itemdb_weight((pl_sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + pl_sd->weight > pl_sd->max_weight) {
  5447. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5448. return -1;
  5449. }
  5450. if (pc_marriage(sd, pl_sd)) {
  5451. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5452. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5453. if( pl_sd->bl.m != sd->bl.m )
  5454. clif_wedding_effect(&sd->bl);
  5455. getring(sd); // Auto-give named rings (Aru)
  5456. getring(pl_sd);
  5457. return 0;
  5458. }
  5459. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5460. return -1;
  5461. }
  5462. /*==========================================
  5463. * @divorce by [MouseJstr], fixed by [Lupus]
  5464. * divorce two players
  5465. *------------------------------------------*/
  5466. ACMD_FUNC(divorce)
  5467. {
  5468. nullpo_retr(-1, sd);
  5469. if (!pc_divorce(sd)) {
  5470. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5471. clif_displaymessage(fd, atcmd_output);
  5472. return -1;
  5473. }
  5474. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5475. clif_displaymessage(fd, atcmd_output);
  5476. return 0;
  5477. }
  5478. /*==========================================
  5479. * @changelook by [Celest]
  5480. *------------------------------------------*/
  5481. ACMD_FUNC(changelook)
  5482. {
  5483. int i, j = 0, k = 0;
  5484. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5485. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5486. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5487. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5488. return -1;
  5489. } else if ( i == 2 ) {
  5490. if (j < 1 || j > 8)
  5491. j = 1;
  5492. j = pos[j - 1];
  5493. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5494. k = j; // swap
  5495. j = LOOK_HEAD_TOP;
  5496. }
  5497. clif_changelook(&sd->bl,j,k);
  5498. return 0;
  5499. }
  5500. /*==========================================
  5501. * @autotrade by durf [Lupus] [Paradox924X]
  5502. * Turns on/off Autotrade for a specific player
  5503. *------------------------------------------*/
  5504. ACMD_FUNC(autotrade) {
  5505. nullpo_retr(-1, sd);
  5506. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5507. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5508. return -1;
  5509. }
  5510. if( pc_isdead(sd) ) {
  5511. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5512. return -1;
  5513. }
  5514. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5515. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5516. return -1;
  5517. }
  5518. sd->state.autotrade = 1;
  5519. if (battle_config.autotrade_monsterignore)
  5520. sd->state.block_action |= PCBLOCK_IMMUNE;
  5521. if( sd->state.vending ){
  5522. vending_update(*sd);
  5523. }else if( sd->state.buyingstore ){
  5524. buyingstore_update(*sd);
  5525. }
  5526. if( battle_config.at_timeout ) {
  5527. int timeout = atoi(message);
  5528. 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);
  5529. }
  5530. if (battle_config.at_logout_event)
  5531. npc_script_event( *sd, NPCE_LOGOUT );
  5532. channel_pcquit(sd,0xF); //leave all chan
  5533. clif_authfail_fd(sd->fd, 15);
  5534. chrif_save(sd, CSAVE_AUTOTRADE);
  5535. return 0;
  5536. }
  5537. /*==========================================
  5538. * @changegm by durf (changed by Lupus)
  5539. * Changes Master of your Guild to a specified guild member
  5540. *------------------------------------------*/
  5541. ACMD_FUNC(changegm)
  5542. {
  5543. map_session_data *pl_sd;
  5544. nullpo_retr(-1, sd);
  5545. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5546. if (sd->status.guild_id == 0 || sd->guild == nullptr || strcmp(sd->guild->guild.master,sd->status.name)) {
  5547. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5548. return -1;
  5549. }
  5550. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5551. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5552. return -1;
  5553. }
  5554. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5555. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5556. return -1;
  5557. }
  5558. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr || pl_sd->status.guild_id != sd->status.guild_id) {
  5559. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5560. return -1;
  5561. }
  5562. if( !battle_config.guild_leaderchange_woe && is_agit_start() ){
  5563. #if PACKETVER >= 20151001
  5564. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_IN_SIEGE_TIME);
  5565. #else
  5566. clif_displaymessage(fd, msg_txt(sd,1513)); // Currently in WoE hours, unable to delegate Guild leader
  5567. #endif
  5568. return -1;
  5569. }
  5570. if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(nullptr),sd->guild->guild.last_leader_change) < battle_config.guild_leaderchange_delay ){
  5571. #if PACKETVER >= 20151001
  5572. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_NOT_TIME);
  5573. #else
  5574. clif_displaymessage(fd, msg_txt(sd,1514)); // You have to wait for a while before delegating a new Guild leader
  5575. #endif
  5576. return -1;
  5577. }
  5578. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5579. return 0;
  5580. }
  5581. /*==========================================
  5582. * @changeleader by Skotlex
  5583. * Changes the leader of a party.
  5584. *------------------------------------------*/
  5585. ACMD_FUNC(changeleader)
  5586. {
  5587. nullpo_retr(-1, sd);
  5588. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5589. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5590. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5591. return -1;
  5592. }
  5593. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),nullptr);
  5594. return 0;
  5595. }
  5596. /*==========================================
  5597. * @partyoption by Skotlex
  5598. * Used to change the item share setting of a party.
  5599. *------------------------------------------*/
  5600. ACMD_FUNC(partyoption)
  5601. {
  5602. struct party_data *p;
  5603. int mi, option;
  5604. char w1[16], w2[16];
  5605. nullpo_retr(-1, sd);
  5606. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == nullptr)
  5607. {
  5608. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5609. return -1;
  5610. }
  5611. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5612. if (mi == MAX_PARTY)
  5613. return -1; //Shouldn't happen
  5614. if (!p->party.member[mi].leader)
  5615. {
  5616. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5617. return -1;
  5618. }
  5619. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5620. {
  5621. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5622. return -1;
  5623. }
  5624. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5625. //Change item share type.
  5626. if (option != p->party.item)
  5627. party_changeoption(sd, p->party.exp, option);
  5628. else
  5629. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5630. return 0;
  5631. }
  5632. /*==========================================
  5633. * @autoloot by Upa-Kun
  5634. * Turns on/off AutoLoot for a specific player
  5635. *------------------------------------------*/
  5636. ACMD_FUNC(autoloot)
  5637. {
  5638. int rate;
  5639. nullpo_retr(-1, sd);
  5640. // autoloot command without value
  5641. if(!message || !*message)
  5642. {
  5643. if (sd->state.autoloot)
  5644. rate = 0;
  5645. else
  5646. rate = 10000;
  5647. } else {
  5648. double drate;
  5649. drate = atof(message);
  5650. rate = (int)(drate*100);
  5651. }
  5652. if (rate < 0) rate = 0;
  5653. if (rate > 10000) rate = 10000;
  5654. sd->state.autoloot = rate;
  5655. if (sd->state.autoloot) {
  5656. 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.
  5657. clif_displaymessage(fd, atcmd_output);
  5658. }else
  5659. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5660. return 0;
  5661. }
  5662. /*==========================================
  5663. * @alootid
  5664. *------------------------------------------*/
  5665. ACMD_FUNC(autolootitem)
  5666. {
  5667. std::shared_ptr<item_data> item_data;
  5668. int i;
  5669. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5670. nullpo_retr(-1, sd);
  5671. if (message && *message) {
  5672. if (message[0] == '+') {
  5673. message++;
  5674. action = 1;
  5675. }
  5676. else if (message[0] == '-') {
  5677. message++;
  5678. action = 2;
  5679. }
  5680. else if (!strcmp(message,"reset"))
  5681. action = 4;
  5682. }
  5683. if (action < 3) // add or remove
  5684. {
  5685. item_data = item_db.find( strtoul( message, nullptr, 10 ) );
  5686. if( item_data == nullptr ){
  5687. item_data = item_db.searchname( message );
  5688. }
  5689. if( item_data == nullptr ){
  5690. // No items founds in the DB with Id or Name
  5691. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5692. return -1;
  5693. }
  5694. }
  5695. switch(action) {
  5696. case 1:
  5697. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5698. if (i != AUTOLOOTITEM_SIZE) {
  5699. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5700. return -1;
  5701. }
  5702. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5703. if (i == AUTOLOOTITEM_SIZE) {
  5704. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5705. return -1;
  5706. }
  5707. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5708. 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}
  5709. clif_displaymessage(fd, atcmd_output);
  5710. sd->state.autolooting = 1;
  5711. break;
  5712. case 2:
  5713. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5714. if (i == AUTOLOOTITEM_SIZE) {
  5715. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5716. return -1;
  5717. }
  5718. sd->state.autolootid[i] = 0;
  5719. 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.
  5720. clif_displaymessage(fd, atcmd_output);
  5721. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5722. if (i == AUTOLOOTITEM_SIZE) {
  5723. sd->state.autolooting = 0;
  5724. }
  5725. break;
  5726. case 3:
  5727. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5728. clif_displaymessage(fd, atcmd_output);
  5729. 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>".
  5730. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5731. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5732. if (i == AUTOLOOTITEM_SIZE) {
  5733. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5734. } else {
  5735. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5736. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5737. {
  5738. if (sd->state.autolootid[i] == 0)
  5739. continue;
  5740. item_data = item_db.find( sd->state.autolootid[i] );
  5741. if( item_data == nullptr ){
  5742. 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);
  5743. continue;
  5744. }
  5745. sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid);
  5746. clif_displaymessage(fd, atcmd_output);
  5747. }
  5748. }
  5749. break;
  5750. case 4:
  5751. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5752. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5753. sd->state.autolooting = 0;
  5754. break;
  5755. }
  5756. return 0;
  5757. }
  5758. /*==========================================
  5759. * @autoloottype
  5760. * Flags:
  5761. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5762. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5763. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5764. * 262144: IT_CASH
  5765. *------------------------------------------
  5766. * Credits:
  5767. * chriser
  5768. * Aleos
  5769. *------------------------------------------*/
  5770. ACMD_FUNC(autoloottype)
  5771. {
  5772. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5773. enum item_types type= IT_UNKNOWN;
  5774. int ITEM_MAX = 1533;
  5775. nullpo_retr(-1, sd);
  5776. if (message && *message) {
  5777. if (message[0] == '+') {
  5778. message++;
  5779. action = 1;
  5780. }
  5781. else if (message[0] == '-') {
  5782. message++;
  5783. action = 2;
  5784. }
  5785. else if (!strcmp(message,"reset"))
  5786. action = 4;
  5787. }
  5788. if (action < 3) { // add or remove
  5789. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5790. type = IT_HEALING;
  5791. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5792. type = IT_USABLE;
  5793. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5794. type = IT_ETC;
  5795. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5796. type = IT_ARMOR;
  5797. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5798. type = IT_WEAPON;
  5799. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5800. type = IT_CARD;
  5801. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5802. type = IT_PETEGG;
  5803. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5804. type = IT_PETARMOR;
  5805. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5806. type = IT_AMMO;
  5807. else {
  5808. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5809. return -1;
  5810. }
  5811. }
  5812. switch (action) {
  5813. case 1:
  5814. if (sd->state.autoloottype&(1<<type)) {
  5815. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5816. return -1;
  5817. }
  5818. if (sd->state.autoloottype == ITEM_MAX) {
  5819. 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>.
  5820. return -1;
  5821. }
  5822. sd->state.autoloottype |= (1<<type); // Stores the type
  5823. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%u}
  5824. clif_displaymessage(fd, atcmd_output);
  5825. break;
  5826. case 2:
  5827. if (!(sd->state.autoloottype&(1<<type))) {
  5828. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5829. return -1;
  5830. }
  5831. sd->state.autoloottype &= ~(1<<type);
  5832. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%u} from your autoloottype list.
  5833. clif_displaymessage(fd, atcmd_output);
  5834. break;
  5835. case 3:
  5836. 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>".
  5837. 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
  5838. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5839. if (sd->state.autoloottype == 0)
  5840. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5841. else {
  5842. uint8 i = 0;
  5843. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5844. while (i < IT_MAX) {
  5845. if (sd->state.autoloottype&(1<<i)) {
  5846. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5847. clif_displaymessage(fd, atcmd_output);
  5848. }
  5849. i++;
  5850. }
  5851. }
  5852. break;
  5853. case 4:
  5854. sd->state.autoloottype = 0;
  5855. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5856. break;
  5857. }
  5858. return 0;
  5859. }
  5860. /*==========================================
  5861. * It is made to rain.
  5862. * No longer available, keeping here just in case it's back someday. [Ind]
  5863. *------------------------------------------*/
  5864. //ACMD_FUNC(rain)
  5865. //{
  5866. // nullpo_retr(-1, sd);
  5867. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5868. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5869. // clif_weather(sd->bl.m);
  5870. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5871. // } else {
  5872. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5873. // clif_weather(sd->bl.m);
  5874. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5875. // }
  5876. // return 0;
  5877. //}
  5878. /*==========================================
  5879. * It is made to snow.
  5880. *------------------------------------------*/
  5881. ACMD_FUNC(snow)
  5882. {
  5883. nullpo_retr(-1, sd);
  5884. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5885. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5886. clif_weather(sd->bl.m);
  5887. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5888. } else {
  5889. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5890. clif_weather(sd->bl.m);
  5891. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5892. }
  5893. return 0;
  5894. }
  5895. /*==========================================
  5896. * Cherry tree snowstorm is made to fall. (Sakura)
  5897. *------------------------------------------*/
  5898. ACMD_FUNC(sakura)
  5899. {
  5900. nullpo_retr(-1, sd);
  5901. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5902. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5903. clif_weather(sd->bl.m);
  5904. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5905. } else {
  5906. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  5907. clif_weather(sd->bl.m);
  5908. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5909. }
  5910. return 0;
  5911. }
  5912. /*==========================================
  5913. * Clouds appear.
  5914. *------------------------------------------*/
  5915. ACMD_FUNC(clouds)
  5916. {
  5917. nullpo_retr(-1, sd);
  5918. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  5919. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5920. clif_weather(sd->bl.m);
  5921. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5922. } else {
  5923. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  5924. clif_weather(sd->bl.m);
  5925. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5926. }
  5927. return 0;
  5928. }
  5929. /*==========================================
  5930. * Different type of clouds using effect 516
  5931. *------------------------------------------*/
  5932. ACMD_FUNC(clouds2)
  5933. {
  5934. nullpo_retr(-1, sd);
  5935. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  5936. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5937. clif_weather(sd->bl.m);
  5938. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5939. } else {
  5940. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  5941. clif_weather(sd->bl.m);
  5942. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5943. }
  5944. return 0;
  5945. }
  5946. /*==========================================
  5947. * Fog hangs over.
  5948. *------------------------------------------*/
  5949. ACMD_FUNC(fog)
  5950. {
  5951. nullpo_retr(-1, sd);
  5952. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  5953. map_setmapflag(sd->bl.m, MF_FOG, false);
  5954. clif_weather(sd->bl.m);
  5955. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5956. } else {
  5957. map_setmapflag(sd->bl.m, MF_FOG, true);
  5958. clif_weather(sd->bl.m);
  5959. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5960. }
  5961. return 0;
  5962. }
  5963. /*==========================================
  5964. * Fallen leaves fall.
  5965. *------------------------------------------*/
  5966. ACMD_FUNC(leaves)
  5967. {
  5968. nullpo_retr(-1, sd);
  5969. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  5970. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5971. clif_weather(sd->bl.m);
  5972. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5973. } else {
  5974. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  5975. clif_weather(sd->bl.m);
  5976. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5977. }
  5978. return 0;
  5979. }
  5980. /*==========================================
  5981. * Fireworks appear.
  5982. *------------------------------------------*/
  5983. ACMD_FUNC(fireworks)
  5984. {
  5985. nullpo_retr(-1, sd);
  5986. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  5987. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5988. clif_weather(sd->bl.m);
  5989. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5990. } else {
  5991. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  5992. clif_weather(sd->bl.m);
  5993. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5994. }
  5995. return 0;
  5996. }
  5997. /*==========================================
  5998. * Clearing Weather Effects by Dexity
  5999. *------------------------------------------*/
  6000. ACMD_FUNC(clearweather)
  6001. {
  6002. nullpo_retr(-1, sd);
  6003. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  6004. map_setmapflag(sd->bl.m, MF_SNOW, false);
  6005. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  6006. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  6007. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  6008. map_setmapflag(sd->bl.m, MF_FOG, false);
  6009. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6010. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6011. clif_weather(sd->bl.m);
  6012. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  6013. return 0;
  6014. }
  6015. /*===============================================================
  6016. * Sound Command - plays a sound for everyone around! [Codemaster]
  6017. *---------------------------------------------------------------*/
  6018. ACMD_FUNC(sound)
  6019. {
  6020. char sound_file[100];
  6021. memset(sound_file, '\0', sizeof(sound_file));
  6022. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6023. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  6024. return -1;
  6025. }
  6026. if(strstr(sound_file, ".wav") == nullptr)
  6027. strcat(sound_file, ".wav");
  6028. clif_soundeffect( sd->bl, sound_file, 0, AREA );
  6029. return 0;
  6030. }
  6031. /*==========================================
  6032. * MOB Search
  6033. *------------------------------------------*/
  6034. ACMD_FUNC(mobsearch)
  6035. {
  6036. nullpo_retr(-1, sd);
  6037. char mob_name[100]={0};
  6038. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6039. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  6040. return -1;
  6041. }
  6042. int mob_id = strtol(mob_name, nullptr, 10);
  6043. if (mob_id == 0)
  6044. mob_id = mobdb_searchname(mob_name);
  6045. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6046. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6047. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  6048. clif_displaymessage(fd, atcmd_output);
  6049. return -1;
  6050. }
  6051. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6052. // strcpy(mob_name, mob->name.c_str()); // --en--
  6053. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  6054. clif_displaymessage(fd, atcmd_output);
  6055. s_mapiterator* it = mapit_geteachmob();
  6056. int number = 0;
  6057. for(;;)
  6058. {
  6059. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6060. if( md == nullptr )
  6061. break;// no more mobs
  6062. if( md->bl.m != sd->bl.m )
  6063. continue;
  6064. if( md->mob_id != mob_id )
  6065. continue;
  6066. ++number;
  6067. if( md->spawn_timer == INVALID_TIMER )
  6068. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  6069. else
  6070. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  6071. clif_displaymessage(fd, atcmd_output);
  6072. }
  6073. mapit_free(it);
  6074. return 0;
  6075. }
  6076. /*==========================================
  6077. * @cleanmap - cleans items on the ground
  6078. * @cleanarea - cleans items on the ground within an specified area
  6079. *------------------------------------------*/
  6080. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  6081. {
  6082. nullpo_ret(bl);
  6083. map_clearflooritem(bl);
  6084. return 0;
  6085. }
  6086. ACMD_FUNC(cleanmap)
  6087. {
  6088. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  6089. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6090. return 0;
  6091. }
  6092. ACMD_FUNC(cleanarea)
  6093. {
  6094. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  6095. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  6096. 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);
  6097. }
  6098. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  6099. 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);
  6100. }
  6101. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  6102. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  6103. }
  6104. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6105. return 0;
  6106. }
  6107. /*==========================================
  6108. * make a NPC/PET talk
  6109. * @npctalkc [SnakeDrak]
  6110. *------------------------------------------*/
  6111. ACMD_FUNC(npctalk)
  6112. {
  6113. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  6114. struct npc_data *nd;
  6115. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  6116. unsigned long color=0;
  6117. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6118. return -1; //no "chatting" while muted.
  6119. if(!ifcolor) {
  6120. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  6121. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  6122. return -1;
  6123. }
  6124. }
  6125. else {
  6126. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6127. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  6128. return -1;
  6129. }
  6130. }
  6131. if (!(nd = npc_name2id(name))) {
  6132. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  6133. return -1;
  6134. }
  6135. strtok(name, "#"); // discard extra name identifier if present
  6136. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6137. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  6138. else clif_disp_overhead(&nd->bl, temp);
  6139. return 0;
  6140. }
  6141. ACMD_FUNC(pettalk)
  6142. {
  6143. char mes[100],temp[CHAT_SIZE_MAX];
  6144. struct pet_data *pd;
  6145. nullpo_retr(-1, sd);
  6146. if ( battle_config.min_chat_delay ) {
  6147. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6148. return 0;
  6149. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6150. }
  6151. if(!sd->status.pet_id || !(pd=sd->pd))
  6152. {
  6153. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  6154. return -1;
  6155. }
  6156. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6157. return -1; //no "chatting" while muted.
  6158. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6159. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  6160. return -1;
  6161. }
  6162. if (message[0] == '/')
  6163. {// pet emotion processing
  6164. const char* emo[] = {
  6165. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6166. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6167. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6168. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  6169. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  6170. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  6171. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  6172. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  6173. "/whisp"
  6174. };
  6175. int i;
  6176. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6177. if( i == ET_DICE1 ) i = rnd_value<int>(ET_DICE1, ET_DICE6); // randomize /dice
  6178. if( i < ARRAYLENGTH(emo) )
  6179. {
  6180. if (sd->emotionlasttime + 1 >= time(nullptr)) { // not more than 1 per second
  6181. sd->emotionlasttime = time(nullptr);
  6182. return 0;
  6183. }
  6184. sd->emotionlasttime = time(nullptr);
  6185. clif_emotion(&pd->bl, i);
  6186. return 0;
  6187. }
  6188. }
  6189. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6190. clif_disp_overhead(&pd->bl, temp);
  6191. return 0;
  6192. }
  6193. /// @users - displays the number of players present on each map (and percentage)
  6194. /// #users displays on the target user instead of self
  6195. ACMD_FUNC(users)
  6196. {
  6197. char buf[CHAT_SIZE_MAX];
  6198. int i;
  6199. int users[MAX_MAPINDEX];
  6200. int users_all;
  6201. struct s_mapiterator* iter;
  6202. memset(users, 0, sizeof(users));
  6203. users_all = 0;
  6204. // count users on each map
  6205. iter = mapit_getallusers();
  6206. for(;;)
  6207. {
  6208. map_session_data* sd2 = (map_session_data*)mapit_next(iter);
  6209. if( sd2 == nullptr )
  6210. break;// no more users
  6211. if( sd2->mapindex >= MAX_MAPINDEX )
  6212. continue;// invalid mapindex
  6213. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6214. if( users_all < INT_MAX ) ++users_all;
  6215. }
  6216. mapit_free(iter);
  6217. // display results for each map
  6218. for( i = 0; i < MAX_MAPINDEX; ++i )
  6219. {
  6220. if( users[i] == 0 )
  6221. continue;// empty
  6222. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6223. clif_displaymessage(sd->fd, buf);
  6224. }
  6225. // display overall count
  6226. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6227. clif_displaymessage(sd->fd, buf);
  6228. return 0;
  6229. }
  6230. /*==========================================
  6231. *
  6232. *------------------------------------------*/
  6233. ACMD_FUNC(reset)
  6234. {
  6235. pc_resetstate(sd);
  6236. pc_resetskill(sd,1);
  6237. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  6238. clif_displaymessage(fd, atcmd_output);
  6239. return 0;
  6240. }
  6241. /*==========================================
  6242. *
  6243. *------------------------------------------*/
  6244. ACMD_FUNC(summon)
  6245. {
  6246. char name[NAME_LENGTH];
  6247. int mob_id = 0;
  6248. int duration = 0;
  6249. struct mob_data *md;
  6250. t_tick tick=gettick();
  6251. nullpo_retr(-1, sd);
  6252. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  6253. {
  6254. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  6255. return -1;
  6256. }
  6257. if (duration < 1)
  6258. duration =1;
  6259. else if (duration > 60)
  6260. duration =60;
  6261. if ((mob_id = atoi(name)) == 0)
  6262. mob_id = mobdb_searchname(name);
  6263. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6264. {
  6265. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6266. return -1;
  6267. }
  6268. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  6269. if(!md)
  6270. return -1;
  6271. md->master_id=sd->bl.id;
  6272. md->special_state.ai=AI_ATTACK;
  6273. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6274. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  6275. mob_spawn(md);
  6276. sc_start4(nullptr,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6277. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  6278. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  6279. return 0;
  6280. }
  6281. /*==========================================
  6282. * @adjgroup
  6283. * Temporarily move player to another group
  6284. * Useful during beta testing to allow players to use GM commands for short periods of time
  6285. *------------------------------------------*/
  6286. ACMD_FUNC(adjgroup)
  6287. {
  6288. int new_group = 0;
  6289. nullpo_retr(-1, sd);
  6290. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  6291. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  6292. return -1;
  6293. }
  6294. if (!player_group_db.exists(new_group)) {
  6295. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  6296. return -1;
  6297. }
  6298. sd->group_id = new_group;
  6299. pc_group_pc_load(sd);/* update cache */
  6300. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  6301. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  6302. return 0;
  6303. }
  6304. /*==========================================
  6305. * @trade by [MouseJstr]
  6306. * Open a trade window with a remote player
  6307. *------------------------------------------*/
  6308. ACMD_FUNC(trade)
  6309. {
  6310. map_session_data* pl_sd = nullptr;;
  6311. nullpo_retr(-1, sd);
  6312. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6313. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6314. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  6315. return -1;
  6316. }
  6317. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  6318. {
  6319. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6320. return -1;
  6321. }
  6322. trade_traderequest(sd, pl_sd);
  6323. return 0;
  6324. }
  6325. /*==========================================
  6326. * @setbattleflag by [MouseJstr]
  6327. * set a battle_config flag without having to reboot
  6328. *------------------------------------------*/
  6329. ACMD_FUNC(setbattleflag)
  6330. {
  6331. char flag[128], value[128];
  6332. int reload = 0;
  6333. nullpo_retr(-1, sd);
  6334. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) < 2) {
  6335. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  6336. return -1;
  6337. }
  6338. if (battle_set_value(flag, value) == 0)
  6339. {
  6340. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  6341. return -1;
  6342. }
  6343. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  6344. if (reload)
  6345. mob_reload();
  6346. return 0;
  6347. }
  6348. /*==========================================
  6349. * @unmute [Valaris]
  6350. *------------------------------------------*/
  6351. ACMD_FUNC(unmute)
  6352. {
  6353. map_session_data* pl_sd = nullptr;;
  6354. nullpo_retr(-1, sd);
  6355. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6356. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6357. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6358. return -1;
  6359. }
  6360. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6361. {
  6362. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6363. return -1;
  6364. }
  6365. if(!pl_sd->sc.getSCE(SC_NOCHAT)) {
  6366. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6367. return -1;
  6368. }
  6369. pl_sd->status.manner = 0;
  6370. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6371. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6372. return 0;
  6373. }
  6374. /*==========================================
  6375. * @uptime by MC Cameri
  6376. *------------------------------------------*/
  6377. ACMD_FUNC(uptime)
  6378. {
  6379. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6380. minute = 60, days = 0, hours = 0, minutes = 0;
  6381. nullpo_retr(-1, sd);
  6382. seconds = get_uptime();
  6383. days = seconds/day;
  6384. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6385. hours = seconds/hour;
  6386. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6387. minutes = seconds/minute;
  6388. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6389. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  6390. clif_displaymessage(fd, atcmd_output);
  6391. return 0;
  6392. }
  6393. /*==========================================
  6394. * @changesex
  6395. * => Changes one's account sex. Switch from male to female or visversa
  6396. *------------------------------------------*/
  6397. ACMD_FUNC(changesex)
  6398. {
  6399. int i;
  6400. nullpo_retr(-1, sd);
  6401. pc_resetskill(sd,4);
  6402. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6403. for (i = 0; i < EQI_MAX; i++) {
  6404. if (sd->equip_index[i] >= 0)
  6405. pc_unequipitem(sd, sd->equip_index[i], 3);
  6406. }
  6407. chrif_changesex(sd, true);
  6408. return 0;
  6409. }
  6410. /*==========================================
  6411. * @changecharsex
  6412. * => Changes one's character sex. Switch from male to female or visversa.
  6413. *------------------------------------------*/
  6414. ACMD_FUNC(changecharsex)
  6415. {
  6416. int i;
  6417. nullpo_retr(-1, sd);
  6418. pc_resetskill(sd,4);
  6419. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6420. for (i = 0; i < EQI_MAX; i++) {
  6421. if (sd->equip_index[i] >= 0)
  6422. pc_unequipitem(sd, sd->equip_index[i], 3);
  6423. }
  6424. chrif_changesex(sd, false);
  6425. return 0;
  6426. }
  6427. /*================================================
  6428. * @mute - Mutes a player for a set amount of time
  6429. *------------------------------------------------*/
  6430. ACMD_FUNC(mute)
  6431. {
  6432. map_session_data* pl_sd = nullptr;;
  6433. int manner;
  6434. nullpo_retr(-1, sd);
  6435. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6436. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6437. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6438. return -1;
  6439. }
  6440. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6441. {
  6442. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6443. return -1;
  6444. }
  6445. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6446. {
  6447. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6448. return -1;
  6449. }
  6450. clif_manner_message(sd, 0);
  6451. clif_manner_message(pl_sd, 5);
  6452. if( pl_sd->status.manner < manner ) {
  6453. pl_sd->status.manner -= manner;
  6454. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6455. } else {
  6456. pl_sd->status.manner = 0;
  6457. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6458. }
  6459. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6460. return 0;
  6461. }
  6462. /*==========================================
  6463. * @refresh (like @jumpto <<yourself>>)
  6464. *------------------------------------------*/
  6465. ACMD_FUNC(refresh)
  6466. {
  6467. nullpo_retr(-1, sd);
  6468. clif_refresh(sd);
  6469. return 0;
  6470. }
  6471. ACMD_FUNC(refreshall)
  6472. {
  6473. map_session_data* iter_sd;
  6474. struct s_mapiterator* iter;
  6475. nullpo_retr(-1, sd);
  6476. iter = mapit_getallusers();
  6477. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6478. clif_refresh(iter_sd);
  6479. mapit_free(iter);
  6480. return 0;
  6481. }
  6482. /*==========================================
  6483. * @identify
  6484. * => GM's magnifier.
  6485. *------------------------------------------*/
  6486. ACMD_FUNC(identify)
  6487. {
  6488. int i,num;
  6489. nullpo_retr(-1, sd);
  6490. for(i=num=0;i<MAX_INVENTORY;i++){
  6491. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6492. num++;
  6493. }
  6494. }
  6495. if (num > 0) {
  6496. clif_item_identify_list(sd);
  6497. } else {
  6498. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6499. }
  6500. return 0;
  6501. }
  6502. /*===============================================
  6503. * @identifyall
  6504. * => Indentify all items in inventory - Akinari
  6505. *-----------------------------------------------*/
  6506. ACMD_FUNC(identifyall)
  6507. {
  6508. nullpo_retr(-1, sd);
  6509. pc_identifyall(sd, true);
  6510. return 0;
  6511. }
  6512. /*==========================================
  6513. * @gmotd (Global MOTD)
  6514. * by davidsiaw :P
  6515. *------------------------------------------*/
  6516. ACMD_FUNC(gmotd)
  6517. {
  6518. FILE* fp;
  6519. if( ( fp = fopen(motd_txt, "r") ) != nullptr )
  6520. {
  6521. char buf[CHAT_SIZE_MAX];
  6522. size_t len;
  6523. while( fgets(buf, sizeof(buf), fp) )
  6524. {
  6525. if( buf[0] == '/' && buf[1] == '/' )
  6526. {
  6527. continue;
  6528. }
  6529. len = strlen(buf);
  6530. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6531. {// strip trailing EOL characters
  6532. len--;
  6533. }
  6534. if( len )
  6535. {
  6536. buf[len] = 0;
  6537. intif_broadcast(buf, len+1, 0);
  6538. }
  6539. }
  6540. fclose(fp);
  6541. }
  6542. return 0;
  6543. }
  6544. ACMD_FUNC(misceffect)
  6545. {
  6546. int effect = 0;
  6547. nullpo_retr(-1, sd);
  6548. if (!message || !*message)
  6549. return -1;
  6550. if (sscanf(message, "%11d", &effect) < 1)
  6551. return -1;
  6552. if (effect < NOTIFYEFFECT_BASE_LEVEL_UP || effect > NOTIFYEFFECT_TAEKWON_BASE_LEVEL_UP)
  6553. return -1;
  6554. clif_misceffect( sd->bl, static_cast<e_notify_effect>(effect) );
  6555. return 0;
  6556. }
  6557. /*==========================================
  6558. * MAIL SYSTEM
  6559. *------------------------------------------*/
  6560. ACMD_FUNC(mail)
  6561. {
  6562. nullpo_ret(sd);
  6563. mail_openmail(sd);
  6564. return 0;
  6565. }
  6566. /*==========================================
  6567. * Show Monster DB Info v 1.0
  6568. * originally by [Lupus]
  6569. *------------------------------------------*/
  6570. ACMD_FUNC(mobinfo)
  6571. {
  6572. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6573. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6574. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6575. char atcmd_output2[CHAT_SIZE_MAX];
  6576. uint16 mob_ids[MAX_SEARCH], count;
  6577. uint16 i;
  6578. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6579. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6580. if (!message || !*message) {
  6581. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6582. return -1;
  6583. }
  6584. // If monster identifier/name argument is a name
  6585. if ((i = mobdb_checkid(strtoul(message, nullptr, 10))))
  6586. {
  6587. mob_ids[0] = i;
  6588. count = 1;
  6589. } else
  6590. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6591. if (!count) {
  6592. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6593. return -1;
  6594. }
  6595. if (count >= MAX_SEARCH) {
  6596. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6597. clif_displaymessage(fd, atcmd_output);
  6598. count = MAX_SEARCH;
  6599. }
  6600. for (uint16 k = 0; k < count; k++) {
  6601. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_ids[k]);
  6602. if (mob == nullptr)
  6603. continue;
  6604. t_exp base_exp = mob->base_exp;
  6605. t_exp job_exp = mob->job_exp;
  6606. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6607. base_exp += (base_exp * battle_config.vip_base_exp_increase) / 100;
  6608. job_exp += (job_exp * battle_config.vip_job_exp_increase) / 100;
  6609. }
  6610. #ifdef RENEWAL_EXP
  6611. if( battle_config.atcommand_mobinfo_type ) {
  6612. int penalty = pc_level_penalty_mod( sd, PENALTY_EXP, mob );
  6613. base_exp = base_exp * penalty / 100;
  6614. job_exp = job_exp * penalty / 100;
  6615. }
  6616. #endif
  6617. // stats
  6618. if( mob->get_bosstype() == BOSSTYPE_MVP )
  6619. 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)
  6620. else
  6621. 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)
  6622. clif_displaymessage(fd, atcmd_output);
  6623. 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
  6624. clif_displaymessage(fd, atcmd_output);
  6625. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6626. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6627. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6628. clif_displaymessage(fd, atcmd_output);
  6629. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6630. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6631. mob->range2 , mob->range3, msize[mob->status.size],
  6632. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6633. clif_displaymessage(fd, atcmd_output);
  6634. #ifdef RENEWAL
  6635. sprintf(atcmd_output, msg_txt(sd, 827), mob->status.res, mob->status.mres);// MDEF:%d RES:%d MRES:%d
  6636. clif_displaymessage(fd, atcmd_output);
  6637. #endif
  6638. // drops
  6639. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6640. strcpy(atcmd_output, " ");
  6641. unsigned int j = 0;
  6642. int drop_modifier = 100;
  6643. #ifdef RENEWAL_DROP
  6644. if( battle_config.atcommand_mobinfo_type ){
  6645. drop_modifier = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
  6646. }
  6647. #endif
  6648. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6649. if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].rate < 1)
  6650. continue;
  6651. std::shared_ptr<item_data> id = item_db.find(mob->dropitem[i].nameid);
  6652. if (id == nullptr)
  6653. continue;
  6654. int droprate = mob_getdroprate( &sd->bl, mob, mob->dropitem[i].rate, drop_modifier );
  6655. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), (float)droprate / 100);
  6656. strcat(atcmd_output, atcmd_output2);
  6657. if (++j % 3 == 0) {
  6658. clif_displaymessage(fd, atcmd_output);
  6659. strcpy(atcmd_output, " ");
  6660. }
  6661. }
  6662. if (j == 0)
  6663. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6664. else if (j % 3 != 0)
  6665. clif_displaymessage(fd, atcmd_output);
  6666. // mvp
  6667. if( mob->get_bosstype() == BOSSTYPE_MVP ){
  6668. float mvppercent, mvpremain;
  6669. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%llu
  6670. clif_displaymessage(fd, atcmd_output);
  6671. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6672. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6673. j = 0;
  6674. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6675. if (mob->mvpitem[i].nameid == 0)
  6676. continue;
  6677. std::shared_ptr<item_data> id = item_db.find(mob->mvpitem[i].nameid);
  6678. if (id == nullptr)
  6679. continue;
  6680. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6681. mvppercent = (float)mob->mvpitem[i].rate * mvpremain / 10000.0f;
  6682. if(battle_config.item_drop_mvp_mode == 0) {
  6683. mvpremain -= mvppercent;
  6684. }
  6685. if (mvppercent > 0) {
  6686. j++;
  6687. if (j == 1) {
  6688. sprintf(atcmd_output2, " %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6689. } else {
  6690. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6691. }
  6692. strcat(atcmd_output, atcmd_output2);
  6693. }
  6694. }
  6695. if (j == 0)
  6696. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6697. else
  6698. clif_displaymessage(fd, atcmd_output);
  6699. }
  6700. }
  6701. return 0;
  6702. }
  6703. /*=========================================
  6704. * @showmobs by KarLaeda
  6705. * => For 15 sec displays the mobs on minimap
  6706. *------------------------------------------*/
  6707. ACMD_FUNC(showmobs)
  6708. {
  6709. char mob_name[100];
  6710. int mob_id;
  6711. int number = 0;
  6712. struct s_mapiterator* it;
  6713. nullpo_retr(-1, sd);
  6714. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6715. return -1;
  6716. if((mob_id = strtol(mob_name, nullptr, 10)) == 0)
  6717. mob_id = mobdb_searchname(mob_name);
  6718. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6719. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6720. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6721. clif_displaymessage(fd, atcmd_output);
  6722. return 0;
  6723. }
  6724. 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.
  6725. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6726. return 0;
  6727. }
  6728. if(mob_id == strtol(mob_name, nullptr, 10) && !mob->jname.empty())
  6729. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6730. //strcpy(mob_name, mob->name.c_str()); // --en--
  6731. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6732. mob_name, mapindex_id2name(sd->mapindex));
  6733. clif_displaymessage(fd, atcmd_output);
  6734. it = mapit_geteachmob();
  6735. for(;;)
  6736. {
  6737. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6738. if( md == nullptr )
  6739. break;// no more mobs
  6740. if( md->bl.m != sd->bl.m )
  6741. continue;
  6742. if( mob_id != -1 && md->mob_id != mob_id )
  6743. continue;
  6744. if( md->special_state.ai || md->master_id )
  6745. continue; // hide slaves and player summoned mobs
  6746. if( md->spawn_timer != INVALID_TIMER )
  6747. continue; // hide mobs waiting for respawn
  6748. ++number;
  6749. clif_viewpoint( *sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF );
  6750. }
  6751. mapit_free(it);
  6752. return 0;
  6753. }
  6754. /*==========================================
  6755. * homunculus level up [orn]
  6756. *------------------------------------------*/
  6757. ACMD_FUNC(homlevel)
  6758. {
  6759. TBL_HOM * hd;
  6760. int level = 0, i = 0;
  6761. nullpo_retr(-1, sd);
  6762. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6763. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6764. return -1;
  6765. }
  6766. if ( !hom_is_active(sd->hd) ) {
  6767. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6768. return -1;
  6769. }
  6770. hd = sd->hd;
  6771. for (i = 1; i <= level && hd->exp_next; i++){
  6772. hd->homunculus.exp += hd->exp_next;
  6773. if( !hom_levelup(hd) )
  6774. break;
  6775. }
  6776. status_calc_homunculus(hd, SCO_NONE);
  6777. status_percent_heal(&hd->bl, 100, 100);
  6778. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6779. return 0;
  6780. }
  6781. /*==========================================
  6782. * homunculus evolution H [orn]
  6783. *------------------------------------------*/
  6784. ACMD_FUNC(homevolution)
  6785. {
  6786. nullpo_retr(-1, sd);
  6787. if ( !hom_is_active(sd->hd) ) {
  6788. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6789. return -1;
  6790. }
  6791. if ( !hom_evolution(sd->hd) ) {
  6792. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6793. return -1;
  6794. }
  6795. clif_homskillinfoblock( *sd->hd );
  6796. return 0;
  6797. }
  6798. ACMD_FUNC(hommutate)
  6799. {
  6800. int homun_id, m_class = 0, m_id;
  6801. nullpo_retr(-1, sd);
  6802. if (!hom_is_active(sd->hd)) {
  6803. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6804. return -1;
  6805. }
  6806. if (!message || !*message) {
  6807. homun_id = rnd_value<uint16>(MER_EIRA, MER_ELEANOR);
  6808. } else {
  6809. homun_id = atoi(message);
  6810. }
  6811. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6812. m_id = hom_class2mapid(homun_id);
  6813. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6814. hom_mutate(sd->hd, homun_id);
  6815. } else {
  6816. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6817. }
  6818. return 0;
  6819. }
  6820. /*==========================================
  6821. * call choosen homunculus [orn]
  6822. *------------------------------------------*/
  6823. ACMD_FUNC(makehomun)
  6824. {
  6825. int homunid;
  6826. nullpo_retr(-1, sd);
  6827. if ( sd->status.hom_id ) {
  6828. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6829. return -1;
  6830. }
  6831. if (!message || !*message) {
  6832. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6833. return -1;
  6834. }
  6835. homunid = atoi(message);
  6836. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6837. {
  6838. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6839. return -1;
  6840. }
  6841. hom_create_request(sd,homunid);
  6842. return 0;
  6843. }
  6844. /*==========================================
  6845. * modify homunculus intimacy [orn]
  6846. *------------------------------------------*/
  6847. ACMD_FUNC(homfriendly)
  6848. {
  6849. int friendly = 0;
  6850. nullpo_retr(-1, sd);
  6851. if ( !hom_is_active(sd->hd) ) {
  6852. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6853. return -1;
  6854. }
  6855. if (!message || !*message) {
  6856. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6857. return -1;
  6858. }
  6859. friendly = atoi(message);
  6860. friendly = cap_value(friendly, 0, 1000);
  6861. sd->hd->homunculus.intimacy = friendly * 100 ;
  6862. clif_send_homdata( *sd->hd, SP_INTIMATE );
  6863. return 0;
  6864. }
  6865. /*==========================================
  6866. * modify homunculus hunger [orn]
  6867. *------------------------------------------*/
  6868. ACMD_FUNC(homhungry)
  6869. {
  6870. int hungry = 0;
  6871. nullpo_retr(-1, sd);
  6872. if ( !hom_is_active(sd->hd) ) {
  6873. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6874. return -1;
  6875. }
  6876. if (!message || !*message) {
  6877. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6878. return -1;
  6879. }
  6880. hungry = atoi(message);
  6881. hungry = cap_value(hungry, 0, 100);
  6882. sd->hd->homunculus.hunger = hungry;
  6883. clif_send_homdata( *sd->hd, SP_HUNGRY );
  6884. return 0;
  6885. }
  6886. /*==========================================
  6887. * make the homunculus speak [orn]
  6888. *------------------------------------------*/
  6889. ACMD_FUNC(homtalk)
  6890. {
  6891. char mes[100],temp[CHAT_SIZE_MAX];
  6892. nullpo_retr(-1, sd);
  6893. if ( battle_config.min_chat_delay ) {
  6894. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6895. return 0;
  6896. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6897. }
  6898. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6899. return -1; //no "chatting" while muted.
  6900. if ( !hom_is_active(sd->hd) ) {
  6901. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6902. return -1;
  6903. }
  6904. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6905. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6906. return -1;
  6907. }
  6908. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6909. clif_disp_overhead(&sd->hd->bl, temp);
  6910. return 0;
  6911. }
  6912. /*==========================================
  6913. * Show homunculus stats
  6914. *------------------------------------------*/
  6915. ACMD_FUNC(hominfo)
  6916. {
  6917. struct homun_data *hd;
  6918. nullpo_retr(-1, sd);
  6919. if ( !hom_is_active(sd->hd) ) {
  6920. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6921. return -1;
  6922. }
  6923. hd = sd->hd;
  6924. status_data* status = status_get_status_data(hd->bl);
  6925. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6926. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6927. status->hp, status->max_hp, status->sp, status->max_sp);
  6928. clif_displaymessage(fd, atcmd_output);
  6929. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6930. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6931. clif_displaymessage(fd, atcmd_output);
  6932. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6933. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6934. clif_displaymessage(fd, atcmd_output);
  6935. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6936. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6937. status->str, status->agi, status->vit,
  6938. status->int_, status->dex, status->luk);
  6939. clif_displaymessage(fd, atcmd_output);
  6940. return 0;
  6941. }
  6942. ACMD_FUNC(homstats)
  6943. {
  6944. struct homun_data *hd;
  6945. std::shared_ptr<s_homunculus_db> db;
  6946. struct s_homunculus *hom;
  6947. int lv, min, max, evo;
  6948. nullpo_retr(-1, sd);
  6949. if ( !hom_is_active(sd->hd) ) {
  6950. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6951. return -1;
  6952. }
  6953. hd = sd->hd;
  6954. hom = &hd->homunculus;
  6955. db = hd->homunculusDB;
  6956. lv = hom->level;
  6957. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6958. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6959. clif_displaymessage(fd, atcmd_output);
  6960. lv--; //Since the first increase is at level 2.
  6961. evo = (hom->class_ == db->evo_class);
  6962. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6963. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6964. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6965. clif_displaymessage(fd, atcmd_output);
  6966. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6967. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6968. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6969. clif_displaymessage(fd, atcmd_output);
  6970. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6971. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6972. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6973. clif_displaymessage(fd, atcmd_output);
  6974. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6975. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6976. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6977. clif_displaymessage(fd, atcmd_output);
  6978. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6979. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6980. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6981. clif_displaymessage(fd, atcmd_output);
  6982. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6983. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6984. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6985. clif_displaymessage(fd, atcmd_output);
  6986. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6987. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6988. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6989. clif_displaymessage(fd, atcmd_output);
  6990. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6991. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6992. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6993. clif_displaymessage(fd, atcmd_output);
  6994. return 0;
  6995. }
  6996. ACMD_FUNC(homshuffle)
  6997. {
  6998. nullpo_retr(-1, sd);
  6999. if(!sd->hd)
  7000. return -1; // nothing to do
  7001. if(!hom_shuffle(sd->hd))
  7002. return -1;
  7003. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  7004. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  7005. return 0;
  7006. }
  7007. /*==========================================
  7008. * Show Items DB Info v 1.0
  7009. * originally by [Lupus]
  7010. *------------------------------------------*/
  7011. ACMD_FUNC(iteminfo)
  7012. {
  7013. if (!message || !*message) {
  7014. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  7015. return -1;
  7016. }
  7017. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7018. uint16 count = 1;
  7019. t_itemid itemid = strtoul(message, nullptr, 10);
  7020. if (itemid == 0) // Entered a string
  7021. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7022. else {
  7023. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7024. count = 0;
  7025. }
  7026. if (!count) {
  7027. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7028. return -1;
  7029. }
  7030. if (count == MAX_SEARCH) {
  7031. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7032. clif_displaymessage(fd, atcmd_output);
  7033. }
  7034. for (const auto &result : item_array) {
  7035. std::shared_ptr<item_data> item_data = result.second;
  7036. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s' (%u) Type: %s | Extra Effect: %s
  7037. item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(),item_data->nameid,
  7038. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
  7039. (item_data->script==nullptr)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  7040. );
  7041. clif_displaymessage(fd, atcmd_output);
  7042. 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
  7043. clif_displaymessage(fd, atcmd_output);
  7044. if (item_data->maxchance == -1) {
  7045. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  7046. clif_displaymessage(fd, atcmd_output);
  7047. }
  7048. else if (!battle_config.atcommand_mobinfo_type) {
  7049. if (item_data->maxchance)
  7050. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  7051. else
  7052. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  7053. clif_displaymessage(fd, atcmd_output);
  7054. }
  7055. }
  7056. return 0;
  7057. }
  7058. /*==========================================
  7059. * Show who drops the item.
  7060. *------------------------------------------*/
  7061. ACMD_FUNC(whodrops)
  7062. {
  7063. if (!message || !*message) {
  7064. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  7065. return -1;
  7066. }
  7067. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7068. uint16 count = 1;
  7069. t_itemid itemid = strtoul(message, nullptr, 10);
  7070. if (itemid == 0) // Entered a string
  7071. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7072. else {
  7073. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7074. count = 0;
  7075. }
  7076. if (!count) {
  7077. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7078. return -1;
  7079. }
  7080. if (count == MAX_SEARCH) {
  7081. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7082. clif_displaymessage(fd, atcmd_output);
  7083. }
  7084. for (const auto &result : item_array) {
  7085. std::shared_ptr<item_data> id = result.second;
  7086. sprintf(atcmd_output, msg_txt(sd,1285), item_db.create_item_link( id ).c_str(), id->nameid); // Item: '%s' (ID:%u)
  7087. clif_displaymessage(fd, atcmd_output);
  7088. if (id->mob[0].chance == 0) {
  7089. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  7090. clif_displaymessage(fd, atcmd_output);
  7091. } else {
  7092. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  7093. clif_displaymessage(fd, atcmd_output);
  7094. for (uint16 j=0; j < MAX_SEARCH && id->mob[j].chance > 0; j++)
  7095. {
  7096. int dropchance = id->mob[j].chance;
  7097. std::shared_ptr<s_mob_db> mob = mob_db.find(id->mob[j].id);
  7098. if(!mob) continue;
  7099. #ifdef RENEWAL_DROP
  7100. if( battle_config.atcommand_mobinfo_type ) {
  7101. dropchance = dropchance * pc_level_penalty_mod( sd, PENALTY_DROP, mob ) / 100;
  7102. if (dropchance <= 0 && !battle_config.drop_rate0item)
  7103. dropchance = 1;
  7104. }
  7105. #endif
  7106. if (pc_isvip(sd)) // Display item rate increase for VIP
  7107. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  7108. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob->jname.c_str(), id->mob[j].id, dropchance/100.);
  7109. clif_displaymessage(fd, atcmd_output);
  7110. }
  7111. }
  7112. }
  7113. return 0;
  7114. }
  7115. ACMD_FUNC(whereis)
  7116. {
  7117. uint16 mob_ids[MAX_SEARCH] = {0}, count;
  7118. if (!message || !*message) {
  7119. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  7120. return -1;
  7121. }
  7122. int i_message = atoi(message);
  7123. if (mobdb_checkid(i_message)) {
  7124. // ID given
  7125. mob_ids[0] = i_message;
  7126. count = 1;
  7127. } else {
  7128. // Name given, get all monster associated whith this name
  7129. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  7130. }
  7131. if (count <= 0) {
  7132. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  7133. return -1;
  7134. }
  7135. if (count >= MAX_SEARCH) {
  7136. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7137. clif_displaymessage(fd, atcmd_output);
  7138. count = MAX_SEARCH;
  7139. }
  7140. for (int i = 0; i < count; i++) {
  7141. uint16 mob_id = mob_ids[i];
  7142. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  7143. if(!mob) continue;
  7144. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname.c_str()); // %s spawns in:
  7145. clif_displaymessage(fd, atcmd_output);
  7146. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  7147. if (spawns.size() <= 0) {
  7148. // This monster does not spawn normally.
  7149. clif_displaymessage(fd, msg_txt(sd,1290));
  7150. } else {
  7151. for(auto& spawn : spawns)
  7152. {
  7153. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  7154. if (mapid < 0)
  7155. continue;
  7156. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  7157. clif_displaymessage(fd, atcmd_output);
  7158. }
  7159. }
  7160. }
  7161. return 0;
  7162. }
  7163. ACMD_FUNC(version)
  7164. {
  7165. pc_show_version(sd);
  7166. return 0;
  7167. }
  7168. /*==========================================
  7169. * @mutearea by MouseJstr
  7170. *------------------------------------------*/
  7171. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7172. {
  7173. int time, id;
  7174. map_session_data *pl_sd = (map_session_data *)bl;
  7175. if (pl_sd == nullptr)
  7176. return 0;
  7177. id = va_arg(ap, int);
  7178. time = va_arg(ap, int);
  7179. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  7180. pl_sd->status.manner -= time;
  7181. if (pl_sd->status.manner < 0)
  7182. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  7183. else
  7184. status_change_end(&pl_sd->bl, SC_NOCHAT);
  7185. }
  7186. return 0;
  7187. }
  7188. ACMD_FUNC(mutearea)
  7189. {
  7190. int time;
  7191. nullpo_ret(sd);
  7192. if (!message || !*message) {
  7193. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  7194. return -1;
  7195. }
  7196. time = atoi(message);
  7197. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  7198. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7199. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7200. return 0;
  7201. }
  7202. ACMD_FUNC(rates)
  7203. {
  7204. char buf[CHAT_SIZE_MAX];
  7205. nullpo_ret(sd);
  7206. memset(buf, '\0', sizeof(buf));
  7207. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  7208. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  7209. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  7210. clif_displaymessage(fd, buf);
  7211. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7212. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  7213. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  7214. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  7215. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  7216. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  7217. clif_displaymessage(fd, buf);
  7218. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7219. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  7220. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  7221. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  7222. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  7223. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  7224. clif_displaymessage(fd, buf);
  7225. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7226. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  7227. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  7228. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  7229. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  7230. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  7231. clif_displaymessage(fd, buf);
  7232. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  7233. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  7234. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  7235. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  7236. clif_displaymessage(fd, buf);
  7237. return 0;
  7238. }
  7239. /*==========================================
  7240. * @me by lordalfa
  7241. * => Displays the OUTPUT string on top of the Visible players Heads.
  7242. *------------------------------------------*/
  7243. ACMD_FUNC(me)
  7244. {
  7245. char tempmes[CHAT_SIZE_MAX];
  7246. nullpo_retr(-1, sd);
  7247. memset(tempmes, '\0', sizeof(tempmes));
  7248. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7249. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  7250. return -1; //no "chatting" while muted.
  7251. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  7252. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  7253. return -1;
  7254. }
  7255. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  7256. clif_disp_overhead(&sd->bl, atcmd_output);
  7257. return 0;
  7258. }
  7259. /*==========================================
  7260. * @size
  7261. * => Resize your character sprite. [Valaris]
  7262. *------------------------------------------*/
  7263. ACMD_FUNC(size)
  7264. {
  7265. int size = SZ_SMALL;
  7266. nullpo_retr(-1, sd);
  7267. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  7268. if(sd->state.size) {
  7269. sd->state.size = SZ_SMALL;
  7270. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  7271. }
  7272. sd->state.size = size;
  7273. if( size == SZ_MEDIUM )
  7274. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  7275. else if( size == SZ_BIG )
  7276. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  7277. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7278. return 0;
  7279. }
  7280. ACMD_FUNC(sizeall)
  7281. {
  7282. int size;
  7283. map_session_data *pl_sd;
  7284. struct s_mapiterator* iter;
  7285. size = atoi(message);
  7286. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7287. iter = mapit_getallusers();
  7288. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  7289. if( pl_sd->state.size != size ) {
  7290. if( pl_sd->state.size ) {
  7291. pl_sd->state.size = SZ_SMALL;
  7292. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7293. }
  7294. pl_sd->state.size = size;
  7295. if( size == SZ_MEDIUM )
  7296. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7297. else if( size == SZ_BIG )
  7298. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7299. }
  7300. }
  7301. mapit_free(iter);
  7302. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7303. return 0;
  7304. }
  7305. ACMD_FUNC(sizeguild)
  7306. {
  7307. int size = SZ_SMALL, i;
  7308. char guild[NAME_LENGTH];
  7309. map_session_data *pl_sd;
  7310. nullpo_retr(-1, sd);
  7311. memset(guild, '\0', sizeof(guild));
  7312. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  7313. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  7314. return -1;
  7315. }
  7316. auto g = guild_searchnameid(guild);
  7317. if (!g) {
  7318. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  7319. return -1;
  7320. }
  7321. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7322. for( i = 0; i < g->guild.max_member; i++ ) {
  7323. if( (pl_sd = g->guild.member[i].sd) && pl_sd->state.size != size ) {
  7324. if( pl_sd->state.size ) {
  7325. pl_sd->state.size = SZ_SMALL;
  7326. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7327. }
  7328. pl_sd->state.size = size;
  7329. if( size == SZ_MEDIUM )
  7330. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7331. else if( size == SZ_BIG )
  7332. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7333. }
  7334. }
  7335. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7336. return 0;
  7337. }
  7338. /*==========================================
  7339. * @monsterignore
  7340. * => Makes monsters ignore you. [Valaris]
  7341. *------------------------------------------*/
  7342. ACMD_FUNC(monsterignore)
  7343. {
  7344. nullpo_retr(-1, sd);
  7345. if (sd->state.block_action & PCBLOCK_IMMUNE) {
  7346. sd->state.block_action &= ~PCBLOCK_IMMUNE;
  7347. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  7348. } else {
  7349. sd->state.block_action |= PCBLOCK_IMMUNE;
  7350. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  7351. }
  7352. return 0;
  7353. }
  7354. /*==========================================
  7355. * @fakename
  7356. * => Gives your character a fake name. [Valaris]
  7357. *------------------------------------------*/
  7358. ACMD_FUNC(fakename)
  7359. {
  7360. nullpo_retr(-1, sd);
  7361. if( !message || !*message )
  7362. {
  7363. if( sd->fakename[0] )
  7364. {
  7365. sd->fakename[0] = '\0';
  7366. clif_name_area(&sd->bl);
  7367. if (sd->disguise)
  7368. clif_name_self(&sd->bl);
  7369. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7370. return 0;
  7371. }
  7372. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7373. return -1;
  7374. }
  7375. if( strlen(message) < 2 )
  7376. {
  7377. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7378. return -1;
  7379. }
  7380. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7381. clif_name_area(&sd->bl);
  7382. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  7383. clif_name_self(&sd->bl);
  7384. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7385. return 0;
  7386. }
  7387. /*==========================================
  7388. * Ragnarok Resources
  7389. *------------------------------------------*/
  7390. ACMD_FUNC(mapflag) {
  7391. char flag_name[50];
  7392. short flag = 0, i, j;
  7393. std::string buf;
  7394. nullpo_retr(-1, sd);
  7395. memset(flag_name, '\0', sizeof(flag_name));
  7396. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  7397. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7398. clif_displaymessage(sd->fd,"----------------------------------");
  7399. for( i = MF_MIN; i < MF_MAX; i++ ){
  7400. union u_mapflag_args args = {};
  7401. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  7402. clif_displaymessage(sd->fd, flag_name);
  7403. }
  7404. }
  7405. clif_displaymessage(sd->fd," ");
  7406. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7407. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7408. return 1;
  7409. }
  7410. // Check if the list of mapflags was requested
  7411. if( strcasecmp(flag_name,"available") ){
  7412. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7413. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  7414. if( mapflag != MF_INVALID ){
  7415. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  7416. MF_PVP_NIGHTMAREDROP,
  7417. MF_RESTRICTED,
  7418. MF_NOCOMMAND,
  7419. MF_BEXP,
  7420. MF_JEXP,
  7421. MF_BATTLEGROUND,
  7422. MF_SKILL_DAMAGE,
  7423. MF_SKILL_DURATION };
  7424. if (flag > 0 && util::vector_exists(disabled_mf, mapflag)) {
  7425. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  7426. clif_displaymessage(sd->fd,atcmd_output);
  7427. } else {
  7428. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  7429. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  7430. clif_displaymessage(sd->fd,atcmd_output);
  7431. }
  7432. return 0;
  7433. }else{
  7434. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  7435. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  7436. return 1;
  7437. }
  7438. }
  7439. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7440. clif_displaymessage(sd->fd,"----------------------------------");
  7441. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  7442. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  7443. buf.append(flag_name);
  7444. if( (i + 1) < MF_MAX )
  7445. buf.append(", ");
  7446. j++;
  7447. }
  7448. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  7449. clif_displaymessage(sd->fd, buf.c_str() );
  7450. buf.clear();
  7451. j = 0;
  7452. }
  7453. }
  7454. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7455. return 0;
  7456. }
  7457. /*===================================
  7458. * Remove some messages
  7459. *-----------------------------------*/
  7460. ACMD_FUNC(showexp)
  7461. {
  7462. if (sd->state.showexp) {
  7463. sd->state.showexp = 0;
  7464. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7465. return 0;
  7466. }
  7467. sd->state.showexp = 1;
  7468. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7469. return 0;
  7470. }
  7471. ACMD_FUNC(showzeny)
  7472. {
  7473. if (sd->state.showzeny) {
  7474. sd->state.showzeny = 0;
  7475. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7476. return 0;
  7477. }
  7478. sd->state.showzeny = 1;
  7479. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7480. return 0;
  7481. }
  7482. ACMD_FUNC(showdelay)
  7483. {
  7484. if (sd->state.showdelay) {
  7485. sd->state.showdelay = 0;
  7486. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7487. return 0;
  7488. }
  7489. sd->state.showdelay = 1;
  7490. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7491. return 0;
  7492. }
  7493. /*==========================================
  7494. * Duel organizing functions [LuzZza]
  7495. *
  7496. * @duel [limit|nick] - create a duel
  7497. * @invite <nick> - invite player
  7498. * @accept - accept invitation
  7499. * @reject - reject invitation
  7500. * @leave - leave duel
  7501. *------------------------------------------*/
  7502. ACMD_FUNC(invite)
  7503. {
  7504. size_t did = sd->duel_group;
  7505. map_session_data *target_sd = nullptr;
  7506. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7507. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7508. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7509. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7510. clif_displaymessage(fd, atcmd_output);
  7511. return -1;
  7512. }
  7513. if(did == 0 || !duel_exist(did) ) {
  7514. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7515. return 0;
  7516. }
  7517. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7518. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7519. return 0;
  7520. }
  7521. if((target_sd = map_nick2sd(atcmd_player_name, true)) == nullptr) {
  7522. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7523. return 0;
  7524. }
  7525. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7526. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7527. return 0;
  7528. }
  7529. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7530. {
  7531. 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.
  7532. clif_displaymessage(fd, atcmd_output);
  7533. return 0;
  7534. }
  7535. duel_invite(did, sd, target_sd);
  7536. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7537. return 0;
  7538. }
  7539. ACMD_FUNC(duel)
  7540. {
  7541. unsigned int maxpl = 0;
  7542. if(sd->duel_group > 0) {
  7543. duel_showinfo(sd->duel_group, sd);
  7544. return 0;
  7545. }
  7546. if(sd->duel_invite > 0) {
  7547. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7548. return 0;
  7549. }
  7550. if(!duel_checktime(sd)) {
  7551. char output[CHAT_SIZE_MAX];
  7552. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7553. clif_displaymessage(fd, output);
  7554. return 0;
  7555. }
  7556. if( message[0] ) {
  7557. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7558. if(maxpl < 2 || maxpl > 65535) {
  7559. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7560. return 0;
  7561. }
  7562. duel_create(sd, maxpl);
  7563. } else {
  7564. map_session_data *target_sd = nullptr;
  7565. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7566. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7567. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7568. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7569. clif_displaymessage(fd, atcmd_output);
  7570. return -1;
  7571. }
  7572. target_sd = map_nick2sd(atcmd_player_name,true);
  7573. if(target_sd != nullptr) {
  7574. size_t newduel;
  7575. if((newduel = duel_create(sd, 2)) != -1) {
  7576. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7577. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7578. return 0;
  7579. }
  7580. duel_invite(newduel, sd, target_sd);
  7581. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7582. }
  7583. } else {
  7584. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7585. return 0;
  7586. }
  7587. }
  7588. } else
  7589. duel_create(sd, 0);
  7590. return 0;
  7591. }
  7592. ACMD_FUNC(leave)
  7593. {
  7594. if(sd->duel_group <= 0) {
  7595. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7596. return 0;
  7597. }
  7598. duel_leave(sd->duel_group, sd);
  7599. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7600. return 0;
  7601. }
  7602. ACMD_FUNC(accept)
  7603. {
  7604. if(!duel_checktime(sd)) {
  7605. char output[CHAT_SIZE_MAX];
  7606. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7607. clif_displaymessage(fd, output);
  7608. return 0;
  7609. }
  7610. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7611. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7612. return 0;
  7613. }
  7614. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7615. {
  7616. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7617. return 0;
  7618. }
  7619. duel_accept(sd->duel_invite, sd);
  7620. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7621. return 0;
  7622. }
  7623. ACMD_FUNC(reject)
  7624. {
  7625. if(sd->duel_invite <= 0) {
  7626. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7627. return 0;
  7628. }
  7629. duel_reject(sd->duel_invite, sd);
  7630. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7631. return 0;
  7632. }
  7633. /*===================================
  7634. * Cash Points
  7635. *-----------------------------------*/
  7636. ACMD_FUNC(cash)
  7637. {
  7638. char output[128];
  7639. int value;
  7640. int ret=0;
  7641. nullpo_retr(-1, sd);
  7642. // Since there is no cashpoint update packet we need to force updating like this
  7643. if( sd->state.cashshop_open ){
  7644. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7645. return -1;
  7646. }
  7647. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7648. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7649. return -1;
  7650. }
  7651. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7652. if( !strcmpi(parent_cmd,"cash") )
  7653. {
  7654. if( value > 0 ) {
  7655. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7656. // If this option is set, the message is already sent by pc function
  7657. if( !battle_config.cashshop_show_points ){
  7658. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7659. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7660. }
  7661. }
  7662. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7663. } else {
  7664. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7665. value = -sd->cashPoints;
  7666. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7667. // If this option is set, the message is already sent by pc function
  7668. if( !battle_config.cashshop_show_points ){
  7669. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7670. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7671. }
  7672. }
  7673. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7674. }
  7675. }
  7676. else
  7677. { // @points
  7678. if( value > 0 ) {
  7679. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7680. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7681. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7682. }
  7683. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7684. } else {
  7685. if (-value > sd->kafraPoints) //By command, if cash < value, force it to remove all
  7686. value = -sd->kafraPoints;
  7687. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7688. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7689. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7690. }
  7691. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7692. }
  7693. }
  7694. return 0;
  7695. }
  7696. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7697. ACMD_FUNC(clone)
  7698. {
  7699. int x=0,y=0,flag=0,master=0,i=0;
  7700. map_session_data *pl_sd=nullptr;
  7701. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7702. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7703. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7704. return 0;
  7705. }
  7706. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr) {
  7707. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7708. return 0;
  7709. }
  7710. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7711. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7712. return 0;
  7713. }
  7714. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7715. if (strcmpi(parent_cmd, "clone") == 0)
  7716. flag = 1;
  7717. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7718. flag = 2;
  7719. if(pc_isdead(sd)){
  7720. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7721. return 0;
  7722. }
  7723. master = sd->bl.id;
  7724. if (battle_config.atc_slave_clone_limit
  7725. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7726. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7727. return 0;
  7728. }
  7729. }
  7730. do {
  7731. x = sd->bl.x + rnd_value(-5, 5);
  7732. y = sd->bl.y + rnd_value(-5, 5);
  7733. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7734. if (i >= 10) {
  7735. x = sd->bl.x;
  7736. y = sd->bl.y;
  7737. }
  7738. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7739. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7740. return 0;
  7741. }
  7742. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7743. return 0;
  7744. }
  7745. /*=====================================
  7746. * Autorejecting Invites/Deals [LuzZza]
  7747. * Usage: @noask
  7748. *-------------------------------------*/
  7749. ACMD_FUNC(noask)
  7750. {
  7751. if(sd->state.noask) {
  7752. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7753. sd->state.noask = 0;
  7754. } else {
  7755. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7756. sd->state.noask = 1;
  7757. }
  7758. return 0;
  7759. }
  7760. /*=====================================
  7761. * Send a @request message to all GMs of lowest_gm_level.
  7762. * Usage: @request <petition>
  7763. *-------------------------------------*/
  7764. ACMD_FUNC(request)
  7765. {
  7766. if (!message || !*message) {
  7767. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7768. return -1;
  7769. }
  7770. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7771. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7772. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7773. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7774. return 0;
  7775. }
  7776. /*==========================================
  7777. * Feel (SG designated maps) Reset [HiddenDragon]
  7778. *------------------------------------------*/
  7779. ACMD_FUNC(feelreset)
  7780. {
  7781. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7782. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7783. return -1;
  7784. }
  7785. pc_resetfeel(sd);
  7786. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7787. return 0;
  7788. }
  7789. /*==========================================
  7790. * Hate (SG designated monsters) Reset
  7791. *------------------------------------------*/
  7792. ACMD_FUNC(hatereset)
  7793. {
  7794. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7795. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7796. return -1;
  7797. }
  7798. pc_resethate(sd);
  7799. clif_displaymessage(fd, msg_txt(sd,1515)); // Reset 'Hatred' monsters.
  7800. return 0;
  7801. }
  7802. /*==========================================
  7803. * AUCTION SYSTEM
  7804. *------------------------------------------*/
  7805. ACMD_FUNC(auction)
  7806. {
  7807. nullpo_ret(sd);
  7808. if (!battle_config.feature_auction) {
  7809. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7810. return 0;
  7811. }
  7812. clif_Auction_openwindow(sd);
  7813. return 0;
  7814. }
  7815. /*==========================================
  7816. * Kill Steal Protection
  7817. *------------------------------------------*/
  7818. ACMD_FUNC(ksprotection)
  7819. {
  7820. nullpo_retr(-1,sd);
  7821. if( sd->state.noks ) {
  7822. sd->state.noks = 0;
  7823. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7824. }
  7825. else
  7826. {
  7827. if( !message || !*message || !strcmpi(message, "party") )
  7828. { // Default is Party
  7829. sd->state.noks = 2;
  7830. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7831. }
  7832. else if( !strcmpi(message, "self") )
  7833. {
  7834. sd->state.noks = 1;
  7835. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7836. }
  7837. else if( !strcmpi(message, "guild") )
  7838. {
  7839. sd->state.noks = 3;
  7840. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7841. }
  7842. else
  7843. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7844. }
  7845. return 0;
  7846. }
  7847. /*==========================================
  7848. * Map Kill Steal Protection Setting
  7849. *------------------------------------------*/
  7850. ACMD_FUNC(allowks)
  7851. {
  7852. nullpo_retr(-1,sd);
  7853. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7854. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7855. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7856. } else {
  7857. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7858. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7859. }
  7860. return 0;
  7861. }
  7862. ACMD_FUNC(resetstat)
  7863. {
  7864. nullpo_retr(-1, sd);
  7865. pc_resetstate(sd);
  7866. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7867. clif_displaymessage(fd, atcmd_output);
  7868. return 0;
  7869. }
  7870. ACMD_FUNC(resetskill)
  7871. {
  7872. nullpo_retr(-1,sd);
  7873. pc_resetskill(sd,1);
  7874. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7875. clif_displaymessage(fd, atcmd_output);
  7876. return 0;
  7877. }
  7878. /*==========================================
  7879. * #storagelist: Displays the items list of a player's storage.
  7880. * #cartlist: Displays contents of target's cart.
  7881. * #itemlist: Displays contents of target's inventory.
  7882. *------------------------------------------*/
  7883. ACMD_FUNC(itemlist)
  7884. {
  7885. int i, j, count, counter;
  7886. const char* location;
  7887. struct item* items;
  7888. int size;
  7889. StringBuf buf;
  7890. nullpo_retr(-1, sd);
  7891. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7892. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7893. location = "storage";
  7894. items = sd->storage.u.items_storage;
  7895. size = sd->storage.max_amount;
  7896. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7897. location = "cart";
  7898. items = sd->cart.u.items_cart;
  7899. size = MAX_CART;
  7900. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7901. location = "inventory";
  7902. items = sd->inventory.u.items_inventory;
  7903. size = MAX_INVENTORY;
  7904. } else
  7905. return 1;
  7906. StringBuf_Init(&buf);
  7907. count = 0; // total slots occupied
  7908. counter = 0; // total items found
  7909. for( i = 0; i < size; ++i ) {
  7910. struct item* it = &items[i];
  7911. if( it->nameid == 0 )
  7912. continue;
  7913. std::shared_ptr<item_data> itd = item_db.find(it->nameid);
  7914. if (itd == nullptr)
  7915. continue;
  7916. counter += it->amount;
  7917. count++;
  7918. if( count == 1 ) {
  7919. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7920. clif_displaymessage(fd, StringBuf_Value(&buf));
  7921. StringBuf_Clear(&buf);
  7922. }
  7923. StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, item_db.create_item_link( *it ).c_str(), itd->name.c_str(), it->nameid);
  7924. if( it->equip ) {
  7925. char equipstr[CHAT_SIZE_MAX];
  7926. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7927. if( it->equip&EQP_GARMENT )
  7928. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7929. if( it->equip&EQP_ACC_L )
  7930. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7931. if( it->equip&EQP_ARMOR )
  7932. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7933. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7934. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7935. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7936. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7937. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7938. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7939. if( it->equip&EQP_SHOES )
  7940. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7941. if( it->equip&EQP_ACC_R )
  7942. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7943. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7944. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7945. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7946. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7947. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7948. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7949. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7950. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7951. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7952. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7953. if( (it->equip&EQP_HELM) == EQP_HELM )
  7954. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7955. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7956. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7957. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7958. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7959. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7960. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7961. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7962. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7963. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7964. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7965. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7966. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7967. if( it->equip&EQP_COSTUME_GARMENT )
  7968. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7969. //if( it->equip&EQP_COSTUME_FLOOR )
  7970. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7971. if( it->equip&EQP_AMMO )
  7972. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7973. if( it->equip&EQP_SHADOW_ARMOR )
  7974. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7975. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7976. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7977. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7978. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7979. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7980. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7981. if( it->equip&EQP_SHADOW_SHOES )
  7982. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7983. if( it->equip&EQP_SHADOW_ACC_R )
  7984. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7985. if( it->equip&EQP_SHADOW_ACC_L )
  7986. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7987. // remove final ', '
  7988. equipstr[strlen(equipstr) - 2] = '\0';
  7989. StringBuf_AppendStr(&buf, equipstr);
  7990. }
  7991. clif_displaymessage(fd, StringBuf_Value(&buf));
  7992. StringBuf_Clear(&buf);
  7993. if( it->card[0] == CARD0_PET ) { // pet egg
  7994. if (it->card[3]&1)
  7995. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7996. else
  7997. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7998. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7999. StringBuf_Printf(&buf, msg_txt(sd,1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
  8000. } else if(it->card[0] == CARD0_CREATE) { // created item
  8001. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  8002. } else { // normal item
  8003. int counter2 = 0;
  8004. for( j = 0; j < itd->slots; ++j ) {
  8005. if( it->card[j] == 0 )
  8006. continue;
  8007. std::shared_ptr<item_data> card = item_db.find(it->card[j]);
  8008. if (card == nullptr)
  8009. continue;
  8010. counter2++;
  8011. if( counter2 == 1 )
  8012. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  8013. if( counter2 != 1 )
  8014. StringBuf_AppendStr(&buf, ", ");
  8015. StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, item_db.create_item_link( card ).c_str(), card->nameid);
  8016. }
  8017. if( counter2 > 0 )
  8018. StringBuf_AppendStr(&buf, ")");
  8019. }
  8020. if( StringBuf_Length(&buf) > 0 )
  8021. clif_displaymessage(fd, StringBuf_Value(&buf));
  8022. StringBuf_Clear(&buf);
  8023. }
  8024. if( count == 0 )
  8025. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  8026. else
  8027. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  8028. clif_displaymessage(fd, StringBuf_Value(&buf));
  8029. StringBuf_Destroy(&buf);
  8030. return 0;
  8031. }
  8032. ACMD_FUNC(stats)
  8033. {
  8034. char job_jobname[100];
  8035. char output[CHAT_SIZE_MAX];
  8036. int i;
  8037. struct {
  8038. const char* format;
  8039. int value;
  8040. } output_table[] = {
  8041. { "Base Level - %d", 0 },
  8042. { nullptr, 0 },
  8043. { "Hp - %d", 0 },
  8044. { "MaxHp - %d", 0 },
  8045. { "Sp - %d", 0 },
  8046. { "MaxSp - %d", 0 },
  8047. { "Ap - %d", 0 },
  8048. { "MaxAp - %d", 0 },
  8049. { "Str - %3d", 0 },
  8050. { "Agi - %3d", 0 },
  8051. { "Vit - %3d", 0 },
  8052. { "Int - %3d", 0 },
  8053. { "Dex - %3d", 0 },
  8054. { "Luk - %3d", 0 },
  8055. { "Pow - %3d", 0 },
  8056. { "Sta - %3d", 0 },
  8057. { "Wis - %3d", 0 },
  8058. { "Spl - %3d", 0 },
  8059. { "Con - %3d", 0 },
  8060. { "Crt - %3d", 0 },
  8061. { "Zeny - %d", 0 },
  8062. { "Free Status Points - %d", 0 },
  8063. { "Free Trait Points - %d", 0 },
  8064. { "Free Skill Points - %d", 0 },
  8065. { "JobChangeLvl (2nd) - %d", 0 },
  8066. { "JobChangeLvl (3rd) - %d", 0 },
  8067. { "JobChangeLvl (4th) - %d", 0 },
  8068. { nullptr, 0 }
  8069. };
  8070. memset(job_jobname, '\0', sizeof(job_jobname));
  8071. memset(output, '\0', sizeof(output));
  8072. //direct array initialization with variables is not standard C compliant.
  8073. output_table[0].value = sd->status.base_level;
  8074. output_table[1].format = job_jobname;
  8075. output_table[1].value = sd->status.job_level;
  8076. output_table[2].value = sd->status.hp;
  8077. output_table[3].value = sd->status.max_hp;
  8078. output_table[4].value = sd->status.sp;
  8079. output_table[5].value = sd->status.max_sp;
  8080. output_table[6].value = sd->status.ap;
  8081. output_table[7].value = sd->status.max_ap;
  8082. output_table[8].value = sd->status.str;
  8083. output_table[9].value = sd->status.agi;
  8084. output_table[10].value = sd->status.vit;
  8085. output_table[11].value = sd->status.int_;
  8086. output_table[12].value = sd->status.dex;
  8087. output_table[13].value = sd->status.luk;
  8088. output_table[14].value = sd->status.pow;
  8089. output_table[15].value = sd->status.sta;
  8090. output_table[16].value = sd->status.wis;
  8091. output_table[17].value = sd->status.spl;
  8092. output_table[18].value = sd->status.con;
  8093. output_table[19].value = sd->status.crt;
  8094. output_table[20].value = sd->status.zeny;
  8095. output_table[21].value = sd->status.status_point;
  8096. output_table[22].value = sd->status.trait_point;
  8097. output_table[23].value = sd->status.skill_point;
  8098. output_table[24].value = sd->change_level_2nd;
  8099. output_table[25].value = sd->change_level_3rd;
  8100. output_table[26].value = sd->change_level_4th;
  8101. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  8102. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  8103. clif_displaymessage(fd, output);
  8104. for (i = 0; output_table[i].format != nullptr; i++) {
  8105. sprintf(output, output_table[i].format, output_table[i].value);
  8106. clif_displaymessage(fd, output);
  8107. }
  8108. return 0;
  8109. }
  8110. ACMD_FUNC(delitem)
  8111. {
  8112. char item_name[100];
  8113. int amount = 0, idx;
  8114. nullpo_retr(-1, sd);
  8115. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  8116. {
  8117. 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>).
  8118. return -1;
  8119. }
  8120. std::shared_ptr<item_data> id = item_db.searchname( item_name );
  8121. if( id == nullptr ){
  8122. id = item_db.find( strtoul( item_name, nullptr, 10 ) );
  8123. }
  8124. if( id == nullptr ){
  8125. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  8126. return -1;
  8127. }
  8128. t_itemid nameid = id->nameid;
  8129. int total = amount;
  8130. // delete items
  8131. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  8132. {
  8133. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  8134. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  8135. {// delete pet
  8136. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  8137. }
  8138. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  8139. amount-= delamount;
  8140. }
  8141. // notify target
  8142. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  8143. clif_displaymessage(sd->fd, atcmd_output);
  8144. // notify source
  8145. if( amount == total )
  8146. {
  8147. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  8148. }
  8149. else if( amount )
  8150. {
  8151. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  8152. clif_displaymessage(fd, atcmd_output);
  8153. }
  8154. else
  8155. {
  8156. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  8157. clif_displaymessage(fd, atcmd_output);
  8158. }
  8159. return 0;
  8160. }
  8161. /*==========================================
  8162. * Custom Fonts
  8163. *------------------------------------------*/
  8164. ACMD_FUNC(font)
  8165. {
  8166. int font_id;
  8167. nullpo_retr(-1,sd);
  8168. font_id = atoi(message);
  8169. if( font_id == 0 ) {
  8170. if( sd->status.font ) {
  8171. sd->status.font = 0;
  8172. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  8173. clif_font(sd);
  8174. } else {
  8175. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  8176. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  8177. }
  8178. } else if( font_id < 0 || font_id > 9 )
  8179. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  8180. else if( font_id != sd->status.font ) {
  8181. sd->status.font = font_id;
  8182. clif_font(sd);
  8183. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  8184. } else
  8185. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  8186. return 0;
  8187. }
  8188. /*==========================================
  8189. * type: 1 = commands (@), 2 = charcommands (#)
  8190. *------------------------------------------*/
  8191. static void atcommand_commands_sub(map_session_data* sd, const int fd, AtCommandType type)
  8192. {
  8193. char line_buff[CHATBOX_SIZE];
  8194. char* cur = line_buff;
  8195. AtCommandInfo* cmd;
  8196. DBIterator *iter = db_iterator(atcommand_db);
  8197. int count = 0;
  8198. memset(line_buff,' ',CHATBOX_SIZE);
  8199. line_buff[CHATBOX_SIZE-1] = 0;
  8200. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  8201. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  8202. switch( type ) {
  8203. case COMMAND_CHARCOMMAND:
  8204. if( cmd->char_groups[sd->group->index] == 0 )
  8205. continue;
  8206. break;
  8207. case COMMAND_ATCOMMAND:
  8208. if( cmd->at_groups[sd->group->index] == 0 )
  8209. continue;
  8210. break;
  8211. default:
  8212. continue;
  8213. }
  8214. size_t slen = strlen( cmd->command );
  8215. // flush the text buffer if this command won't fit into it
  8216. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8217. clif_displaymessage(fd,line_buff);
  8218. cur = line_buff;
  8219. memset(line_buff,' ',CHATBOX_SIZE);
  8220. line_buff[CHATBOX_SIZE-1] = 0;
  8221. }
  8222. memcpy(cur,cmd->command,slen);
  8223. cur += slen+(10-slen%10);
  8224. count++;
  8225. }
  8226. dbi_destroy(iter);
  8227. clif_displaymessage(fd,line_buff);
  8228. if ( atcmd_binding_count ) {
  8229. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  8230. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  8231. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  8232. size_t slen = strlen( atcmd_binding[i]->command );
  8233. if ( count_bind == 0 ) {
  8234. cur = line_buff;
  8235. memset(line_buff,' ',CHATBOX_SIZE);
  8236. line_buff[CHATBOX_SIZE-1] = 0;
  8237. clif_displaymessage(fd, "-----------------");
  8238. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  8239. }
  8240. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8241. clif_displaymessage(fd,line_buff);
  8242. cur = line_buff;
  8243. memset(line_buff,' ',CHATBOX_SIZE);
  8244. line_buff[CHATBOX_SIZE-1] = 0;
  8245. }
  8246. memcpy(cur,atcmd_binding[i]->command,slen);
  8247. cur += slen+(10-slen%10);
  8248. count_bind++;
  8249. }
  8250. }
  8251. if ( count_bind )
  8252. clif_displaymessage(fd,line_buff);// last one
  8253. count += count_bind;
  8254. }
  8255. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  8256. clif_displaymessage(fd, atcmd_output);
  8257. return;
  8258. }
  8259. /*==========================================
  8260. * @commands Lists available @ commands to you
  8261. *------------------------------------------*/
  8262. ACMD_FUNC(commands)
  8263. {
  8264. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  8265. return 0;
  8266. }
  8267. /*==========================================
  8268. * @charcommands Lists available # commands to you
  8269. *------------------------------------------*/
  8270. ACMD_FUNC(charcommands) {
  8271. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  8272. return 0;
  8273. }
  8274. /* for new mounts */
  8275. ACMD_FUNC(mount2) {
  8276. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  8277. if (!sd->sc.getSCE(SC_ALL_RIDING)) {
  8278. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  8279. sc_start(nullptr, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  8280. } else {
  8281. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  8282. status_change_end(&sd->bl, SC_ALL_RIDING);
  8283. }
  8284. return 0;
  8285. }
  8286. ACMD_FUNC(accinfo) {
  8287. char query[NAME_LENGTH];
  8288. char type = 0; // type = 1, get only account name
  8289. if (!message || !*message || strlen(message) > NAME_LENGTH
  8290. || ( sscanf(message, "%23s %c", query, &type) < 1))
  8291. {
  8292. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  8293. 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".
  8294. return -1;
  8295. } else if (type != 0) {
  8296. type = type-'0'; //make it int
  8297. if (type != 1) {
  8298. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  8299. return -1;
  8300. }
  8301. }
  8302. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  8303. return 0;
  8304. }
  8305. /**
  8306. * @set <variable name{[index]}>{ <value>}
  8307. *
  8308. * Gets or sets a value of a non server variable.
  8309. * If a value is specified it is used to set the variable's value,
  8310. * if not the variable's value is read.
  8311. * In any case it reads and displays the variable's value.
  8312. *
  8313. * Original implementation by Ind
  8314. */
  8315. ACMD_FUNC(set) {
  8316. char reg[46], val[128], name[32];
  8317. int toset = 0;
  8318. size_t len;
  8319. uint32 index;
  8320. bool is_str = false;
  8321. int64 uid;
  8322. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  8323. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  8324. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  8325. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  8326. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  8327. return -1;
  8328. }
  8329. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  8330. if( reg[0] == '.' ) {
  8331. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  8332. return -1;
  8333. } else if( reg[0] == '\'' ) {
  8334. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  8335. return -1;
  8336. }
  8337. // Check if the user wanted to set an array
  8338. if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
  8339. // The user did not specify array brackets, so we set the index to zero
  8340. index = 0;
  8341. }
  8342. is_str = is_string_variable(name);
  8343. if( ( len = strlen(val) ) > 1 ) {
  8344. if( val[0] == '"' && val[len-1] == '"') {
  8345. val[len-1] = '\0'; //Strip quotes.
  8346. memmove(val, val+1, len-1);
  8347. }
  8348. }
  8349. // Only set the variable if there is a value for it
  8350. if( toset >= 2 ){
  8351. if( is_str ){
  8352. setd_sub_str( nullptr, sd, name, index, val, nullptr );
  8353. }else{
  8354. setd_sub_num( nullptr, sd, name, index, strtoll( val, nullptr, 10 ), nullptr );
  8355. }
  8356. }
  8357. uid = reference_uid( add_str( name ), index );
  8358. if( is_str ) {// string variable
  8359. char* value;
  8360. switch( reg[0] ) {
  8361. case '@':
  8362. value = pc_readregstr(sd, uid);
  8363. break;
  8364. case '$':
  8365. value = mapreg_readregstr(uid);
  8366. break;
  8367. case '#':
  8368. if( reg[1] == '#' )
  8369. value = pc_readaccountreg2str(sd, uid);// global
  8370. else
  8371. value = pc_readaccountregstr(sd, uid);// local
  8372. break;
  8373. default:
  8374. value = pc_readglobalreg_str(sd, uid);
  8375. break;
  8376. }
  8377. if( value == nullptr || *value == '\0' ){// empty string
  8378. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  8379. }else{
  8380. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
  8381. }
  8382. } else {// integer variable
  8383. int64 value;
  8384. switch( reg[0] ) {
  8385. case '@':
  8386. value = pc_readreg(sd, uid);
  8387. break;
  8388. case '$':
  8389. value = mapreg_readreg(uid);
  8390. break;
  8391. case '#':
  8392. if( reg[1] == '#' )
  8393. value = pc_readaccountreg2(sd, uid);// global
  8394. else
  8395. value = pc_readaccountreg(sd, uid);// local
  8396. break;
  8397. default:
  8398. value = pc_readglobalreg(sd, uid);
  8399. break;
  8400. }
  8401. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
  8402. }
  8403. clif_displaymessage(fd, atcmd_output);
  8404. return 0;
  8405. }
  8406. ACMD_FUNC(addperm) {
  8407. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  8408. bool add;
  8409. int i;
  8410. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  8411. add = (strcmpi(parent_cmd, "addperm") == 0);
  8412. if( !message || !*message ) {
  8413. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8414. clif_displaymessage(fd, atcmd_output);
  8415. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8416. for( i = 0; i < perm_size; i++ ) {
  8417. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8418. clif_displaymessage(fd, atcmd_output);
  8419. }
  8420. return -1;
  8421. }
  8422. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8423. if( i == perm_size ) {
  8424. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8425. clif_displaymessage(fd, atcmd_output);
  8426. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8427. for( i = 0; i < perm_size; i++ ) {
  8428. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8429. clif_displaymessage(fd, atcmd_output);
  8430. }
  8431. return -1;
  8432. }
  8433. if( add && pc_has_permission( sd, pc_g_permission_name[i].permission) ){
  8434. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8435. clif_displaymessage(fd, atcmd_output);
  8436. return -1;
  8437. }else if( !add && !pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8438. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8439. clif_displaymessage(fd, atcmd_output);
  8440. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8441. clif_displaymessage(fd, atcmd_output);
  8442. for( i = 0; i < perm_size; i++ ) {
  8443. if( pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8444. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8445. clif_displaymessage(fd, atcmd_output);
  8446. }
  8447. }
  8448. return -1;
  8449. }
  8450. if( add ){
  8451. sd->permissions.set( pc_g_permission_name[i].permission );
  8452. }else{
  8453. sd->permissions.reset( pc_g_permission_name[i].permission );
  8454. }
  8455. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8456. clif_displaymessage(fd, atcmd_output);
  8457. return 0;
  8458. }
  8459. ACMD_FUNC(unloadnpcfile) {
  8460. if( !message || !*message ) {
  8461. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8462. return -1;
  8463. }
  8464. if( npc_unloadfile(message) )
  8465. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8466. else {
  8467. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8468. return -1;
  8469. }
  8470. return 0;
  8471. }
  8472. ACMD_FUNC(cart) {
  8473. #define MC_CART_MDFY(idx, x) \
  8474. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8475. sd->status.skill[(idx)].lv = (x)?1:0; \
  8476. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8477. int val = atoi(message);
  8478. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8479. uint16 sk_idx = 0;
  8480. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8481. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8482. clif_displaymessage(fd, atcmd_output);
  8483. return -1;
  8484. }
  8485. if( val == 0 && !pc_iscarton(sd) ) {
  8486. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8487. return -1;
  8488. }
  8489. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8490. return -1;
  8491. if( need_skill ) {
  8492. MC_CART_MDFY(sk_idx,1);
  8493. }
  8494. if( !pc_setcart(sd, val) ) {
  8495. if( need_skill ) {
  8496. MC_CART_MDFY(sk_idx,0);
  8497. }
  8498. return -1;/* @cart failed */
  8499. }
  8500. if( need_skill ) {
  8501. MC_CART_MDFY(sk_idx,0);
  8502. }
  8503. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8504. return 0;
  8505. #undef MC_CART_MDFY
  8506. }
  8507. /* Channel System [Ind] */
  8508. ACMD_FUNC(join){
  8509. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8510. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8511. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8512. clif_displaymessage(fd, atcmd_output);
  8513. return -1;
  8514. }
  8515. return channel_pcjoin(sd, chname, pass);
  8516. }
  8517. /*
  8518. * Display available option for @channel command
  8519. * @command : the name of used command (for alias case)
  8520. */
  8521. static inline void atcmd_channel_help(map_session_data *sd, const char *command)
  8522. {
  8523. int fd = sd->fd;
  8524. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8525. bool can_create = (can_delete || channel_config.private_channel.allow);
  8526. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8527. //option create
  8528. if( can_create ) {
  8529. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8530. clif_displaymessage(fd, atcmd_output);
  8531. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8532. }
  8533. //option delete
  8534. if(can_delete){
  8535. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8536. clif_displaymessage(fd, atcmd_output);
  8537. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8538. }
  8539. //option list
  8540. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8541. clif_displaymessage(fd, atcmd_output);
  8542. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8543. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8544. clif_displaymessage(fd, atcmd_output);
  8545. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8546. if( can_create ) {
  8547. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8548. clif_displaymessage(fd, atcmd_output);
  8549. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8550. }
  8551. //option setcolor
  8552. if(can_create){
  8553. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8554. clif_displaymessage(fd, atcmd_output);
  8555. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8556. }
  8557. //option join
  8558. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8559. clif_displaymessage(fd, atcmd_output);
  8560. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8561. //option leave
  8562. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8563. clif_displaymessage(fd, atcmd_output);
  8564. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8565. //option bindto
  8566. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8567. clif_displaymessage(fd, atcmd_output);
  8568. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8569. //option unbind
  8570. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8571. clif_displaymessage(fd, atcmd_output);
  8572. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8573. //option ban/unban/banlist
  8574. if( can_create ) {
  8575. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8576. clif_displaymessage(fd, atcmd_output);
  8577. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8578. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8579. clif_displaymessage(fd, atcmd_output);
  8580. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8581. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8582. clif_displaymessage(fd, atcmd_output);
  8583. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8584. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8585. clif_displaymessage(fd, atcmd_output);
  8586. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8587. }
  8588. //option setopt
  8589. if(can_create){
  8590. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8591. clif_displaymessage(fd, atcmd_output);
  8592. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8593. }
  8594. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8595. clif_displaymessage(fd, atcmd_output);
  8596. }
  8597. ACMD_FUNC(channel) {
  8598. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8599. sub1[0] = sub2[0] = '\0';
  8600. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8601. atcmd_channel_help(sd,command);
  8602. return 0;
  8603. }
  8604. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8605. return channel_pcdelete(sd,sub1);
  8606. } else if ( strcmpi(key,"list") == 0 ) {
  8607. return channel_display_list(sd,sub1);
  8608. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8609. return channel_pccolor(sd, sub1, sub2);
  8610. } else if ( strcmpi(key,"join") == 0 ) {
  8611. return channel_pcjoin(sd, sub1, sub2);
  8612. }else if ( strcmpi(key,"leave") == 0 ) {
  8613. return channel_pcleave(sd, sub1);
  8614. } else if ( strcmpi(key,"bindto") == 0 ) {
  8615. return channel_pcbind(sd, sub1);
  8616. } else if ( strcmpi(key,"unbind") == 0 ) {
  8617. return channel_pcunbind(sd);
  8618. } else if ( strcmpi(key,"ban") == 0 ) {
  8619. return channel_pcban(sd,sub1,sub2,0);
  8620. } else if ( strcmpi(key,"kick") == 0 ) {
  8621. return channel_pckick(sd,sub1,sub2);
  8622. } else if ( strcmpi(key,"banlist") == 0 ) {
  8623. return channel_pcban(sd,sub1,nullptr,3);
  8624. } else if ( strcmpi(key,"unban") == 0 ) {
  8625. return channel_pcban(sd,sub1,sub2,1);
  8626. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8627. return channel_pcban(sd,sub1,nullptr,2);
  8628. } else {
  8629. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8630. sub3[0] = sub4[0] = '\0';
  8631. sscanf(sub2, "%19s %19s", sub3, sub4);
  8632. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8633. if (sub4[0] != '\0') {
  8634. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8635. return -1;
  8636. }
  8637. return channel_pccreate(sd,sub1,sub3);
  8638. } else if ( strcmpi(key,"setopt") == 0 ) {
  8639. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8640. }
  8641. atcmd_channel_help(sd,command);
  8642. }
  8643. return 0;
  8644. }
  8645. ACMD_FUNC(fontcolor)
  8646. {
  8647. if( !message || !*message ) {
  8648. channel_display_list(sd,"colors");
  8649. return -1;
  8650. }
  8651. if( strcmpi(message,"Normal") == 0 ) {
  8652. sd->fontcolor = 0;
  8653. } else {
  8654. unsigned char k;
  8655. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8656. if( k == channel_config.colors_count ) {
  8657. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8658. clif_displaymessage(fd, atcmd_output);
  8659. return -1;
  8660. }
  8661. sd->fontcolor = k;
  8662. }
  8663. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8664. clif_displaymessage(fd, atcmd_output);
  8665. return 0;
  8666. }
  8667. ACMD_FUNC(langtype)
  8668. {
  8669. char langstr[8];
  8670. int i=0, fail=0;
  8671. memset(langstr, '\0', sizeof(langstr));
  8672. if(sscanf(message, "%3s", langstr) >= 1){
  8673. int lang=0;
  8674. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8675. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8676. char output[100];
  8677. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8678. sd->langtype = lang;
  8679. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8680. clif_displaymessage(fd,output);
  8681. return 0;
  8682. } else if (lang != -1) { //defined langage but failed check
  8683. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8684. return -1;
  8685. }
  8686. }
  8687. //wrong or no entry
  8688. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8689. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8690. while(fail != -1){ //out of range
  8691. fail = msg_checklangtype(i,false);
  8692. if(fail == 1)
  8693. clif_displaymessage(fd,msg_langtype2langstr(i));
  8694. i++;
  8695. }
  8696. return -1;
  8697. }
  8698. #ifdef VIP_ENABLE
  8699. ACMD_FUNC(vip) {
  8700. map_session_data* pl_sd = nullptr;;
  8701. char * modif_p;
  8702. int32 vipdifftime = 0;
  8703. time_t now=time(nullptr);
  8704. nullpo_retr(-1, sd);
  8705. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8706. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8707. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8708. return -1;
  8709. }
  8710. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8711. modif_p = atcmd_output;
  8712. vipdifftime = (int32)solve_time(modif_p);
  8713. if (vipdifftime == 0) {
  8714. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8715. 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.
  8716. return -1;
  8717. }
  8718. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  8719. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8720. return -1;
  8721. }
  8722. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8723. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8724. return -1;
  8725. }
  8726. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8727. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8728. if (pl_sd->vip.time <= now) {
  8729. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8730. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8731. } else {
  8732. int year,month,day,hour,minute,second;
  8733. char timestr[21];
  8734. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8735. 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.
  8736. clif_displaymessage(pl_sd->fd,atcmd_output);
  8737. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8738. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8739. clif_displaymessage(pl_sd->fd,atcmd_output);
  8740. if (pl_sd != sd) {
  8741. 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.
  8742. clif_displaymessage(fd,atcmd_output);
  8743. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8744. clif_displaymessage(fd,atcmd_output);
  8745. }
  8746. }
  8747. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8748. return 0;
  8749. }
  8750. /** Enable/disable rate info */
  8751. ACMD_FUNC(showrate) {
  8752. nullpo_retr(-1,sd);
  8753. if (!sd->vip.disableshowrate) {
  8754. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8755. sd->vip.disableshowrate = 1;
  8756. } else {
  8757. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8758. sd->vip.disableshowrate = 0;
  8759. }
  8760. clif_displaymessage(fd,atcmd_output);
  8761. return 0;
  8762. }
  8763. #endif
  8764. ACMD_FUNC(fullstrip) {
  8765. int i;
  8766. TBL_PC *tsd;
  8767. nullpo_retr(-1,sd);
  8768. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8769. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8770. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8771. return -1;
  8772. }
  8773. if((tsd=map_nick2sd(atcmd_player_name,false)) == nullptr && (tsd=map_id2sd(atoi(atcmd_player_name))) == nullptr){
  8774. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8775. return -1;
  8776. }
  8777. for( i = 0; i < EQI_MAX; i++ ) {
  8778. if( tsd->equip_index[ i ] >= 0 )
  8779. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8780. }
  8781. return 0;
  8782. }
  8783. ACMD_FUNC(changedress){
  8784. sc_type name2id[] = {
  8785. SC_WEDDING,
  8786. SC_XMAS,
  8787. SC_SUMMER,
  8788. SC_DRESSUP,
  8789. SC_HANBOK,
  8790. SC_OKTOBERFEST
  8791. };
  8792. for( sc_type type : name2id ) {
  8793. if( sd->sc.getSCE(type) ) {
  8794. status_change_end( &sd->bl, type );
  8795. // You should only be able to have one - so we cancel here
  8796. break;
  8797. }
  8798. }
  8799. return 0;
  8800. }
  8801. ACMD_FUNC(costume) {
  8802. const char* names[] = {
  8803. "Wedding",
  8804. "Xmas",
  8805. "Summer",
  8806. "Summer2",
  8807. "Hanbok",
  8808. "Oktoberfest"
  8809. };
  8810. const int name2id[] = {
  8811. SC_WEDDING,
  8812. SC_XMAS,
  8813. SC_SUMMER,
  8814. SC_DRESSUP,
  8815. SC_HANBOK,
  8816. SC_OKTOBERFEST
  8817. };
  8818. unsigned short k = 0, len = ARRAYLENGTH(names);
  8819. if( !message || !*message ) {
  8820. for( k = 0; k < len; k++ ) {
  8821. if( sd->sc.getSCE(name2id[k]) ) {
  8822. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8823. clif_displaymessage(sd->fd, atcmd_output);
  8824. status_change_end(&sd->bl, (sc_type)name2id[k]);
  8825. return 0;
  8826. }
  8827. }
  8828. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8829. for( k = 0; k < len; k++ ) {
  8830. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8831. clif_displaymessage(sd->fd, atcmd_output);
  8832. }
  8833. return -1;
  8834. }
  8835. for( k = 0; k < len; k++ ) {
  8836. if( sd->sc.getSCE(name2id[k]) ) {
  8837. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8838. clif_displaymessage(sd->fd, atcmd_output);
  8839. return -1;
  8840. }
  8841. }
  8842. for( k = 0; k < len; k++ )
  8843. if( strcmpi(message, names[k]) == 0 )
  8844. break;
  8845. if( k == len ) {
  8846. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8847. clif_displaymessage(sd->fd, atcmd_output);
  8848. return -1;
  8849. }
  8850. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  8851. return 0;
  8852. }
  8853. /**
  8854. * Clone other player's equipments
  8855. * Usage: @cloneequip <char name/ID>
  8856. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8857. * @author [Cydh], [Antares]
  8858. */
  8859. ACMD_FUNC(cloneequip) {
  8860. map_session_data *pl_sd;
  8861. nullpo_retr(-1, sd);
  8862. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8863. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8864. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8865. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8866. clif_displaymessage(fd, atcmd_output);
  8867. return -1;
  8868. }
  8869. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8870. clif_displaymessage(fd, msg_txt(sd, 3));
  8871. return -1;
  8872. }
  8873. if (sd == pl_sd) {
  8874. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8875. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8876. clif_displaymessage(fd, atcmd_output);
  8877. return -1;
  8878. }
  8879. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8881. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8882. clif_displaymessage(fd, atcmd_output);
  8883. return -1;
  8884. }
  8885. else {
  8886. int8 i;
  8887. for (i = 0; i < EQI_MAX; i++) {
  8888. short idx;
  8889. char flag = 0;
  8890. struct item tmp_item;
  8891. if ((idx = pl_sd->equip_index[i]) < 0)
  8892. continue;
  8893. if (i == EQI_AMMO)
  8894. continue;
  8895. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8896. continue;
  8897. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8898. if (itemdb_isspecial(tmp_item.card[0]))
  8899. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8900. tmp_item.bound = 0;
  8901. tmp_item.expire_time = 0;
  8902. tmp_item.unique_id = 0;
  8903. tmp_item.favorite = 0;
  8904. tmp_item.amount = 1;
  8905. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8906. clif_additem(sd, 0, 0, flag);
  8907. else
  8908. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8909. }
  8910. }
  8911. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8912. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8913. clif_displaymessage(fd, atcmd_output);
  8914. return 0;
  8915. }
  8916. /**
  8917. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8918. * Usage: @clonestat <char name/ID>
  8919. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8920. * @author [Cydh], [Antares]
  8921. */
  8922. ACMD_FUNC(clonestat) {
  8923. map_session_data *pl_sd;
  8924. nullpo_retr(-1, sd);
  8925. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8926. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8927. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8928. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8929. clif_displaymessage(fd, atcmd_output);
  8930. return -1;
  8931. }
  8932. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8933. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8934. return -1;
  8935. }
  8936. if (sd == pl_sd) {
  8937. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8938. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8939. clif_displaymessage(fd, atcmd_output);
  8940. return -1;
  8941. }
  8942. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8943. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8944. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8945. clif_displaymessage(fd, atcmd_output);
  8946. return -1;
  8947. }
  8948. else {
  8949. uint8 i;
  8950. short max_status[PARAM_MAX] = {};
  8951. pc_resetstate(sd);
  8952. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE)) {
  8953. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  8954. if (i >= PARAM_POW && !(sd->class_ & JOBL_FOURTH))
  8955. continue;
  8956. max_status[i] = SHRT_MAX;
  8957. }
  8958. } else {
  8959. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  8960. if (i >= PARAM_POW && sd->class_ & JOBL_FOURTH)
  8961. continue;
  8962. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  8963. }
  8964. }
  8965. #define clonestat_check(cmd,stat)\
  8966. {\
  8967. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8968. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8969. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8970. clif_displaymessage(fd, atcmd_output);\
  8971. sd->status.cmd = max_status[(stat)];\
  8972. }\
  8973. else\
  8974. sd->status.cmd = pl_sd->status.cmd;\
  8975. }
  8976. clonestat_check(str, PARAM_STR);
  8977. clonestat_check(agi, PARAM_AGI);
  8978. clonestat_check(vit, PARAM_VIT);
  8979. clonestat_check(int_, PARAM_INT);
  8980. clonestat_check(dex, PARAM_DEX);
  8981. clonestat_check(luk, PARAM_LUK);
  8982. for (i = PARAM_STR; i < PARAM_POW; i++) {
  8983. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  8984. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  8985. }
  8986. if (sd->class_ & JOBL_FOURTH) {
  8987. clonestat_check(pow, PARAM_POW);
  8988. clonestat_check(sta, PARAM_STA);
  8989. clonestat_check(wis, PARAM_WIS);
  8990. clonestat_check(spl, PARAM_SPL);
  8991. clonestat_check(con, PARAM_CON);
  8992. clonestat_check(crt, PARAM_CRT);
  8993. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  8994. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  8995. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  8996. }
  8997. }
  8998. status_calc_pc(sd, SCO_FORCE);
  8999. }
  9000. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9001. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  9002. clif_displaymessage(fd, atcmd_output);
  9003. #undef clonestat_check
  9004. return 0;
  9005. }
  9006. /**
  9007. * Adopt a character.
  9008. * Usage: @adopt <char name>
  9009. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  9010. */
  9011. ACMD_FUNC(adopt)
  9012. {
  9013. TBL_PC *b_sd;
  9014. enum adopt_responses response;
  9015. nullpo_retr(-1, sd);
  9016. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9017. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  9018. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  9019. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  9020. clif_displaymessage(fd, atcmd_output);
  9021. return -1;
  9022. }
  9023. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  9024. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  9025. return -1;
  9026. }
  9027. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  9028. if (response == ADOPT_ALLOWED) {
  9029. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  9030. b_sd->adopt_invite = sd->status.account_id;
  9031. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  9032. return 0;
  9033. }
  9034. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  9035. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  9036. return -1;
  9037. }
  9038. /**
  9039. * Opens the limited sale window.
  9040. * Usage: @limitedsale or client command /limitedsale on supported clients
  9041. */
  9042. ACMD_FUNC(limitedsale){
  9043. nullpo_retr(-1, sd);
  9044. clif_sale_open(sd);
  9045. return 0;
  9046. }
  9047. /**
  9048. * Displays camera information from the client.
  9049. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  9050. */
  9051. ACMD_FUNC(camerainfo){
  9052. nullpo_retr(-1, sd);
  9053. if( message == nullptr || message[0] == '\0' ){
  9054. clif_camerainfo( sd, true );
  9055. return 0;
  9056. }
  9057. float range = 0;
  9058. float rotation = 0;
  9059. float latitude = 0;
  9060. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  9061. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  9062. return -1;
  9063. }
  9064. clif_camerainfo( sd, false, range, rotation, latitude );
  9065. return 0;
  9066. }
  9067. ACMD_FUNC(resurrect) {
  9068. nullpo_retr(-1, sd);
  9069. if (!pc_revive_item(sd))
  9070. return -1;
  9071. return 0;
  9072. }
  9073. ACMD_FUNC(quest) {
  9074. uint8 i;
  9075. int quest_id = 0;
  9076. nullpo_retr(-1, sd);
  9077. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9078. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9079. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9080. clif_displaymessage(fd, atcmd_output);
  9081. return -1;
  9082. }
  9083. if (!quest_search(quest_id)) {
  9084. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9085. clif_displaymessage(fd, atcmd_output);
  9086. return -1;
  9087. }
  9088. const char* type[] = { "setquest", "erasequest", "completequest", "checkquest" };
  9089. ARR_FIND( 0, ARRAYLENGTH(type), i, strcmpi(command+1, type[i]) == 0 );
  9090. switch(i) {
  9091. case 0:
  9092. if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
  9093. sprintf(atcmd_output, msg_txt(sd,1507), quest_id); // Character already has quest %d.
  9094. clif_displaymessage(fd, atcmd_output);
  9095. return -1;
  9096. }
  9097. quest_add(sd, quest_id);
  9098. pc_show_questinfo(sd);
  9099. break;
  9100. case 1:
  9101. if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
  9102. sprintf(atcmd_output, msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
  9103. clif_displaymessage(fd, atcmd_output);
  9104. return -1;
  9105. }
  9106. quest_delete(sd, quest_id);
  9107. pc_show_questinfo(sd);
  9108. break;
  9109. case 2:
  9110. if (quest_check(sd, quest_id, HAVEQUEST) < 0)
  9111. quest_add(sd, quest_id);
  9112. if (quest_check(sd, quest_id, HAVEQUEST) < 2)
  9113. quest_update_status(sd, quest_id, Q_COMPLETE);
  9114. pc_show_questinfo(sd);
  9115. break;
  9116. case 3:
  9117. sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
  9118. clif_displaymessage(fd, atcmd_output);
  9119. sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST)); // HAVEQUEST : %d
  9120. clif_displaymessage(fd, atcmd_output);
  9121. sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING)); // HUNTING : %d
  9122. clif_displaymessage(fd, atcmd_output);
  9123. sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME)); // PLAYTIME : %d
  9124. clif_displaymessage(fd, atcmd_output);
  9125. break;
  9126. }
  9127. return 0;
  9128. }
  9129. /**
  9130. * Opens the refineUI
  9131. * Usage: @refineui
  9132. */
  9133. ACMD_FUNC(refineui)
  9134. {
  9135. nullpo_retr(-1, sd);
  9136. #if PACKETVER < 20161012
  9137. clif_displaymessage(fd, msg_txt(sd, 773)); // This command requires packet version 2016-10-12 or newer.
  9138. return -1;
  9139. #else
  9140. if( !battle_config.feature_refineui ){
  9141. clif_displaymessage(fd, msg_txt(sd, 774)); // This command is disabled via configuration.
  9142. return -1;
  9143. }
  9144. if( sd->state.refineui_open ){
  9145. clif_displaymessage(fd, msg_txt(sd, 775)); // You have already opened the refine UI.
  9146. return -1;
  9147. }
  9148. clif_refineui_open(sd);
  9149. return 0;
  9150. #endif
  9151. }
  9152. ACMD_FUNC( stylist ){
  9153. nullpo_retr(-1, sd);
  9154. #if PACKETVER < 20151104
  9155. clif_displaymessage( fd, msg_txt( sd, 798 ) ); // This command requires packet version 2015-11-04 or newer.
  9156. return -1;
  9157. #else
  9158. if( !battle_config.feature_stylist ){
  9159. clif_displaymessage( fd, msg_txt( sd, 774 ) ); // This command is disabled via configuration.
  9160. return -1;
  9161. }
  9162. if( sd->state.stylist_open ){
  9163. clif_displaymessage( fd, msg_txt( sd, 799 ) ); // You have already opened the stylist UI.
  9164. return -1;
  9165. }
  9166. clif_ui_open( *sd, OUT_UI_STYLIST, 0 );
  9167. return 0;
  9168. #endif
  9169. }
  9170. /**
  9171. * Add fame point(s) to a player
  9172. * Usage: @addfame <amount>
  9173. */
  9174. ACMD_FUNC(addfame)
  9175. {
  9176. nullpo_retr(-1, sd);
  9177. int famepoint = 0;
  9178. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9179. if (!message || !*message || sscanf(message, "%11d", &famepoint) < 1 || famepoint == 0) {
  9180. sprintf(atcmd_output, msg_txt(sd, 1516), command); // Usage: %s <fame points>.
  9181. clif_displaymessage(fd, atcmd_output);
  9182. return -1;
  9183. }
  9184. if (!pc_addfame(*sd, famepoint)) {
  9185. sprintf(atcmd_output, msg_txt(sd, 1517), job_name(sd->status.class_)); // Cannot add fame to class '%s'.
  9186. clif_displaymessage(fd, atcmd_output);
  9187. return -1;
  9188. }
  9189. sprintf(atcmd_output, msg_txt(sd, 1518), famepoint, sd->status.name); // %d points were added to '%s'.
  9190. clif_displaymessage(fd, atcmd_output);
  9191. return 0;
  9192. }
  9193. /**
  9194. * Opens the enchantgrade UI
  9195. * Usage: @enchantgradeui
  9196. */
  9197. ACMD_FUNC( enchantgradeui ){
  9198. nullpo_retr( -1, sd );
  9199. #if !( PACKETVER_MAIN_NUM >= 20200916 || PACKETVER_RE_NUM >= 20200724 )
  9200. sprintf( atcmd_output, msg_txt( sd, 798 ), "2020-07-24" ); // This command requires packet version %s or newer.
  9201. clif_displaymessage( fd, atcmd_output );
  9202. return -1;
  9203. #else
  9204. clif_ui_open( *sd, OUT_UI_ENCHANTGRADE, 0 );
  9205. return 0;
  9206. #endif
  9207. }
  9208. ACMD_FUNC( roulette ){
  9209. nullpo_retr( -1, sd );
  9210. #if PACKETVER < 20141022
  9211. sprintf( atcmd_output, msg_txt( sd, 798 ), "2014-10-22" ); // This command requires packet version %s or newer.
  9212. clif_displaymessage( fd, atcmd_output );
  9213. return -1;
  9214. #else
  9215. if( !battle_config.feature_roulette ){
  9216. clif_displaymessage( fd, msg_txt( sd, 1497 ) ); // Roulette is disabled
  9217. return -1;
  9218. }
  9219. clif_roulette_open( sd );
  9220. return 0;
  9221. #endif
  9222. }
  9223. /**
  9224. * Replaces a card ID in an equip
  9225. * Usage: @setcard <equip position> <slot> <card_id>
  9226. */
  9227. ACMD_FUNC(setcard)
  9228. {
  9229. nullpo_retr(-1, sd);
  9230. int position = 0, slot, card_id;
  9231. if (!message || !*message || sscanf(message, "%11d %11d %11d", &position, &slot, &card_id) < 3) {
  9232. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9233. 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>).
  9234. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  9235. clif_displaymessage(fd, atcmd_output);
  9236. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  9237. clif_displaymessage(fd, atcmd_output);
  9238. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  9239. clif_displaymessage(fd, atcmd_output);
  9240. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  9241. clif_displaymessage(fd, atcmd_output);
  9242. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  9243. clif_displaymessage(fd, atcmd_output);
  9244. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  9245. clif_displaymessage(fd, atcmd_output);
  9246. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  9247. clif_displaymessage(fd, atcmd_output);
  9248. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  9249. clif_displaymessage(fd, atcmd_output);
  9250. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  9251. clif_displaymessage(fd, atcmd_output);
  9252. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  9253. return -1;
  9254. }
  9255. if (position < EQP_HEAD_LOW || position > EQP_HEAD_MID) {
  9256. clif_displaymessage(fd, msg_txt(sd,1531)); // Invalid position.
  9257. return -1;
  9258. }
  9259. if (slot < 0 || slot >= MAX_SLOTS) {
  9260. clif_displaymessage(fd, msg_txt(sd,1532)); // Invalid slot number.
  9261. return -1;
  9262. }
  9263. if (card_id != 0) {
  9264. std::shared_ptr<item_data> item_data = item_db.find( card_id );
  9265. if (item_data == nullptr) {
  9266. clif_displaymessage(fd, msg_txt(sd,1530)); // Invalid card ID.
  9267. return -1;
  9268. }
  9269. if (item_data->type != IT_CARD) {
  9270. clif_displaymessage(fd, msg_txt(sd,1529)); // The item type must be a card or enchant.
  9271. return -1;
  9272. }
  9273. }
  9274. int16 i = pc_checkequip(sd, position);
  9275. if (i < 0) {
  9276. clif_displaymessage(fd, msg_txt(sd,1528)); // You are not wearing any equipment in this position.
  9277. return -1;
  9278. }
  9279. int current_position = sd->inventory.u.items_inventory[i].equip;
  9280. pc_unequipitem(sd, i, 3);
  9281. log_pick_pc( sd, LOG_TYPE_COMMAND, -1, &sd->inventory.u.items_inventory[i] );
  9282. sd->inventory.u.items_inventory[i].card[slot] = card_id;
  9283. log_pick_pc( sd, LOG_TYPE_COMMAND, 1, &sd->inventory.u.items_inventory[i] );
  9284. clif_delitem( *sd, i, 1, 0 );
  9285. clif_additem(sd, i, 1, 0);
  9286. pc_equipitem(sd, i, current_position);
  9287. return 0;
  9288. }
  9289. #include <custom/atcommand.inc>
  9290. /**
  9291. * Fills the reference of available commands in atcommand DBMap
  9292. **/
  9293. #define ACMD_DEF(x) { #x, atcommand_ ## x, nullptr, nullptr, 0 }
  9294. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, nullptr, nullptr, 0 }
  9295. // Define with restriction
  9296. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, nullptr, nullptr, r }
  9297. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, nullptr, nullptr, r }
  9298. void atcommand_basecommands(void) {
  9299. /**
  9300. * Command reference list, place the base of your commands here
  9301. * TODO: List all commands that causing crash
  9302. **/
  9303. AtCommandInfo atcommand_base[] = {
  9304. #include <custom/atcommand_def.inc>
  9305. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  9306. ACMD_DEF(where),
  9307. ACMD_DEF(jumpto),
  9308. ACMD_DEF(jump),
  9309. ACMD_DEF(who),
  9310. ACMD_DEF2("who2", who),
  9311. ACMD_DEF2("who3", who),
  9312. ACMD_DEF2("whomap", who),
  9313. ACMD_DEF2("whomap2", who),
  9314. ACMD_DEF2("whomap3", who),
  9315. ACMD_DEF(whogm),
  9316. ACMD_DEF(save),
  9317. ACMD_DEF(load),
  9318. ACMD_DEF(speed),
  9319. ACMD_DEF(storage),
  9320. ACMD_DEF(guildstorage),
  9321. ACMD_DEF(option),
  9322. ACMD_DEF(hide), // + /hide
  9323. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  9324. ACMD_DEF(kill),
  9325. ACMD_DEF(alive),
  9326. ACMD_DEF(kami),
  9327. ACMD_DEF2("kamib", kami),
  9328. ACMD_DEF2("kamic", kami),
  9329. ACMD_DEF2("lkami", kami),
  9330. ACMD_DEF(heal),
  9331. ACMD_DEF(healap),
  9332. ACMD_DEF(item),
  9333. ACMD_DEF(item2),
  9334. ACMD_DEF2("itembound",item),
  9335. ACMD_DEF2("itembound2",item2),
  9336. ACMD_DEF(itemreset),
  9337. ACMD_DEF(clearstorage),
  9338. ACMD_DEF(cleargstorage),
  9339. ACMD_DEF(clearcart),
  9340. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  9341. ACMD_DEF2("jlvl", joblevelup),
  9342. ACMD_DEF(help),
  9343. ACMD_DEF(pvpoff),
  9344. ACMD_DEF(pvpon),
  9345. ACMD_DEF(gvgoff),
  9346. ACMD_DEF(gvgon),
  9347. ACMD_DEF(model),
  9348. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  9349. ACMD_DEF(monster),
  9350. ACMD_DEF2("monstersmall", monster),
  9351. ACMD_DEF2("monsterbig", monster),
  9352. ACMD_DEF(killmonster),
  9353. ACMD_DEF2("killmonster2", killmonster),
  9354. ACMD_DEF(refine),
  9355. ACMD_DEF(grade),
  9356. ACMD_DEF(produce),
  9357. ACMD_DEF(memo),
  9358. ACMD_DEF(gat),
  9359. ACMD_DEF(displaystatus),
  9360. ACMD_DEF2("stpoint", statuspoint),
  9361. ACMD_DEF2("trpoint", traitpoint),
  9362. ACMD_DEF2("skpoint", skillpoint),
  9363. ACMD_DEF(zeny),
  9364. ACMD_DEF2("str", param),
  9365. ACMD_DEF2("agi", param),
  9366. ACMD_DEF2("vit", param),
  9367. ACMD_DEF2("int", param),
  9368. ACMD_DEF2("dex", param),
  9369. ACMD_DEF2("luk", param),
  9370. ACMD_DEF2("pow", param),
  9371. ACMD_DEF2("sta", param),
  9372. ACMD_DEF2("wis", param),
  9373. ACMD_DEF2("spl", param),
  9374. ACMD_DEF2("con", param),
  9375. ACMD_DEF2("crt", param),
  9376. ACMD_DEF2("glvl", guildlevelup),
  9377. ACMD_DEF(makeegg),
  9378. ACMD_DEF(hatch),
  9379. ACMD_DEF(petfriendly),
  9380. ACMD_DEF(pethungry),
  9381. ACMD_DEF(petrename),
  9382. ACMD_DEF(recall), // + /recall
  9383. ACMD_DEF(night),
  9384. ACMD_DEF(day),
  9385. ACMD_DEF(doom),
  9386. ACMD_DEF(doommap),
  9387. ACMD_DEF(raise),
  9388. ACMD_DEF(raisemap),
  9389. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  9390. ACMD_DEF(kickall),
  9391. ACMD_DEF(allskill),
  9392. ACMD_DEF(questskill),
  9393. ACMD_DEF(lostskill),
  9394. ACMD_DEF(spiritball),
  9395. ACMD_DEF(soulball),
  9396. ACMD_DEF(party),
  9397. ACMD_DEF(guild),
  9398. ACMD_DEF(breakguild),
  9399. ACMD_DEF(agitstart),
  9400. ACMD_DEF(agitend),
  9401. ACMD_DEF(mapexit),
  9402. ACMD_DEF(idsearch),
  9403. ACMD_DEF(broadcast), // + /b and /nb
  9404. ACMD_DEF(localbroadcast), // + /lb and /nlb
  9405. ACMD_DEF(recallall),
  9406. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  9407. ACMD_DEF2("reloaditemdb", reload),
  9408. ACMD_DEF2("reloadcashdb", reload),
  9409. ACMD_DEF2("reloadmobdb", reload),
  9410. ACMD_DEF2("reloadskilldb", reload),
  9411. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  9412. ACMD_DEF2("reloadatcommand", reload),
  9413. ACMD_DEF2("reloadbattleconf", reload),
  9414. ACMD_DEF2("reloadstatusdb", reload),
  9415. ACMD_DEF2("reloadpcdb", reload),
  9416. ACMD_DEF2("reloadmotd", reload),
  9417. ACMD_DEF2("reloadquestdb", reload),
  9418. ACMD_DEF2("reloadmsgconf", reload),
  9419. ACMD_DEF2("reloadinstancedb", reload),
  9420. ACMD_DEF2("reloadachievementdb",reload),
  9421. ACMD_DEF2("reloadattendancedb",reload),
  9422. ACMD_DEF2("reloadbarterdb",reload),
  9423. ACMD_DEF(partysharelvl),
  9424. ACMD_DEF(mapinfo),
  9425. ACMD_DEF(dye),
  9426. ACMD_DEF2("hairstyle", hair_style),
  9427. ACMD_DEF2("haircolor", hair_color),
  9428. ACMD_DEF2("allstats", stat_all),
  9429. ACMD_DEF2("alltraits", trait_all),
  9430. ACMD_DEF2("block", char_block),
  9431. ACMD_DEF2("ban", char_ban),
  9432. ACMD_DEF2("unblock", char_unblock),
  9433. ACMD_DEF2("unban", char_unban),
  9434. ACMD_DEF2("charban", char_ban),
  9435. ACMD_DEF2("charunban", char_unban),
  9436. ACMD_DEF2("mount", mount_peco),
  9437. ACMD_DEF(guildspy),
  9438. ACMD_DEF(partyspy),
  9439. ACMD_DEF(clanspy),
  9440. ACMD_DEF(repairall),
  9441. ACMD_DEF(guildrecall),
  9442. ACMD_DEF(partyrecall),
  9443. ACMD_DEF(nuke),
  9444. ACMD_DEF(shownpc),
  9445. ACMD_DEF(hidenpc),
  9446. ACMD_DEF(loadnpc),
  9447. ACMD_DEF(unloadnpc),
  9448. ACMD_DEF(reloadnpcfile),
  9449. ACMD_DEF2("time", servertime),
  9450. ACMD_DEF(jail),
  9451. ACMD_DEF(unjail),
  9452. ACMD_DEF(jailfor),
  9453. ACMD_DEF(jailtime),
  9454. ACMD_DEF(disguise),
  9455. ACMD_DEF(undisguise),
  9456. ACMD_DEF(email),
  9457. ACMD_DEF(effect),
  9458. ACMD_DEF(follow),
  9459. ACMD_DEF(addwarp),
  9460. ACMD_DEF(skillon),
  9461. ACMD_DEF(skilloff),
  9462. ACMD_DEF(killer),
  9463. ACMD_DEF(npcmove),
  9464. ACMD_DEF(killable),
  9465. ACMD_DEF(dropall),
  9466. ACMD_DEF(stockall),
  9467. ACMD_DEF(storeall),
  9468. ACMD_DEF(skillid),
  9469. ACMD_DEF(useskill),
  9470. ACMD_DEF(displayskill),
  9471. ACMD_DEF(displayskillcast),
  9472. ACMD_DEF(displayskillunit),
  9473. ACMD_DEF(snow),
  9474. ACMD_DEF(sakura),
  9475. ACMD_DEF(clouds),
  9476. ACMD_DEF(clouds2),
  9477. ACMD_DEF(fog),
  9478. ACMD_DEF(fireworks),
  9479. ACMD_DEF(leaves),
  9480. ACMD_DEF(summon),
  9481. ACMD_DEF(adjgroup),
  9482. ACMD_DEF(trade),
  9483. ACMD_DEF(send),
  9484. ACMD_DEF(setbattleflag),
  9485. ACMD_DEF(unmute),
  9486. ACMD_DEF(clearweather),
  9487. ACMD_DEF(uptime),
  9488. ACMD_DEF(changesex),
  9489. ACMD_DEF(changecharsex),
  9490. ACMD_DEF(mute),
  9491. ACMD_DEF(refresh),
  9492. ACMD_DEF(refreshall),
  9493. ACMD_DEF(identify),
  9494. ACMD_DEF(identifyall),
  9495. ACMD_DEF(gmotd),
  9496. ACMD_DEF(misceffect),
  9497. ACMD_DEF(mobsearch),
  9498. ACMD_DEF(cleanmap),
  9499. ACMD_DEF(cleanarea),
  9500. ACMD_DEF(npctalk),
  9501. ACMD_DEF(pettalk),
  9502. ACMD_DEF(users),
  9503. ACMD_DEF(reset),
  9504. ACMD_DEF(skilltree),
  9505. ACMD_DEF(marry),
  9506. ACMD_DEF(divorce),
  9507. ACMD_DEF(sound),
  9508. ACMD_DEF(undisguiseall),
  9509. ACMD_DEF(disguiseall),
  9510. ACMD_DEF(changelook),
  9511. ACMD_DEF(autoloot),
  9512. ACMD_DEF2("alootid", autolootitem),
  9513. ACMD_DEF(autoloottype),
  9514. ACMD_DEF(mobinfo),
  9515. ACMD_DEF(exp),
  9516. ACMD_DEF(version),
  9517. ACMD_DEF(mutearea),
  9518. ACMD_DEF(rates),
  9519. ACMD_DEF(iteminfo),
  9520. ACMD_DEF(whodrops),
  9521. ACMD_DEF(whereis),
  9522. ACMD_DEF(mapflag),
  9523. ACMD_DEF(me),
  9524. ACMD_DEF(monsterignore),
  9525. ACMD_DEF(fakename),
  9526. ACMD_DEF(size),
  9527. ACMD_DEF(showexp),
  9528. ACMD_DEF(showzeny),
  9529. ACMD_DEF(showdelay),
  9530. ACMD_DEF(autotrade),
  9531. ACMD_DEF(changegm),
  9532. ACMD_DEF(changeleader),
  9533. ACMD_DEF(partyoption),
  9534. ACMD_DEF(invite),
  9535. ACMD_DEF(duel),
  9536. ACMD_DEF(leave),
  9537. ACMD_DEF(accept),
  9538. ACMD_DEF(reject),
  9539. ACMD_DEF(clone),
  9540. ACMD_DEF2("slaveclone", clone),
  9541. ACMD_DEF2("evilclone", clone),
  9542. ACMD_DEF(tonpc),
  9543. ACMD_DEF(commands),
  9544. ACMD_DEF(noask),
  9545. ACMD_DEF(request),
  9546. ACMD_DEF(homlevel),
  9547. ACMD_DEF(homevolution),
  9548. ACMD_DEF(hommutate),
  9549. ACMD_DEF(makehomun),
  9550. ACMD_DEF(homfriendly),
  9551. ACMD_DEF(homhungry),
  9552. ACMD_DEF(homtalk),
  9553. ACMD_DEF(hominfo),
  9554. ACMD_DEF(homstats),
  9555. ACMD_DEF(homshuffle),
  9556. ACMD_DEF(showmobs),
  9557. ACMD_DEF(feelreset),
  9558. ACMD_DEF(hatereset),
  9559. ACMD_DEF(auction),
  9560. ACMD_DEF(mail),
  9561. ACMD_DEF2("noks", ksprotection),
  9562. ACMD_DEF(allowks),
  9563. ACMD_DEF(cash),
  9564. ACMD_DEF2("points", cash),
  9565. ACMD_DEF(agitstart2),
  9566. ACMD_DEF(agitend2),
  9567. ACMD_DEF(resetskill),
  9568. ACMD_DEF(resetstat),
  9569. ACMD_DEF2("storagelist", itemlist),
  9570. ACMD_DEF2("cartlist", itemlist),
  9571. ACMD_DEF2("itemlist", itemlist),
  9572. ACMD_DEF(stats),
  9573. ACMD_DEF(delitem),
  9574. ACMD_DEF(charcommands),
  9575. ACMD_DEF(font),
  9576. ACMD_DEF(accinfo),
  9577. ACMD_DEF(set),
  9578. ACMD_DEF(undisguiseguild),
  9579. ACMD_DEF(disguiseguild),
  9580. ACMD_DEF(sizeall),
  9581. ACMD_DEF(sizeguild),
  9582. ACMD_DEF(addperm),
  9583. ACMD_DEF2("rmvperm", addperm),
  9584. ACMD_DEF(unloadnpcfile),
  9585. ACMD_DEF(cart),
  9586. ACMD_DEF(mount2),
  9587. ACMD_DEF(join),
  9588. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  9589. ACMD_DEF(fontcolor),
  9590. ACMD_DEF(langtype),
  9591. #ifdef VIP_ENABLE
  9592. ACMD_DEF(vip),
  9593. ACMD_DEF(showrate),
  9594. #endif
  9595. ACMD_DEF(fullstrip),
  9596. ACMD_DEF(costume),
  9597. ACMD_DEF(cloneequip),
  9598. ACMD_DEF(clonestat),
  9599. ACMD_DEF(bodystyle),
  9600. ACMD_DEF(adopt),
  9601. ACMD_DEF(agitstart3),
  9602. ACMD_DEF(agitend3),
  9603. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9604. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9605. ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9606. ACMD_DEFR(resurrect, ATCMD_NOCONSOLE),
  9607. ACMD_DEF2("setquest", quest),
  9608. ACMD_DEF2("erasequest", quest),
  9609. ACMD_DEF2("completequest", quest),
  9610. ACMD_DEF2("checkquest", quest),
  9611. ACMD_DEF(refineui),
  9612. ACMD_DEFR(stylist, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9613. ACMD_DEF(addfame),
  9614. ACMD_DEFR(enchantgradeui, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9615. ACMD_DEFR(roulette, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9616. ACMD_DEF(setcard),
  9617. };
  9618. AtCommandInfo* atcommand;
  9619. int i;
  9620. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9621. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9622. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9623. continue;
  9624. }
  9625. CREATE(atcommand, AtCommandInfo, 1);
  9626. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9627. atcommand->func = atcommand_base[i].func;
  9628. atcommand->restriction = atcommand_base[i].restriction;
  9629. strdb_put(atcommand_db, atcommand->command, atcommand);
  9630. }
  9631. return;
  9632. }
  9633. /*==========================================
  9634. * Command lookup functions
  9635. *------------------------------------------*/
  9636. bool atcommand_exists(const char* name)
  9637. {
  9638. return strdb_exists(atcommand_db, name);
  9639. }
  9640. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9641. {
  9642. if (strdb_exists(atcommand_db, name))
  9643. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9644. return nullptr;
  9645. }
  9646. /// AtCommand suggestion
  9647. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand) {
  9648. DBIterator* atcommand_iter;
  9649. AtCommandInfo* command_info = nullptr;
  9650. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9651. char* full_match[MAX_SUGGESTIONS];
  9652. char* suggestions[MAX_SUGGESTIONS];
  9653. char* match;
  9654. int prefix_count = 0, full_count = 0;
  9655. bool can_use;
  9656. if (!battle_config.atcommand_suggestions_enabled)
  9657. return;
  9658. atcommand_iter = db_iterator(atcommand_db);
  9659. // Build the matches
  9660. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  9661. match = strstr(command_info->command, name);
  9662. can_use = pc_can_use_command(sd, command_info->command, type);
  9663. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9664. suggestions[prefix_count] = command_info->command;
  9665. ++prefix_count;
  9666. }
  9667. if ( full_count < MAX_SUGGESTIONS && match != nullptr && match != command_info->command && can_use ) {
  9668. full_match[full_count] = command_info->command;
  9669. ++full_count;
  9670. }
  9671. }
  9672. for( auto& pair : atcommand_alias_db ){
  9673. std::shared_ptr<s_atcommand_alias_info> info = pair.second;
  9674. if( pc_can_use_command( sd, info->command->command, type ) ){
  9675. for( const std::string& alias_str : info->aliases ){
  9676. char* alias = const_cast<char *>(alias_str.c_str());
  9677. match = strstr( alias, name );
  9678. if( prefix_count < MAX_SUGGESTIONS && match == alias ){
  9679. suggestions[prefix_count] = alias;
  9680. ++prefix_count;
  9681. }
  9682. if( full_count < MAX_SUGGESTIONS && match != nullptr && match != alias ){
  9683. full_match[full_count] = alias;
  9684. ++full_count;
  9685. }
  9686. }
  9687. }
  9688. }
  9689. if ((full_count+prefix_count) > 0) {
  9690. char buffer[512];
  9691. int i;
  9692. // Merge full match and prefix match results
  9693. if (prefix_count < MAX_SUGGESTIONS) {
  9694. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9695. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9696. }
  9697. // Build the suggestion string
  9698. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  9699. strcat(buffer,"\n");
  9700. for(i=0; i < prefix_count; ++i) {
  9701. strcat(buffer,suggestions[i]);
  9702. strcat(buffer," ");
  9703. }
  9704. clif_displaymessage(sd->fd, buffer);
  9705. }
  9706. dbi_destroy(atcommand_iter);
  9707. }
  9708. /**
  9709. * Executes an at-command
  9710. * @param fd
  9711. * @param sd
  9712. * @param message
  9713. * @param type
  9714. * 0 : script call (atcommand)
  9715. * 1 : normal player @atcommand
  9716. * 2 : console (admin:@atcommand)
  9717. * 3 : script call (useatcmd)
  9718. */
  9719. bool is_atcommand(const int fd, map_session_data* sd, const char* message, int type)
  9720. {
  9721. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  9722. char output[CHAT_SIZE_MAX];
  9723. //Reconstructed message
  9724. char atcmd_msg[CHAT_SIZE_MAX * 2];
  9725. TBL_PC * ssd = nullptr; //sd for target
  9726. AtCommandInfo * info;
  9727. bool is_atcommand = true; // false if it's a charcommand
  9728. nullpo_retr(false, sd);
  9729. //Shouldn't happen
  9730. if ( !message || !*message )
  9731. return false;
  9732. //If cannot use atcomamnd while talking with NPC [Kichi]
  9733. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  9734. return false;
  9735. //Block NOCHAT but do not display it as a normal message
  9736. if ( sd->sc.getSCE(SC_NOCHAT) && sd->sc.getSCE(SC_NOCHAT)->val1&MANNER_NOCOMMAND )
  9737. return true;
  9738. // skip 10/11-langtype's codepage indicator, if detected
  9739. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9740. message += 3;
  9741. //Should display as a normal message
  9742. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9743. return false;
  9744. // type value 0|2 = script|console invoked: bypass restrictions
  9745. if ( type == 1 || type == 3) {
  9746. //Commands are disabled on maps flagged as 'nocommand'
  9747. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  9748. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  9749. return false;
  9750. }
  9751. }
  9752. if (*message == charcommand_symbol)
  9753. is_atcommand = false;
  9754. if (is_atcommand) { // @command
  9755. sprintf(atcmd_msg, "%s", message);
  9756. ssd = sd;
  9757. } else { // #command
  9758. char charname[NAME_LENGTH];
  9759. int n;
  9760. //Checks to see if #command has a name or a name + parameters.
  9761. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  9762. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  9763. ) {
  9764. if (pc_get_group_level(sd) == 0) {
  9765. if (n < 1)
  9766. return false; // No command found. Display as normal message.
  9767. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9768. 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
  9769. return false;
  9770. }
  9771. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9772. clif_displaymessage(fd, output);
  9773. return true;
  9774. }
  9775. ssd = map_nick2sd(charname,true);
  9776. if (ssd == nullptr) {
  9777. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9778. clif_displaymessage(fd, output);
  9779. return true;
  9780. }
  9781. if (n > 2)
  9782. sprintf(atcmd_msg, "%s %s", command, params);
  9783. else
  9784. sprintf(atcmd_msg, "%s", command);
  9785. }
  9786. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9787. sd->idletime = last_tick;
  9788. if (battle_config.hom_idle_no_share && sd->hd && battle_config.idletime_hom_option&IDLE_ATCOMMAND)
  9789. sd->idletime_hom = last_tick;
  9790. if (battle_config.mer_idle_no_share && sd->md && battle_config.idletime_mer_option&IDLE_ATCOMMAND)
  9791. sd->idletime_mer = last_tick;
  9792. //Clearing these to be used once more.
  9793. memset(command, '\0', sizeof(command));
  9794. memset(params, '\0', sizeof(params));
  9795. //check to see if any params exist within this command
  9796. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9797. params[0] = '\0';
  9798. if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
  9799. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9800. clif_displaymessage(fd, output);
  9801. return true;
  9802. }
  9803. // @commands (script based)
  9804. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9805. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9806. // Check if the binding isn't nullptr and there is a NPC event, level of usage met, et cetera
  9807. if( binding != nullptr && binding->npc_event[0] &&
  9808. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9809. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9810. {
  9811. // Check if self or character invoking; if self == character invoked, then self invoke.
  9812. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9813. return true;
  9814. }
  9815. }
  9816. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9817. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9818. if (info == nullptr) {
  9819. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9820. return false;
  9821. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9822. clif_displaymessage(fd, output);
  9823. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9824. return true;
  9825. }
  9826. //check restriction
  9827. if (info->restriction) {
  9828. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9829. return true;
  9830. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9831. return true;
  9832. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9833. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9834. return true;
  9835. }
  9836. // type == 1 : player invoked
  9837. if (type == 1) {
  9838. if ((is_atcommand && info->at_groups[sd->group->index] == 0) ||
  9839. (!is_atcommand && info->char_groups[sd->group->index] == 0) )
  9840. return false;
  9841. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9842. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9843. return true;
  9844. }
  9845. }
  9846. //Attempt to use the command
  9847. if ( (info->func(fd, ssd, command, params) != 0) )
  9848. {
  9849. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9850. clif_displaymessage(fd, output);
  9851. return true;
  9852. }
  9853. //Log only if successful.
  9854. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9855. return true;
  9856. }
  9857. void atcommand_db_load_groups(){
  9858. DBIterator *iter = db_iterator(atcommand_db);
  9859. AtCommandInfo* cmd;
  9860. size_t pc_group_max = player_group_db.size();
  9861. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9862. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9863. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9864. for( auto& it : player_group_db ){
  9865. cmd->at_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_ATCOMMAND );
  9866. cmd->char_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_CHARCOMMAND );
  9867. }
  9868. }
  9869. dbi_destroy(iter);
  9870. }
  9871. void atcommand_db_clear(void) {
  9872. if (atcommand_db != nullptr) {
  9873. DBIterator *iter = db_iterator(atcommand_db);
  9874. AtCommandInfo* cmd;
  9875. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9876. aFree(cmd->at_groups);
  9877. aFree(cmd->char_groups);
  9878. }
  9879. dbi_destroy(iter);
  9880. db_destroy(atcommand_db);
  9881. }
  9882. atcommand_alias_db.clear();
  9883. }
  9884. void atcommand_doload(void) {
  9885. atcommand_db_clear();
  9886. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9887. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9888. atcommand_alias_db.load();
  9889. }
  9890. void do_init_atcommand(void) {
  9891. atcommand_doload();
  9892. }
  9893. void do_final_atcommand(void) {
  9894. atcommand_db_clear();
  9895. }