atcommand.cpp 341 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344
  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 <set>
  5. #include <unordered_map>
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include "../common/cbasetypes.hpp"
  9. #include "../common/database.hpp"
  10. #include "../common/cli.hpp"
  11. #include "../common/conf.hpp"
  12. #include "../common/malloc.hpp"
  13. #include "../common/mmo.hpp"
  14. #include "../common/nullpo.hpp"
  15. #include "../common/random.hpp"
  16. #include "../common/showmsg.hpp"
  17. #include "../common/socket.hpp"
  18. #include "../common/strlib.hpp"
  19. #include "../common/timer.hpp"
  20. #include "../common/utilities.hpp"
  21. #include "../common/utils.hpp"
  22. #include "achievement.hpp"
  23. #include "battle.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 "log.hpp"
  37. #include "mail.hpp"
  38. #include "map.hpp"
  39. #include "mapreg.hpp"
  40. #include "mercenary.hpp"
  41. #include "mob.hpp"
  42. #include "npc.hpp"
  43. #include "party.hpp"
  44. #include "pc.hpp"
  45. #include "pc_groups.hpp"
  46. #include "pet.hpp"
  47. #include "quest.hpp"
  48. #include "script.hpp"
  49. #include "storage.hpp"
  50. #include "trade.hpp"
  51. using namespace rathena;
  52. #define ATCOMMAND_LENGTH 50
  53. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  54. typedef struct AtCommandInfo AtCommandInfo;
  55. int atcmd_binding_count = 0;
  56. /// Atcommand restriction usage
  57. enum e_atcmd_restict {
  58. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  59. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  60. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  61. };
  62. struct AtCommandInfo {
  63. char command[ATCOMMAND_LENGTH];
  64. AtCommandFunc func;
  65. char* at_groups; /// Quick @commands "can-use" lookup
  66. char* char_groups; /// Quick @charcommands "can-use" lookup
  67. uint8 restriction; /// Restrictions see enum e_restict
  68. };
  69. struct s_atcommand_alias_info{
  70. AtCommandInfo *command;
  71. std::set<std::string> aliases;
  72. std::string help;
  73. };
  74. char atcommand_symbol = '@'; // first char of the commands
  75. char charcommand_symbol = '#';
  76. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  77. static AtCommandInfo* get_atcommandinfo_byname( const char* name );
  78. class AtcommandAliasDatabase : public TypesafeYamlDatabase<std::string, s_atcommand_alias_info>{
  79. private:
  80. std::unordered_map<std::string, std::string> aliases;
  81. public:
  82. AtcommandAliasDatabase() : TypesafeYamlDatabase( "ATCOMMAND_DB", 1 ){
  83. }
  84. void clear();
  85. const std::string getDefaultLocation();
  86. uint64 parseBodyNode( const YAML::Node& node );
  87. const char* checkAlias( const char* alias );
  88. };
  89. void AtcommandAliasDatabase::clear(){
  90. TypesafeYamlDatabase::clear();
  91. this->aliases.clear();
  92. }
  93. const std::string AtcommandAliasDatabase::getDefaultLocation(){
  94. return std::string(conf_path) + "/atcommands.yml";
  95. }
  96. uint64 AtcommandAliasDatabase::parseBodyNode( const YAML::Node& node ){
  97. std::string command;
  98. if( !this->asString( node, "Command", command ) ){
  99. return 0;
  100. }
  101. AtCommandInfo* commandinfo = get_atcommandinfo_byname( command.c_str() );
  102. if( commandinfo == nullptr ){
  103. this->invalidWarning( node["Command"], "Command %s does not exist.\n", command.c_str() );
  104. return 0;
  105. }
  106. std::shared_ptr<s_atcommand_alias_info> info = this->find( command );
  107. bool exists = info != nullptr;
  108. if( !exists ){
  109. info = std::make_shared<s_atcommand_alias_info>();
  110. info->command = commandinfo;
  111. }
  112. if( this->nodeExists( node, "Help" ) ){
  113. std::string help;
  114. if( !this->asString( node, "Help", help ) ){
  115. return 0;
  116. }
  117. info->help = help;
  118. }
  119. if( this->nodeExists( node, "Aliases" ) ){
  120. const YAML::Node& aliasesNode = node["Aliases"];
  121. if( !aliasesNode.IsSequence() ){
  122. this->invalidWarning( aliasesNode, "Aliases should be a sequence.\n" );
  123. return 0;
  124. }
  125. for( const auto& subNode : aliasesNode ){
  126. std::string alias = subNode.as<std::string>();
  127. info->aliases.insert( alias );
  128. this->aliases[alias] = command;
  129. }
  130. }
  131. if( !exists ){
  132. this->put( command, info );
  133. }
  134. return 1;
  135. }
  136. const char* AtcommandAliasDatabase::checkAlias( const char* alias ){
  137. std::string alias_str( alias );
  138. std::string* command = util::umap_find( this->aliases, alias_str );
  139. if( command == nullptr ){
  140. return alias;
  141. }else{
  142. return command->c_str();
  143. }
  144. }
  145. AtcommandAliasDatabase atcommand_alias_db;
  146. static char atcmd_output[CHAT_SIZE_MAX];
  147. static char atcmd_player_name[NAME_LENGTH];
  148. const char *parent_cmd;
  149. struct atcmd_binding_data** atcmd_binding;
  150. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  151. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  152. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  153. // @commands (script-based)
  154. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  155. int i = 0;
  156. if( *name == atcommand_symbol || *name == charcommand_symbol )
  157. name++; // for backwards compatibility
  158. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  159. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  160. }
  161. /**
  162. * retrieves the help string associated with a given command.
  163. *
  164. * @param name the name of the command to retrieve help information for
  165. * @return the string associated with the command, or NULL
  166. */
  167. static const char* atcommand_help_string( const char* command ){
  168. // remove the prefix symbol for the raw name of the command
  169. if( *command == atcommand_symbol || *command == charcommand_symbol ){
  170. command++;
  171. }
  172. // convert alias to the real command name
  173. command = atcommand_alias_db.checkAlias( command );
  174. // attempt to find the first default help command
  175. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command );
  176. // failed to find the help property in the configuration file
  177. if( info == nullptr ){
  178. return nullptr;
  179. }
  180. // push the result from the method
  181. return info->help.c_str();
  182. }
  183. /*==========================================
  184. * @send (used for testing packet sends from the client)
  185. *------------------------------------------*/
  186. ACMD_FUNC(send)
  187. {
  188. int len=0,type;
  189. // read message type as hex number (without the 0x)
  190. if(!message || !*message ||
  191. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  192. || sscanf(message, "%8x", &type)==1) )
  193. {
  194. int i;
  195. for (i = 900; i <= 903; ++i)
  196. clif_displaymessage(fd, msg_txt(sd,i));
  197. return -1;
  198. }
  199. #define PARSE_ERROR(error,p) \
  200. {\
  201. clif_displaymessage(fd, (error));\
  202. sprintf(atcmd_output, ">%s", (p));\
  203. clif_displaymessage(fd, atcmd_output);\
  204. }
  205. //define PARSE_ERROR
  206. #define CHECK_EOS(p) \
  207. if(*(p) == 0){\
  208. clif_displaymessage(fd, "Unexpected end of string");\
  209. return -1;\
  210. }
  211. //define CHECK_EOS
  212. #define SKIP_VALUE(p) \
  213. {\
  214. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  215. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  216. }
  217. //define SKIP_VALUE
  218. #define GET_VALUE(p,num) \
  219. {\
  220. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  221. PARSE_ERROR("Invalid number in:",(p));\
  222. return -1;\
  223. }\
  224. }
  225. //define GET_VALUE
  226. if (type > 0 && type < MAX_PACKET_DB) {
  227. int off,end;
  228. long num;
  229. if(len)
  230. {// show packet length
  231. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  232. clif_displaymessage(fd, atcmd_output);
  233. return 0;
  234. }
  235. len=packet_db[type].len;
  236. off=2;
  237. if(len == 0)
  238. {// unknown packet - ERROR
  239. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  240. clif_displaymessage(fd, atcmd_output);
  241. return -1;
  242. } else if(len == -1)
  243. {// dynamic packet
  244. len=SHRT_MAX-4; // maximum length
  245. off=4;
  246. }
  247. WFIFOHEAD(fd, len);
  248. WFIFOW(fd,0)=TOW(type);
  249. // parse packet contents
  250. SKIP_VALUE(message);
  251. while(*message != 0 && off < len){
  252. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  253. {// default (byte)
  254. GET_VALUE(message,num);
  255. WFIFOB(fd,off)=TOB(num);
  256. ++off;
  257. } else if(TOUPPER(*message) == 'B')
  258. {// byte
  259. ++message;
  260. GET_VALUE(message,num);
  261. WFIFOB(fd,off)=TOB(num);
  262. ++off;
  263. } else if(TOUPPER(*message) == 'W')
  264. {// word (2 bytes)
  265. ++message;
  266. GET_VALUE(message,num);
  267. WFIFOW(fd,off)=TOW(num);
  268. off+=2;
  269. } else if(TOUPPER(*message) == 'L')
  270. {// long word (4 bytes)
  271. ++message;
  272. GET_VALUE(message,num);
  273. WFIFOL(fd,off)=TOL(num);
  274. off+=4;
  275. } else if(TOUPPER(*message) == 'S')
  276. {// string - escapes are valid
  277. // get string length - num <= 0 means not fixed length (default)
  278. ++message;
  279. if(*message == '"'){
  280. num=0;
  281. } else {
  282. GET_VALUE(message,num);
  283. while(*message != '"')
  284. {// find start of string
  285. if(*message == 0 || ISSPACE(*message)){
  286. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  287. return -1;
  288. }
  289. ++message;
  290. }
  291. }
  292. // parse string
  293. ++message;
  294. CHECK_EOS(message);
  295. end=(num<=0? 0: min(off+((int)num),len));
  296. for(; *message != '"' && (off < end || end == 0); ++off){
  297. if(*message == '\\'){
  298. ++message;
  299. CHECK_EOS(message);
  300. switch(*message){
  301. case 'a': num=0x07; break; // Bell
  302. case 'b': num=0x08; break; // Backspace
  303. case 't': num=0x09; break; // Horizontal tab
  304. case 'n': num=0x0A; break; // Line feed
  305. case 'v': num=0x0B; break; // Vertical tab
  306. case 'f': num=0x0C; break; // Form feed
  307. case 'r': num=0x0D; break; // Carriage return
  308. case 'e': num=0x1B; break; // Escape
  309. default: num=*message; break;
  310. case 'x': // Hexadecimal
  311. {
  312. ++message;
  313. CHECK_EOS(message);
  314. if(!ISXDIGIT(*message)){
  315. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  316. return -1;
  317. }
  318. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  319. if(ISXDIGIT(*message)){
  320. ++message;
  321. CHECK_EOS(message);
  322. num<<=8;
  323. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  324. }
  325. WFIFOB(fd,off)=TOB(num);
  326. ++message;
  327. CHECK_EOS(message);
  328. continue;
  329. }
  330. case '0':
  331. case '1':
  332. case '2':
  333. case '3':
  334. case '4':
  335. case '5':
  336. case '6':
  337. case '7': // Octal
  338. {
  339. num=*message-'0'; // 1st octal digit
  340. ++message;
  341. CHECK_EOS(message);
  342. if(ISDIGIT(*message) && *message < '8'){
  343. num<<=3;
  344. num+=*message-'0'; // 2nd octal digit
  345. ++message;
  346. CHECK_EOS(message);
  347. if(ISDIGIT(*message) && *message < '8'){
  348. num<<=3;
  349. num+=*message-'0'; // 3rd octal digit
  350. ++message;
  351. CHECK_EOS(message);
  352. }
  353. }
  354. WFIFOB(fd,off)=TOB(num);
  355. continue;
  356. }
  357. }
  358. } else
  359. num=*message;
  360. WFIFOB(fd,off)=TOB(num);
  361. ++message;
  362. CHECK_EOS(message);
  363. }//for
  364. while(*message != '"')
  365. {// ignore extra characters
  366. ++message;
  367. CHECK_EOS(message);
  368. }
  369. // terminate the string
  370. if(off < end)
  371. {// fill the rest with 0's
  372. memset(WFIFOP(fd,off),0,end-off);
  373. off=end;
  374. }
  375. } else
  376. {// unknown
  377. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  378. return -1;
  379. }
  380. SKIP_VALUE(message);
  381. }
  382. if(packet_db[type].len == -1)
  383. {// send dynamic packet
  384. WFIFOW(fd,2)=TOW(off);
  385. WFIFOSET(fd,off);
  386. } else
  387. {// send static packet
  388. if(off < len)
  389. memset(WFIFOP(fd,off),0,len-off);
  390. WFIFOSET(fd,len);
  391. }
  392. } else {
  393. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  394. return -1;
  395. }
  396. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  397. clif_displaymessage(fd, atcmd_output);
  398. return 0;
  399. #undef PARSE_ERROR
  400. #undef CHECK_EOS
  401. #undef SKIP_VALUE
  402. #undef GET_VALUE
  403. }
  404. /**
  405. * Retrieves map name suggestions for a given string.
  406. * This will first check if any map names contain the given string, and will
  407. * print out MAX_SUGGESTIONS results if any maps are found.
  408. * Otherwise, suggestions will be calculated through Levenshtein distance,
  409. * and up to 5 of the closest matches will be printed.
  410. *
  411. * @author Euphy
  412. */
  413. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  414. // Minimum length for suggestions is 2 characters
  415. if( strlen( name ) < 2 ){
  416. return;
  417. }
  418. std::vector<const char*> suggestions;
  419. suggestions.reserve( MAX_SUGGESTIONS );
  420. // check for maps that contain string
  421. for (int i = 0; i < map_num; i++) {
  422. struct map_data *mapdata = map_getmapdata(i);
  423. // Prevent suggestion of instance mapnames
  424. if( mapdata->instance_id != 0 ){
  425. continue;
  426. }
  427. if( strstr( mapdata->name, name ) != nullptr ){
  428. suggestions.push_back( mapdata->name );
  429. if( suggestions.size() == MAX_SUGGESTIONS ){
  430. break;
  431. }
  432. }
  433. }
  434. // if no maps found, search by edit distance
  435. if( suggestions.empty() ){
  436. // Levenshtein > 4 is bad
  437. const int LEVENSHTEIN_MAX = 4;
  438. std::unordered_map<int, std::vector<const char*>> maps;
  439. for (int i = 0; i < map_num; i++) {
  440. struct map_data *mapdata = map_getmapdata(i);
  441. // Prevent suggestion of instance mapnames
  442. if(mapdata->instance_id != 0 ){
  443. continue;
  444. }
  445. // Calculate the levenshtein distance of the two strings
  446. int distance = levenshtein(mapdata->name, name);
  447. // Check if it is above the maximum defined distance
  448. if( distance > LEVENSHTEIN_MAX ){
  449. continue;
  450. }
  451. std::vector<const char*>& vector = maps[distance];
  452. // Do not add more entries than required
  453. if( vector.size() == MAX_SUGGESTIONS ){
  454. continue;
  455. }
  456. vector.push_back(mapdata->name);
  457. }
  458. for( int distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){
  459. std::vector<const char*>& vector = maps[distance];
  460. for( const char* found_map : vector ){
  461. suggestions.push_back( found_map );
  462. if( suggestions.size() == MAX_SUGGESTIONS ){
  463. break;
  464. }
  465. }
  466. if( suggestions.size() == MAX_SUGGESTIONS ){
  467. break;
  468. }
  469. }
  470. }
  471. // If no suggestion could be made, do not output anything at all
  472. if( suggestions.empty() ){
  473. return;
  474. }
  475. char buffer[CHAT_SIZE_MAX];
  476. // build the suggestion string
  477. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  478. strcat(buffer, "\n");
  479. for( const char* suggestion : suggestions ){
  480. strcat(buffer, suggestion);
  481. strcat(buffer, " ");
  482. }
  483. clif_displaymessage(sd->fd, buffer);
  484. }
  485. /*==========================================
  486. * @rura, @warp, @mapmove
  487. *------------------------------------------*/
  488. ACMD_FUNC(mapmove)
  489. {
  490. char map_name[MAP_NAME_LENGTH_EXT];
  491. unsigned short mapindex;
  492. short x = 0, y = 0;
  493. int16 m = -1;
  494. nullpo_retr(-1, sd);
  495. memset(map_name, '\0', sizeof(map_name));
  496. if (!message || !*message ||
  497. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  498. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  499. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  500. return -1;
  501. }
  502. mapindex = mapindex_name2idx(map_name, nullptr);
  503. if (mapindex)
  504. m = map_mapindex2mapid(mapindex);
  505. if (m < 0) { // m < 0 means on different server! [Kevin]
  506. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  507. if (battle_config.warp_suggestions_enabled)
  508. warp_get_suggestions(sd, map_name);
  509. return -1;
  510. }
  511. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  512. { //This is to prevent the pc_setpos call from printing an error.
  513. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  514. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  515. x = y = 0; //Invalid cell, use random spot.
  516. }
  517. 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, sd->group_level)) {
  518. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  519. return -1;
  520. }
  521. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  522. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  523. return -1;
  524. }
  525. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  526. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  527. return -1;
  528. }
  529. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  530. return 0;
  531. }
  532. /*==========================================
  533. * Displays where a character is. Corrected version by Silent. [Skotlex]
  534. *------------------------------------------*/
  535. ACMD_FUNC(where)
  536. {
  537. struct map_session_data* pl_sd;
  538. nullpo_retr(-1, sd);
  539. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  540. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  541. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  542. return -1;
  543. }
  544. pl_sd = map_nick2sd(atcmd_player_name,true);
  545. if (pl_sd == NULL ||
  546. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  547. (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))
  548. ) {
  549. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  550. return -1;
  551. }
  552. 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);
  553. clif_displaymessage(fd, atcmd_output);
  554. return 0;
  555. }
  556. /*==========================================
  557. *
  558. *------------------------------------------*/
  559. ACMD_FUNC(jumpto)
  560. {
  561. struct map_session_data *pl_sd = NULL;
  562. nullpo_retr(-1, sd);
  563. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  564. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  565. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  566. return -1;
  567. }
  568. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  569. {
  570. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  571. return -1;
  572. }
  573. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  574. {
  575. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  576. return -1;
  577. }
  578. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  579. {
  580. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  581. return -1;
  582. }
  583. if( pc_isdead(sd) )
  584. {
  585. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  586. return -1;
  587. }
  588. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  589. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  590. clif_displaymessage(fd, atcmd_output);
  591. return 0;
  592. }
  593. /*==========================================
  594. *
  595. *------------------------------------------*/
  596. ACMD_FUNC(jump)
  597. {
  598. short x = 0, y = 0;
  599. nullpo_retr(-1, sd);
  600. memset(atcmd_output, '\0', sizeof(atcmd_output));
  601. sscanf(message, "%6hd %6hd", &x, &y);
  602. if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  603. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  604. return -1;
  605. }
  606. if( pc_isdead(sd) )
  607. {
  608. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  609. return -1;
  610. }
  611. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  612. { //This is to prevent the pc_setpos call from printing an error.
  613. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  614. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  615. x = y = 0; //Invalid cell, use random spot.
  616. }
  617. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  618. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  619. clif_displaymessage(fd, atcmd_output);
  620. return 0;
  621. }
  622. /*==========================================
  623. * Display list of online characters with
  624. * various info.
  625. *------------------------------------------*/
  626. ACMD_FUNC(who) {
  627. struct map_session_data *pl_sd = NULL;
  628. struct s_mapiterator *iter = NULL;
  629. char player_name[NAME_LENGTH] = "";
  630. int count = 0;
  631. int level = 0;
  632. StringBuf buf;
  633. /**
  634. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  635. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  636. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  637. */
  638. int display_type = 1;
  639. int map_id = -1;
  640. nullpo_retr(-1, sd);
  641. if (strstr(command, "map") != NULL) {
  642. char map_name[MAP_NAME_LENGTH_EXT] = "";
  643. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  644. map_id = sd->bl.m;
  645. } else {
  646. sscanf(message, "%23s", player_name);
  647. }
  648. if (strstr(command, "2") != NULL)
  649. display_type = 2;
  650. else if (strstr(command, "3") != NULL)
  651. display_type = 3;
  652. level = pc_get_group_level(sd);
  653. StringBuf_Init(&buf);
  654. iter = mapit_getallusers();
  655. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  656. 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
  657. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  658. || (map_id >= 0 && pl_sd->bl.m != map_id))
  659. continue;
  660. switch (display_type) {
  661. case 2: {
  662. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  663. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  664. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  665. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  666. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  667. break;
  668. }
  669. case 3: {
  670. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  671. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  672. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  673. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  674. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  675. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  676. break;
  677. }
  678. default: {
  679. struct party_data *p = party_search(pl_sd->status.party_id);
  680. struct guild *g = pl_sd->guild;
  681. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  682. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  683. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  684. if (p != NULL)
  685. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  686. if (g != NULL)
  687. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  688. break;
  689. }
  690. }
  691. clif_displaymessage(fd, StringBuf_Value(&buf));
  692. StringBuf_Clear(&buf);
  693. count++;
  694. }
  695. }
  696. mapit_free(iter);
  697. if (map_id < 0) {
  698. if (count == 0)
  699. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  700. else if (count == 1)
  701. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  702. else
  703. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  704. } else {
  705. struct map_data *mapdata = map_getmapdata(map_id);
  706. if (count == 0)
  707. StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'.
  708. else if (count == 1)
  709. StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'.
  710. else
  711. StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'.
  712. }
  713. clif_displaymessage(fd, StringBuf_Value(&buf));
  714. StringBuf_Destroy(&buf);
  715. return 0;
  716. }
  717. /*==========================================
  718. *
  719. *------------------------------------------*/
  720. ACMD_FUNC(whogm)
  721. {
  722. struct map_session_data* pl_sd;
  723. struct s_mapiterator* iter;
  724. int j, count;
  725. int level;
  726. char match_text[CHAT_SIZE_MAX];
  727. char player_name[NAME_LENGTH];
  728. struct guild *g;
  729. struct party_data *p;
  730. nullpo_retr(-1, sd);
  731. memset(atcmd_output, '\0', sizeof(atcmd_output));
  732. memset(match_text, '\0', sizeof(match_text));
  733. memset(player_name, '\0', sizeof(player_name));
  734. if (sscanf(message, "%255[^\n]", match_text) < 1)
  735. strcpy(match_text, "");
  736. for (j = 0; match_text[j]; j++)
  737. match_text[j] = TOLOWER(match_text[j]);
  738. count = 0;
  739. level = pc_get_group_level(sd);
  740. iter = mapit_getallusers();
  741. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  742. {
  743. int pl_level = pc_get_group_level(pl_sd);
  744. if (!pl_level)
  745. continue;
  746. if (match_text[0])
  747. {
  748. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  749. for (j = 0; player_name[j]; j++)
  750. player_name[j] = TOLOWER(player_name[j]);
  751. // search with no case sensitive
  752. if (strstr(player_name, match_text) == NULL)
  753. continue;
  754. }
  755. if (pl_level > level) {
  756. if (pc_isinvisible(pl_sd))
  757. continue;
  758. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  759. clif_displaymessage(fd, atcmd_output);
  760. count++;
  761. continue;
  762. }
  763. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  764. pl_sd->status.name, pl_level,
  765. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  766. clif_displaymessage(fd, atcmd_output);
  767. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  768. pl_sd->status.base_level,
  769. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  770. clif_displaymessage(fd, atcmd_output);
  771. p = party_search(pl_sd->status.party_id);
  772. g = pl_sd->guild;
  773. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  774. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  775. clif_displaymessage(fd, atcmd_output);
  776. count++;
  777. }
  778. mapit_free(iter);
  779. if (count == 0)
  780. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  781. else if (count == 1)
  782. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  783. else {
  784. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  785. clif_displaymessage(fd, atcmd_output);
  786. }
  787. return 0;
  788. }
  789. /*==========================================
  790. *
  791. *------------------------------------------*/
  792. ACMD_FUNC(save)
  793. {
  794. nullpo_retr(-1, sd);
  795. if( map_getmapdata(sd->bl.m)->instance_id ) {
  796. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  797. return 1;
  798. }
  799. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  800. if (sd->status.pet_id > 0 && sd->pd)
  801. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  802. chrif_save(sd, CSAVE_NORMAL);
  803. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  804. return 0;
  805. }
  806. /*==========================================
  807. *
  808. *------------------------------------------*/
  809. ACMD_FUNC(load)
  810. {
  811. int16 m;
  812. nullpo_retr(-1, sd);
  813. m = map_mapindex2mapid(sd->status.save_point.map);
  814. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  815. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  816. return -1;
  817. }
  818. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  819. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  820. return -1;
  821. }
  822. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  823. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  824. return 0;
  825. }
  826. /*==========================================
  827. *
  828. *------------------------------------------*/
  829. ACMD_FUNC(speed)
  830. {
  831. short speed;
  832. nullpo_retr(-1, sd);
  833. memset(atcmd_output, '\0', sizeof(atcmd_output));
  834. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  835. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  836. clif_displaymessage(fd, atcmd_output);
  837. return -1;
  838. }
  839. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  840. if (speed < 0)
  841. sd->base_status.speed = DEFAULT_WALK_SPEED;
  842. else
  843. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  844. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  845. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  846. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  847. } else
  848. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  849. status_calc_bl(&sd->bl, SCB_SPEED);
  850. return 0;
  851. }
  852. /*==========================================
  853. *
  854. *------------------------------------------*/
  855. ACMD_FUNC(storage)
  856. {
  857. nullpo_retr(-1, sd);
  858. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  859. return -1;
  860. if (storage_storageopen(sd) == 1)
  861. { //Already open.
  862. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  863. return -1;
  864. }
  865. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  866. return 0;
  867. }
  868. /*==========================================
  869. *
  870. *------------------------------------------*/
  871. ACMD_FUNC(guildstorage)
  872. {
  873. nullpo_retr(-1, sd);
  874. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  875. return -1;
  876. switch (storage_guild_storageopen(sd)) {
  877. case GSTORAGE_OPEN:
  878. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  879. break;
  880. case GSTORAGE_STORAGE_ALREADY_OPEN:
  881. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  882. return -1;
  883. case GSTORAGE_ALREADY_OPEN:
  884. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  885. return -1;
  886. case GSTORAGE_NO_GUILD:
  887. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  888. return -1;
  889. case GSTORAGE_NO_STORAGE:
  890. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  891. return -1;
  892. case GSTORAGE_NO_PERMISSION:
  893. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  894. return -1;
  895. }
  896. return 0;
  897. }
  898. /*==========================================
  899. *
  900. *------------------------------------------*/
  901. ACMD_FUNC(option)
  902. {
  903. int param1 = 0, param2 = 0, param3 = 0;
  904. nullpo_retr(-1, sd);
  905. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  906. {// failed to match the parameters so inform the user of the options
  907. const char* text;
  908. // attempt to find the setting information for this command
  909. text = atcommand_help_string( command );
  910. // notify the user of the requirement to enter an option
  911. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  912. if( text )
  913. {// send the help text associated with this command
  914. clif_displaymessage( fd, text );
  915. }
  916. return -1;
  917. }
  918. sd->sc.opt1 = param1;
  919. sd->sc.opt2 = param2;
  920. pc_setoption(sd, param3);
  921. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  922. return 0;
  923. }
  924. /*==========================================
  925. *
  926. *------------------------------------------*/
  927. ACMD_FUNC(hide)
  928. {
  929. nullpo_retr(-1, sd);
  930. if (pc_isinvisible(sd)) {
  931. sd->sc.option &= ~OPTION_INVISIBLE;
  932. if (sd->disguise)
  933. status_set_viewdata(&sd->bl, sd->disguise);
  934. else
  935. status_set_viewdata(&sd->bl, sd->status.class_);
  936. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  937. // increment the number of pvp players on the map
  938. map_getmapdata(sd->bl.m)->users_pvp++;
  939. if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) )
  940. {// register the player for ranking calculations
  941. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  942. }
  943. //bugreport:2266
  944. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  945. } else {
  946. sd->sc.option |= OPTION_INVISIBLE;
  947. sd->vd.class_ = JT_INVISIBLE;
  948. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  949. // decrement the number of pvp players on the map
  950. map_getmapdata(sd->bl.m)->users_pvp--;
  951. if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER )
  952. {// unregister the player for ranking
  953. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  954. sd->pvp_timer = INVALID_TIMER;
  955. }
  956. }
  957. clif_changeoption(&sd->bl);
  958. return 0;
  959. }
  960. /*==========================================
  961. * Changes a character's class
  962. *------------------------------------------*/
  963. ACMD_FUNC(jobchange)
  964. {
  965. int job = 0, upper = 0;
  966. const char* text;
  967. nullpo_retr(-1, sd);
  968. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  969. int i;
  970. bool found = false;
  971. upper = 0;
  972. // Normal Jobs
  973. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  974. if (strncmpi(message, job_name(i), 16) == 0) {
  975. job = i;
  976. found = true;
  977. }
  978. }
  979. // High Jobs, Babys, Third, and Fourth
  980. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  981. if (strncmpi(message, job_name(i), 16) == 0) {
  982. job = i;
  983. found = true;
  984. }
  985. }
  986. if (!found) {
  987. text = atcommand_help_string(command);
  988. if (text)
  989. clif_displaymessage(fd, text);
  990. return -1;
  991. }
  992. }
  993. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  994. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  995. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE_KNIGHT2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  996. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2
  997. || (job >= JOB_WINDHAWK2 && job <= JOB_IMPERIAL_GUARD2) || job == JOB_SKY_EMPEROR2)
  998. { // Deny direct transformation into dummy jobs
  999. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  1000. return 0;
  1001. }
  1002. if (pcdb_checkid(job))
  1003. {
  1004. if (pc_jobchange(sd, job, upper))
  1005. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  1006. else {
  1007. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  1008. return -1;
  1009. }
  1010. } else {
  1011. text = atcommand_help_string(command);
  1012. if (text)
  1013. clif_displaymessage(fd, text);
  1014. return -1;
  1015. }
  1016. return 0;
  1017. }
  1018. /*==========================================
  1019. *
  1020. *------------------------------------------*/
  1021. ACMD_FUNC(kill)
  1022. {
  1023. nullpo_retr(-1, sd);
  1024. status_kill(&sd->bl);
  1025. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1026. if (fd != sd->fd)
  1027. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1028. return 0;
  1029. }
  1030. /*==========================================
  1031. *
  1032. *------------------------------------------*/
  1033. ACMD_FUNC(alive)
  1034. {
  1035. nullpo_retr(-1, sd);
  1036. if (!status_revive(&sd->bl, 100, 100))
  1037. {
  1038. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  1039. return -1;
  1040. }
  1041. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1042. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1043. return 0;
  1044. }
  1045. /*==========================================
  1046. * +kamic [LuzZza]
  1047. *------------------------------------------*/
  1048. ACMD_FUNC(kami)
  1049. {
  1050. unsigned long color=0;
  1051. nullpo_retr(-1, sd);
  1052. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1053. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1054. if (!message || !*message) {
  1055. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1056. return -1;
  1057. }
  1058. sscanf(message, "%255[^\n]", atcmd_output);
  1059. if (strstr(command, "l") != NULL)
  1060. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  1061. else
  1062. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  1063. } else {
  1064. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1065. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1066. return -1;
  1067. }
  1068. if(color > 0xFFFFFF) {
  1069. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1070. return -1;
  1071. }
  1072. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1073. }
  1074. return 0;
  1075. }
  1076. /*==========================================
  1077. *
  1078. *------------------------------------------*/
  1079. ACMD_FUNC(heal)
  1080. {
  1081. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1082. nullpo_retr(-1, sd);
  1083. sscanf(message, "%11d %11d", &hp, &sp);
  1084. // some overflow checks
  1085. if( hp == INT_MIN ) hp++;
  1086. if( sp == INT_MIN ) sp++;
  1087. if ( hp == 0 && sp == 0 ) {
  1088. if (!status_percent_heal(&sd->bl, 100, 100))
  1089. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1090. else
  1091. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1092. return 0;
  1093. }
  1094. if ( hp > 0 && sp >= 0 ) {
  1095. if(!status_heal(&sd->bl, hp, sp, 0))
  1096. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1097. else
  1098. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1099. return 0;
  1100. }
  1101. if ( hp < 0 && sp <= 0 ) {
  1102. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0, 0);
  1103. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1104. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1105. return 0;
  1106. }
  1107. //Opposing signs.
  1108. if ( hp ) {
  1109. if (hp > 0)
  1110. status_heal(&sd->bl, hp, 0, 0);
  1111. else {
  1112. status_damage(NULL, &sd->bl, -hp, 0, 0, 0, 0);
  1113. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1114. }
  1115. }
  1116. if ( sp ) {
  1117. if (sp > 0)
  1118. status_heal(&sd->bl, 0, sp, 0);
  1119. else
  1120. status_damage(NULL, &sd->bl, 0, -sp, 0, 0, 0);
  1121. }
  1122. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1123. return 0;
  1124. }
  1125. /*==========================================
  1126. * Recover's AP and allows exact adjustments. [Rytech]
  1127. *------------------------------------------*/
  1128. ACMD_FUNC(healap)
  1129. {
  1130. int ap = 0;
  1131. nullpo_retr(-1, sd);
  1132. sscanf(message, "%11d", &ap);
  1133. // Overflow check.
  1134. if (ap == INT_MIN) ap++;
  1135. if (ap == 0) {
  1136. if (!status_percent_heal(&sd->bl, 0, 0, 100))
  1137. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1138. else
  1139. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1140. return 0;
  1141. }else if (ap > 0) {
  1142. if (!status_heal(&sd->bl, 0, 0, ap, 0))
  1143. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1144. else
  1145. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1146. return 0;
  1147. }else{
  1148. status_damage(NULL, &sd->bl, 0, 0, -ap, 0, 0, 0);
  1149. clif_displaymessage(fd, msg_txt(sd, 822));// AP modified.
  1150. return 0;
  1151. }
  1152. }
  1153. /*==========================================
  1154. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1155. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1156. *------------------------------------------*/
  1157. ACMD_FUNC(item)
  1158. {
  1159. char item_name[100];
  1160. int number = 0, bound = BOUND_NONE;
  1161. char flag = 0;
  1162. char *itemlist;
  1163. nullpo_retr(-1, sd);
  1164. memset(item_name, '\0', sizeof(item_name));
  1165. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1166. if (!strcmpi(parent_cmd,"itembound")) {
  1167. if (!message || !*message || (
  1168. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1169. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1170. {
  1171. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1172. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1173. return -1;
  1174. }
  1175. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1176. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1177. return -1;
  1178. }
  1179. } else if (!message || !*message || (
  1180. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1181. sscanf(message, "%99s %11d", item_name, &number) < 1
  1182. )) {
  1183. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1184. return -1;
  1185. }
  1186. std::vector<std::shared_ptr<item_data>> items;
  1187. itemlist = strtok(item_name, ":");
  1188. while( itemlist != nullptr ){
  1189. std::shared_ptr<item_data> item = item_db.searchname( itemlist );
  1190. if( item == nullptr ){
  1191. item = item_db.find( strtoul( itemlist, nullptr, 10 ) );
  1192. }
  1193. if( item == nullptr ){
  1194. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1195. return -1;
  1196. }
  1197. items.push_back( item );
  1198. itemlist = strtok(NULL, ":"); //next itemline
  1199. }
  1200. if (number <= 0)
  1201. number = 1;
  1202. int get_count = number;
  1203. // Produce items in list
  1204. for( const auto& item : items ){
  1205. t_itemid item_id = item->nameid;
  1206. //Check if it's stackable.
  1207. if( !itemdb_isstackable2( item.get() ) ){
  1208. get_count = 1;
  1209. }
  1210. for( int i = 0; i < number; i += get_count ){
  1211. // if not pet egg
  1212. if (!pet_create_egg(sd, item_id)) {
  1213. struct item item_tmp = {};
  1214. item_tmp.nameid = item_id;
  1215. item_tmp.identify = 1;
  1216. item_tmp.bound = bound;
  1217. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1218. clif_additem(sd, 0, 0, flag);
  1219. }
  1220. }
  1221. }
  1222. if (flag == 0)
  1223. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1224. return 0;
  1225. }
  1226. /*==========================================
  1227. *
  1228. *------------------------------------------*/
  1229. ACMD_FUNC(item2)
  1230. {
  1231. char item_name[100];
  1232. int number = 0, bound = BOUND_NONE;
  1233. int identify = 0, refine = 0, attr = 0;
  1234. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1235. nullpo_retr(-1, sd);
  1236. memset(item_name, '\0', sizeof(item_name));
  1237. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1238. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1239. if (!message || !*message || (
  1240. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1241. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1242. {
  1243. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1244. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1245. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1246. return -1;
  1247. }
  1248. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1249. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1250. return -1;
  1251. }
  1252. } else if ( !message || !*message || (
  1253. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1254. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1255. )) {
  1256. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1257. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1258. return -1;
  1259. }
  1260. if (number <= 0)
  1261. number = 1;
  1262. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  1263. if( item_data == nullptr ){
  1264. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  1265. }
  1266. if( item_data != nullptr ){
  1267. int loop, get_count, i;
  1268. char flag = 0;
  1269. //Check if it's stackable.
  1270. if( !itemdb_isstackable2( item_data.get() ) ){
  1271. loop = number;
  1272. get_count = 1;
  1273. }else{
  1274. loop = 1;
  1275. get_count = number;
  1276. }
  1277. if( itemdb_isequip2( item_data.get() ) ){
  1278. refine = cap_value( refine, 0, MAX_REFINE );
  1279. }else{
  1280. // All other items cannot be refined and are always identified
  1281. identify = 1;
  1282. refine = attr = 0;
  1283. }
  1284. for (i = 0; i < loop; i++) {
  1285. // if not pet egg
  1286. if (!pet_create_egg(sd, item_data->nameid)) {
  1287. struct item item_tmp = {};
  1288. item_tmp.nameid = item_data->nameid;
  1289. item_tmp.identify = identify;
  1290. item_tmp.refine = refine;
  1291. item_tmp.attribute = attr;
  1292. item_tmp.card[0] = c1;
  1293. item_tmp.card[1] = c2;
  1294. item_tmp.card[2] = c3;
  1295. item_tmp.card[3] = c4;
  1296. item_tmp.bound = bound;
  1297. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1298. clif_additem(sd, 0, 0, flag);
  1299. }
  1300. }
  1301. if (flag == 0)
  1302. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1303. } else {
  1304. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1305. return -1;
  1306. }
  1307. return 0;
  1308. }
  1309. /*==========================================
  1310. *
  1311. *------------------------------------------*/
  1312. ACMD_FUNC(itemreset)
  1313. {
  1314. int i;
  1315. nullpo_retr(-1, sd);
  1316. for (i = 0; i < MAX_INVENTORY; i++) {
  1317. 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])) {
  1318. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1319. }
  1320. }
  1321. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1322. return 0;
  1323. }
  1324. /*==========================================
  1325. * Atcommand @lvlup
  1326. *------------------------------------------*/
  1327. ACMD_FUNC(baselevelup)
  1328. {
  1329. int level=0, i=0, status_point=0, trait_point=0;
  1330. nullpo_retr(-1, sd);
  1331. level = atoi(message);
  1332. if (!message || !*message || !level) {
  1333. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1334. return -1;
  1335. }
  1336. if (level > 0) {
  1337. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1338. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1339. return -1;
  1340. } // End Addition
  1341. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1342. level = pc_maxbaselv(sd) - sd->status.base_level;
  1343. for (i = 0; i < level; i++)
  1344. {
  1345. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i);
  1346. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i);
  1347. }
  1348. sd->status.status_point += status_point;
  1349. sd->status.trait_point += trait_point;
  1350. sd->status.base_level += (unsigned int)level;
  1351. status_calc_pc(sd, SCO_FORCE);
  1352. status_percent_heal(&sd->bl, 100, 100);
  1353. clif_misceffect(&sd->bl, 0);
  1354. for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) {
  1355. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j);
  1356. achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_);
  1357. }
  1358. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1359. } else {
  1360. if (sd->status.base_level == 1) {
  1361. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1362. return -1;
  1363. }
  1364. level*=-1;
  1365. if ((unsigned int)level >= sd->status.base_level)
  1366. level = sd->status.base_level-1;
  1367. for (i = 0; i > -level; i--)
  1368. {
  1369. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i - 1);
  1370. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i - 1);
  1371. }
  1372. if (sd->status.status_point < status_point || sd->status.trait_point < trait_point)
  1373. pc_resetstate(sd);
  1374. if (sd->status.status_point < status_point)
  1375. sd->status.status_point = 0;
  1376. else
  1377. sd->status.status_point -= status_point;
  1378. if (sd->status.trait_point < trait_point)
  1379. sd->status.trait_point = 0;
  1380. else
  1381. sd->status.trait_point -= trait_point;
  1382. sd->status.base_level -= (unsigned int)level;
  1383. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1384. status_calc_pc(sd, SCO_FORCE);
  1385. level*=-1;
  1386. }
  1387. sd->status.base_exp = 0;
  1388. clif_updatestatus(sd, SP_STATUSPOINT);
  1389. clif_updatestatus(sd, SP_TRAITPOINT);
  1390. clif_updatestatus(sd, SP_BASELEVEL);
  1391. clif_updatestatus(sd, SP_BASEEXP);
  1392. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1393. pc_baselevelchanged(sd);
  1394. if(sd->status.party_id)
  1395. party_send_levelup(sd);
  1396. if( level > 0 && battle_config.atcommand_levelup_events )
  1397. npc_script_event(sd,NPCE_BASELVUP);
  1398. return 0;
  1399. }
  1400. /*==========================================
  1401. *
  1402. *------------------------------------------*/
  1403. ACMD_FUNC(joblevelup)
  1404. {
  1405. int level=0;
  1406. nullpo_retr(-1, sd);
  1407. level = atoi(message);
  1408. if (!message || !*message || !level) {
  1409. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1410. return -1;
  1411. }
  1412. if (level > 0) {
  1413. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1414. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1415. return -1;
  1416. }
  1417. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1418. level = pc_maxjoblv(sd) - sd->status.job_level;
  1419. sd->status.job_level += (unsigned int)level;
  1420. sd->status.skill_point += level;
  1421. clif_misceffect(&sd->bl, 1);
  1422. for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++)
  1423. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i);
  1424. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1425. } else {
  1426. if (sd->status.job_level == 1) {
  1427. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1428. return -1;
  1429. }
  1430. level *=-1;
  1431. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1432. level = sd->status.job_level-1;
  1433. sd->status.job_level -= (unsigned int)level;
  1434. if (sd->status.skill_point < level)
  1435. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1436. if (sd->status.skill_point < level)
  1437. sd->status.skill_point = 0;
  1438. else
  1439. sd->status.skill_point -= level;
  1440. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1441. level *=-1;
  1442. }
  1443. sd->status.job_exp = 0;
  1444. clif_updatestatus(sd, SP_JOBLEVEL);
  1445. clif_updatestatus(sd, SP_JOBEXP);
  1446. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1447. clif_updatestatus(sd, SP_SKILLPOINT);
  1448. status_calc_pc(sd, SCO_FORCE);
  1449. if( level > 0 && battle_config.atcommand_levelup_events )
  1450. npc_script_event(sd,NPCE_JOBLVUP);
  1451. return 0;
  1452. }
  1453. /*==========================================
  1454. * @help
  1455. *------------------------------------------*/
  1456. ACMD_FUNC(help){
  1457. const char *command_name = nullptr;
  1458. nullpo_retr(-1, sd);
  1459. if (!message || !*message) {
  1460. command_name = "help"; // If no command_name specified, display help for @help.
  1461. } else {
  1462. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1463. ++message;
  1464. command_name = atcommand_alias_db.checkAlias(message);
  1465. }
  1466. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1467. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1468. clif_displaymessage(fd, atcmd_output);
  1469. atcommand_get_suggestions(sd, command_name, true);
  1470. return -1;
  1471. }
  1472. // attempt to find the first default help command
  1473. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_name );
  1474. const char* text = info != nullptr ? info->help.c_str() : nullptr;
  1475. if( text == nullptr ){
  1476. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1477. clif_displaymessage(fd, atcmd_output);
  1478. atcommand_get_suggestions(sd, command_name, true);
  1479. return -1;
  1480. }
  1481. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1482. clif_displaymessage(fd, atcmd_output);
  1483. { // Display aliases
  1484. StringBuf buf;
  1485. bool has_aliases = false;
  1486. StringBuf_Init(&buf);
  1487. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1488. for( const std::string& alias : info->aliases ){
  1489. StringBuf_Printf( &buf, " %s", alias.c_str() );
  1490. has_aliases = true;
  1491. }
  1492. if (has_aliases)
  1493. clif_displaymessage(fd, StringBuf_Value(&buf));
  1494. StringBuf_Destroy(&buf);
  1495. }
  1496. // Display help contents
  1497. clif_displaymessage(fd, text);
  1498. return 0;
  1499. }
  1500. /*==========================================
  1501. *
  1502. *------------------------------------------*/
  1503. ACMD_FUNC(pvpoff)
  1504. {
  1505. nullpo_retr(-1, sd);
  1506. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1507. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1508. return -1;
  1509. }
  1510. map_setmapflag(sd->bl.m, MF_PVP, false);
  1511. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1512. return 0;
  1513. }
  1514. /*==========================================
  1515. *
  1516. *------------------------------------------*/
  1517. ACMD_FUNC(pvpon)
  1518. {
  1519. nullpo_retr(-1, sd);
  1520. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1521. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1522. return -1;
  1523. }
  1524. map_setmapflag(sd->bl.m, MF_PVP, true);
  1525. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1526. return 0;
  1527. }
  1528. /*==========================================
  1529. *
  1530. *------------------------------------------*/
  1531. ACMD_FUNC(gvgoff)
  1532. {
  1533. nullpo_retr(-1, sd);
  1534. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1535. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1536. return -1;
  1537. }
  1538. map_setmapflag(sd->bl.m, MF_GVG, false);
  1539. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1540. return 0;
  1541. }
  1542. /*==========================================
  1543. *
  1544. *------------------------------------------*/
  1545. ACMD_FUNC(gvgon)
  1546. {
  1547. nullpo_retr(-1, sd);
  1548. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1549. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1550. return -1;
  1551. }
  1552. map_setmapflag(sd->bl.m, MF_GVG, true);
  1553. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1554. return 0;
  1555. }
  1556. /*==========================================
  1557. *
  1558. *------------------------------------------*/
  1559. ACMD_FUNC(model)
  1560. {
  1561. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1562. nullpo_retr(-1, sd);
  1563. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1564. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1565. 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>).
  1566. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1567. clif_displaymessage(fd, atcmd_output);
  1568. return -1;
  1569. }
  1570. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1571. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1572. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1573. pc_changelook(sd, LOOK_HAIR, hair_style);
  1574. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1575. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1576. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1577. } else {
  1578. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1579. return -1;
  1580. }
  1581. return 0;
  1582. }
  1583. /*==========================================
  1584. * @bodystyle [Rytech]
  1585. *------------------------------------------*/
  1586. ACMD_FUNC(bodystyle)
  1587. {
  1588. int body_style = 0;
  1589. nullpo_retr(-1, sd);
  1590. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1591. 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) {
  1592. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1593. return -1;
  1594. }
  1595. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1596. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1597. clif_displaymessage(fd, atcmd_output);
  1598. return -1;
  1599. }
  1600. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1601. pc_changelook(sd, LOOK_BODY2, body_style);
  1602. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1603. } else {
  1604. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1605. return -1;
  1606. }
  1607. return 0;
  1608. }
  1609. /*==========================================
  1610. * @dye && @ccolor
  1611. *------------------------------------------*/
  1612. ACMD_FUNC(dye)
  1613. {
  1614. int cloth_color = 0;
  1615. nullpo_retr(-1, sd);
  1616. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1617. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1618. 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>).
  1619. clif_displaymessage(fd, atcmd_output);
  1620. return -1;
  1621. }
  1622. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1623. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1624. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1625. } else {
  1626. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1627. return -1;
  1628. }
  1629. return 0;
  1630. }
  1631. /*==========================================
  1632. * @hairstyle && @hstyle
  1633. *------------------------------------------*/
  1634. ACMD_FUNC(hair_style)
  1635. {
  1636. int hair_style = 0;
  1637. nullpo_retr(-1, sd);
  1638. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1639. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1640. 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>).
  1641. clif_displaymessage(fd, atcmd_output);
  1642. return -1;
  1643. }
  1644. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1645. pc_changelook(sd, LOOK_HAIR, hair_style);
  1646. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1647. } else {
  1648. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1649. return -1;
  1650. }
  1651. return 0;
  1652. }
  1653. /*==========================================
  1654. * @haircolor && @hcolor
  1655. *------------------------------------------*/
  1656. ACMD_FUNC(hair_color)
  1657. {
  1658. int hair_color = 0;
  1659. nullpo_retr(-1, sd);
  1660. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1661. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1662. 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>).
  1663. clif_displaymessage(fd, atcmd_output);
  1664. return -1;
  1665. }
  1666. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1667. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1668. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1669. } else {
  1670. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1671. return -1;
  1672. }
  1673. return 0;
  1674. }
  1675. /*==========================================
  1676. * @go [city_number or city_name] - Updated by Harbin
  1677. *------------------------------------------*/
  1678. ACMD_FUNC(go)
  1679. {
  1680. int i;
  1681. int town;
  1682. char map_name[MAP_NAME_LENGTH];
  1683. const struct {
  1684. char map[MAP_NAME_LENGTH];
  1685. int x, y;
  1686. } data[] = {
  1687. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1688. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1689. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1690. { MAP_PAYON, 162, 233 }, // 3=Payon
  1691. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1692. #ifdef RENEWAL
  1693. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1694. #else
  1695. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1696. #endif
  1697. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1698. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1699. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1700. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1701. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1702. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1703. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1704. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1705. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1706. #ifdef RENEWAL
  1707. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1708. #else
  1709. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1710. #endif
  1711. { MAP_JAIL, 23, 61 }, // 16=Prison
  1712. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1713. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1714. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1715. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1716. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1717. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1718. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1719. { MAP_VEINS, 216, 123 }, // 24=Veins
  1720. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1721. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1722. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1723. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1724. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1725. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1726. { MAP_MORA, 44, 151 }, // 31=Mora
  1727. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1728. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1729. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1730. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1731. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1732. };
  1733. nullpo_retr(-1, sd);
  1734. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1735. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1736. return 0;
  1737. }
  1738. memset(map_name, '\0', sizeof(map_name));
  1739. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1740. // get the number
  1741. town = atoi(message);
  1742. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1743. {// no value matched so send the list of locations
  1744. const char* text;
  1745. // attempt to find the text help string
  1746. text = atcommand_help_string( command );
  1747. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1748. if( text )
  1749. {// send the text to the client
  1750. clif_displaymessage( fd, text );
  1751. }
  1752. return -1;
  1753. }
  1754. // get possible name of the city
  1755. map_name[MAP_NAME_LENGTH-1] = '\0';
  1756. for (i = 0; map_name[i]; i++)
  1757. map_name[i] = TOLOWER(map_name[i]);
  1758. // try to identify the map name
  1759. if (strncmp(map_name, "prontera", 3) == 0) {
  1760. town = 0;
  1761. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1762. strncmp(map_name, "morroc", 4) == 0) {
  1763. town = 1;
  1764. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1765. town = 2;
  1766. } else if (strncmp(map_name, "payon", 3) == 0) {
  1767. town = 3;
  1768. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1769. town = 4;
  1770. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1771. town = 5;
  1772. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1773. town = 6;
  1774. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1775. strcmp(map_name, "christmas") == 0 ||
  1776. strncmp(map_name, "xmas", 3) == 0 ||
  1777. strncmp(map_name, "x-mas", 3) == 0) {
  1778. town = 7;
  1779. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1780. town = 8;
  1781. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1782. strncmp(map_name, "yuno", 3) == 0) {
  1783. town = 9;
  1784. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1785. town = 10;
  1786. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1787. strncmp(map_name, "gonryun", 3) == 0) {
  1788. town = 11;
  1789. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1790. town = 12;
  1791. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1792. town = 13;
  1793. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1794. town = 14;
  1795. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1796. strncmp(map_name, "startpoint", 3) == 0 ||
  1797. strncmp(map_name, "beginning", 3) == 0) {
  1798. town = 15;
  1799. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1800. strncmp(map_name, "prison", 3) == 0 ||
  1801. strncmp(map_name, "jail", 3) == 0) {
  1802. town = 16;
  1803. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1804. town = 17;
  1805. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1806. town = 18;
  1807. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1808. town = 19;
  1809. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1810. town = 20;
  1811. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1812. town = 21;
  1813. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1814. town = 22;
  1815. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1816. town = 23;
  1817. } else if (strncmp(map_name, "veins", 3) == 0) {
  1818. town = 24;
  1819. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1820. town = 25;
  1821. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1822. town = 26;
  1823. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1824. town = 27;
  1825. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1826. town = 28;
  1827. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1828. town = 29;
  1829. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1830. town = 30;
  1831. } else if (strcmp(map_name, "mora") == 0) {
  1832. town = 31;
  1833. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1834. town = 32;
  1835. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1836. town = 33;
  1837. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1838. town = 34;
  1839. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1840. town = 35;
  1841. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1842. town = 36;
  1843. }
  1844. if (town >= 0 && town < ARRAYLENGTH(data))
  1845. {
  1846. int16 m = map_mapname2mapid(data[town].map);
  1847. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1848. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1849. return -1;
  1850. }
  1851. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1852. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1853. return -1;
  1854. }
  1855. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1856. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1857. } else {
  1858. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1859. return -1;
  1860. }
  1861. } else { // if you arrive here, you have an error in town variable when reading of names
  1862. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1863. return -1;
  1864. }
  1865. return 0;
  1866. }
  1867. /*==========================================
  1868. *
  1869. *------------------------------------------*/
  1870. ACMD_FUNC(monster)
  1871. {
  1872. char name[NAME_LENGTH];
  1873. char monster[NAME_LENGTH];
  1874. char eventname[EVENT_NAME_LENGTH] = "";
  1875. int mob_id;
  1876. int number = 0;
  1877. int count;
  1878. int i, range;
  1879. short mx, my;
  1880. unsigned int size;
  1881. nullpo_retr(-1, sd);
  1882. memset(name, '\0', sizeof(name));
  1883. memset(monster, '\0', sizeof(monster));
  1884. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1885. if (!message || !*message) {
  1886. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1887. return -1;
  1888. }
  1889. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1890. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1891. //All data can be left as it is.
  1892. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1893. //Here, it is possible name was not given and we are using monster for it.
  1894. if (count < 3) //Blank mob's name.
  1895. name[0] = '\0';
  1896. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1897. //All data can be left as it is.
  1898. } else if (sscanf(message, "%23s", monster) > 0) {
  1899. //As before, name may be already filled.
  1900. name[0] = '\0';
  1901. } else {
  1902. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1903. return -1;
  1904. }
  1905. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1906. mob_id = mobdb_checkid(atoi(monster));
  1907. if (mob_id == 0) {
  1908. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1909. return -1;
  1910. }
  1911. if (mob_id == MOBID_EMPERIUM) {
  1912. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1913. return -1;
  1914. }
  1915. if (number <= 0)
  1916. number = 1;
  1917. if( !name[0] )
  1918. strcpy(name, "--ja--");
  1919. // 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
  1920. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1921. number = battle_config.atc_spawn_quantity_limit;
  1922. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1923. if (strcmp(parent_cmd, "monstersmall") == 0)
  1924. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1925. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1926. size = SZ_BIG;
  1927. else
  1928. size = SZ_SMALL;
  1929. if (battle_config.etc_log)
  1930. 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);
  1931. count = 0;
  1932. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1933. for (i = 0; i < number; i++) {
  1934. int k;
  1935. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1936. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1937. if(k) {
  1938. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1939. count ++;
  1940. }
  1941. }
  1942. if (count != 0)
  1943. if (number == count)
  1944. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1945. else {
  1946. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1947. clif_displaymessage(fd, atcmd_output);
  1948. }
  1949. else {
  1950. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1951. return -1;
  1952. }
  1953. return 0;
  1954. }
  1955. /*==========================================
  1956. *
  1957. *------------------------------------------*/
  1958. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1959. {
  1960. struct mob_data *md;
  1961. int flag;
  1962. nullpo_ret(md=(struct mob_data *)bl);
  1963. flag = va_arg(ap, int);
  1964. if (md->guardian_data)
  1965. return 0; //Do not touch WoE mobs!
  1966. if (flag)
  1967. status_zap(bl,md->status.hp, 0);
  1968. else
  1969. status_kill(bl);
  1970. return 1;
  1971. }
  1972. ACMD_FUNC(killmonster)
  1973. {
  1974. int map_id, drop_flag;
  1975. char map_name[MAP_NAME_LENGTH_EXT];
  1976. nullpo_retr(-1, sd);
  1977. memset(map_name, '\0', sizeof(map_name));
  1978. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1979. map_id = sd->bl.m;
  1980. else {
  1981. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1982. map_id = sd->bl.m;
  1983. }
  1984. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1985. drop_flag = strcmpi(parent_cmd, "killmonster2");
  1986. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1987. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1988. return 0;
  1989. }
  1990. /*==========================================
  1991. *
  1992. *------------------------------------------*/
  1993. ACMD_FUNC(refine)
  1994. {
  1995. int j, position = 0, refine = 0, current_position, final_refine;
  1996. int count;
  1997. nullpo_retr(-1, sd);
  1998. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1999. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  2000. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  2001. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2002. clif_displaymessage(fd, atcmd_output);
  2003. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2004. clif_displaymessage(fd, atcmd_output);
  2005. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2006. clif_displaymessage(fd, atcmd_output);
  2007. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2008. clif_displaymessage(fd, atcmd_output);
  2009. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2010. clif_displaymessage(fd, atcmd_output);
  2011. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2012. clif_displaymessage(fd, atcmd_output);
  2013. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2014. clif_displaymessage(fd, atcmd_output);
  2015. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2016. clif_displaymessage(fd, atcmd_output);
  2017. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2018. clif_displaymessage(fd, atcmd_output);
  2019. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2020. clif_displaymessage(fd, atcmd_output);
  2021. return -1;
  2022. }
  2023. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2024. count = 0;
  2025. for (j = 0; j < EQI_MAX; j++) {
  2026. int i;
  2027. if ((i = sd->equip_index[j]) < 0)
  2028. continue;
  2029. if(j == EQI_AMMO)
  2030. continue;
  2031. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2032. continue;
  2033. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2034. continue;
  2035. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  2036. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  2037. sd->inventory.u.items_inventory[i].refine = final_refine;
  2038. current_position = sd->inventory.u.items_inventory[i].equip;
  2039. pc_unequipitem(sd, i, 3);
  2040. clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine);
  2041. clif_delitem(sd, i, 1, 3);
  2042. clif_additem(sd, i, 1, 0);
  2043. pc_equipitem(sd, i, current_position);
  2044. clif_misceffect(&sd->bl, 3);
  2045. if( sd->inventory_data[i]->type == IT_WEAPON ){
  2046. achievement_update_objective(sd, AG_ENCHANT_SUCCESS, 2, sd->inventory_data[i]->weapon_level, sd->inventory.u.items_inventory[i].refine);
  2047. }
  2048. count++;
  2049. }
  2050. }
  2051. if (count == 0)
  2052. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2053. else if (count == 1)
  2054. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2055. else {
  2056. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2057. clif_displaymessage(fd, atcmd_output);
  2058. }
  2059. return 0;
  2060. }
  2061. /*==========================================
  2062. *
  2063. *------------------------------------------*/
  2064. ACMD_FUNC(produce)
  2065. {
  2066. char item_name[100];
  2067. t_itemid item_id;
  2068. int attribute = 0, star = 0;
  2069. nullpo_retr(-1, sd);
  2070. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2071. memset(item_name, '\0', sizeof(item_name));
  2072. if (!message || !*message || (
  2073. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2074. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2075. )) {
  2076. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2077. return -1;
  2078. }
  2079. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  2080. if( item_data == nullptr ){
  2081. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  2082. }
  2083. if( item_data == nullptr ){
  2084. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2085. return -1;
  2086. }
  2087. item_id = item_data->nameid;
  2088. if( itemdb_isequip2( item_data.get() ) ){
  2089. char flag = 0;
  2090. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2091. attribute = ATTRIBUTE_NORMAL;
  2092. if (star < MIN_STAR || star > MAX_STAR)
  2093. star = 0;
  2094. struct item tmp_item = {};
  2095. tmp_item.nameid = item_id;
  2096. tmp_item.amount = 1;
  2097. tmp_item.identify = 1;
  2098. tmp_item.card[0] = CARD0_FORGE;
  2099. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2100. ((star*5) << 8) + attribute:0;
  2101. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2102. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2103. clif_produceeffect(sd, 0, item_id);
  2104. clif_misceffect(&sd->bl, 3);
  2105. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2106. clif_additem(sd, 0, 0, flag);
  2107. } else {
  2108. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name.c_str()); // The item (%u: '%s') is not equipable.
  2109. clif_displaymessage(fd, atcmd_output);
  2110. return -1;
  2111. }
  2112. return 0;
  2113. }
  2114. /*==========================================
  2115. *
  2116. *------------------------------------------*/
  2117. ACMD_FUNC(memo)
  2118. {
  2119. int position = 0;
  2120. nullpo_retr(-1, sd);
  2121. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2122. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2123. {
  2124. int i;
  2125. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2126. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2127. {
  2128. if( sd->status.memo_point[i].map )
  2129. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  2130. else
  2131. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2132. clif_displaymessage(sd->fd, atcmd_output);
  2133. }
  2134. return 0;
  2135. }
  2136. if( position < 0 || position >= MAX_MEMOPOINTS )
  2137. {
  2138. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2139. clif_displaymessage(fd, atcmd_output);
  2140. return -1;
  2141. }
  2142. return !pc_memo( sd, position );
  2143. }
  2144. /*==========================================
  2145. *
  2146. *------------------------------------------*/
  2147. ACMD_FUNC(gat)
  2148. {
  2149. int y;
  2150. nullpo_retr(-1, sd);
  2151. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2152. for (y = 2; y >= -2; y--) {
  2153. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2154. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2155. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2156. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2157. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2158. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2159. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2160. clif_displaymessage(fd, atcmd_output);
  2161. }
  2162. return 0;
  2163. }
  2164. /*==========================================
  2165. *
  2166. *------------------------------------------*/
  2167. ACMD_FUNC(displaystatus)
  2168. {
  2169. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2170. nullpo_retr(-1, sd);
  2171. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2172. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2173. return -1;
  2174. }
  2175. if (i < 2) flag = 1;
  2176. if (i < 3) tick = 0;
  2177. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2178. return 0;
  2179. }
  2180. /*==========================================
  2181. * @stpoint (Rewritten by [Yor])
  2182. *------------------------------------------*/
  2183. ACMD_FUNC(statuspoint)
  2184. {
  2185. int point;
  2186. unsigned int new_status_point;
  2187. if (!message || !*message || (point = atoi(message)) == 0) {
  2188. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2189. return -1;
  2190. }
  2191. if(point < 0)
  2192. {
  2193. if(sd->status.status_point < (unsigned int)(-point))
  2194. {
  2195. new_status_point = 0;
  2196. }
  2197. else
  2198. {
  2199. new_status_point = sd->status.status_point + point;
  2200. }
  2201. }
  2202. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2203. {
  2204. new_status_point = UINT_MAX;
  2205. }
  2206. else
  2207. {
  2208. new_status_point = sd->status.status_point + point;
  2209. }
  2210. if (new_status_point != sd->status.status_point) {
  2211. sd->status.status_point = new_status_point;
  2212. clif_updatestatus(sd, SP_STATUSPOINT);
  2213. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2214. } else {
  2215. if (point < 0)
  2216. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2217. else
  2218. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2219. return -1;
  2220. }
  2221. return 0;
  2222. }
  2223. /*==========================================
  2224. * @trpoint
  2225. *------------------------------------------*/
  2226. ACMD_FUNC(traitpoint)
  2227. {
  2228. int point;
  2229. unsigned int new_trait_point;
  2230. if (!message || !*message || (point = atoi(message)) == 0) {
  2231. clif_displaymessage(fd, msg_txt(sd, 820)); // Please enter a number (usage: @trpoint <number of points>).
  2232. return -1;
  2233. }
  2234. if (point < 0)
  2235. {
  2236. if (sd->status.trait_point < (unsigned int)(-point))
  2237. {
  2238. new_trait_point = 0;
  2239. }
  2240. else
  2241. {
  2242. new_trait_point = sd->status.trait_point + point;
  2243. }
  2244. }
  2245. else if (UINT_MAX - sd->status.trait_point < (unsigned int)point)
  2246. {
  2247. new_trait_point = UINT_MAX;
  2248. }
  2249. else
  2250. {
  2251. new_trait_point = sd->status.trait_point + point;
  2252. }
  2253. if (new_trait_point != sd->status.trait_point) {
  2254. sd->status.trait_point = new_trait_point;
  2255. clif_updatestatus(sd, SP_TRAITPOINT);
  2256. clif_displaymessage(fd, msg_txt(sd, 174)); // Number of status points changed.
  2257. }
  2258. else {
  2259. if (point < 0)
  2260. clif_displaymessage(fd, msg_txt(sd, 41)); // Unable to decrease the number/value.
  2261. else
  2262. clif_displaymessage(fd, msg_txt(sd, 149)); // Unable to increase the number/value.
  2263. return -1;
  2264. }
  2265. return 0;
  2266. }
  2267. /*==========================================
  2268. * @skpoint (Rewritten by [Yor])
  2269. *------------------------------------------*/
  2270. ACMD_FUNC(skillpoint)
  2271. {
  2272. int point;
  2273. unsigned int new_skill_point;
  2274. nullpo_retr(-1, sd);
  2275. if (!message || !*message || (point = atoi(message)) == 0) {
  2276. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2277. return -1;
  2278. }
  2279. if(point < 0)
  2280. {
  2281. if(sd->status.skill_point < (unsigned int)(-point))
  2282. {
  2283. new_skill_point = 0;
  2284. }
  2285. else
  2286. {
  2287. new_skill_point = sd->status.skill_point + point;
  2288. }
  2289. }
  2290. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2291. {
  2292. new_skill_point = UINT_MAX;
  2293. }
  2294. else
  2295. {
  2296. new_skill_point = sd->status.skill_point + point;
  2297. }
  2298. if (new_skill_point != sd->status.skill_point) {
  2299. sd->status.skill_point = new_skill_point;
  2300. clif_updatestatus(sd, SP_SKILLPOINT);
  2301. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2302. } else {
  2303. if (point < 0)
  2304. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2305. else
  2306. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2307. return -1;
  2308. }
  2309. return 0;
  2310. }
  2311. /*==========================================
  2312. * @zeny
  2313. *------------------------------------------*/
  2314. ACMD_FUNC(zeny)
  2315. {
  2316. int zeny=0, ret=-1;
  2317. nullpo_retr(-1, sd);
  2318. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2319. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2320. return -1;
  2321. }
  2322. if(zeny > 0){
  2323. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2324. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2325. }
  2326. else {
  2327. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2328. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2329. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2330. }
  2331. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2332. return 0;
  2333. }
  2334. /*==========================================
  2335. *
  2336. *------------------------------------------*/
  2337. ACMD_FUNC(param)
  2338. {
  2339. nullpo_retr(-1, sd);
  2340. uint8 stat;
  2341. int value = 0;
  2342. uint16 new_value, status, max_status;
  2343. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2344. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2345. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2346. return -1;
  2347. }
  2348. ARR_FIND( 0, ARRAYLENGTH(parameter_names), stat, strcmpi(command + 1, parameter_names[stat]) == 0 );
  2349. if( stat == ARRAYLENGTH(parameter_names)) { // normally impossible...
  2350. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2351. return -1;
  2352. }
  2353. if( stat < PARAM_POW ){
  2354. status = pc_getstat( sd, SP_STR + stat - PARAM_STR );
  2355. }else{
  2356. if( !( sd->class_ & JOBL_FOURTH ) ){
  2357. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2358. return -1;
  2359. }
  2360. status = pc_getstat( sd, SP_POW + stat - PARAM_POW );
  2361. }
  2362. if( pc_has_permission( sd, PC_PERM_BYPASS_MAX_STAT ) ){
  2363. max_status = SHRT_MAX;
  2364. }else{
  2365. max_status = pc_maxparameter( sd, static_cast<e_params>( stat ) );
  2366. }
  2367. if( value > 0 && status + value >= max_status ){
  2368. new_value = max_status;
  2369. }else if( value < 0 && abs( value ) >= status ){
  2370. if( stat < PARAM_POW ){
  2371. new_value = 1;
  2372. }else{
  2373. new_value = 0;
  2374. }
  2375. }else{
  2376. new_value = status + value;
  2377. }
  2378. if( new_value != status ){
  2379. if (stat < PARAM_POW) {
  2380. pc_setstat( sd, SP_STR + stat - PARAM_STR, new_value );
  2381. clif_updatestatus(sd, SP_STR + stat);
  2382. clif_updatestatus(sd, SP_USTR + stat);
  2383. } else {
  2384. pc_setstat( sd, SP_POW + stat - PARAM_POW, new_value );
  2385. clif_updatestatus(sd, SP_POW + stat - PARAM_POW);
  2386. clif_updatestatus(sd, SP_UPOW + stat - PARAM_POW);
  2387. }
  2388. status_calc_pc(sd, SCO_FORCE);
  2389. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2390. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2391. } else {
  2392. if (value < 0)
  2393. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2394. else
  2395. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2396. return -1;
  2397. }
  2398. return 0;
  2399. }
  2400. /*==========================================
  2401. * Stat all by fritz (rewritten by [Yor])
  2402. *------------------------------------------*/
  2403. ACMD_FUNC(stat_all)
  2404. {
  2405. nullpo_retr(-1, sd);
  2406. int value = 0;
  2407. uint8 count, i;
  2408. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2409. for (i = PARAM_STR; i < PARAM_POW; i++)
  2410. status[i] = pc_getstat(sd, SP_STR + i);
  2411. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2412. for (i = PARAM_STR; i < PARAM_POW; i++)
  2413. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2414. value = SHRT_MAX;
  2415. } else {
  2416. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2417. for (i = PARAM_STR; i < PARAM_POW; i++)
  2418. max_status[i] = SHRT_MAX;
  2419. } else {
  2420. for (i = PARAM_STR; i < PARAM_POW; i++)
  2421. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2422. }
  2423. }
  2424. count = 0;
  2425. for (i = PARAM_STR; i < PARAM_POW; i++) {
  2426. short new_value;
  2427. if (value > 0 && status[i] + value >= max_status[i])
  2428. new_value = max_status[i];
  2429. else if (value < 0 && abs(value) >= status[i])
  2430. new_value = 1;
  2431. else
  2432. new_value = status[i] + value;
  2433. if (new_value != status[i]) {
  2434. pc_setstat( sd, SP_STR + i, new_value );
  2435. clif_updatestatus(sd, SP_STR + i);
  2436. clif_updatestatus(sd, SP_USTR + i);
  2437. count++;
  2438. }
  2439. }
  2440. if (count > 0) { // if at least 1 stat modified
  2441. status_calc_pc(sd, SCO_FORCE);
  2442. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2443. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2444. } else {
  2445. if (value < 0)
  2446. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2447. else
  2448. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2449. return -1;
  2450. }
  2451. return 0;
  2452. }
  2453. /*==========================================
  2454. * Traits
  2455. *------------------------------------------*/
  2456. ACMD_FUNC(trait_all) {
  2457. nullpo_retr(-1, sd);
  2458. #ifndef RENEWAL
  2459. sprintf(atcmd_output, msg_txt(sd, 154), command); // %s failed.
  2460. clif_displaymessage(fd, atcmd_output);
  2461. return -1;
  2462. #endif
  2463. if( !( sd->class_ & JOBL_FOURTH ) ){
  2464. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2465. return -1;
  2466. }
  2467. int value = 0;
  2468. uint8 i;
  2469. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2470. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2471. status[i] = pc_getstat(sd, SP_POW + i - PARAM_POW);
  2472. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2473. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2474. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2475. value = SHRT_MAX;
  2476. } else {
  2477. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2478. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2479. max_status[i] = SHRT_MAX;
  2480. } else {
  2481. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2482. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2483. }
  2484. }
  2485. uint8 count = 0;
  2486. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  2487. short new_value;
  2488. if (value > 0 && status[i] + value >= max_status[i])
  2489. new_value = max_status[i];
  2490. else if (value < 0 && abs(value) >= status[i])
  2491. new_value = 0;
  2492. else
  2493. new_value = status[i] + value;
  2494. if (new_value != status[i]) {
  2495. pc_setstat( sd, SP_POW + i - PARAM_POW, new_value );
  2496. clif_updatestatus(sd, SP_POW + i - PARAM_POW);
  2497. clif_updatestatus(sd, SP_UPOW + i - PARAM_POW);
  2498. count++;
  2499. }
  2500. }
  2501. if (count > 0) { // if at least 1 stat modified
  2502. status_calc_pc(sd, SCO_FORCE);
  2503. clif_displaymessage(fd, msg_txt(sd, 84)); // All stats changed!
  2504. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2505. } else {
  2506. if (value < 0)
  2507. clif_displaymessage(fd, msg_txt(sd, 177)); // You cannot decrease that stat anymore.
  2508. else
  2509. clif_displaymessage(fd, msg_txt(sd, 178)); // You cannot increase that stat anymore.
  2510. return -1;
  2511. }
  2512. return 0;
  2513. }
  2514. /*==========================================
  2515. *
  2516. *------------------------------------------*/
  2517. ACMD_FUNC(guildlevelup) {
  2518. int level = 0;
  2519. short added_level;
  2520. struct guild *guild_info;
  2521. nullpo_retr(-1, sd);
  2522. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2523. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2524. return -1;
  2525. }
  2526. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2527. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2528. return -1;
  2529. }
  2530. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2531. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2532. // return -1;
  2533. //}
  2534. added_level = (short)level;
  2535. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2536. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2537. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2538. added_level = 1 - guild_info->guild_lv;
  2539. if (added_level != 0) {
  2540. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2541. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2542. } else {
  2543. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2544. return -1;
  2545. }
  2546. return 0;
  2547. }
  2548. /*==========================================
  2549. *
  2550. *------------------------------------------*/
  2551. ACMD_FUNC(makeegg) {
  2552. int id;
  2553. nullpo_retr(-1, sd);
  2554. if (!message || !*message) {
  2555. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2556. return -1;
  2557. }
  2558. // for monster name
  2559. if ((id = mobdb_searchname(message)) != 0)
  2560. ;
  2561. else
  2562. id = atoi(message);
  2563. std::shared_ptr<s_pet_db> pet = pet_db.find(id);
  2564. if( pet == nullptr ){
  2565. t_itemid nameid;
  2566. // for egg name
  2567. std::shared_ptr<item_data> item_data = item_db.searchname( message );
  2568. if( item_data != nullptr ){
  2569. nameid = item_data->nameid;
  2570. }else{
  2571. nameid = strtoul( message, nullptr, 10 );
  2572. }
  2573. pet = pet_db_search( nameid, PET_EGG );
  2574. }
  2575. int res(-1);
  2576. if (pet != nullptr) {
  2577. std::shared_ptr<s_mob_db> mdb = mob_db.find(pet->class_);
  2578. if(mdb){
  2579. sd->catch_target_class = pet->class_;
  2580. 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())){
  2581. res = 0;
  2582. } else {
  2583. res = -2; //char server down
  2584. }
  2585. }
  2586. }
  2587. switch(res){
  2588. case -1:
  2589. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2590. break;
  2591. case -2:
  2592. clif_displaymessage(fd, msg_txt(sd,407)); //charserver link broken
  2593. break;
  2594. }
  2595. return res;
  2596. }
  2597. /*==========================================
  2598. *
  2599. *------------------------------------------*/
  2600. ACMD_FUNC(hatch) {
  2601. nullpo_retr(-1, sd);
  2602. if (sd->status.pet_id <= 0)
  2603. clif_sendegg(sd);
  2604. else {
  2605. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2606. return -1;
  2607. }
  2608. return 0;
  2609. }
  2610. /*==========================================
  2611. *
  2612. *------------------------------------------*/
  2613. ACMD_FUNC(petfriendly) {
  2614. int friendly;
  2615. struct pet_data *pd;
  2616. nullpo_retr(-1, sd);
  2617. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2618. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2619. return -1;
  2620. }
  2621. pd = sd->pd;
  2622. if (!pd) {
  2623. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2624. return -1;
  2625. }
  2626. if (friendly < 0 || friendly > 1000)
  2627. {
  2628. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2629. return -1;
  2630. }
  2631. if (friendly == pd->pet.intimate) {
  2632. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2633. return -1;
  2634. }
  2635. pet_set_intimate(pd, friendly);
  2636. clif_send_petstatus(sd);
  2637. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2638. return 0;
  2639. }
  2640. /*==========================================
  2641. *
  2642. *------------------------------------------*/
  2643. ACMD_FUNC(pethungry)
  2644. {
  2645. int hungry;
  2646. struct pet_data *pd;
  2647. nullpo_retr(-1, sd);
  2648. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2649. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2650. return -1;
  2651. }
  2652. pd = sd->pd;
  2653. if (!sd->status.pet_id || !pd) {
  2654. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2655. return -1;
  2656. }
  2657. if (hungry < 0 || hungry > 100) {
  2658. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2659. return -1;
  2660. }
  2661. if (hungry == pd->pet.hungry) {
  2662. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2663. return -1;
  2664. }
  2665. pd->pet.hungry = hungry;
  2666. clif_send_petstatus(sd);
  2667. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2668. return 0;
  2669. }
  2670. /*==========================================
  2671. *
  2672. *------------------------------------------*/
  2673. ACMD_FUNC(petrename)
  2674. {
  2675. struct pet_data *pd;
  2676. nullpo_retr(-1, sd);
  2677. if (!sd->status.pet_id || !sd->pd) {
  2678. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2679. return -1;
  2680. }
  2681. pd = sd->pd;
  2682. if (!pd->pet.rename_flag) {
  2683. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2684. return -1;
  2685. }
  2686. pd->pet.rename_flag = 0;
  2687. intif_save_petdata(sd->status.account_id, &pd->pet);
  2688. clif_send_petstatus(sd);
  2689. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2690. return 0;
  2691. }
  2692. /*==========================================
  2693. *
  2694. *------------------------------------------*/
  2695. ACMD_FUNC(recall) {
  2696. struct map_session_data *pl_sd = NULL;
  2697. nullpo_retr(-1, sd);
  2698. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2699. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2700. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2701. return -1;
  2702. }
  2703. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2704. {
  2705. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2706. return -1;
  2707. }
  2708. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2709. {
  2710. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2711. return -1;
  2712. }
  2713. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2714. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2715. return -1;
  2716. }
  2717. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2718. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2719. return -1;
  2720. }
  2721. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2722. return -1;
  2723. }
  2724. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2725. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2726. return -1;
  2727. }
  2728. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2729. clif_displaymessage(fd, atcmd_output);
  2730. return 0;
  2731. }
  2732. /*==========================================
  2733. * charblock command (usage: charblock <player_name>)
  2734. * This command do a definitiv ban on a player
  2735. *------------------------------------------*/
  2736. ACMD_FUNC(char_block)
  2737. {
  2738. nullpo_retr(-1, sd);
  2739. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2740. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2741. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2742. clif_displaymessage(fd, atcmd_output);
  2743. return -1;
  2744. }
  2745. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2746. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2747. clif_displaymessage(fd, atcmd_output);
  2748. return 0;
  2749. }
  2750. /*==========================================
  2751. * accountban command (usage: ban <%time> <player_name>)
  2752. * charban command (usage: charban <%time> <player_name>)
  2753. * %time see common/timer.cpp::solve_time()
  2754. *------------------------------------------*/
  2755. ACMD_FUNC(char_ban)
  2756. {
  2757. char *modif_p, output[CHAT_SIZE_MAX];
  2758. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2759. enum chrif_req_op bantype;
  2760. nullpo_retr(-1, sd);
  2761. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2762. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2763. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2764. if (strcmpi(parent_cmd,"charban") == 0)
  2765. bantype = CHRIF_OP_BAN;
  2766. else if (strcmpi(parent_cmd,"ban") == 0)
  2767. bantype = CHRIF_OP_LOGIN_BAN;
  2768. else
  2769. return -1;
  2770. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2771. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2772. clif_displaymessage(fd, output);
  2773. return -1;
  2774. }
  2775. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2776. modif_p = atcmd_output;
  2777. timediff = (int32)solve_time(modif_p); //discard seconds
  2778. if (timediff == 0) { //allow negative ?
  2779. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2780. clif_displaymessage(fd, output);
  2781. 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.
  2782. return -1;
  2783. }
  2784. if( timediff < 0 && (
  2785. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2786. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2787. ))
  2788. {
  2789. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2790. return -1;
  2791. }
  2792. if (bantype == CHRIF_OP_BAN)
  2793. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2794. else
  2795. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2796. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2797. clif_displaymessage(fd, output);
  2798. return 0;
  2799. }
  2800. /*==========================================
  2801. * charunblock command (usage: charunblock <player_name>)
  2802. *------------------------------------------*/
  2803. ACMD_FUNC(char_unblock)
  2804. {
  2805. nullpo_retr(-1, sd);
  2806. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2807. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2808. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2809. clif_displaymessage(fd, atcmd_output);
  2810. return -1;
  2811. }
  2812. // send answer to login server via char-server
  2813. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2814. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2815. clif_displaymessage(fd, atcmd_output);
  2816. return 0;
  2817. }
  2818. /*==========================================
  2819. * acc unban command (usage: unban <player_name>)
  2820. * char unban command (usage: charunban <player_name>)
  2821. *------------------------------------------*/
  2822. ACMD_FUNC(char_unban){
  2823. enum chrif_req_op unbantype;
  2824. nullpo_retr(-1, sd);
  2825. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2826. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2827. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2828. if (strcmpi(parent_cmd,"charunban") == 0)
  2829. unbantype = CHRIF_OP_UNBAN;
  2830. else if (strcmpi(parent_cmd,"unban") == 0)
  2831. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2832. else
  2833. return -1;
  2834. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2835. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2836. clif_displaymessage(fd, atcmd_output);
  2837. return -1;
  2838. }
  2839. if (unbantype == CHRIF_OP_UNBAN)
  2840. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2841. else
  2842. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2843. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2844. clif_displaymessage(fd, atcmd_output);
  2845. return 0;
  2846. }
  2847. /*==========================================
  2848. *
  2849. *------------------------------------------*/
  2850. ACMD_FUNC(night)
  2851. {
  2852. nullpo_retr(-1, sd);
  2853. if (night_flag != 1) {
  2854. map_night_timer(night_timer_tid, 0, 0, 1);
  2855. } else {
  2856. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2857. return -1;
  2858. }
  2859. return 0;
  2860. }
  2861. /*==========================================
  2862. *
  2863. *------------------------------------------*/
  2864. ACMD_FUNC(day)
  2865. {
  2866. nullpo_retr(-1, sd);
  2867. if (night_flag != 0) {
  2868. map_day_timer(day_timer_tid, 0, 0, 1);
  2869. } else {
  2870. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2871. return -1;
  2872. }
  2873. return 0;
  2874. }
  2875. /*==========================================
  2876. *
  2877. *------------------------------------------*/
  2878. ACMD_FUNC(doom)
  2879. {
  2880. struct map_session_data* pl_sd;
  2881. struct s_mapiterator* iter;
  2882. nullpo_retr(-1, sd);
  2883. iter = mapit_getallusers();
  2884. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2885. {
  2886. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2887. {
  2888. status_kill(&pl_sd->bl);
  2889. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2890. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2891. }
  2892. }
  2893. mapit_free(iter);
  2894. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2895. return 0;
  2896. }
  2897. /*==========================================
  2898. *
  2899. *------------------------------------------*/
  2900. ACMD_FUNC(doommap)
  2901. {
  2902. struct map_session_data* pl_sd;
  2903. struct s_mapiterator* iter;
  2904. nullpo_retr(-1, sd);
  2905. iter = mapit_getallusers();
  2906. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2907. {
  2908. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2909. {
  2910. status_kill(&pl_sd->bl);
  2911. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2912. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2913. }
  2914. }
  2915. mapit_free(iter);
  2916. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2917. return 0;
  2918. }
  2919. /*==========================================
  2920. *
  2921. *------------------------------------------*/
  2922. static void atcommand_raise_sub(struct map_session_data* sd) {
  2923. status_revive(&sd->bl, 100, 100);
  2924. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2925. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2926. }
  2927. /*==========================================
  2928. *
  2929. *------------------------------------------*/
  2930. ACMD_FUNC(raise)
  2931. {
  2932. struct map_session_data* pl_sd;
  2933. struct s_mapiterator* iter;
  2934. nullpo_retr(-1, sd);
  2935. iter = mapit_getallusers();
  2936. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2937. if( pc_isdead(pl_sd) )
  2938. atcommand_raise_sub(pl_sd);
  2939. mapit_free(iter);
  2940. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2941. return 0;
  2942. }
  2943. /*==========================================
  2944. *
  2945. *------------------------------------------*/
  2946. ACMD_FUNC(raisemap)
  2947. {
  2948. struct map_session_data* pl_sd;
  2949. struct s_mapiterator* iter;
  2950. nullpo_retr(-1, sd);
  2951. iter = mapit_getallusers();
  2952. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2953. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2954. atcommand_raise_sub(pl_sd);
  2955. mapit_free(iter);
  2956. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2957. return 0;
  2958. }
  2959. /*==========================================
  2960. *
  2961. *------------------------------------------*/
  2962. ACMD_FUNC(kick)
  2963. {
  2964. struct map_session_data *pl_sd;
  2965. nullpo_retr(-1, sd);
  2966. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2967. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2968. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2969. return -1;
  2970. }
  2971. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2972. {
  2973. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2974. return -1;
  2975. }
  2976. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2977. {
  2978. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2979. return -1;
  2980. }
  2981. clif_GM_kick(sd, pl_sd);
  2982. return 0;
  2983. }
  2984. /*==========================================
  2985. *
  2986. *------------------------------------------*/
  2987. ACMD_FUNC(kickall)
  2988. {
  2989. struct map_session_data* pl_sd;
  2990. struct s_mapiterator* iter;
  2991. nullpo_retr(-1, sd);
  2992. iter = mapit_getallusers();
  2993. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2994. {
  2995. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2996. if (sd->status.account_id != pl_sd->status.account_id)
  2997. clif_GM_kick(NULL, pl_sd);
  2998. }
  2999. }
  3000. mapit_free(iter);
  3001. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  3002. return 0;
  3003. }
  3004. /*==========================================
  3005. *
  3006. *------------------------------------------*/
  3007. ACMD_FUNC(allskill)
  3008. {
  3009. nullpo_retr(-1, sd);
  3010. pc_allskillup(sd); // all skills
  3011. sd->status.skill_point = 0; // 0 skill points
  3012. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3013. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  3014. return 0;
  3015. }
  3016. /*==========================================
  3017. *
  3018. *------------------------------------------*/
  3019. ACMD_FUNC(questskill)
  3020. {
  3021. uint16 skill_id;
  3022. nullpo_retr(-1, sd);
  3023. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3024. {// also send a list of skills applicable to this command
  3025. const char* text;
  3026. // attempt to find the text corresponding to this command
  3027. text = atcommand_help_string( command );
  3028. // send the error message as always
  3029. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3030. if( text )
  3031. {// send the skill ID list associated with this command
  3032. clif_displaymessage( fd, text );
  3033. }
  3034. return -1;
  3035. }
  3036. if (skill_id >= MAX_SKILL_ID) {
  3037. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3038. return -1;
  3039. }
  3040. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3041. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3042. return -1;
  3043. }
  3044. if (pc_checkskill(sd, skill_id) > 0) {
  3045. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  3046. return -1;
  3047. }
  3048. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  3049. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  3050. return 0;
  3051. }
  3052. /*==========================================
  3053. *
  3054. *------------------------------------------*/
  3055. ACMD_FUNC(lostskill)
  3056. {
  3057. uint16 skill_id = 0, sk_idx = 0;
  3058. nullpo_retr(-1, sd);
  3059. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3060. {// also send a list of skills applicable to this command
  3061. const char* text;
  3062. // attempt to find the text corresponding to this command
  3063. text = atcommand_help_string( command );
  3064. // send the error message as always
  3065. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3066. if( text )
  3067. {// send the skill ID list associated with this command
  3068. clif_displaymessage( fd, text );
  3069. }
  3070. return -1;
  3071. }
  3072. if (!(sk_idx = skill_get_index(skill_id))) {
  3073. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3074. return -1;
  3075. }
  3076. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3077. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3078. return -1;
  3079. }
  3080. if (pc_checkskill(sd, skill_id) == 0) {
  3081. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  3082. return -1;
  3083. }
  3084. sd->status.skill[sk_idx].lv = 0;
  3085. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  3086. clif_deleteskill(sd,skill_id);
  3087. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  3088. return 0;
  3089. }
  3090. /*==========================================
  3091. *
  3092. *------------------------------------------*/
  3093. ACMD_FUNC(spiritball)
  3094. {
  3095. uint32 max_spiritballs;
  3096. int number;
  3097. nullpo_retr(-1, sd);
  3098. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3099. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3100. {
  3101. char msg[CHAT_SIZE_MAX];
  3102. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  3103. clif_displaymessage(fd, msg);
  3104. return -1;
  3105. }
  3106. if( sd->spiritball > 0 )
  3107. pc_delspiritball(sd, sd->spiritball, 1);
  3108. sd->spiritball = number;
  3109. clif_spiritball(&sd->bl);
  3110. // no message, player can look the difference
  3111. return 0;
  3112. }
  3113. ACMD_FUNC(soulball)
  3114. {
  3115. int number;
  3116. nullpo_retr(-1, sd);
  3117. if (!message || !*message || (number = atoi(message)) < 0 || number > MAX_SOUL_BALL) {
  3118. char msg[CHAT_SIZE_MAX];
  3119. safesnprintf(msg, sizeof(msg), "Usage: @soulball <number: 0-%d>", MAX_SOUL_BALL);
  3120. clif_displaymessage(fd, msg);
  3121. return -1;
  3122. }
  3123. if (sd->soulball > 0)
  3124. pc_delsoulball(sd, sd->soulball, true);
  3125. sd->soulball = number;
  3126. clif_soulball(sd);
  3127. return 0;
  3128. }
  3129. /*==========================================
  3130. *
  3131. *------------------------------------------*/
  3132. ACMD_FUNC(party)
  3133. {
  3134. char party[NAME_LENGTH];
  3135. nullpo_retr(-1, sd);
  3136. memset(party, '\0', sizeof(party));
  3137. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3138. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  3139. return -1;
  3140. }
  3141. party_create(sd, party, 0, 0);
  3142. return 0;
  3143. }
  3144. /*==========================================
  3145. *
  3146. *------------------------------------------*/
  3147. ACMD_FUNC(guild)
  3148. {
  3149. char guild[NAME_LENGTH];
  3150. int prev;
  3151. nullpo_retr(-1, sd);
  3152. memset(guild, '\0', sizeof(guild));
  3153. if (sd->clan) {
  3154. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  3155. return -1;
  3156. }
  3157. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3158. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  3159. return -1;
  3160. }
  3161. prev = battle_config.guild_emperium_check;
  3162. battle_config.guild_emperium_check = 0;
  3163. guild_create(sd, guild);
  3164. battle_config.guild_emperium_check = prev;
  3165. return 0;
  3166. }
  3167. ACMD_FUNC(breakguild)
  3168. {
  3169. nullpo_retr(-1, sd);
  3170. if (sd->status.guild_id) { // Check if the player has a guild
  3171. struct guild *g;
  3172. g = sd->guild; // Search the guild
  3173. if (g) { // Check if guild was found
  3174. if (sd->state.gmaster_flag) { // Check if player is guild master
  3175. int ret = 0;
  3176. ret = guild_break(sd, g->name); // Break guild
  3177. if (ret) { // Check if anything went wrong
  3178. return 0; // Guild was broken
  3179. } else {
  3180. return -1; // Something went wrong
  3181. }
  3182. } else { // Not guild master
  3183. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3184. return -1;
  3185. }
  3186. } else { // Guild was not found. HOW?
  3187. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3188. return -1;
  3189. }
  3190. } else { // Player does not have a guild
  3191. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3192. return -1;
  3193. }
  3194. }
  3195. /**
  3196. * Start WoE:FE
  3197. */
  3198. ACMD_FUNC(agitstart)
  3199. {
  3200. nullpo_retr(-1, sd);
  3201. if( guild_agit_start() ){
  3202. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3203. return 0;
  3204. }else{
  3205. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3206. return -1;
  3207. }
  3208. }
  3209. /**
  3210. * Start WoE:SE
  3211. */
  3212. ACMD_FUNC(agitstart2)
  3213. {
  3214. nullpo_retr(-1, sd);
  3215. if( guild_agit2_start() ){
  3216. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3217. return 0;
  3218. }else{
  3219. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3220. return -1;
  3221. }
  3222. }
  3223. /**
  3224. * Start WoE:TE
  3225. */
  3226. ACMD_FUNC(agitstart3)
  3227. {
  3228. nullpo_retr(-1, sd);
  3229. if( guild_agit3_start() ){
  3230. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3231. return 0;
  3232. }else{
  3233. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3234. return -1;
  3235. }
  3236. }
  3237. /**
  3238. * End WoE:FE
  3239. */
  3240. ACMD_FUNC(agitend)
  3241. {
  3242. nullpo_retr(-1, sd);
  3243. if( guild_agit_end() ){
  3244. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3245. return 0;
  3246. }else{
  3247. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3248. return -1;
  3249. }
  3250. }
  3251. /**
  3252. * End WoE:SE
  3253. */
  3254. ACMD_FUNC(agitend2)
  3255. {
  3256. nullpo_retr(-1, sd);
  3257. if( guild_agit2_end() ){
  3258. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3259. return 0;
  3260. }else{
  3261. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3262. return -1;
  3263. }
  3264. }
  3265. /**
  3266. * End WoE:TE
  3267. */
  3268. ACMD_FUNC(agitend3)
  3269. {
  3270. nullpo_retr(-1, sd);
  3271. if( guild_agit3_end() ){
  3272. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3273. return 0;
  3274. }else{
  3275. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3276. return -1;
  3277. }
  3278. }
  3279. /*==========================================
  3280. * @mapexit - shuts down the map server
  3281. *------------------------------------------*/
  3282. ACMD_FUNC(mapexit)
  3283. {
  3284. nullpo_retr(-1, sd);
  3285. do_shutdown();
  3286. return 0;
  3287. }
  3288. /*==========================================
  3289. * idsearch <part_of_name>: revrited by [Yor]
  3290. *------------------------------------------*/
  3291. ACMD_FUNC(idsearch)
  3292. {
  3293. char item_name[100];
  3294. unsigned int i, match;
  3295. struct item_data *item_array[MAX_SEARCH];
  3296. nullpo_retr(-1, sd);
  3297. memset(item_name, '\0', sizeof(item_name));
  3298. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3299. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3300. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3301. return -1;
  3302. }
  3303. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3304. clif_displaymessage(fd, atcmd_output);
  3305. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3306. if (match == MAX_SEARCH) {
  3307. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3308. clif_displaymessage(fd, atcmd_output);
  3309. }
  3310. for(i = 0; i < match; i++) {
  3311. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->ename.c_str(), item_array[i]->nameid); // %s: %u
  3312. clif_displaymessage(fd, atcmd_output);
  3313. }
  3314. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3315. clif_displaymessage(fd, atcmd_output);
  3316. return 0;
  3317. }
  3318. /*==========================================
  3319. * Recall All Characters Online To Your Location
  3320. *------------------------------------------*/
  3321. ACMD_FUNC(recallall)
  3322. {
  3323. struct map_session_data* pl_sd;
  3324. struct s_mapiterator* iter;
  3325. int count;
  3326. nullpo_retr(-1, sd);
  3327. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3328. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3329. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3330. return -1;
  3331. }
  3332. count = 0;
  3333. iter = mapit_getallusers();
  3334. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3335. {
  3336. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3337. {
  3338. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3339. continue; // Don't waste time warping the character to the same place.
  3340. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3341. count++;
  3342. else {
  3343. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3344. count++;
  3345. }
  3346. }
  3347. }
  3348. }
  3349. mapit_free(iter);
  3350. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3351. if (count) {
  3352. 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.
  3353. clif_displaymessage(fd, atcmd_output);
  3354. }
  3355. return 0;
  3356. }
  3357. /*==========================================
  3358. * Recall online characters of a guild to your location
  3359. *------------------------------------------*/
  3360. ACMD_FUNC(guildrecall)
  3361. {
  3362. struct map_session_data* pl_sd;
  3363. struct s_mapiterator* iter;
  3364. int count;
  3365. char guild_name[NAME_LENGTH];
  3366. struct guild *g;
  3367. nullpo_retr(-1, sd);
  3368. memset(guild_name, '\0', sizeof(guild_name));
  3369. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3370. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3371. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3372. return -1;
  3373. }
  3374. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3375. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3376. return -1;
  3377. }
  3378. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3379. (g = guild_search(atoi(message))) == NULL)
  3380. {
  3381. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3382. return -1;
  3383. }
  3384. count = 0;
  3385. iter = mapit_getallusers();
  3386. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3387. {
  3388. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3389. {
  3390. 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))
  3391. continue; // Skip GMs greater than you... or chars already on the cell
  3392. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3393. count++;
  3394. else{
  3395. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3396. count++;
  3397. }
  3398. }
  3399. }
  3400. }
  3401. mapit_free(iter);
  3402. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3403. clif_displaymessage(fd, atcmd_output);
  3404. if (count) {
  3405. 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.
  3406. clif_displaymessage(fd, atcmd_output);
  3407. }
  3408. return 0;
  3409. }
  3410. /*==========================================
  3411. * Recall online characters of a party to your location
  3412. *------------------------------------------*/
  3413. ACMD_FUNC(partyrecall)
  3414. {
  3415. struct map_session_data* pl_sd;
  3416. struct s_mapiterator* iter;
  3417. char party_name[NAME_LENGTH];
  3418. struct party_data *p;
  3419. int count;
  3420. nullpo_retr(-1, sd);
  3421. memset(party_name, '\0', sizeof(party_name));
  3422. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3423. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3424. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3425. return -1;
  3426. }
  3427. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3428. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3429. return -1;
  3430. }
  3431. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3432. (p = party_search(atoi(message))) == NULL)
  3433. {
  3434. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3435. return -1;
  3436. }
  3437. count = 0;
  3438. iter = mapit_getallusers();
  3439. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3440. {
  3441. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3442. {
  3443. 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))
  3444. continue; // Skip GMs greater than you... or chars already on the cell
  3445. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3446. count++;
  3447. else{
  3448. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3449. count++;
  3450. }
  3451. }
  3452. }
  3453. }
  3454. mapit_free(iter);
  3455. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3456. clif_displaymessage(fd, atcmd_output);
  3457. if (count) {
  3458. 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.
  3459. clif_displaymessage(fd, atcmd_output);
  3460. }
  3461. return 0;
  3462. }
  3463. /*==========================================
  3464. *
  3465. *------------------------------------------*/
  3466. void atcommand_doload();
  3467. ACMD_FUNC(reload) {
  3468. nullpo_retr(-1, sd);
  3469. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3470. const char* text;
  3471. text = atcommand_help_string( command );
  3472. if(text)
  3473. clif_displaymessage( fd, text );
  3474. return -1;
  3475. }
  3476. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3477. itemdb_reload();
  3478. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3479. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3480. mob_reload();
  3481. pet_db.reload();
  3482. hom_reload();
  3483. mercenary_db.reload();
  3484. elemental_db.reload();
  3485. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3486. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3487. skill_reload();
  3488. hom_reload_skill();
  3489. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3490. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3491. config_t run_test;
  3492. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3493. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3494. return -1;
  3495. }
  3496. config_destroy(&run_test);
  3497. atcommand_doload();
  3498. pc_groups_reload();
  3499. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3500. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3501. struct Battle_Config prev_config;
  3502. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3503. battle_config_read(BATTLE_CONF_FILENAME);
  3504. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3505. || prev_config.item_rate_common != battle_config.item_rate_common
  3506. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3507. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3508. || prev_config.item_rate_card != battle_config.item_rate_card
  3509. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3510. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3511. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3512. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3513. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3514. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3515. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3516. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3517. || prev_config.item_rate_use != battle_config.item_rate_use
  3518. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3519. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3520. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3521. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3522. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3523. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3524. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3525. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3526. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3527. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3528. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3529. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3530. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3531. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3532. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3533. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3534. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3535. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3536. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3537. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3538. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3539. )
  3540. { // Exp or Drop rates changed.
  3541. mob_reload(); //Needed as well so rate changes take effect.
  3542. }
  3543. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3544. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3545. status_readdb( true );
  3546. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3547. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3548. pc_readdb();
  3549. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3550. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3551. pc_read_motd();
  3552. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3553. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3554. struct s_mapiterator* iter;
  3555. struct map_session_data* pl_sd;
  3556. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3557. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3558. iter = mapit_getallusers();
  3559. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3560. pc_close_npc(pl_sd,1);
  3561. clif_cutin(pl_sd, "", 255);
  3562. pl_sd->state.block_action &= ~(PCBLOCK_ALL ^ PCBLOCK_IMMUNE);
  3563. bg_queue_leave(pl_sd);
  3564. }
  3565. mapit_free(iter);
  3566. for (auto &bg : bg_queues) {
  3567. for (auto &bg_sd : bg->teama_members)
  3568. bg_team_leave(bg_sd, false, false); // Kick Team A from battlegrounds
  3569. for (auto &bg_sd : bg->teamb_members)
  3570. bg_team_leave(bg_sd, false, false); // Kick Team B from battlegrounds
  3571. bg_queue_clear(bg, true);
  3572. }
  3573. flush_fifos();
  3574. map_reloadnpc(true); // reload config files seeking for npcs
  3575. script_reload();
  3576. npc_reload();
  3577. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3578. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3579. map_msg_reload();
  3580. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3581. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3582. if (quest_db.reload())
  3583. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3584. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3585. if (instance_db.reload())
  3586. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3587. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3588. achievement_db_reload();
  3589. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3590. } else if (strstr(command, "attendancedb") || strncmp(message, "attendancedb", 4) == 0) {
  3591. attendance_db.reload();
  3592. clif_displaymessage(fd, msg_txt(sd, 795)); // Attendance database has been reloaded.
  3593. }
  3594. return 0;
  3595. }
  3596. /*==========================================
  3597. * @partysharelvl <share_range> [Akinari]
  3598. * Updates char server party share level range in runtime
  3599. * Temporary - Permanent update in inter_athena.conf
  3600. *------------------------------------------*/
  3601. ACMD_FUNC(partysharelvl) {
  3602. unsigned int share_lvl;
  3603. nullpo_retr(-1, sd);
  3604. if(!message || !*message) {
  3605. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3606. return -1;
  3607. } else {
  3608. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3609. }
  3610. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3611. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3612. else //Char server offline
  3613. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3614. return 0;
  3615. }
  3616. /*==========================================
  3617. * @mapinfo [0-3] <map name> by MC_Cameri
  3618. * => Shows information about the map [map name]
  3619. * 0 = no additional information
  3620. * 1 = Show users in that map and their location
  3621. * 2 = Shows NPCs in that map
  3622. * 3 = Shows the chats in that map
  3623. *------------------------------------------*/
  3624. ACMD_FUNC(mapinfo) {
  3625. struct map_session_data* pl_sd;
  3626. struct s_mapiterator* iter;
  3627. struct chat_data *cd = NULL;
  3628. char direction[12];
  3629. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3630. unsigned short m_index;
  3631. char mapname[MAP_NAME_LENGTH];
  3632. nullpo_retr(-1, sd);
  3633. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3634. memset(mapname, '\0', sizeof(mapname));
  3635. memset(direction, '\0', sizeof(direction));
  3636. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3637. if (list < 0 || list > 3) {
  3638. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3639. return -1;
  3640. }
  3641. if (mapname[0] == '\0') {
  3642. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3643. m_id = map_mapindex2mapid(sd->mapindex);
  3644. } else {
  3645. m_id = map_mapname2mapid(mapname);
  3646. }
  3647. if (m_id < 0) {
  3648. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3649. return -1;
  3650. }
  3651. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3652. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3653. // count chats (for initial message)
  3654. chat_num = 0;
  3655. iter = mapit_getallusers();
  3656. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3657. if( pl_sd->mapindex == m_index ) {
  3658. if( pl_sd->state.vending )
  3659. vend_num++;
  3660. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3661. chat_num++;
  3662. }
  3663. }
  3664. mapit_free(iter);
  3665. struct map_data *mapdata = map_getmapdata(m_id);
  3666. 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
  3667. clif_displaymessage(fd, atcmd_output);
  3668. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3669. if (map_getmapflag(m_id, MF_TOWN))
  3670. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3671. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3672. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3673. clif_displaymessage(fd, atcmd_output);
  3674. }
  3675. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3676. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3677. else
  3678. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3679. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3680. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3681. clif_displaymessage(fd, atcmd_output);
  3682. }
  3683. /* Skill damage adjustment info [Cydh] */
  3684. if (mapdata->flag[MF_SKILL_DAMAGE]) {
  3685. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3686. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3687. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3688. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3689. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3690. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3691. mapdata->damage_adjust.caster);
  3692. clif_displaymessage(fd, atcmd_output);
  3693. if (!mapdata->skill_damage.empty()) {
  3694. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3695. for (auto skilldmg : mapdata->skill_damage) {
  3696. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3697. skill_get_name(skilldmg.first),
  3698. skilldmg.second.rate[SKILLDMG_PC],
  3699. skilldmg.second.rate[SKILLDMG_MOB],
  3700. skilldmg.second.rate[SKILLDMG_BOSS],
  3701. skilldmg.second.rate[SKILLDMG_OTHER],
  3702. skilldmg.second.caster);
  3703. clif_displaymessage(fd,atcmd_output);
  3704. }
  3705. }
  3706. }
  3707. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3708. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3709. for (const auto &it : mapdata->skill_duration) {
  3710. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3711. clif_displaymessage(fd, atcmd_output);
  3712. }
  3713. }
  3714. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3715. if (map_getmapflag(m_id, MF_PVP))
  3716. strcat(atcmd_output, " Pvp ON |");
  3717. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3718. strcat(atcmd_output, " NoGuild |");
  3719. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3720. strcat(atcmd_output, " NoParty |");
  3721. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3722. strcat(atcmd_output, " NightmareDrop |");
  3723. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3724. strcat(atcmd_output, " NoCalcRank |");
  3725. clif_displaymessage(fd, atcmd_output);
  3726. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3727. if (map_getmapflag(m_id, MF_GVG))
  3728. strcat(atcmd_output, " GvG ON |");
  3729. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3730. strcat(atcmd_output, " GvG Dungeon |");
  3731. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3732. strcat(atcmd_output, " GvG Castle |");
  3733. if (map_getmapflag(m_id, MF_GVG_TE))
  3734. strcat(atcmd_output, " GvG TE |");
  3735. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3736. strcat(atcmd_output, " GvG TE Castle |");
  3737. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3738. strcat(atcmd_output, " NoParty |");
  3739. clif_displaymessage(fd, atcmd_output);
  3740. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3741. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3742. strcat(atcmd_output, " NoTeleport |");
  3743. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3744. strcat(atcmd_output, " Monster NoTeleport |");
  3745. if (map_getmapflag(m_id, MF_NOWARP))
  3746. strcat(atcmd_output, " NoWarp |");
  3747. if (map_getmapflag(m_id, MF_NOWARPTO))
  3748. strcat(atcmd_output, " NoWarpTo |");
  3749. if (map_getmapflag(m_id, MF_NORETURN))
  3750. strcat(atcmd_output, " NoReturn |");
  3751. if (map_getmapflag(m_id, MF_NOGO))
  3752. strcat(atcmd_output, " NoGo |"); //
  3753. if (map_getmapflag(m_id, MF_NOMEMO))
  3754. strcat(atcmd_output, " NoMemo |");
  3755. clif_displaymessage(fd, atcmd_output);
  3756. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3757. (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
  3758. clif_displaymessage(fd, atcmd_output);
  3759. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3760. if (!mapdata->save.map)
  3761. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3762. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3763. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3764. clif_displaymessage(fd, atcmd_output);
  3765. }
  3766. else {
  3767. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3768. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3769. clif_displaymessage(fd, atcmd_output);
  3770. }
  3771. }
  3772. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3773. if (map_getmapflag(m_id, MF_SNOW))
  3774. strcat(atcmd_output, " Snow |");
  3775. if (map_getmapflag(m_id, MF_FOG))
  3776. strcat(atcmd_output, " Fog |");
  3777. if (map_getmapflag(m_id, MF_SAKURA))
  3778. strcat(atcmd_output, " Sakura |");
  3779. if (map_getmapflag(m_id, MF_CLOUDS))
  3780. strcat(atcmd_output, " Clouds |");
  3781. if (map_getmapflag(m_id, MF_CLOUDS2))
  3782. strcat(atcmd_output, " Clouds2 |");
  3783. if (map_getmapflag(m_id, MF_FIREWORKS))
  3784. strcat(atcmd_output, " Fireworks |");
  3785. if (map_getmapflag(m_id, MF_LEAVES))
  3786. strcat(atcmd_output, " Leaves |");
  3787. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3788. strcat(atcmd_output, " Displays Night |");
  3789. clif_displaymessage(fd, atcmd_output);
  3790. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3791. if (map_getmapflag(m_id, MF_NOBRANCH))
  3792. strcat(atcmd_output, " NoBranch |");
  3793. if (map_getmapflag(m_id, MF_NOTRADE))
  3794. strcat(atcmd_output, " NoTrade |");
  3795. if (map_getmapflag(m_id, MF_NOVENDING))
  3796. strcat(atcmd_output, " NoVending |");
  3797. if (map_getmapflag(m_id, MF_NODROP))
  3798. strcat(atcmd_output, " NoDrop |");
  3799. if (map_getmapflag(m_id, MF_NOSKILL))
  3800. strcat(atcmd_output, " NoSkill |");
  3801. if (map_getmapflag(m_id, MF_NOICEWALL))
  3802. strcat(atcmd_output, " NoIcewall |");
  3803. if (map_getmapflag(m_id, MF_ALLOWKS))
  3804. strcat(atcmd_output, " AllowKS |");
  3805. if (map_getmapflag(m_id, MF_RESET))
  3806. strcat(atcmd_output, " Reset |");
  3807. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3808. strcat(atcmd_output, " HideMobHPBar |");
  3809. clif_displaymessage(fd, atcmd_output);
  3810. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3811. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3812. strcat(atcmd_output, " NoCommand |");
  3813. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3814. strcat(atcmd_output, " NoBaseEXP |");
  3815. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3816. strcat(atcmd_output, " NoJobEXP |");
  3817. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3818. strcat(atcmd_output, " NoMobLoot |");
  3819. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3820. strcat(atcmd_output, " NoMVPLoot |");
  3821. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3822. strcat(atcmd_output, " PartyLock |");
  3823. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3824. strcat(atcmd_output, " GuildLock |");
  3825. if (map_getmapflag(m_id, MF_LOADEVENT))
  3826. strcat(atcmd_output, " Loadevent |");
  3827. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3828. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  3829. if (map_getmapflag(m_id, MF_NOUSECART))
  3830. strcat(atcmd_output, " NoUsecart |");
  3831. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  3832. strcat(atcmd_output, " NoItemConsumption |");
  3833. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  3834. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  3835. if (map_getmapflag(m_id, MF_NOMINEEFFECT))
  3836. strcat(atcmd_output, " NoMineEffect |");
  3837. if (map_getmapflag(m_id, MF_NOLOCKON))
  3838. strcat(atcmd_output, " NoLockOn |");
  3839. if (map_getmapflag(m_id, MF_NOTOMB))
  3840. strcat(atcmd_output, " NoTomb |");
  3841. if (map_getmapflag(m_id, MF_NOCOSTUME))
  3842. strcat(atcmd_output, " NoCostume |");
  3843. clif_displaymessage(fd, atcmd_output);
  3844. switch (list) {
  3845. case 0:
  3846. // Do nothing. It's list 0, no additional display.
  3847. break;
  3848. case 1:
  3849. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3850. iter = mapit_getallusers();
  3851. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3852. {
  3853. if (pl_sd->mapindex == m_index) {
  3854. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3855. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3856. clif_displaymessage(fd, atcmd_output);
  3857. }
  3858. }
  3859. mapit_free(iter);
  3860. break;
  3861. case 2:
  3862. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3863. for (i = 0; i < mapdata->npc_num;)
  3864. {
  3865. struct npc_data *nd = mapdata->npc[i];
  3866. switch(nd->ud.dir) {
  3867. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3868. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3869. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3870. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3871. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3872. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3873. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3874. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3875. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3876. }
  3877. if(strcmp(nd->name,nd->exname) == 0)
  3878. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3879. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3880. else
  3881. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3882. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3883. clif_displaymessage(fd, atcmd_output);
  3884. }
  3885. break;
  3886. case 3:
  3887. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3888. iter = mapit_getallusers();
  3889. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3890. {
  3891. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3892. pl_sd->mapindex == m_index &&
  3893. cd->usersd[0] == pl_sd)
  3894. {
  3895. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3896. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3897. clif_displaymessage(fd, atcmd_output);
  3898. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3899. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3900. clif_displaymessage(fd, atcmd_output);
  3901. }
  3902. }
  3903. mapit_free(iter);
  3904. break;
  3905. default: // normally impossible to arrive here
  3906. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3907. return -1;
  3908. break;
  3909. }
  3910. return 0;
  3911. }
  3912. /*==========================================
  3913. *
  3914. *------------------------------------------*/
  3915. ACMD_FUNC(mount_peco)
  3916. {
  3917. nullpo_retr(-1, sd);
  3918. if (sd->disguise) {
  3919. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3920. return -1;
  3921. }
  3922. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3923. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3924. unsigned int option = OPTION_DRAGON1;
  3925. if( message[0] ) {
  3926. int color = atoi(message);
  3927. option = ( color == 2 ? OPTION_DRAGON2 :
  3928. color == 3 ? OPTION_DRAGON3 :
  3929. color == 4 ? OPTION_DRAGON4 :
  3930. color == 5 ? OPTION_DRAGON5 :
  3931. OPTION_DRAGON1 );
  3932. }
  3933. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3934. pc_setoption(sd, sd->sc.option|option);
  3935. } else {
  3936. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3937. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3938. }
  3939. return 0;
  3940. }
  3941. 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)) ) {
  3942. if( !pc_isridingwug(sd) ) {
  3943. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3944. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3945. } else {
  3946. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3947. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3948. }
  3949. return 0;
  3950. }
  3951. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3952. if( !pc_ismadogear(sd) ) {
  3953. e_mado_type type = MADO_ROBOT;
  3954. if (message[0]) {
  3955. int tmp = strtol(message, nullptr, 10);
  3956. switch (tmp) {
  3957. case MADO_ROBOT:
  3958. case MADO_SUIT:
  3959. type = static_cast<e_mado_type>(tmp);
  3960. break;
  3961. default:
  3962. type = MADO_ROBOT;
  3963. break;
  3964. }
  3965. }
  3966. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3967. pc_setmadogear(sd, true, type);
  3968. } else {
  3969. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3970. pc_setmadogear(sd, false);
  3971. }
  3972. return 0;
  3973. }
  3974. if (!pc_isriding(sd)) { // if actually no peco
  3975. if (!pc_checkskill(sd, KN_RIDING)) {
  3976. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3977. return -1;
  3978. }
  3979. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3980. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3981. } else {//Dismount
  3982. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3983. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3984. }
  3985. return 0;
  3986. }
  3987. /*==========================================
  3988. *Spy Commands by Syrus22
  3989. *------------------------------------------*/
  3990. ACMD_FUNC(guildspy)
  3991. {
  3992. char guild_name[NAME_LENGTH];
  3993. struct guild *g;
  3994. nullpo_retr(-1, sd);
  3995. memset(guild_name, '\0', sizeof(guild_name));
  3996. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3997. if (!enable_spy)
  3998. {
  3999. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4000. return -1;
  4001. }
  4002. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4003. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  4004. return -1;
  4005. }
  4006. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4007. (g = guild_search(atoi(message))) != NULL) {
  4008. if (sd->guildspy == g->guild_id) {
  4009. sd->guildspy = 0;
  4010. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  4011. clif_displaymessage(fd, atcmd_output);
  4012. } else {
  4013. sd->guildspy = g->guild_id;
  4014. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  4015. clif_displaymessage(fd, atcmd_output);
  4016. }
  4017. } else {
  4018. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  4019. return -1;
  4020. }
  4021. return 0;
  4022. }
  4023. /*==========================================
  4024. *
  4025. *------------------------------------------*/
  4026. ACMD_FUNC(partyspy)
  4027. {
  4028. char party_name[NAME_LENGTH];
  4029. struct party_data *p;
  4030. nullpo_retr(-1, sd);
  4031. memset(party_name, '\0', sizeof(party_name));
  4032. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4033. if (!enable_spy)
  4034. {
  4035. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4036. return -1;
  4037. }
  4038. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4039. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  4040. return -1;
  4041. }
  4042. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4043. (p = party_search(atoi(message))) != NULL) {
  4044. if (sd->partyspy == p->party.party_id) {
  4045. sd->partyspy = 0;
  4046. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  4047. clif_displaymessage(fd, atcmd_output);
  4048. } else {
  4049. sd->partyspy = p->party.party_id;
  4050. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  4051. clif_displaymessage(fd, atcmd_output);
  4052. }
  4053. } else {
  4054. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  4055. return -1;
  4056. }
  4057. return 0;
  4058. }
  4059. ACMD_FUNC(clanspy){
  4060. char clan_name[NAME_LENGTH];
  4061. struct clan* c;
  4062. nullpo_retr(-1, sd);
  4063. memset(clan_name, '\0', sizeof(clan_name));
  4064. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4065. if( !enable_spy ){
  4066. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  4067. return -1;
  4068. }
  4069. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  4070. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  4071. return -1;
  4072. }
  4073. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  4074. (c = clan_search(atoi(message))) != NULL) {
  4075. if (sd->clanspy == c->id) {
  4076. sd->clanspy = 0;
  4077. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  4078. clif_displaymessage(fd, atcmd_output);
  4079. }
  4080. else {
  4081. sd->clanspy = c->id;
  4082. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  4083. clif_displaymessage(fd, atcmd_output);
  4084. }
  4085. }
  4086. else {
  4087. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  4088. return -1;
  4089. }
  4090. return 0;
  4091. }
  4092. /*==========================================
  4093. * @repairall [Valaris]
  4094. *------------------------------------------*/
  4095. ACMD_FUNC(repairall)
  4096. {
  4097. int count, i;
  4098. nullpo_retr(-1, sd);
  4099. count = 0;
  4100. for (i = 0; i < MAX_INVENTORY; i++) {
  4101. 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])) {
  4102. sd->inventory.u.items_inventory[i].attribute = 0;
  4103. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  4104. count++;
  4105. }
  4106. }
  4107. if (count > 0) {
  4108. clif_misceffect(&sd->bl, 3);
  4109. clif_equiplist(sd);
  4110. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  4111. } else {
  4112. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  4113. return -1;
  4114. }
  4115. return 0;
  4116. }
  4117. /*==========================================
  4118. * @nuke [Valaris]
  4119. *------------------------------------------*/
  4120. ACMD_FUNC(nuke)
  4121. {
  4122. struct map_session_data *pl_sd;
  4123. nullpo_retr(-1, sd);
  4124. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4125. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4126. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  4127. return -1;
  4128. }
  4129. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  4130. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  4131. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4132. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  4133. } else {
  4134. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4135. return -1;
  4136. }
  4137. } else {
  4138. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4139. return -1;
  4140. }
  4141. return 0;
  4142. }
  4143. /*==========================================
  4144. * @tonpc
  4145. *------------------------------------------*/
  4146. ACMD_FUNC(tonpc)
  4147. {
  4148. char npcname[NPC_NAME_LENGTH];
  4149. struct npc_data *nd;
  4150. nullpo_retr(-1, sd);
  4151. memset(npcname, 0, sizeof(npcname));
  4152. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  4153. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  4154. return -1;
  4155. }
  4156. if ((nd = npc_name2id(npcname)) != NULL) {
  4157. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  4158. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  4159. else
  4160. return -1;
  4161. } else {
  4162. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4163. return -1;
  4164. }
  4165. return 0;
  4166. }
  4167. /*==========================================
  4168. *
  4169. *------------------------------------------*/
  4170. ACMD_FUNC(shownpc)
  4171. {
  4172. char NPCname[NPC_NAME_LENGTH];
  4173. nullpo_retr(-1, sd);
  4174. memset(NPCname, '\0', sizeof(NPCname));
  4175. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4176. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  4177. return -1;
  4178. }
  4179. npc_data* nd = npc_name2id(NPCname);
  4180. if (nd) {
  4181. npc_enable(*nd, NPCVIEW_ENABLE);
  4182. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4183. } else {
  4184. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4185. return -1;
  4186. }
  4187. return 0;
  4188. }
  4189. /*==========================================
  4190. *
  4191. *------------------------------------------*/
  4192. ACMD_FUNC(hidenpc)
  4193. {
  4194. char NPCname[NPC_NAME_LENGTH];
  4195. nullpo_retr(-1, sd);
  4196. memset(NPCname, '\0', sizeof(NPCname));
  4197. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4198. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4199. return -1;
  4200. }
  4201. npc_data* nd = npc_name2id(NPCname);
  4202. if (!nd) {
  4203. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4204. return -1;
  4205. }
  4206. npc_enable(*nd, NPCVIEW_DISABLE);
  4207. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4208. return 0;
  4209. }
  4210. ACMD_FUNC(loadnpc)
  4211. {
  4212. if (!message || !*message) {
  4213. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4214. return -1;
  4215. }
  4216. if (!npc_addsrcfile(message, true)) {
  4217. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4218. return -1;
  4219. }
  4220. npc_read_event_script();
  4221. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was loaded.\n", message );
  4222. npc_event_doall_path( script_config.init_event_name, message );
  4223. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4224. return 0;
  4225. }
  4226. ACMD_FUNC(unloadnpc)
  4227. {
  4228. struct npc_data *nd;
  4229. char NPCname[NPC_NAME_LENGTH];
  4230. nullpo_retr(-1, sd);
  4231. memset(NPCname, '\0', sizeof(NPCname));
  4232. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4233. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4234. return -1;
  4235. }
  4236. if ((nd = npc_name2id(NPCname)) == NULL) {
  4237. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4238. return -1;
  4239. }
  4240. npc_unload_duplicates(nd);
  4241. npc_unload(nd,true);
  4242. npc_read_event_script();
  4243. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4244. return 0;
  4245. }
  4246. ACMD_FUNC(reloadnpcfile) {
  4247. if (!message || !*message) {
  4248. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4249. return -1;
  4250. }
  4251. if (npc_unloadfile(message))
  4252. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4253. if (!npc_addsrcfile(message, true)) {
  4254. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4255. return -1;
  4256. }
  4257. npc_read_event_script();
  4258. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was reloaded.\n", message );
  4259. npc_event_doall_path( script_config.init_event_name, message );
  4260. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4261. return 0;
  4262. }
  4263. /*==========================================
  4264. * time in txt for time command (by [Yor])
  4265. *------------------------------------------*/
  4266. char* txt_time(t_tick duration_)
  4267. {
  4268. int days, hours, minutes, seconds;
  4269. char temp[CHAT_SIZE_MAX];
  4270. static char temp1[CHAT_SIZE_MAX];
  4271. memset(temp, '\0', sizeof(temp));
  4272. memset(temp1, '\0', sizeof(temp1));
  4273. // Cap it
  4274. int duration = (int)duration_;
  4275. days = duration / (60 * 60 * 24);
  4276. duration = duration - (60 * 60 * 24 * days);
  4277. hours = duration / (60 * 60);
  4278. duration = duration - (60 * 60 * hours);
  4279. minutes = duration / 60;
  4280. seconds = duration - (60 * minutes);
  4281. if (days == 1)
  4282. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4283. else if (days > 1)
  4284. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4285. if (hours == 1)
  4286. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4287. else if (hours > 1)
  4288. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4289. if (minutes < 2)
  4290. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4291. else
  4292. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4293. if (seconds == 1)
  4294. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4295. else if (seconds > 1)
  4296. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4297. return temp1;
  4298. }
  4299. /*==========================================
  4300. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4301. * Calculation management of GM modification (@day/@night GM commands) is done
  4302. *------------------------------------------*/
  4303. ACMD_FUNC(servertime)
  4304. {
  4305. const struct TimerData * timer_data;
  4306. time_t time_server; // variable for number of seconds (used with time() function)
  4307. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4308. char temp[CHAT_SIZE_MAX];
  4309. nullpo_retr(-1, sd);
  4310. memset(temp, '\0', sizeof(temp));
  4311. time(&time_server); // get time in seconds since 1/1/1970
  4312. datetime = localtime(&time_server); // convert seconds in structure
  4313. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4314. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4315. clif_displaymessage(fd, temp);
  4316. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4317. if (night_flag == 0)
  4318. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4319. else
  4320. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4321. } else if (battle_config.night_duration == 0)
  4322. if (night_flag == 1) { // we start with night
  4323. if ((timer_data = get_timer(day_timer_tid)) != nullptr) {
  4324. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4325. clif_displaymessage(fd, temp);
  4326. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4327. } else
  4328. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4329. } else
  4330. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4331. else if (battle_config.day_duration == 0)
  4332. if (night_flag == 0) { // we start with day
  4333. if ((timer_data = get_timer(night_timer_tid)) != nullptr) {
  4334. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4335. clif_displaymessage(fd, temp);
  4336. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4337. } else
  4338. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4339. } else
  4340. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4341. else {
  4342. const struct TimerData * timer_data2;
  4343. if (night_flag == 0) {
  4344. if ((timer_data = get_timer(night_timer_tid)) != nullptr && (timer_data2 = get_timer(day_timer_tid)) != nullptr) {
  4345. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4346. clif_displaymessage(fd, temp);
  4347. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4348. 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.
  4349. else
  4350. 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.
  4351. clif_displaymessage(fd, temp);
  4352. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4353. clif_displaymessage(fd, temp);
  4354. } else
  4355. clif_displaymessage(fd, msg_txt(sd, 231)); // Game time: The game is in permanent daylight.
  4356. } else {
  4357. if ((timer_data = get_timer(day_timer_tid)) != nullptr && (timer_data2 = get_timer(night_timer_tid)) != nullptr) {
  4358. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4359. clif_displaymessage(fd, temp);
  4360. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4361. 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.
  4362. else
  4363. 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.
  4364. clif_displaymessage(fd, temp);
  4365. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4366. clif_displaymessage(fd, temp);
  4367. } else
  4368. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4369. }
  4370. }
  4371. return 0;
  4372. }
  4373. /*==========================================
  4374. * @jail <char_name> by [Yor]
  4375. * Special warp! No check with nowarp and nowarpto flag
  4376. *------------------------------------------*/
  4377. ACMD_FUNC(jail)
  4378. {
  4379. struct map_session_data *pl_sd;
  4380. int x, y;
  4381. unsigned short m_index;
  4382. nullpo_retr(-1, sd);
  4383. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4384. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4385. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4386. return -1;
  4387. }
  4388. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4389. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4390. return -1;
  4391. }
  4392. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4393. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4394. return -1;
  4395. }
  4396. if (pl_sd->sc.data[SC_JAILED]) {
  4397. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4398. return -1;
  4399. }
  4400. switch(rnd() % 2) { //Jail Locations
  4401. case 0:
  4402. m_index = mapindex_name2id(MAP_JAIL);
  4403. x = 24;
  4404. y = 75;
  4405. break;
  4406. default:
  4407. m_index = mapindex_name2id(MAP_JAIL);
  4408. x = 49;
  4409. y = 75;
  4410. break;
  4411. }
  4412. //Duration of INT_MAX to specify infinity.
  4413. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4414. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4415. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4416. return 0;
  4417. }
  4418. /*==========================================
  4419. * @unjail/@discharge <char_name> by [Yor]
  4420. * Special warp! No check with nowarp and nowarpto flag
  4421. *------------------------------------------*/
  4422. ACMD_FUNC(unjail)
  4423. {
  4424. struct map_session_data *pl_sd;
  4425. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4426. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4427. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4428. return -1;
  4429. }
  4430. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4431. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4432. return -1;
  4433. }
  4434. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4435. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4436. return -1;
  4437. }
  4438. if (!pl_sd->sc.data[SC_JAILED]) {
  4439. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4440. return -1;
  4441. }
  4442. //Reset jail time to 1 sec.
  4443. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4444. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4445. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4446. return 0;
  4447. }
  4448. ACMD_FUNC(jailfor) {
  4449. struct map_session_data *pl_sd = NULL;
  4450. char * modif_p;
  4451. int jailtime = 0,x,y;
  4452. short m_index = 0;
  4453. nullpo_retr(-1, sd);
  4454. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4455. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4456. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4457. return -1;
  4458. }
  4459. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4460. modif_p = atcmd_output;
  4461. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4462. if (jailtime == 0) {
  4463. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4464. 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.
  4465. return -1;
  4466. }
  4467. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4468. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4469. return -1;
  4470. }
  4471. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4472. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4473. return -1;
  4474. }
  4475. // Added by Coltaro
  4476. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4477. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4478. if (jailtime <= 0) {
  4479. jailtime = 0;
  4480. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4481. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4482. } else {
  4483. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4484. char timestr[21];
  4485. time_t now=time(NULL);
  4486. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4487. 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
  4488. clif_displaymessage(pl_sd->fd, atcmd_output);
  4489. 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
  4490. clif_displaymessage(fd, atcmd_output);
  4491. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4492. sprintf(atcmd_output,"Release date is: %s",timestr);
  4493. clif_displaymessage(pl_sd->fd, atcmd_output);
  4494. clif_displaymessage(fd, atcmd_output);
  4495. }
  4496. } else if (jailtime < 0) {
  4497. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4498. return -1;
  4499. }
  4500. // Jail locations, add more as you wish.
  4501. switch(rnd()%2) {
  4502. case 1: // Jail #1
  4503. m_index = mapindex_name2id(MAP_JAIL);
  4504. x = 49; y = 75;
  4505. break;
  4506. default: // Default Jail
  4507. m_index = mapindex_name2id(MAP_JAIL);
  4508. x = 24; y = 75;
  4509. break;
  4510. }
  4511. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  4512. return 0;
  4513. }
  4514. //By Coltaro
  4515. ACMD_FUNC(jailtime){
  4516. int year, month, day, hour, minute, second;
  4517. char timestr[21];
  4518. time_t now = time(NULL);
  4519. nullpo_retr(-1, sd);
  4520. if (!sd->sc.data[SC_JAILED]) {
  4521. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4522. return -1;
  4523. }
  4524. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4525. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4526. return 0;
  4527. }
  4528. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4529. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4530. return -1;
  4531. }
  4532. // Get remaining jail time
  4533. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4534. 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
  4535. clif_displaymessage(fd, atcmd_output);
  4536. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4537. sprintf(atcmd_output,"Release date is: %s",timestr);
  4538. clif_displaymessage(fd, atcmd_output);
  4539. return 0;
  4540. }
  4541. /*==========================================
  4542. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4543. *------------------------------------------*/
  4544. ACMD_FUNC(disguise)
  4545. {
  4546. int id = 0;
  4547. nullpo_retr(-1, sd);
  4548. if (!message || !*message) {
  4549. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4550. return -1;
  4551. }
  4552. if ((id = atoi(message)) > 0)
  4553. { //Acquired an ID
  4554. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4555. id = 0; //Invalid id for either mobs or npcs.
  4556. } else { //Acquired a Name
  4557. if ((id = mobdb_searchname(message)) == 0)
  4558. {
  4559. struct npc_data* nd = npc_name2id(message);
  4560. if (nd != NULL)
  4561. id = nd->class_;
  4562. }
  4563. }
  4564. if (id == 0)
  4565. {
  4566. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4567. return -1;
  4568. }
  4569. if(pc_isriding(sd))
  4570. {
  4571. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4572. return -1;
  4573. }
  4574. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4575. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4576. return -1;
  4577. }
  4578. pc_disguise(sd, id);
  4579. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4580. return 0;
  4581. }
  4582. /*==========================================
  4583. * DisguiseAll
  4584. *------------------------------------------*/
  4585. ACMD_FUNC(disguiseall)
  4586. {
  4587. int mob_id=0;
  4588. struct map_session_data *pl_sd;
  4589. struct s_mapiterator* iter;
  4590. nullpo_retr(-1, sd);
  4591. if (!message || !*message) {
  4592. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4593. return -1;
  4594. }
  4595. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4596. mob_id = atoi(message);
  4597. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4598. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4599. return -1;
  4600. }
  4601. iter = mapit_getallusers();
  4602. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4603. pc_disguise(pl_sd, mob_id);
  4604. mapit_free(iter);
  4605. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4606. return 0;
  4607. }
  4608. /*==========================================
  4609. * DisguiseGuild
  4610. *------------------------------------------*/
  4611. ACMD_FUNC(disguiseguild)
  4612. {
  4613. int id = 0, i;
  4614. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4615. struct guild *g;
  4616. memset(monster, '\0', sizeof(monster));
  4617. memset(guild, '\0', sizeof(guild));
  4618. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4619. 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>).
  4620. return -1;
  4621. }
  4622. if( (id = atoi(monster)) > 0 ) {
  4623. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4624. id = 0;
  4625. } else {
  4626. if( (id = mobdb_searchname(monster)) == 0 ) {
  4627. struct npc_data* nd = npc_name2id(monster);
  4628. if( nd != NULL )
  4629. id = nd->class_;
  4630. }
  4631. }
  4632. if( id == 0 ) {
  4633. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4634. return -1;
  4635. }
  4636. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4637. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4638. return -1;
  4639. }
  4640. for( i = 0; i < g->max_member; i++ ){
  4641. struct map_session_data *pl_sd;
  4642. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4643. pc_disguise(pl_sd, id);
  4644. }
  4645. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4646. return 0;
  4647. }
  4648. /*==========================================
  4649. * @undisguise by [Yor]
  4650. *------------------------------------------*/
  4651. ACMD_FUNC(undisguise)
  4652. {
  4653. nullpo_retr(-1, sd);
  4654. if (sd->disguise) {
  4655. pc_disguise(sd, 0);
  4656. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4657. } else {
  4658. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4659. return -1;
  4660. }
  4661. return 0;
  4662. }
  4663. /*==========================================
  4664. * UndisguiseAll
  4665. *------------------------------------------*/
  4666. ACMD_FUNC(undisguiseall)
  4667. {
  4668. struct map_session_data *pl_sd;
  4669. struct s_mapiterator* iter;
  4670. nullpo_retr(-1, sd);
  4671. iter = mapit_getallusers();
  4672. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4673. if( pl_sd->disguise )
  4674. pc_disguise(pl_sd, 0);
  4675. mapit_free(iter);
  4676. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4677. return 0;
  4678. }
  4679. /*==========================================
  4680. * UndisguiseGuild
  4681. *------------------------------------------*/
  4682. ACMD_FUNC(undisguiseguild)
  4683. {
  4684. char guild_name[NAME_LENGTH];
  4685. struct guild *g;
  4686. int i;
  4687. nullpo_retr(-1, sd);
  4688. memset(guild_name, '\0', sizeof(guild_name));
  4689. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4690. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4691. return -1;
  4692. }
  4693. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  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->max_member; i++){
  4698. struct map_session_data *pl_sd;
  4699. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4700. pc_disguise(pl_sd, 0);
  4701. }
  4702. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4703. return 0;
  4704. }
  4705. /*==========================================
  4706. * @exp by [Skotlex]
  4707. *------------------------------------------*/
  4708. ACMD_FUNC(exp)
  4709. {
  4710. char output[CHAT_SIZE_MAX];
  4711. double nextb, nextj;
  4712. nullpo_retr(-1, sd);
  4713. memset(output, '\0', sizeof(output));
  4714. nextb = (double)pc_nextbaseexp(sd);
  4715. if (nextb)
  4716. nextb = sd->status.base_exp*100.0/nextb;
  4717. nextj = (double)pc_nextjobexp(sd);
  4718. if (nextj)
  4719. nextj = sd->status.job_exp*100.0/nextj;
  4720. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4721. clif_displaymessage(fd, output);
  4722. return 0;
  4723. }
  4724. /*==========================================
  4725. * @broadcast by [Valaris]
  4726. *------------------------------------------*/
  4727. ACMD_FUNC(broadcast)
  4728. {
  4729. nullpo_retr(-1, sd);
  4730. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4731. if (!message || !*message) {
  4732. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4733. return -1;
  4734. }
  4735. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4736. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4737. return 0;
  4738. }
  4739. /*==========================================
  4740. * @localbroadcast by [Valaris]
  4741. *------------------------------------------*/
  4742. ACMD_FUNC(localbroadcast)
  4743. {
  4744. nullpo_retr(-1, sd);
  4745. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4746. if (!message || !*message) {
  4747. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4748. return -1;
  4749. }
  4750. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4751. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4752. return 0;
  4753. }
  4754. /*==========================================
  4755. * @email <actual@email> <new@email> by [Yor]
  4756. *------------------------------------------*/
  4757. ACMD_FUNC(email)
  4758. {
  4759. char actual_email[100];
  4760. char new_email[100];
  4761. nullpo_retr(-1, sd);
  4762. memset(actual_email, '\0', sizeof(actual_email));
  4763. memset(new_email, '\0', sizeof(new_email));
  4764. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4765. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4766. return -1;
  4767. }
  4768. if (e_mail_check(actual_email) == 0) {
  4769. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4770. return -1;
  4771. } else if (e_mail_check(new_email) == 0) {
  4772. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4773. return -1;
  4774. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4775. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4776. return -1;
  4777. } else if (strcmpi(actual_email, new_email) == 0) {
  4778. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4779. return -1;
  4780. }
  4781. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4782. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4783. return 0;
  4784. }
  4785. /*==========================================
  4786. *@effect
  4787. *------------------------------------------*/
  4788. ACMD_FUNC(effect)
  4789. {
  4790. int type = EF_NONE;
  4791. nullpo_retr(-1, sd);
  4792. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4793. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4794. return -1;
  4795. }
  4796. if( type <= EF_NONE || type >= EF_MAX ){
  4797. 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.
  4798. clif_displaymessage(fd, atcmd_output);
  4799. return -1;
  4800. }
  4801. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4802. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4803. return 0;
  4804. }
  4805. /*==========================================
  4806. * @killer by MouseJstr
  4807. * enable killing players even when not in pvp
  4808. *------------------------------------------*/
  4809. ACMD_FUNC(killer)
  4810. {
  4811. nullpo_retr(-1, sd);
  4812. sd->state.killer = !sd->state.killer;
  4813. if(sd->state.killer)
  4814. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4815. else {
  4816. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4817. pc_stop_attack(sd);
  4818. }
  4819. return 0;
  4820. }
  4821. /*==========================================
  4822. * @killable by MouseJstr
  4823. * enable other people killing you
  4824. *------------------------------------------*/
  4825. ACMD_FUNC(killable)
  4826. {
  4827. nullpo_retr(-1, sd);
  4828. sd->state.killable = !sd->state.killable;
  4829. if(sd->state.killable)
  4830. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4831. else {
  4832. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4833. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4834. }
  4835. return 0;
  4836. }
  4837. /*==========================================
  4838. * @skillon by MouseJstr
  4839. * turn skills on for the map
  4840. *------------------------------------------*/
  4841. ACMD_FUNC(skillon)
  4842. {
  4843. nullpo_retr(-1, sd);
  4844. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4845. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4846. return 0;
  4847. }
  4848. /*==========================================
  4849. * @skilloff by MouseJstr
  4850. * Turn skills off on the map
  4851. *------------------------------------------*/
  4852. ACMD_FUNC(skilloff)
  4853. {
  4854. nullpo_retr(-1, sd);
  4855. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  4856. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4857. return 0;
  4858. }
  4859. /*==========================================
  4860. * @npcmove by MouseJstr
  4861. * move a npc
  4862. *------------------------------------------*/
  4863. ACMD_FUNC(npcmove)
  4864. {
  4865. short x = 0, y = 0;
  4866. struct npc_data *nd = 0;
  4867. char npc_name[NPC_NAME_LENGTH];
  4868. nullpo_retr(-1, sd);
  4869. memset(npc_name, '\0', sizeof npc_name);
  4870. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4871. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4872. return -1;
  4873. }
  4874. if ((nd = npc_name2id(npc_name)) == NULL)
  4875. {
  4876. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4877. return -1;
  4878. }
  4879. if ( npc_movenpc( nd, x, y ) )
  4880. { //actually failed to move
  4881. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4882. return -1; //Not on a map.
  4883. } else
  4884. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4885. return 0;
  4886. }
  4887. /*==========================================
  4888. * @addwarp by MouseJstr
  4889. * Create a new static warp point.
  4890. *------------------------------------------*/
  4891. ACMD_FUNC(addwarp)
  4892. {
  4893. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4894. short x,y;
  4895. unsigned short m;
  4896. struct npc_data* nd;
  4897. nullpo_retr(-1, sd);
  4898. memset(warpname, '\0', sizeof(warpname));
  4899. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4900. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4901. return -1;
  4902. }
  4903. m = mapindex_name2id(mapname);
  4904. if( m == 0 )
  4905. {
  4906. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4907. clif_displaymessage(fd, atcmd_output);
  4908. return -1;
  4909. }
  4910. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4911. if( nd == NULL )
  4912. return -1;
  4913. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4914. clif_displaymessage(fd, atcmd_output);
  4915. return 0;
  4916. }
  4917. /*==========================================
  4918. * @follow by [MouseJstr]
  4919. * Follow a player .. staying no more then 5 spaces away
  4920. *------------------------------------------*/
  4921. ACMD_FUNC(follow)
  4922. {
  4923. struct map_session_data *pl_sd = NULL;
  4924. nullpo_retr(-1, sd);
  4925. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4926. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4927. if (sd->followtarget == -1)
  4928. return -1;
  4929. pc_stop_following (sd);
  4930. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4931. return 0;
  4932. }
  4933. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4934. {
  4935. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4936. return -1;
  4937. }
  4938. if (sd->followtarget == pl_sd->bl.id) {
  4939. pc_stop_following (sd);
  4940. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4941. } else {
  4942. pc_follow(sd, pl_sd->bl.id);
  4943. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4944. }
  4945. return 0;
  4946. }
  4947. /*==========================================
  4948. * @dropall by [MouseJstr] and [Xantara]
  4949. * Drops all your possession on the ground based on item type
  4950. *------------------------------------------*/
  4951. ACMD_FUNC(dropall)
  4952. {
  4953. int8 type = -1;
  4954. uint16 i, count = 0, count2 = 0;
  4955. struct item_data *item_data = NULL;
  4956. nullpo_retr(-1, sd);
  4957. if( message[0] ) {
  4958. type = atoi(message);
  4959. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4960. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4961. {
  4962. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  4963. 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
  4964. return -1;
  4965. }
  4966. }
  4967. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4968. if( sd->inventory.u.items_inventory[i].amount ) {
  4969. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4970. 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);
  4971. continue;
  4972. }
  4973. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4974. continue;
  4975. if( type == -1 || type == (uint8)item_data->type ) {
  4976. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4977. pc_unequipitem(sd, i, 3);
  4978. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  4979. pet_return_egg( sd, sd->pd );
  4980. }
  4981. pc_equipswitch_remove(sd, i);
  4982. int amount = sd->inventory.u.items_inventory[i].amount;
  4983. if(pc_dropitem(sd, i, amount))
  4984. count += amount;
  4985. else count2 += amount;
  4986. }
  4987. }
  4988. }
  4989. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4990. clif_displaymessage(fd, atcmd_output);
  4991. return 0;
  4992. }
  4993. /*==========================================
  4994. * @storeall by [MouseJstr]
  4995. * Put everything into storage
  4996. *------------------------------------------*/
  4997. ACMD_FUNC(storeall)
  4998. {
  4999. int i;
  5000. nullpo_retr(-1, sd);
  5001. if (sd->state.storage_flag != 1)
  5002. { //Open storage.
  5003. if( storage_storageopen(sd) == 1 ) {
  5004. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  5005. return -1;
  5006. }
  5007. }
  5008. for (i = 0; i < MAX_INVENTORY; i++) {
  5009. if (sd->inventory.u.items_inventory[i].amount) {
  5010. if(sd->inventory.u.items_inventory[i].equip != 0)
  5011. pc_unequipitem(sd, i, 3);
  5012. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5013. pet_return_egg( sd, sd->pd );
  5014. }
  5015. pc_equipswitch_remove(sd, i);
  5016. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  5017. }
  5018. }
  5019. storage_storageclose(sd);
  5020. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  5021. return 0;
  5022. }
  5023. ACMD_FUNC(clearstorage)
  5024. {
  5025. int i, j;
  5026. nullpo_retr(-1, sd);
  5027. if (sd->state.storage_flag == 1) {
  5028. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5029. return -1;
  5030. }
  5031. if (sd->state.storage_flag == 3) {
  5032. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5033. return -1;
  5034. }
  5035. j = sd->storage.amount;
  5036. for (i = 0; i < j; ++i) {
  5037. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  5038. }
  5039. sd->state.storage_flag = 1;
  5040. storage_storageclose(sd);
  5041. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  5042. return 0;
  5043. }
  5044. ACMD_FUNC(cleargstorage)
  5045. {
  5046. int i, j;
  5047. struct guild *g;
  5048. struct s_storage *gstorage;
  5049. nullpo_retr(-1, sd);
  5050. g = sd->guild;
  5051. if (g == NULL) {
  5052. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  5053. return -1;
  5054. }
  5055. if (sd->state.storage_flag == 1) {
  5056. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5057. return -1;
  5058. }
  5059. if (sd->state.storage_flag == 2) {
  5060. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  5061. return -1;
  5062. }
  5063. if (sd->state.storage_flag == 3) {
  5064. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5065. return -1;
  5066. }
  5067. gstorage = guild2storage2(sd->status.guild_id);
  5068. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  5069. return -1;
  5070. }
  5071. j = gstorage->amount;
  5072. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  5073. for (i = 0; i < j; ++i) {
  5074. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  5075. }
  5076. storage_guild_storageclose(sd);
  5077. gstorage->lock = false; // Cleaning done, release lock
  5078. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  5079. return 0;
  5080. }
  5081. ACMD_FUNC(clearcart)
  5082. {
  5083. int i;
  5084. nullpo_retr(-1, sd);
  5085. if (pc_iscarton(sd) == 0) {
  5086. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  5087. return -1;
  5088. }
  5089. if (sd->state.vending == 1) { //Somehow...
  5090. return -1;
  5091. }
  5092. for (i = 0; i < MAX_CART; i++) {
  5093. if (sd->cart.u.items_cart[i].nameid > 0)
  5094. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  5095. }
  5096. clif_clearcart(fd);
  5097. clif_updatestatus(sd,SP_CARTINFO);
  5098. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  5099. return 0;
  5100. }
  5101. /*==========================================
  5102. * @skillid by [MouseJstr]
  5103. * lookup a skill by name
  5104. *------------------------------------------*/
  5105. #define MAX_SKILLID_PARTIAL_RESULTS 5
  5106. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  5107. ACMD_FUNC(skillid) {
  5108. int skillen, i, found = 0;
  5109. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  5110. nullpo_retr(-1, sd);
  5111. if (!message || !*message) {
  5112. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  5113. return -1;
  5114. }
  5115. skillen = strlen(message);
  5116. for(const auto & skill : skill_db) {
  5117. uint16 skill_id = skill.second->nameid;
  5118. uint16 idx = skill_get_index(skill_id);
  5119. const char *name = skill.second->name;
  5120. const char *desc = skill.second->desc;
  5121. if (strnicmp(name, message, skillen) == 0 || strnicmp(desc, message, skillen) == 0) {
  5122. sprintf(atcmd_output, msg_txt(sd,1164), skill_id, desc, name); // skill %d: %s (%s)
  5123. clif_displaymessage(fd, atcmd_output);
  5124. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(name,message) || stristr(desc,message) ) ) {
  5125. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), skill_id, desc, name); // // skill %d: %s (%s)
  5126. }
  5127. }
  5128. if( found ) {
  5129. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  5130. clif_displaymessage(fd, atcmd_output);
  5131. }
  5132. for(i = 0; i < found; i++) { /* partials */
  5133. clif_displaymessage(fd, partials[i]);
  5134. }
  5135. return 0;
  5136. }
  5137. /*==========================================
  5138. * @useskill by [MouseJstr]
  5139. * A way of using skills without having to find them in the skills menu
  5140. *------------------------------------------*/
  5141. ACMD_FUNC(useskill)
  5142. {
  5143. struct map_session_data *pl_sd = NULL;
  5144. struct block_list *bl;
  5145. uint16 skill_id;
  5146. uint16 skill_lv;
  5147. nullpo_retr(-1, sd);
  5148. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5149. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  5150. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  5151. return -1;
  5152. }
  5153. if (!skill_id || !skill_db.find(skill_id)) {
  5154. clif_displaymessage(fd, msg_txt(sd, 198)); // This skill number doesn't exist.
  5155. return -1;
  5156. }
  5157. if (!skill_lv)
  5158. skill_lv = 1;
  5159. if(!strcmp(atcmd_player_name,"self"))
  5160. pl_sd = sd; //quick keyword
  5161. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
  5162. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5163. return -1;
  5164. }
  5165. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5166. {
  5167. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5168. return -1;
  5169. }
  5170. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5171. bl = &sd->hd->bl;
  5172. else
  5173. bl = &sd->bl;
  5174. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  5175. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  5176. else
  5177. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  5178. return 0;
  5179. }
  5180. /*==========================================
  5181. * @displayskill by [Skotlex]
  5182. * Debug command to locate new skill IDs. It sends the
  5183. * three possible skill-effect packets to the area.
  5184. *------------------------------------------*/
  5185. ACMD_FUNC(displayskill)
  5186. {
  5187. struct status_data * status;
  5188. t_tick tick;
  5189. uint16 skill_id;
  5190. uint16 skill_lv = 1;
  5191. uint16 type = 0;
  5192. nullpo_retr(-1, sd);
  5193. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &skill_id, &skill_lv, &type) < 1)
  5194. {
  5195. clif_displaymessage(fd, msg_txt(sd,1166));// Usage: @displayskill <skill ID> {<skill level> <type>}
  5196. clif_displaymessage(fd, msg_txt(sd,825));// Effect Types: 0: All, 1: Damage, 2: Splash Dmg, 3: No Damage, 4: Ground
  5197. return -1;
  5198. }
  5199. status = status_get_status_data(&sd->bl);
  5200. tick = gettick();
  5201. if (type == 0 || type == 1)
  5202. clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SINGLE);
  5203. if (type == 0 || type == 2)
  5204. clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  5205. if (type == 0 || type == 3)
  5206. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  5207. if (type == 0 || type == 4)
  5208. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  5209. return 0;
  5210. }
  5211. /*==========================================
  5212. * @displayskillcast by [Rytech]
  5213. * Debug command to view casting animations for skills.
  5214. * Can target self or the ground. Ground target can be
  5215. * useful for seeing casting circle size.
  5216. *------------------------------------------*/
  5217. ACMD_FUNC(displayskillcast)
  5218. {
  5219. uint16 skill_id;
  5220. uint16 skill_lv = 1;
  5221. uint16 cast_time = 5000;
  5222. uint16 target_type = 0;
  5223. nullpo_retr(-1, sd);
  5224. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu %6hu", &skill_id, &skill_lv, &target_type, &cast_time) < 1)
  5225. {
  5226. clif_displaymessage(fd, msg_txt(sd, 824));// Usage: @displayskillcast <skill ID> {<skill level> <ground target flag> <cast time>}
  5227. return -1;
  5228. }
  5229. if ( target_type == 1)
  5230. clif_skillcasting(&sd->bl, sd->bl.id, 0, sd->bl.x, sd->bl.y, skill_id, skill_lv, 0, cast_time);
  5231. else
  5232. clif_skillcasting(&sd->bl, sd->bl.id, sd->bl.id, 0, 0, skill_id, skill_lv, 0, cast_time);
  5233. return 0;
  5234. }
  5235. /*==========================================
  5236. * @displayskillunit by [Rytech]
  5237. * Debug command to view unit animations for skills.
  5238. *------------------------------------------*/
  5239. ACMD_FUNC(displayskillunit)
  5240. {
  5241. uint16 unit_id;
  5242. uint16 range = 0;
  5243. uint16 skill_lv = 1;
  5244. nullpo_retr(-1, sd);
  5245. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &unit_id, &skill_lv, &range) < 1)
  5246. {
  5247. clif_displaymessage(fd, msg_txt(sd, 826));// Usage: @displayskillunit <unit ID> {<skill level> <range>}
  5248. return -1;
  5249. }
  5250. clif_skill_unit_test(&sd->bl, sd->bl.x, sd->bl.y, unit_id, range, skill_lv);
  5251. return 0;
  5252. }
  5253. /*==========================================
  5254. * @skilltree by [MouseJstr]
  5255. * prints the skill tree for a player required to get to a skill
  5256. *------------------------------------------*/
  5257. ACMD_FUNC(skilltree)
  5258. {
  5259. struct map_session_data *pl_sd = NULL;
  5260. uint16 skill_id;
  5261. nullpo_retr(-1, sd);
  5262. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5263. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  5264. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  5265. return -1;
  5266. }
  5267. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5268. {
  5269. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5270. return -1;
  5271. }
  5272. int c = pc_mapid2jobid( pc_calc_skilltree_normalize_job( pl_sd ), pl_sd->status.sex );
  5273. 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).
  5274. clif_displaymessage(fd, atcmd_output);
  5275. auto entry = skill_tree_db.get_skill_data(c, skill_id);
  5276. if (entry == nullptr) {
  5277. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5278. return 0;
  5279. }
  5280. bool meets = true;
  5281. for (const auto &it : entry->need) {
  5282. if (pc_checkskill(sd, it.first) < it.second) {
  5283. sprintf(atcmd_output, msg_txt(sd,1170), it.second, skill_get_desc(it.first)); // Player requires level %d of skill %s.
  5284. clif_displaymessage(fd, atcmd_output);
  5285. meets = false;
  5286. }
  5287. }
  5288. if (meets) {
  5289. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5290. }
  5291. return 0;
  5292. }
  5293. // Hand a ring with partners name on it to this char
  5294. void getring (struct map_session_data* sd)
  5295. {
  5296. char flag = 0;
  5297. t_itemid item_id;
  5298. struct item item_tmp;
  5299. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5300. memset(&item_tmp, 0, sizeof(item_tmp));
  5301. item_tmp.nameid = item_id;
  5302. item_tmp.identify = 1;
  5303. item_tmp.card[0] = CARD0_FORGE;
  5304. item_tmp.card[2] = GetWord(sd->status.partner_id,0);
  5305. item_tmp.card[3] = GetWord(sd->status.partner_id,1);
  5306. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5307. clif_additem(sd,0,0,flag);
  5308. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  5309. }
  5310. }
  5311. /*==========================================
  5312. * @marry by [MouseJstr], fixed by Lupus
  5313. * Marry two players
  5314. *------------------------------------------*/
  5315. ACMD_FUNC(marry)
  5316. {
  5317. struct map_session_data *pl_sd = NULL;
  5318. nullpo_retr(-1, sd);
  5319. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5320. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5321. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5322. return -1;
  5323. }
  5324. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  5325. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5326. return -1;
  5327. }
  5328. if (pc_marriage(sd, pl_sd)) {
  5329. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5330. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5331. if( pl_sd->bl.m != sd->bl.m )
  5332. clif_wedding_effect(&sd->bl);
  5333. getring(sd); // Auto-give named rings (Aru)
  5334. getring(pl_sd);
  5335. return 0;
  5336. }
  5337. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5338. return -1;
  5339. }
  5340. /*==========================================
  5341. * @divorce by [MouseJstr], fixed by [Lupus]
  5342. * divorce two players
  5343. *------------------------------------------*/
  5344. ACMD_FUNC(divorce)
  5345. {
  5346. nullpo_retr(-1, sd);
  5347. if (!pc_divorce(sd)) {
  5348. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5349. clif_displaymessage(fd, atcmd_output);
  5350. return -1;
  5351. }
  5352. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5353. clif_displaymessage(fd, atcmd_output);
  5354. return 0;
  5355. }
  5356. /*==========================================
  5357. * @changelook by [Celest]
  5358. *------------------------------------------*/
  5359. ACMD_FUNC(changelook)
  5360. {
  5361. int i, j = 0, k = 0;
  5362. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5363. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5364. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5365. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5366. return -1;
  5367. } else if ( i == 2 ) {
  5368. if (j < 1 || j > 8)
  5369. j = 1;
  5370. j = pos[j - 1];
  5371. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5372. k = j; // swap
  5373. j = LOOK_HEAD_TOP;
  5374. }
  5375. clif_changelook(&sd->bl,j,k);
  5376. return 0;
  5377. }
  5378. /*==========================================
  5379. * @autotrade by durf [Lupus] [Paradox924X]
  5380. * Turns on/off Autotrade for a specific player
  5381. *------------------------------------------*/
  5382. ACMD_FUNC(autotrade) {
  5383. nullpo_retr(-1, sd);
  5384. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5385. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5386. return -1;
  5387. }
  5388. if( pc_isdead(sd) ) {
  5389. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5390. return -1;
  5391. }
  5392. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5393. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5394. return -1;
  5395. }
  5396. sd->state.autotrade = 1;
  5397. if (battle_config.autotrade_monsterignore)
  5398. sd->state.block_action |= PCBLOCK_IMMUNE;
  5399. if( sd->state.vending ){
  5400. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
  5401. Sql_ShowDebug( mmysql_handle );
  5402. }
  5403. }else if( sd->state.buyingstore ){
  5404. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
  5405. Sql_ShowDebug( mmysql_handle );
  5406. }
  5407. }
  5408. if( battle_config.at_timeout ) {
  5409. int timeout = atoi(message);
  5410. status_change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
  5411. }
  5412. if (battle_config.at_logout_event)
  5413. npc_script_event(sd, NPCE_LOGOUT); //Logout Event
  5414. channel_pcquit(sd,0xF); //leave all chan
  5415. clif_authfail_fd(sd->fd, 15);
  5416. chrif_save(sd, CSAVE_AUTOTRADE);
  5417. return 0;
  5418. }
  5419. /*==========================================
  5420. * @changegm by durf (changed by Lupus)
  5421. * Changes Master of your Guild to a specified guild member
  5422. *------------------------------------------*/
  5423. ACMD_FUNC(changegm)
  5424. {
  5425. struct guild *g;
  5426. struct map_session_data *pl_sd;
  5427. nullpo_retr(-1, sd);
  5428. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5429. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5430. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5431. return -1;
  5432. }
  5433. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5434. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5435. return -1;
  5436. }
  5437. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5438. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5439. return -1;
  5440. }
  5441. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5442. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5443. return -1;
  5444. }
  5445. if( !battle_config.guild_leaderchange_woe && is_agit_start() ){
  5446. #if PACKETVER >= 20151001
  5447. clif_msg(sd, GUILD_MASTER_WOE);
  5448. #else
  5449. clif_displaymessage(fd, msg_txt(sd,1513)); // Currently in WoE hours, unable to delegate Guild leader
  5450. #endif
  5451. return -1;
  5452. }
  5453. if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(NULL),sd->guild->last_leader_change) < battle_config.guild_leaderchange_delay ){
  5454. #if PACKETVER >= 20151001
  5455. clif_msg(sd, GUILD_MASTER_DELAY);
  5456. #else
  5457. clif_displaymessage(fd, msg_txt(sd,1514)); // You have to wait for a while before delegating a new Guild leader
  5458. #endif
  5459. return -1;
  5460. }
  5461. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5462. return 0;
  5463. }
  5464. /*==========================================
  5465. * @changeleader by Skotlex
  5466. * Changes the leader of a party.
  5467. *------------------------------------------*/
  5468. ACMD_FUNC(changeleader)
  5469. {
  5470. nullpo_retr(-1, sd);
  5471. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5472. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5473. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5474. return -1;
  5475. }
  5476. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
  5477. return 0;
  5478. }
  5479. /*==========================================
  5480. * @partyoption by Skotlex
  5481. * Used to change the item share setting of a party.
  5482. *------------------------------------------*/
  5483. ACMD_FUNC(partyoption)
  5484. {
  5485. struct party_data *p;
  5486. int mi, option;
  5487. char w1[16], w2[16];
  5488. nullpo_retr(-1, sd);
  5489. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5490. {
  5491. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5492. return -1;
  5493. }
  5494. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5495. if (mi == MAX_PARTY)
  5496. return -1; //Shouldn't happen
  5497. if (!p->party.member[mi].leader)
  5498. {
  5499. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5500. return -1;
  5501. }
  5502. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5503. {
  5504. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5505. return -1;
  5506. }
  5507. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5508. //Change item share type.
  5509. if (option != p->party.item)
  5510. party_changeoption(sd, p->party.exp, option);
  5511. else
  5512. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5513. return 0;
  5514. }
  5515. /*==========================================
  5516. * @autoloot by Upa-Kun
  5517. * Turns on/off AutoLoot for a specific player
  5518. *------------------------------------------*/
  5519. ACMD_FUNC(autoloot)
  5520. {
  5521. int rate;
  5522. nullpo_retr(-1, sd);
  5523. // autoloot command without value
  5524. if(!message || !*message)
  5525. {
  5526. if (sd->state.autoloot)
  5527. rate = 0;
  5528. else
  5529. rate = 10000;
  5530. } else {
  5531. double drate;
  5532. drate = atof(message);
  5533. rate = (int)(drate*100);
  5534. }
  5535. if (rate < 0) rate = 0;
  5536. if (rate > 10000) rate = 10000;
  5537. sd->state.autoloot = rate;
  5538. if (sd->state.autoloot) {
  5539. 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.
  5540. clif_displaymessage(fd, atcmd_output);
  5541. }else
  5542. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5543. return 0;
  5544. }
  5545. /*==========================================
  5546. * @alootid
  5547. *------------------------------------------*/
  5548. ACMD_FUNC(autolootitem)
  5549. {
  5550. std::shared_ptr<item_data> item_data;
  5551. int i;
  5552. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5553. nullpo_retr(-1, sd);
  5554. if (message && *message) {
  5555. if (message[0] == '+') {
  5556. message++;
  5557. action = 1;
  5558. }
  5559. else if (message[0] == '-') {
  5560. message++;
  5561. action = 2;
  5562. }
  5563. else if (!strcmp(message,"reset"))
  5564. action = 4;
  5565. }
  5566. if (action < 3) // add or remove
  5567. {
  5568. item_data = item_db.find( strtoul( message, nullptr, 10 ) );
  5569. if( item_data == nullptr ){
  5570. item_data = item_db.searchname( message );
  5571. }
  5572. if( item_data == nullptr ){
  5573. // No items founds in the DB with Id or Name
  5574. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5575. return -1;
  5576. }
  5577. }
  5578. switch(action) {
  5579. case 1:
  5580. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5581. if (i != AUTOLOOTITEM_SIZE) {
  5582. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5583. return -1;
  5584. }
  5585. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5586. if (i == AUTOLOOTITEM_SIZE) {
  5587. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5588. return -1;
  5589. }
  5590. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5591. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name.c_str(), item_data->ename.c_str(), item_data->nameid); // Autolooting item: '%s'/'%s' {%u}
  5592. clif_displaymessage(fd, atcmd_output);
  5593. sd->state.autolooting = 1;
  5594. break;
  5595. case 2:
  5596. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5597. if (i == AUTOLOOTITEM_SIZE) {
  5598. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5599. return -1;
  5600. }
  5601. sd->state.autolootid[i] = 0;
  5602. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name.c_str(), item_data->ename.c_str(), item_data->nameid); // Removed item: '%s'/'%s' {%u} from your autolootitem list.
  5603. clif_displaymessage(fd, atcmd_output);
  5604. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5605. if (i == AUTOLOOTITEM_SIZE) {
  5606. sd->state.autolooting = 0;
  5607. }
  5608. break;
  5609. case 3:
  5610. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5611. clif_displaymessage(fd, atcmd_output);
  5612. 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>".
  5613. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5614. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5615. if (i == AUTOLOOTITEM_SIZE) {
  5616. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5617. } else {
  5618. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5619. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5620. {
  5621. if (sd->state.autolootid[i] == 0)
  5622. continue;
  5623. item_data = item_db.find( sd->state.autolootid[i] );
  5624. if( item_data == nullptr ){
  5625. 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);
  5626. continue;
  5627. }
  5628. sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_data->ename.c_str(), item_data->nameid);
  5629. clif_displaymessage(fd, atcmd_output);
  5630. }
  5631. }
  5632. break;
  5633. case 4:
  5634. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5635. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5636. sd->state.autolooting = 0;
  5637. break;
  5638. }
  5639. return 0;
  5640. }
  5641. /*==========================================
  5642. * @autoloottype
  5643. * Flags:
  5644. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5645. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5646. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5647. * 262144: IT_CASH
  5648. *------------------------------------------
  5649. * Credits:
  5650. * chriser
  5651. * Aleos
  5652. *------------------------------------------*/
  5653. ACMD_FUNC(autoloottype)
  5654. {
  5655. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5656. enum item_types type= IT_UNKNOWN;
  5657. int ITEM_MAX = 1533;
  5658. nullpo_retr(-1, sd);
  5659. if (message && *message) {
  5660. if (message[0] == '+') {
  5661. message++;
  5662. action = 1;
  5663. }
  5664. else if (message[0] == '-') {
  5665. message++;
  5666. action = 2;
  5667. }
  5668. else if (!strcmp(message,"reset"))
  5669. action = 4;
  5670. }
  5671. if (action < 3) { // add or remove
  5672. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5673. type = IT_HEALING;
  5674. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5675. type = IT_USABLE;
  5676. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5677. type = IT_ETC;
  5678. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5679. type = IT_ARMOR;
  5680. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5681. type = IT_WEAPON;
  5682. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5683. type = IT_CARD;
  5684. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5685. type = IT_PETEGG;
  5686. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5687. type = IT_PETARMOR;
  5688. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5689. type = IT_AMMO;
  5690. else {
  5691. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5692. return -1;
  5693. }
  5694. }
  5695. switch (action) {
  5696. case 1:
  5697. if (sd->state.autoloottype&(1<<type)) {
  5698. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5699. return -1;
  5700. }
  5701. if (sd->state.autoloottype == ITEM_MAX) {
  5702. 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>.
  5703. return -1;
  5704. }
  5705. sd->state.autoloottype |= (1<<type); // Stores the type
  5706. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%u}
  5707. clif_displaymessage(fd, atcmd_output);
  5708. break;
  5709. case 2:
  5710. if (!(sd->state.autoloottype&(1<<type))) {
  5711. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5712. return -1;
  5713. }
  5714. sd->state.autoloottype &= ~(1<<type);
  5715. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%u} from your autoloottype list.
  5716. clif_displaymessage(fd, atcmd_output);
  5717. break;
  5718. case 3:
  5719. 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>".
  5720. 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
  5721. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5722. if (sd->state.autoloottype == 0)
  5723. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5724. else {
  5725. uint8 i = 0;
  5726. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5727. while (i < IT_MAX) {
  5728. if (sd->state.autoloottype&(1<<i)) {
  5729. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5730. clif_displaymessage(fd, atcmd_output);
  5731. }
  5732. i++;
  5733. }
  5734. }
  5735. break;
  5736. case 4:
  5737. sd->state.autoloottype = 0;
  5738. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5739. break;
  5740. }
  5741. return 0;
  5742. }
  5743. /*==========================================
  5744. * It is made to rain.
  5745. * No longer available, keeping here just in case it's back someday. [Ind]
  5746. *------------------------------------------*/
  5747. //ACMD_FUNC(rain)
  5748. //{
  5749. // nullpo_retr(-1, sd);
  5750. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5751. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5752. // clif_weather(sd->bl.m);
  5753. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5754. // } else {
  5755. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5756. // clif_weather(sd->bl.m);
  5757. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5758. // }
  5759. // return 0;
  5760. //}
  5761. /*==========================================
  5762. * It is made to snow.
  5763. *------------------------------------------*/
  5764. ACMD_FUNC(snow)
  5765. {
  5766. nullpo_retr(-1, sd);
  5767. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5768. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5769. clif_weather(sd->bl.m);
  5770. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5771. } else {
  5772. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5773. clif_weather(sd->bl.m);
  5774. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5775. }
  5776. return 0;
  5777. }
  5778. /*==========================================
  5779. * Cherry tree snowstorm is made to fall. (Sakura)
  5780. *------------------------------------------*/
  5781. ACMD_FUNC(sakura)
  5782. {
  5783. nullpo_retr(-1, sd);
  5784. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5785. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5786. clif_weather(sd->bl.m);
  5787. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5788. } else {
  5789. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  5790. clif_weather(sd->bl.m);
  5791. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5792. }
  5793. return 0;
  5794. }
  5795. /*==========================================
  5796. * Clouds appear.
  5797. *------------------------------------------*/
  5798. ACMD_FUNC(clouds)
  5799. {
  5800. nullpo_retr(-1, sd);
  5801. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  5802. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5803. clif_weather(sd->bl.m);
  5804. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5805. } else {
  5806. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  5807. clif_weather(sd->bl.m);
  5808. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5809. }
  5810. return 0;
  5811. }
  5812. /*==========================================
  5813. * Different type of clouds using effect 516
  5814. *------------------------------------------*/
  5815. ACMD_FUNC(clouds2)
  5816. {
  5817. nullpo_retr(-1, sd);
  5818. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  5819. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5820. clif_weather(sd->bl.m);
  5821. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5822. } else {
  5823. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  5824. clif_weather(sd->bl.m);
  5825. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5826. }
  5827. return 0;
  5828. }
  5829. /*==========================================
  5830. * Fog hangs over.
  5831. *------------------------------------------*/
  5832. ACMD_FUNC(fog)
  5833. {
  5834. nullpo_retr(-1, sd);
  5835. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  5836. map_setmapflag(sd->bl.m, MF_FOG, false);
  5837. clif_weather(sd->bl.m);
  5838. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5839. } else {
  5840. map_setmapflag(sd->bl.m, MF_FOG, true);
  5841. clif_weather(sd->bl.m);
  5842. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5843. }
  5844. return 0;
  5845. }
  5846. /*==========================================
  5847. * Fallen leaves fall.
  5848. *------------------------------------------*/
  5849. ACMD_FUNC(leaves)
  5850. {
  5851. nullpo_retr(-1, sd);
  5852. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  5853. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5854. clif_weather(sd->bl.m);
  5855. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5856. } else {
  5857. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  5858. clif_weather(sd->bl.m);
  5859. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5860. }
  5861. return 0;
  5862. }
  5863. /*==========================================
  5864. * Fireworks appear.
  5865. *------------------------------------------*/
  5866. ACMD_FUNC(fireworks)
  5867. {
  5868. nullpo_retr(-1, sd);
  5869. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  5870. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5871. clif_weather(sd->bl.m);
  5872. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5873. } else {
  5874. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  5875. clif_weather(sd->bl.m);
  5876. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5877. }
  5878. return 0;
  5879. }
  5880. /*==========================================
  5881. * Clearing Weather Effects by Dexity
  5882. *------------------------------------------*/
  5883. ACMD_FUNC(clearweather)
  5884. {
  5885. nullpo_retr(-1, sd);
  5886. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  5887. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5888. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5889. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5890. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5891. map_setmapflag(sd->bl.m, MF_FOG, false);
  5892. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5893. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5894. clif_weather(sd->bl.m);
  5895. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  5896. return 0;
  5897. }
  5898. /*===============================================================
  5899. * Sound Command - plays a sound for everyone around! [Codemaster]
  5900. *---------------------------------------------------------------*/
  5901. ACMD_FUNC(sound)
  5902. {
  5903. char sound_file[100];
  5904. memset(sound_file, '\0', sizeof(sound_file));
  5905. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5906. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5907. return -1;
  5908. }
  5909. if(strstr(sound_file, ".wav") == NULL)
  5910. strcat(sound_file, ".wav");
  5911. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5912. return 0;
  5913. }
  5914. /*==========================================
  5915. * MOB Search
  5916. *------------------------------------------*/
  5917. ACMD_FUNC(mobsearch)
  5918. {
  5919. nullpo_retr(-1, sd);
  5920. char mob_name[100]={0};
  5921. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5922. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5923. return -1;
  5924. }
  5925. int mob_id = strtol(mob_name, nullptr, 10);
  5926. if (mob_id == 0)
  5927. mob_id = mobdb_searchname(mob_name);
  5928. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  5929. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  5930. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5931. clif_displaymessage(fd, atcmd_output);
  5932. return -1;
  5933. }
  5934. strcpy(mob_name, mob->jname.c_str()); // --ja--
  5935. // strcpy(mob_name, mob->name.c_str()); // --en--
  5936. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5937. clif_displaymessage(fd, atcmd_output);
  5938. s_mapiterator* it = mapit_geteachmob();
  5939. int number = 0;
  5940. for(;;)
  5941. {
  5942. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5943. if( md == NULL )
  5944. break;// no more mobs
  5945. if( md->bl.m != sd->bl.m )
  5946. continue;
  5947. if( md->mob_id != mob_id )
  5948. continue;
  5949. ++number;
  5950. if( md->spawn_timer == INVALID_TIMER )
  5951. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5952. else
  5953. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5954. clif_displaymessage(fd, atcmd_output);
  5955. }
  5956. mapit_free(it);
  5957. return 0;
  5958. }
  5959. /*==========================================
  5960. * @cleanmap - cleans items on the ground
  5961. * @cleanarea - cleans items on the ground within an specified area
  5962. *------------------------------------------*/
  5963. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5964. {
  5965. nullpo_ret(bl);
  5966. map_clearflooritem(bl);
  5967. return 0;
  5968. }
  5969. ACMD_FUNC(cleanmap)
  5970. {
  5971. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5972. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5973. return 0;
  5974. }
  5975. ACMD_FUNC(cleanarea)
  5976. {
  5977. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5978. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5979. 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);
  5980. }
  5981. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5982. 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);
  5983. }
  5984. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5985. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5986. }
  5987. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5988. return 0;
  5989. }
  5990. /*==========================================
  5991. * make a NPC/PET talk
  5992. * @npctalkc [SnakeDrak]
  5993. *------------------------------------------*/
  5994. ACMD_FUNC(npctalk)
  5995. {
  5996. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  5997. struct npc_data *nd;
  5998. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5999. unsigned long color=0;
  6000. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6001. return -1; //no "chatting" while muted.
  6002. if(!ifcolor) {
  6003. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  6004. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  6005. return -1;
  6006. }
  6007. }
  6008. else {
  6009. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6010. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  6011. return -1;
  6012. }
  6013. }
  6014. if (!(nd = npc_name2id(name))) {
  6015. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  6016. return -1;
  6017. }
  6018. strtok(name, "#"); // discard extra name identifier if present
  6019. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6020. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  6021. else clif_disp_overhead(&nd->bl, temp);
  6022. return 0;
  6023. }
  6024. ACMD_FUNC(pettalk)
  6025. {
  6026. char mes[100],temp[CHAT_SIZE_MAX];
  6027. struct pet_data *pd;
  6028. nullpo_retr(-1, sd);
  6029. if ( battle_config.min_chat_delay ) {
  6030. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6031. return 0;
  6032. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6033. }
  6034. if(!sd->status.pet_id || !(pd=sd->pd))
  6035. {
  6036. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  6037. return -1;
  6038. }
  6039. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6040. return -1; //no "chatting" while muted.
  6041. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6042. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  6043. return -1;
  6044. }
  6045. if (message[0] == '/')
  6046. {// pet emotion processing
  6047. const char* emo[] = {
  6048. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6049. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6050. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6051. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  6052. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  6053. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  6054. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  6055. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  6056. "/whisp"
  6057. };
  6058. int i;
  6059. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6060. if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
  6061. if( i < ARRAYLENGTH(emo) )
  6062. {
  6063. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  6064. sd->emotionlasttime = time(NULL);
  6065. return 0;
  6066. }
  6067. sd->emotionlasttime = time(NULL);
  6068. clif_emotion(&pd->bl, i);
  6069. return 0;
  6070. }
  6071. }
  6072. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6073. clif_disp_overhead(&pd->bl, temp);
  6074. return 0;
  6075. }
  6076. /// @users - displays the number of players present on each map (and percentage)
  6077. /// #users displays on the target user instead of self
  6078. ACMD_FUNC(users)
  6079. {
  6080. char buf[CHAT_SIZE_MAX];
  6081. int i;
  6082. int users[MAX_MAPINDEX];
  6083. int users_all;
  6084. struct s_mapiterator* iter;
  6085. memset(users, 0, sizeof(users));
  6086. users_all = 0;
  6087. // count users on each map
  6088. iter = mapit_getallusers();
  6089. for(;;)
  6090. {
  6091. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  6092. if( sd2 == NULL )
  6093. break;// no more users
  6094. if( sd2->mapindex >= MAX_MAPINDEX )
  6095. continue;// invalid mapindex
  6096. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6097. if( users_all < INT_MAX ) ++users_all;
  6098. }
  6099. mapit_free(iter);
  6100. // display results for each map
  6101. for( i = 0; i < MAX_MAPINDEX; ++i )
  6102. {
  6103. if( users[i] == 0 )
  6104. continue;// empty
  6105. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6106. clif_displaymessage(sd->fd, buf);
  6107. }
  6108. // display overall count
  6109. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6110. clif_displaymessage(sd->fd, buf);
  6111. return 0;
  6112. }
  6113. /*==========================================
  6114. *
  6115. *------------------------------------------*/
  6116. ACMD_FUNC(reset)
  6117. {
  6118. pc_resetstate(sd);
  6119. pc_resetskill(sd,1);
  6120. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  6121. clif_displaymessage(fd, atcmd_output);
  6122. return 0;
  6123. }
  6124. /*==========================================
  6125. *
  6126. *------------------------------------------*/
  6127. ACMD_FUNC(summon)
  6128. {
  6129. char name[NAME_LENGTH];
  6130. int mob_id = 0;
  6131. int duration = 0;
  6132. struct mob_data *md;
  6133. t_tick tick=gettick();
  6134. nullpo_retr(-1, sd);
  6135. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  6136. {
  6137. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  6138. return -1;
  6139. }
  6140. if (duration < 1)
  6141. duration =1;
  6142. else if (duration > 60)
  6143. duration =60;
  6144. if ((mob_id = atoi(name)) == 0)
  6145. mob_id = mobdb_searchname(name);
  6146. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6147. {
  6148. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6149. return -1;
  6150. }
  6151. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  6152. if(!md)
  6153. return -1;
  6154. md->master_id=sd->bl.id;
  6155. md->special_state.ai=AI_ATTACK;
  6156. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6157. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  6158. mob_spawn(md);
  6159. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6160. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  6161. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  6162. return 0;
  6163. }
  6164. /*==========================================
  6165. * @adjgroup
  6166. * Temporarily move player to another group
  6167. * Useful during beta testing to allow players to use GM commands for short periods of time
  6168. *------------------------------------------*/
  6169. ACMD_FUNC(adjgroup)
  6170. {
  6171. int new_group = 0;
  6172. nullpo_retr(-1, sd);
  6173. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  6174. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  6175. return -1;
  6176. }
  6177. if (!pc_group_exists(new_group)) {
  6178. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  6179. return -1;
  6180. }
  6181. sd->group_id = new_group;
  6182. pc_group_pc_load(sd);/* update cache */
  6183. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  6184. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  6185. return 0;
  6186. }
  6187. /*==========================================
  6188. * @trade by [MouseJstr]
  6189. * Open a trade window with a remote player
  6190. *------------------------------------------*/
  6191. ACMD_FUNC(trade)
  6192. {
  6193. struct map_session_data *pl_sd = NULL;
  6194. nullpo_retr(-1, sd);
  6195. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6196. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6197. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  6198. return -1;
  6199. }
  6200. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  6201. {
  6202. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6203. return -1;
  6204. }
  6205. trade_traderequest(sd, pl_sd);
  6206. return 0;
  6207. }
  6208. /*==========================================
  6209. * @setbattleflag by [MouseJstr]
  6210. * set a battle_config flag without having to reboot
  6211. *------------------------------------------*/
  6212. ACMD_FUNC(setbattleflag)
  6213. {
  6214. char flag[128], value[128];
  6215. int reload = 0;
  6216. nullpo_retr(-1, sd);
  6217. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
  6218. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  6219. return -1;
  6220. }
  6221. if (battle_set_value(flag, value) == 0)
  6222. {
  6223. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  6224. return -1;
  6225. }
  6226. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  6227. if (reload)
  6228. mob_reload();
  6229. return 0;
  6230. }
  6231. /*==========================================
  6232. * @unmute [Valaris]
  6233. *------------------------------------------*/
  6234. ACMD_FUNC(unmute)
  6235. {
  6236. struct map_session_data *pl_sd = NULL;
  6237. nullpo_retr(-1, sd);
  6238. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6239. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6240. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6241. return -1;
  6242. }
  6243. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6244. {
  6245. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6246. return -1;
  6247. }
  6248. if(!pl_sd->sc.data[SC_NOCHAT]) {
  6249. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6250. return -1;
  6251. }
  6252. pl_sd->status.manner = 0;
  6253. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6254. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6255. return 0;
  6256. }
  6257. /*==========================================
  6258. * @uptime by MC Cameri
  6259. *------------------------------------------*/
  6260. ACMD_FUNC(uptime)
  6261. {
  6262. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6263. minute = 60, days = 0, hours = 0, minutes = 0;
  6264. nullpo_retr(-1, sd);
  6265. seconds = get_uptime();
  6266. days = seconds/day;
  6267. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6268. hours = seconds/hour;
  6269. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6270. minutes = seconds/minute;
  6271. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6272. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  6273. clif_displaymessage(fd, atcmd_output);
  6274. return 0;
  6275. }
  6276. /*==========================================
  6277. * @changesex
  6278. * => Changes one's account sex. Switch from male to female or visversa
  6279. *------------------------------------------*/
  6280. ACMD_FUNC(changesex)
  6281. {
  6282. int i;
  6283. nullpo_retr(-1, sd);
  6284. pc_resetskill(sd,4);
  6285. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6286. for (i = 0; i < EQI_MAX; i++) {
  6287. if (sd->equip_index[i] >= 0)
  6288. pc_unequipitem(sd, sd->equip_index[i], 3);
  6289. }
  6290. chrif_changesex(sd, true);
  6291. return 0;
  6292. }
  6293. /*==========================================
  6294. * @changecharsex
  6295. * => Changes one's character sex. Switch from male to female or visversa.
  6296. *------------------------------------------*/
  6297. ACMD_FUNC(changecharsex)
  6298. {
  6299. int i;
  6300. nullpo_retr(-1, sd);
  6301. pc_resetskill(sd,4);
  6302. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6303. for (i = 0; i < EQI_MAX; i++) {
  6304. if (sd->equip_index[i] >= 0)
  6305. pc_unequipitem(sd, sd->equip_index[i], 3);
  6306. }
  6307. chrif_changesex(sd, false);
  6308. return 0;
  6309. }
  6310. /*================================================
  6311. * @mute - Mutes a player for a set amount of time
  6312. *------------------------------------------------*/
  6313. ACMD_FUNC(mute)
  6314. {
  6315. struct map_session_data *pl_sd = NULL;
  6316. int manner;
  6317. nullpo_retr(-1, sd);
  6318. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6319. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6320. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6321. return -1;
  6322. }
  6323. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6324. {
  6325. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6326. return -1;
  6327. }
  6328. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6329. {
  6330. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6331. return -1;
  6332. }
  6333. clif_manner_message(sd, 0);
  6334. clif_manner_message(pl_sd, 5);
  6335. if( pl_sd->status.manner < manner ) {
  6336. pl_sd->status.manner -= manner;
  6337. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6338. } else {
  6339. pl_sd->status.manner = 0;
  6340. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6341. }
  6342. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6343. return 0;
  6344. }
  6345. /*==========================================
  6346. * @refresh (like @jumpto <<yourself>>)
  6347. *------------------------------------------*/
  6348. ACMD_FUNC(refresh)
  6349. {
  6350. nullpo_retr(-1, sd);
  6351. clif_refresh(sd);
  6352. return 0;
  6353. }
  6354. ACMD_FUNC(refreshall)
  6355. {
  6356. struct map_session_data* iter_sd;
  6357. struct s_mapiterator* iter;
  6358. nullpo_retr(-1, sd);
  6359. iter = mapit_getallusers();
  6360. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6361. clif_refresh(iter_sd);
  6362. mapit_free(iter);
  6363. return 0;
  6364. }
  6365. /*==========================================
  6366. * @identify
  6367. * => GM's magnifier.
  6368. *------------------------------------------*/
  6369. ACMD_FUNC(identify)
  6370. {
  6371. int i,num;
  6372. nullpo_retr(-1, sd);
  6373. for(i=num=0;i<MAX_INVENTORY;i++){
  6374. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6375. num++;
  6376. }
  6377. }
  6378. if (num > 0) {
  6379. clif_item_identify_list(sd);
  6380. } else {
  6381. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6382. }
  6383. return 0;
  6384. }
  6385. /*===============================================
  6386. * @identifyall
  6387. * => Indentify all items in inventory - Akinari
  6388. *-----------------------------------------------*/
  6389. ACMD_FUNC(identifyall)
  6390. {
  6391. nullpo_retr(-1, sd);
  6392. pc_identifyall(sd, true);
  6393. return 0;
  6394. }
  6395. /*==========================================
  6396. * @gmotd (Global MOTD)
  6397. * by davidsiaw :P
  6398. *------------------------------------------*/
  6399. ACMD_FUNC(gmotd)
  6400. {
  6401. FILE* fp;
  6402. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6403. {
  6404. char buf[CHAT_SIZE_MAX];
  6405. size_t len;
  6406. while( fgets(buf, sizeof(buf), fp) )
  6407. {
  6408. if( buf[0] == '/' && buf[1] == '/' )
  6409. {
  6410. continue;
  6411. }
  6412. len = strlen(buf);
  6413. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6414. {// strip trailing EOL characters
  6415. len--;
  6416. }
  6417. if( len )
  6418. {
  6419. buf[len] = 0;
  6420. intif_broadcast(buf, len+1, 0);
  6421. }
  6422. }
  6423. fclose(fp);
  6424. }
  6425. return 0;
  6426. }
  6427. ACMD_FUNC(misceffect)
  6428. {
  6429. int effect = 0;
  6430. nullpo_retr(-1, sd);
  6431. if (!message || !*message)
  6432. return -1;
  6433. if (sscanf(message, "%11d", &effect) < 1)
  6434. return -1;
  6435. clif_misceffect(&sd->bl,effect);
  6436. return 0;
  6437. }
  6438. /*==========================================
  6439. * MAIL SYSTEM
  6440. *------------------------------------------*/
  6441. ACMD_FUNC(mail)
  6442. {
  6443. nullpo_ret(sd);
  6444. mail_openmail(sd);
  6445. return 0;
  6446. }
  6447. /*==========================================
  6448. * Show Monster DB Info v 1.0
  6449. * originally by [Lupus]
  6450. *------------------------------------------*/
  6451. ACMD_FUNC(mobinfo)
  6452. {
  6453. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6454. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6455. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6456. char atcmd_output2[CHAT_SIZE_MAX];
  6457. struct item_data *item_data;
  6458. uint16 mob_ids[MAX_SEARCH];
  6459. int count;
  6460. int i, k;
  6461. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6462. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6463. if (!message || !*message) {
  6464. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6465. return -1;
  6466. }
  6467. // If monster identifier/name argument is a name
  6468. if ((i = mobdb_checkid(atoi(message))))
  6469. {
  6470. mob_ids[0] = i;
  6471. count = 1;
  6472. } else
  6473. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6474. if (!count) {
  6475. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6476. return -1;
  6477. }
  6478. if (count >= MAX_SEARCH) {
  6479. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6480. clif_displaymessage(fd, atcmd_output);
  6481. count = MAX_SEARCH;
  6482. }
  6483. for (k = 0; k < count; k++) {
  6484. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_ids[k]);
  6485. if (mob == nullptr)
  6486. continue;
  6487. t_exp base_exp = mob->base_exp;
  6488. t_exp job_exp = mob->job_exp;
  6489. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6490. base_exp += (base_exp * battle_config.vip_base_exp_increase) / 100;
  6491. job_exp += (job_exp * battle_config.vip_job_exp_increase) / 100;
  6492. }
  6493. #ifdef RENEWAL_EXP
  6494. if( battle_config.atcommand_mobinfo_type ) {
  6495. int penalty = pc_level_penalty_mod( sd, PENALTY_EXP, mob );
  6496. base_exp = base_exp * penalty / 100;
  6497. job_exp = job_exp * penalty / 100;
  6498. }
  6499. #endif
  6500. // stats
  6501. if( mob->get_bosstype() == BOSSTYPE_MVP )
  6502. 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)
  6503. else
  6504. 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)
  6505. clif_displaymessage(fd, atcmd_output);
  6506. 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
  6507. clif_displaymessage(fd, atcmd_output);
  6508. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6509. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6510. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6511. clif_displaymessage(fd, atcmd_output);
  6512. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6513. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6514. mob->range2 , mob->range3, msize[mob->status.size],
  6515. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6516. clif_displaymessage(fd, atcmd_output);
  6517. #ifdef RENEWAL
  6518. sprintf(atcmd_output, msg_txt(sd, 827), mob->status.res, mob->status.mres);// MDEF:%d RES:%d MRES:%d
  6519. clif_displaymessage(fd, atcmd_output);
  6520. #endif
  6521. // drops
  6522. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6523. strcpy(atcmd_output, " ");
  6524. unsigned int j = 0;
  6525. int drop_modifier = 100;
  6526. #ifdef RENEWAL_DROP
  6527. if( battle_config.atcommand_mobinfo_type ){
  6528. drop_modifier = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
  6529. }
  6530. #endif
  6531. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6532. if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].rate < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6533. continue;
  6534. int droprate = mob_getdroprate( &sd->bl, mob, mob->dropitem[i].rate, drop_modifier );
  6535. if (item_data->slots)
  6536. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->ename.c_str(), item_data->slots, (float)droprate / 100);
  6537. else
  6538. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->ename.c_str(), (float)droprate / 100);
  6539. strcat(atcmd_output, atcmd_output2);
  6540. if (++j % 3 == 0) {
  6541. clif_displaymessage(fd, atcmd_output);
  6542. strcpy(atcmd_output, " ");
  6543. }
  6544. }
  6545. if (j == 0)
  6546. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6547. else if (j % 3 != 0)
  6548. clif_displaymessage(fd, atcmd_output);
  6549. // mvp
  6550. if( mob->get_bosstype() == BOSSTYPE_MVP ){
  6551. float mvppercent, mvpremain;
  6552. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%llu
  6553. clif_displaymessage(fd, atcmd_output);
  6554. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6555. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6556. j = 0;
  6557. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6558. if (mob->mvpitem[i].nameid == 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6559. continue;
  6560. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6561. mvppercent = (float)mob->mvpitem[i].rate * mvpremain / 10000.0f;
  6562. if(battle_config.item_drop_mvp_mode == 0) {
  6563. mvpremain -= mvppercent;
  6564. }
  6565. if (mvppercent > 0) {
  6566. j++;
  6567. if (j == 1) {
  6568. if (item_data->slots)
  6569. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->ename.c_str(), item_data->slots, mvppercent);
  6570. else
  6571. sprintf(atcmd_output2, " %s %02.02f%%", item_data->ename.c_str(), mvppercent);
  6572. } else {
  6573. if (item_data->slots)
  6574. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->ename.c_str(), item_data->slots, mvppercent);
  6575. else
  6576. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->ename.c_str(), mvppercent);
  6577. }
  6578. strcat(atcmd_output, atcmd_output2);
  6579. }
  6580. }
  6581. if (j == 0)
  6582. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6583. else
  6584. clif_displaymessage(fd, atcmd_output);
  6585. }
  6586. }
  6587. return 0;
  6588. }
  6589. /*=========================================
  6590. * @showmobs by KarLaeda
  6591. * => For 15 sec displays the mobs on minimap
  6592. *------------------------------------------*/
  6593. ACMD_FUNC(showmobs)
  6594. {
  6595. char mob_name[100];
  6596. int mob_id;
  6597. int number = 0;
  6598. struct s_mapiterator* it;
  6599. nullpo_retr(-1, sd);
  6600. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6601. return -1;
  6602. if((mob_id = strtol(mob_name, nullptr, 10)) == 0)
  6603. mob_id = mobdb_searchname(mob_name);
  6604. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6605. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6606. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6607. clif_displaymessage(fd, atcmd_output);
  6608. return 0;
  6609. }
  6610. 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.
  6611. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6612. return 0;
  6613. }
  6614. if(mob_id == strtol(mob_name, nullptr, 10) && !mob->jname.empty())
  6615. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6616. //strcpy(mob_name, mob->name.c_str()); // --en--
  6617. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6618. mob_name, mapindex_id2name(sd->mapindex));
  6619. clif_displaymessage(fd, atcmd_output);
  6620. it = mapit_geteachmob();
  6621. for(;;)
  6622. {
  6623. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6624. if( md == NULL )
  6625. break;// no more mobs
  6626. if( md->bl.m != sd->bl.m )
  6627. continue;
  6628. if( mob_id != -1 && md->mob_id != mob_id )
  6629. continue;
  6630. if( md->special_state.ai || md->master_id )
  6631. continue; // hide slaves and player summoned mobs
  6632. if( md->spawn_timer != INVALID_TIMER )
  6633. continue; // hide mobs waiting for respawn
  6634. ++number;
  6635. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6636. }
  6637. mapit_free(it);
  6638. return 0;
  6639. }
  6640. /*==========================================
  6641. * homunculus level up [orn]
  6642. *------------------------------------------*/
  6643. ACMD_FUNC(homlevel)
  6644. {
  6645. TBL_HOM * hd;
  6646. int level = 0, i = 0;
  6647. nullpo_retr(-1, sd);
  6648. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6649. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6650. return -1;
  6651. }
  6652. if ( !hom_is_active(sd->hd) ) {
  6653. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6654. return -1;
  6655. }
  6656. hd = sd->hd;
  6657. for (i = 1; i <= level && hd->exp_next; i++){
  6658. hd->homunculus.exp += hd->exp_next;
  6659. if( !hom_levelup(hd) )
  6660. break;
  6661. }
  6662. status_calc_homunculus(hd, SCO_NONE);
  6663. status_percent_heal(&hd->bl, 100, 100);
  6664. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6665. return 0;
  6666. }
  6667. /*==========================================
  6668. * homunculus evolution H [orn]
  6669. *------------------------------------------*/
  6670. ACMD_FUNC(homevolution)
  6671. {
  6672. nullpo_retr(-1, sd);
  6673. if ( !hom_is_active(sd->hd) ) {
  6674. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6675. return -1;
  6676. }
  6677. if ( !hom_evolution(sd->hd) ) {
  6678. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6679. return -1;
  6680. }
  6681. clif_homskillinfoblock(sd);
  6682. return 0;
  6683. }
  6684. ACMD_FUNC(hommutate)
  6685. {
  6686. int homun_id, m_class = 0, m_id;
  6687. nullpo_retr(-1, sd);
  6688. if (!hom_is_active(sd->hd)) {
  6689. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6690. return -1;
  6691. }
  6692. if (!message || !*message) {
  6693. homun_id = 6048 + (rnd() % 4);
  6694. } else {
  6695. homun_id = atoi(message);
  6696. }
  6697. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6698. m_id = hom_class2mapid(homun_id);
  6699. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6700. hom_mutate(sd->hd, homun_id);
  6701. } else {
  6702. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6703. }
  6704. return 0;
  6705. }
  6706. /*==========================================
  6707. * call choosen homunculus [orn]
  6708. *------------------------------------------*/
  6709. ACMD_FUNC(makehomun)
  6710. {
  6711. int homunid;
  6712. nullpo_retr(-1, sd);
  6713. if ( sd->status.hom_id ) {
  6714. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6715. return -1;
  6716. }
  6717. if (!message || !*message) {
  6718. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6719. return -1;
  6720. }
  6721. homunid = atoi(message);
  6722. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6723. {
  6724. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6725. return -1;
  6726. }
  6727. hom_create_request(sd,homunid);
  6728. return 0;
  6729. }
  6730. /*==========================================
  6731. * modify homunculus intimacy [orn]
  6732. *------------------------------------------*/
  6733. ACMD_FUNC(homfriendly)
  6734. {
  6735. int friendly = 0;
  6736. nullpo_retr(-1, sd);
  6737. if ( !hom_is_active(sd->hd) ) {
  6738. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6739. return -1;
  6740. }
  6741. if (!message || !*message) {
  6742. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6743. return -1;
  6744. }
  6745. friendly = atoi(message);
  6746. friendly = cap_value(friendly, 0, 1000);
  6747. sd->hd->homunculus.intimacy = friendly * 100 ;
  6748. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6749. return 0;
  6750. }
  6751. /*==========================================
  6752. * modify homunculus hunger [orn]
  6753. *------------------------------------------*/
  6754. ACMD_FUNC(homhungry)
  6755. {
  6756. int hungry = 0;
  6757. nullpo_retr(-1, sd);
  6758. if ( !hom_is_active(sd->hd) ) {
  6759. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6760. return -1;
  6761. }
  6762. if (!message || !*message) {
  6763. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6764. return -1;
  6765. }
  6766. hungry = atoi(message);
  6767. hungry = cap_value(hungry, 0, 100);
  6768. sd->hd->homunculus.hunger = hungry;
  6769. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6770. return 0;
  6771. }
  6772. /*==========================================
  6773. * make the homunculus speak [orn]
  6774. *------------------------------------------*/
  6775. ACMD_FUNC(homtalk)
  6776. {
  6777. char mes[100],temp[CHAT_SIZE_MAX];
  6778. nullpo_retr(-1, sd);
  6779. if ( battle_config.min_chat_delay ) {
  6780. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6781. return 0;
  6782. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6783. }
  6784. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6785. return -1; //no "chatting" while muted.
  6786. if ( !hom_is_active(sd->hd) ) {
  6787. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6788. return -1;
  6789. }
  6790. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6791. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6792. return -1;
  6793. }
  6794. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6795. clif_disp_overhead(&sd->hd->bl, temp);
  6796. return 0;
  6797. }
  6798. /*==========================================
  6799. * Show homunculus stats
  6800. *------------------------------------------*/
  6801. ACMD_FUNC(hominfo)
  6802. {
  6803. struct homun_data *hd;
  6804. struct status_data *status;
  6805. nullpo_retr(-1, sd);
  6806. if ( !hom_is_active(sd->hd) ) {
  6807. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6808. return -1;
  6809. }
  6810. hd = sd->hd;
  6811. status = status_get_status_data(&hd->bl);
  6812. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6813. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6814. status->hp, status->max_hp, status->sp, status->max_sp);
  6815. clif_displaymessage(fd, atcmd_output);
  6816. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6817. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6818. clif_displaymessage(fd, atcmd_output);
  6819. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6820. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6821. clif_displaymessage(fd, atcmd_output);
  6822. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6823. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6824. status->str, status->agi, status->vit,
  6825. status->int_, status->dex, status->luk);
  6826. clif_displaymessage(fd, atcmd_output);
  6827. return 0;
  6828. }
  6829. ACMD_FUNC(homstats)
  6830. {
  6831. struct homun_data *hd;
  6832. struct s_homunculus_db *db;
  6833. struct s_homunculus *hom;
  6834. int lv, min, max, evo;
  6835. nullpo_retr(-1, sd);
  6836. if ( !hom_is_active(sd->hd) ) {
  6837. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6838. return -1;
  6839. }
  6840. hd = sd->hd;
  6841. hom = &hd->homunculus;
  6842. db = hd->homunculusDB;
  6843. lv = hom->level;
  6844. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6845. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6846. clif_displaymessage(fd, atcmd_output);
  6847. lv--; //Since the first increase is at level 2.
  6848. evo = (hom->class_ == db->evo_class);
  6849. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6850. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6851. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6852. clif_displaymessage(fd, atcmd_output);
  6853. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6854. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6855. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6856. clif_displaymessage(fd, atcmd_output);
  6857. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6858. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6859. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6860. clif_displaymessage(fd, atcmd_output);
  6861. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6862. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6863. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6864. clif_displaymessage(fd, atcmd_output);
  6865. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6866. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6867. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6868. clif_displaymessage(fd, atcmd_output);
  6869. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6870. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6871. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6872. clif_displaymessage(fd, atcmd_output);
  6873. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6874. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6875. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6876. clif_displaymessage(fd, atcmd_output);
  6877. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6878. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6879. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6880. clif_displaymessage(fd, atcmd_output);
  6881. return 0;
  6882. }
  6883. ACMD_FUNC(homshuffle)
  6884. {
  6885. nullpo_retr(-1, sd);
  6886. if(!sd->hd)
  6887. return -1; // nothing to do
  6888. if(!hom_shuffle(sd->hd))
  6889. return -1;
  6890. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6891. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6892. return 0;
  6893. }
  6894. /*==========================================
  6895. * Show Items DB Info v 1.0
  6896. * originally by [Lupus]
  6897. *------------------------------------------*/
  6898. ACMD_FUNC(iteminfo)
  6899. {
  6900. struct item_data *item_array[MAX_SEARCH];
  6901. int i, count = 1;
  6902. if (!message || !*message) {
  6903. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6904. return -1;
  6905. }
  6906. if ((item_array[0] = itemdb_exists(strtoul(message, nullptr, 10))) == nullptr)
  6907. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6908. if (!count) {
  6909. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6910. return -1;
  6911. }
  6912. if (count == MAX_SEARCH) {
  6913. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6914. clif_displaymessage(fd, atcmd_output);
  6915. }
  6916. for (i = 0; i < count; i++) {
  6917. struct item_data * item_data = item_array[i];
  6918. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%u) Type: %s | Extra Effect: %s
  6919. item_data->name.c_str(),item_data->ename.c_str(),item_data->slots,item_data->nameid,
  6920. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
  6921. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6922. );
  6923. clif_displaymessage(fd, atcmd_output);
  6924. 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
  6925. clif_displaymessage(fd, atcmd_output);
  6926. if (item_data->maxchance == -1) {
  6927. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6928. clif_displaymessage(fd, atcmd_output);
  6929. }
  6930. else if (!battle_config.atcommand_mobinfo_type) {
  6931. if (item_data->maxchance)
  6932. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6933. else
  6934. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6935. clif_displaymessage(fd, atcmd_output);
  6936. }
  6937. }
  6938. return 0;
  6939. }
  6940. /*==========================================
  6941. * Show who drops the item.
  6942. *------------------------------------------*/
  6943. ACMD_FUNC(whodrops)
  6944. {
  6945. struct item_data *item_data, *item_array[MAX_SEARCH];
  6946. int i,j, count = 1;
  6947. if (!message || !*message) {
  6948. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6949. return -1;
  6950. }
  6951. if ((item_array[0] = itemdb_exists(strtoul(message, nullptr, 10))) == nullptr)
  6952. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6953. if (!count) {
  6954. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6955. return -1;
  6956. }
  6957. if (count == MAX_SEARCH) {
  6958. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6959. clif_displaymessage(fd, atcmd_output);
  6960. }
  6961. for (i = 0; i < count; i++) {
  6962. item_data = item_array[i];
  6963. sprintf(atcmd_output, msg_txt(sd,1285), item_data->ename.c_str(), item_data->slots, item_data->nameid); // Item: '%s'[%d] (ID:%u)
  6964. clif_displaymessage(fd, atcmd_output);
  6965. if (item_data->mob[0].chance == 0) {
  6966. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6967. clif_displaymessage(fd, atcmd_output);
  6968. } else {
  6969. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6970. clif_displaymessage(fd, atcmd_output);
  6971. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6972. {
  6973. int dropchance = item_data->mob[j].chance;
  6974. std::shared_ptr<s_mob_db> mob = mob_db.find(item_data->mob[j].id);
  6975. if(!mob) continue;
  6976. #ifdef RENEWAL_DROP
  6977. if( battle_config.atcommand_mobinfo_type ) {
  6978. dropchance = dropchance * pc_level_penalty_mod( sd, PENALTY_DROP, mob ) / 100;
  6979. if (dropchance <= 0 && !battle_config.drop_rate0item)
  6980. dropchance = 1;
  6981. }
  6982. #endif
  6983. if (pc_isvip(sd)) // Display item rate increase for VIP
  6984. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6985. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob->jname.c_str(), item_data->mob[j].id, dropchance/100.);
  6986. clif_displaymessage(fd, atcmd_output);
  6987. }
  6988. }
  6989. }
  6990. return 0;
  6991. }
  6992. ACMD_FUNC(whereis)
  6993. {
  6994. uint16 mob_ids[MAX_SEARCH] = {0};
  6995. int count = 0;
  6996. if (!message || !*message) {
  6997. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6998. return -1;
  6999. }
  7000. int i_message = atoi(message);
  7001. if (mobdb_checkid(i_message)) {
  7002. // ID given
  7003. mob_ids[0] = i_message;
  7004. count = 1;
  7005. } else {
  7006. // Name given, get all monster associated whith this name
  7007. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  7008. }
  7009. if (count <= 0) {
  7010. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  7011. return -1;
  7012. }
  7013. if (count >= MAX_SEARCH) {
  7014. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7015. clif_displaymessage(fd, atcmd_output);
  7016. count = MAX_SEARCH;
  7017. }
  7018. for (int i = 0; i < count; i++) {
  7019. uint16 mob_id = mob_ids[i];
  7020. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  7021. if(!mob) continue;
  7022. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname.c_str()); // %s spawns in:
  7023. clif_displaymessage(fd, atcmd_output);
  7024. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  7025. if (spawns.size() <= 0) {
  7026. // This monster does not spawn normally.
  7027. clif_displaymessage(fd, msg_txt(sd,1290));
  7028. } else {
  7029. for(auto& spawn : spawns)
  7030. {
  7031. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  7032. if (mapid < 0)
  7033. continue;
  7034. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  7035. clif_displaymessage(fd, atcmd_output);
  7036. }
  7037. }
  7038. }
  7039. return 0;
  7040. }
  7041. ACMD_FUNC(version)
  7042. {
  7043. pc_show_version(sd);
  7044. return 0;
  7045. }
  7046. /*==========================================
  7047. * @mutearea by MouseJstr
  7048. *------------------------------------------*/
  7049. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7050. {
  7051. int time, id;
  7052. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  7053. if (pl_sd == NULL)
  7054. return 0;
  7055. id = va_arg(ap, int);
  7056. time = va_arg(ap, int);
  7057. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  7058. pl_sd->status.manner -= time;
  7059. if (pl_sd->status.manner < 0)
  7060. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  7061. else
  7062. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  7063. }
  7064. return 0;
  7065. }
  7066. ACMD_FUNC(mutearea)
  7067. {
  7068. int time;
  7069. nullpo_ret(sd);
  7070. if (!message || !*message) {
  7071. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  7072. return -1;
  7073. }
  7074. time = atoi(message);
  7075. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  7076. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7077. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7078. return 0;
  7079. }
  7080. ACMD_FUNC(rates)
  7081. {
  7082. char buf[CHAT_SIZE_MAX];
  7083. nullpo_ret(sd);
  7084. memset(buf, '\0', sizeof(buf));
  7085. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  7086. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  7087. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  7088. clif_displaymessage(fd, buf);
  7089. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7090. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  7091. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  7092. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  7093. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  7094. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  7095. clif_displaymessage(fd, buf);
  7096. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7097. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  7098. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  7099. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  7100. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  7101. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  7102. clif_displaymessage(fd, buf);
  7103. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7104. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  7105. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  7106. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  7107. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  7108. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  7109. clif_displaymessage(fd, buf);
  7110. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  7111. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  7112. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  7113. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  7114. clif_displaymessage(fd, buf);
  7115. return 0;
  7116. }
  7117. /*==========================================
  7118. * @me by lordalfa
  7119. * => Displays the OUTPUT string on top of the Visible players Heads.
  7120. *------------------------------------------*/
  7121. ACMD_FUNC(me)
  7122. {
  7123. char tempmes[CHAT_SIZE_MAX];
  7124. nullpo_retr(-1, sd);
  7125. memset(tempmes, '\0', sizeof(tempmes));
  7126. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7127. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  7128. return -1; //no "chatting" while muted.
  7129. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  7130. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  7131. return -1;
  7132. }
  7133. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  7134. clif_disp_overhead(&sd->bl, atcmd_output);
  7135. return 0;
  7136. }
  7137. /*==========================================
  7138. * @size
  7139. * => Resize your character sprite. [Valaris]
  7140. *------------------------------------------*/
  7141. ACMD_FUNC(size)
  7142. {
  7143. int size = SZ_SMALL;
  7144. nullpo_retr(-1, sd);
  7145. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  7146. if(sd->state.size) {
  7147. sd->state.size = SZ_SMALL;
  7148. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  7149. }
  7150. sd->state.size = size;
  7151. if( size == SZ_MEDIUM )
  7152. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  7153. else if( size == SZ_BIG )
  7154. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  7155. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7156. return 0;
  7157. }
  7158. ACMD_FUNC(sizeall)
  7159. {
  7160. int size;
  7161. struct map_session_data *pl_sd;
  7162. struct s_mapiterator* iter;
  7163. size = atoi(message);
  7164. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7165. iter = mapit_getallusers();
  7166. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  7167. if( pl_sd->state.size != size ) {
  7168. if( pl_sd->state.size ) {
  7169. pl_sd->state.size = SZ_SMALL;
  7170. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7171. }
  7172. pl_sd->state.size = size;
  7173. if( size == SZ_MEDIUM )
  7174. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7175. else if( size == SZ_BIG )
  7176. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7177. }
  7178. }
  7179. mapit_free(iter);
  7180. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7181. return 0;
  7182. }
  7183. ACMD_FUNC(sizeguild)
  7184. {
  7185. int size = SZ_SMALL, i;
  7186. char guild[NAME_LENGTH];
  7187. struct map_session_data *pl_sd;
  7188. struct guild *g;
  7189. nullpo_retr(-1, sd);
  7190. memset(guild, '\0', sizeof(guild));
  7191. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  7192. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  7193. return -1;
  7194. }
  7195. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  7196. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  7197. return -1;
  7198. }
  7199. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7200. for( i = 0; i < g->max_member; i++ ) {
  7201. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  7202. if( pl_sd->state.size ) {
  7203. pl_sd->state.size = SZ_SMALL;
  7204. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7205. }
  7206. pl_sd->state.size = size;
  7207. if( size == SZ_MEDIUM )
  7208. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7209. else if( size == SZ_BIG )
  7210. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7211. }
  7212. }
  7213. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7214. return 0;
  7215. }
  7216. /*==========================================
  7217. * @monsterignore
  7218. * => Makes monsters ignore you. [Valaris]
  7219. *------------------------------------------*/
  7220. ACMD_FUNC(monsterignore)
  7221. {
  7222. nullpo_retr(-1, sd);
  7223. if (sd->state.block_action & PCBLOCK_IMMUNE) {
  7224. sd->state.block_action &= ~PCBLOCK_IMMUNE;
  7225. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  7226. } else {
  7227. sd->state.block_action |= PCBLOCK_IMMUNE;
  7228. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  7229. }
  7230. return 0;
  7231. }
  7232. /*==========================================
  7233. * @fakename
  7234. * => Gives your character a fake name. [Valaris]
  7235. *------------------------------------------*/
  7236. ACMD_FUNC(fakename)
  7237. {
  7238. nullpo_retr(-1, sd);
  7239. if( !message || !*message )
  7240. {
  7241. if( sd->fakename[0] )
  7242. {
  7243. sd->fakename[0] = '\0';
  7244. clif_name_area(&sd->bl);
  7245. if (sd->disguise)
  7246. clif_name_self(&sd->bl);
  7247. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7248. return 0;
  7249. }
  7250. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7251. return -1;
  7252. }
  7253. if( strlen(message) < 2 )
  7254. {
  7255. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7256. return -1;
  7257. }
  7258. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7259. clif_name_area(&sd->bl);
  7260. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  7261. clif_name_self(&sd->bl);
  7262. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7263. return 0;
  7264. }
  7265. /*==========================================
  7266. * Ragnarok Resources
  7267. *------------------------------------------*/
  7268. ACMD_FUNC(mapflag) {
  7269. char flag_name[50];
  7270. short flag = 0, i, j;
  7271. std::string buf;
  7272. nullpo_retr(-1, sd);
  7273. memset(flag_name, '\0', sizeof(flag_name));
  7274. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  7275. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7276. clif_displaymessage(sd->fd,"----------------------------------");
  7277. for( i = MF_MIN; i < MF_MAX; i++ ){
  7278. union u_mapflag_args args = {};
  7279. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  7280. clif_displaymessage(sd->fd, flag_name);
  7281. }
  7282. }
  7283. clif_displaymessage(sd->fd," ");
  7284. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7285. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7286. return 1;
  7287. }
  7288. // Check if the list of mapflags was requested
  7289. if( strcasecmp(flag_name,"available") ){
  7290. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7291. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  7292. if( mapflag != MF_INVALID ){
  7293. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  7294. MF_PVP_NIGHTMAREDROP,
  7295. MF_RESTRICTED,
  7296. MF_NOCOMMAND,
  7297. MF_BEXP,
  7298. MF_JEXP,
  7299. MF_BATTLEGROUND,
  7300. MF_SKILL_DAMAGE,
  7301. MF_SKILL_DURATION };
  7302. if (flag > 0 && util::vector_exists(disabled_mf, mapflag)) {
  7303. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  7304. clif_displaymessage(sd->fd,atcmd_output);
  7305. } else {
  7306. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  7307. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  7308. clif_displaymessage(sd->fd,atcmd_output);
  7309. }
  7310. return 0;
  7311. }else{
  7312. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  7313. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  7314. return 1;
  7315. }
  7316. }
  7317. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7318. clif_displaymessage(sd->fd,"----------------------------------");
  7319. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  7320. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  7321. buf.append(flag_name);
  7322. if( (i + 1) < MF_MAX )
  7323. buf.append(", ");
  7324. j++;
  7325. }
  7326. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  7327. clif_displaymessage(sd->fd, buf.c_str() );
  7328. buf.clear();
  7329. j = 0;
  7330. }
  7331. }
  7332. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7333. return 0;
  7334. }
  7335. /*===================================
  7336. * Remove some messages
  7337. *-----------------------------------*/
  7338. ACMD_FUNC(showexp)
  7339. {
  7340. if (sd->state.showexp) {
  7341. sd->state.showexp = 0;
  7342. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7343. return 0;
  7344. }
  7345. sd->state.showexp = 1;
  7346. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7347. return 0;
  7348. }
  7349. ACMD_FUNC(showzeny)
  7350. {
  7351. if (sd->state.showzeny) {
  7352. sd->state.showzeny = 0;
  7353. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7354. return 0;
  7355. }
  7356. sd->state.showzeny = 1;
  7357. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7358. return 0;
  7359. }
  7360. ACMD_FUNC(showdelay)
  7361. {
  7362. if (sd->state.showdelay) {
  7363. sd->state.showdelay = 0;
  7364. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7365. return 0;
  7366. }
  7367. sd->state.showdelay = 1;
  7368. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7369. return 0;
  7370. }
  7371. /*==========================================
  7372. * Duel organizing functions [LuzZza]
  7373. *
  7374. * @duel [limit|nick] - create a duel
  7375. * @invite <nick> - invite player
  7376. * @accept - accept invitation
  7377. * @reject - reject invitation
  7378. * @leave - leave duel
  7379. *------------------------------------------*/
  7380. ACMD_FUNC(invite)
  7381. {
  7382. unsigned int did = sd->duel_group;
  7383. struct map_session_data *target_sd = NULL;
  7384. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7385. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7386. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7387. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7388. clif_displaymessage(fd, atcmd_output);
  7389. return -1;
  7390. }
  7391. if(did == 0 || !duel_exist(did) ) {
  7392. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7393. return 0;
  7394. }
  7395. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7396. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7397. return 0;
  7398. }
  7399. if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
  7400. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7401. return 0;
  7402. }
  7403. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7404. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7405. return 0;
  7406. }
  7407. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7408. {
  7409. 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.
  7410. clif_displaymessage(fd, atcmd_output);
  7411. return 0;
  7412. }
  7413. duel_invite(did, sd, target_sd);
  7414. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7415. return 0;
  7416. }
  7417. ACMD_FUNC(duel)
  7418. {
  7419. unsigned int maxpl = 0;
  7420. if(sd->duel_group > 0) {
  7421. duel_showinfo(sd->duel_group, sd);
  7422. return 0;
  7423. }
  7424. if(sd->duel_invite > 0) {
  7425. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7426. return 0;
  7427. }
  7428. if(!duel_checktime(sd)) {
  7429. char output[CHAT_SIZE_MAX];
  7430. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7431. clif_displaymessage(fd, output);
  7432. return 0;
  7433. }
  7434. if( message[0] ) {
  7435. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7436. if(maxpl < 2 || maxpl > 65535) {
  7437. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7438. return 0;
  7439. }
  7440. duel_create(sd, maxpl);
  7441. } else {
  7442. struct map_session_data *target_sd = NULL;
  7443. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7444. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7445. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7446. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7447. clif_displaymessage(fd, atcmd_output);
  7448. return -1;
  7449. }
  7450. target_sd = map_nick2sd(atcmd_player_name,true);
  7451. if(target_sd != NULL) {
  7452. unsigned int newduel;
  7453. if((newduel = duel_create(sd, 2)) != -1) {
  7454. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7455. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7456. return 0;
  7457. }
  7458. duel_invite(newduel, sd, target_sd);
  7459. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7460. }
  7461. } else {
  7462. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7463. return 0;
  7464. }
  7465. }
  7466. } else
  7467. duel_create(sd, 0);
  7468. return 0;
  7469. }
  7470. ACMD_FUNC(leave)
  7471. {
  7472. if(sd->duel_group <= 0) {
  7473. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7474. return 0;
  7475. }
  7476. duel_leave(sd->duel_group, sd);
  7477. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7478. return 0;
  7479. }
  7480. ACMD_FUNC(accept)
  7481. {
  7482. if(!duel_checktime(sd)) {
  7483. char output[CHAT_SIZE_MAX];
  7484. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7485. clif_displaymessage(fd, output);
  7486. return 0;
  7487. }
  7488. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7489. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7490. return 0;
  7491. }
  7492. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7493. {
  7494. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7495. return 0;
  7496. }
  7497. duel_accept(sd->duel_invite, sd);
  7498. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7499. return 0;
  7500. }
  7501. ACMD_FUNC(reject)
  7502. {
  7503. if(sd->duel_invite <= 0) {
  7504. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7505. return 0;
  7506. }
  7507. duel_reject(sd->duel_invite, sd);
  7508. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7509. return 0;
  7510. }
  7511. /*===================================
  7512. * Cash Points
  7513. *-----------------------------------*/
  7514. ACMD_FUNC(cash)
  7515. {
  7516. char output[128];
  7517. int value;
  7518. int ret=0;
  7519. nullpo_retr(-1, sd);
  7520. // Since there is no cashpoint update packet we need to force updating like this
  7521. if( sd->state.cashshop_open ){
  7522. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7523. return -1;
  7524. }
  7525. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7526. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7527. return -1;
  7528. }
  7529. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7530. if( !strcmpi(parent_cmd,"cash") )
  7531. {
  7532. if( value > 0 ) {
  7533. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7534. // If this option is set, the message is already sent by pc function
  7535. if( !battle_config.cashshop_show_points ){
  7536. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7537. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7538. }
  7539. }
  7540. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7541. } else {
  7542. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7543. value = -sd->cashPoints;
  7544. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7545. // If this option is set, the message is already sent by pc function
  7546. if( !battle_config.cashshop_show_points ){
  7547. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7548. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7549. }
  7550. }
  7551. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7552. }
  7553. }
  7554. else
  7555. { // @points
  7556. if( value > 0 ) {
  7557. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7558. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7559. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7560. }
  7561. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7562. } else {
  7563. if (-value > sd->kafraPoints) //By command, if cash < value, force it to remove all
  7564. value = -sd->kafraPoints;
  7565. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7566. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7567. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7568. }
  7569. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7570. }
  7571. }
  7572. return 0;
  7573. }
  7574. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7575. ACMD_FUNC(clone)
  7576. {
  7577. int x=0,y=0,flag=0,master=0,i=0;
  7578. struct map_session_data *pl_sd=NULL;
  7579. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7580. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7581. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7582. return 0;
  7583. }
  7584. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
  7585. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7586. return 0;
  7587. }
  7588. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7589. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7590. return 0;
  7591. }
  7592. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7593. if (strcmpi(parent_cmd, "clone") == 0)
  7594. flag = 1;
  7595. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7596. flag = 2;
  7597. if(pc_isdead(sd)){
  7598. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7599. return 0;
  7600. }
  7601. master = sd->bl.id;
  7602. if (battle_config.atc_slave_clone_limit
  7603. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7604. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7605. return 0;
  7606. }
  7607. }
  7608. do {
  7609. x = sd->bl.x + (rnd() % 10 - 5);
  7610. y = sd->bl.y + (rnd() % 10 - 5);
  7611. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7612. if (i >= 10) {
  7613. x = sd->bl.x;
  7614. y = sd->bl.y;
  7615. }
  7616. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7617. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7618. return 0;
  7619. }
  7620. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7621. return 0;
  7622. }
  7623. /*=====================================
  7624. * Autorejecting Invites/Deals [LuzZza]
  7625. * Usage: @noask
  7626. *-------------------------------------*/
  7627. ACMD_FUNC(noask)
  7628. {
  7629. if(sd->state.noask) {
  7630. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7631. sd->state.noask = 0;
  7632. } else {
  7633. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7634. sd->state.noask = 1;
  7635. }
  7636. return 0;
  7637. }
  7638. /*=====================================
  7639. * Send a @request message to all GMs of lowest_gm_level.
  7640. * Usage: @request <petition>
  7641. *-------------------------------------*/
  7642. ACMD_FUNC(request)
  7643. {
  7644. if (!message || !*message) {
  7645. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7646. return -1;
  7647. }
  7648. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7649. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7650. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7651. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7652. return 0;
  7653. }
  7654. /*==========================================
  7655. * Feel (SG designated maps) Reset [HiddenDragon]
  7656. *------------------------------------------*/
  7657. ACMD_FUNC(feelreset)
  7658. {
  7659. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7660. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7661. return -1;
  7662. }
  7663. pc_resetfeel(sd);
  7664. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7665. return 0;
  7666. }
  7667. /*==========================================
  7668. * Hate (SG designated monsters) Reset
  7669. *------------------------------------------*/
  7670. ACMD_FUNC(hatereset)
  7671. {
  7672. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7673. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7674. return -1;
  7675. }
  7676. pc_resethate(sd);
  7677. clif_displaymessage(fd, msg_txt(sd,1515)); // Reset 'Hatred' monsters.
  7678. return 0;
  7679. }
  7680. /*==========================================
  7681. * AUCTION SYSTEM
  7682. *------------------------------------------*/
  7683. ACMD_FUNC(auction)
  7684. {
  7685. nullpo_ret(sd);
  7686. if (!battle_config.feature_auction) {
  7687. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7688. return 0;
  7689. }
  7690. clif_Auction_openwindow(sd);
  7691. return 0;
  7692. }
  7693. /*==========================================
  7694. * Kill Steal Protection
  7695. *------------------------------------------*/
  7696. ACMD_FUNC(ksprotection)
  7697. {
  7698. nullpo_retr(-1,sd);
  7699. if( sd->state.noks ) {
  7700. sd->state.noks = 0;
  7701. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7702. }
  7703. else
  7704. {
  7705. if( !message || !*message || !strcmpi(message, "party") )
  7706. { // Default is Party
  7707. sd->state.noks = 2;
  7708. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7709. }
  7710. else if( !strcmpi(message, "self") )
  7711. {
  7712. sd->state.noks = 1;
  7713. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7714. }
  7715. else if( !strcmpi(message, "guild") )
  7716. {
  7717. sd->state.noks = 3;
  7718. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7719. }
  7720. else
  7721. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7722. }
  7723. return 0;
  7724. }
  7725. /*==========================================
  7726. * Map Kill Steal Protection Setting
  7727. *------------------------------------------*/
  7728. ACMD_FUNC(allowks)
  7729. {
  7730. nullpo_retr(-1,sd);
  7731. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7732. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7733. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7734. } else {
  7735. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7736. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7737. }
  7738. return 0;
  7739. }
  7740. ACMD_FUNC(resetstat)
  7741. {
  7742. nullpo_retr(-1, sd);
  7743. pc_resetstate(sd);
  7744. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7745. clif_displaymessage(fd, atcmd_output);
  7746. return 0;
  7747. }
  7748. ACMD_FUNC(resetskill)
  7749. {
  7750. nullpo_retr(-1,sd);
  7751. pc_resetskill(sd,1);
  7752. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7753. clif_displaymessage(fd, atcmd_output);
  7754. return 0;
  7755. }
  7756. /*==========================================
  7757. * #storagelist: Displays the items list of a player's storage.
  7758. * #cartlist: Displays contents of target's cart.
  7759. * #itemlist: Displays contents of target's inventory.
  7760. *------------------------------------------*/
  7761. ACMD_FUNC(itemlist)
  7762. {
  7763. int i, j, count, counter;
  7764. const char* location;
  7765. const struct item* items;
  7766. int size;
  7767. StringBuf buf;
  7768. nullpo_retr(-1, sd);
  7769. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7770. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7771. location = "storage";
  7772. items = sd->storage.u.items_storage;
  7773. size = sd->storage.max_amount;
  7774. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7775. location = "cart";
  7776. items = sd->cart.u.items_cart;
  7777. size = MAX_CART;
  7778. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7779. location = "inventory";
  7780. items = sd->inventory.u.items_inventory;
  7781. size = MAX_INVENTORY;
  7782. } else
  7783. return 1;
  7784. StringBuf_Init(&buf);
  7785. count = 0; // total slots occupied
  7786. counter = 0; // total items found
  7787. for( i = 0; i < size; ++i ) {
  7788. const struct item* it = &items[i];
  7789. struct item_data* itd;
  7790. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7791. continue;
  7792. counter += it->amount;
  7793. count++;
  7794. if( count == 1 ) {
  7795. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7796. clif_displaymessage(fd, StringBuf_Value(&buf));
  7797. StringBuf_Clear(&buf);
  7798. }
  7799. if( it->refine )
  7800. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %u)", it->amount, itd->ename.c_str(), it->refine, itd->name.c_str(), it->nameid);
  7801. else
  7802. StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, itd->ename.c_str(), itd->name.c_str(), it->nameid);
  7803. if( it->equip ) {
  7804. char equipstr[CHAT_SIZE_MAX];
  7805. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7806. if( it->equip&EQP_GARMENT )
  7807. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7808. if( it->equip&EQP_ACC_L )
  7809. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7810. if( it->equip&EQP_ARMOR )
  7811. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7812. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7813. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7814. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7815. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7816. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7817. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7818. if( it->equip&EQP_SHOES )
  7819. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7820. if( it->equip&EQP_ACC_R )
  7821. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7822. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7823. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7824. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7825. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7826. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7827. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7828. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7829. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7830. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7831. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7832. if( (it->equip&EQP_HELM) == EQP_HELM )
  7833. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7834. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7835. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7836. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7837. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7838. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7839. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7840. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7841. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7842. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7843. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7844. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7845. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7846. if( it->equip&EQP_COSTUME_GARMENT )
  7847. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7848. //if( it->equip&EQP_COSTUME_FLOOR )
  7849. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7850. if( it->equip&EQP_AMMO )
  7851. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7852. if( it->equip&EQP_SHADOW_ARMOR )
  7853. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7854. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7855. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7856. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7857. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7858. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7859. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7860. if( it->equip&EQP_SHADOW_SHOES )
  7861. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7862. if( it->equip&EQP_SHADOW_ACC_R )
  7863. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7864. if( it->equip&EQP_SHADOW_ACC_L )
  7865. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7866. // remove final ', '
  7867. equipstr[strlen(equipstr) - 2] = '\0';
  7868. StringBuf_AppendStr(&buf, equipstr);
  7869. }
  7870. clif_displaymessage(fd, StringBuf_Value(&buf));
  7871. StringBuf_Clear(&buf);
  7872. if( it->card[0] == CARD0_PET ) { // pet egg
  7873. if (it->card[3]&1)
  7874. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7875. else
  7876. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7877. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7878. 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)
  7879. } else if(it->card[0] == CARD0_CREATE) { // created item
  7880. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7881. } else { // normal item
  7882. int counter2 = 0;
  7883. for( j = 0; j < itd->slots; ++j ) {
  7884. struct item_data* card;
  7885. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7886. continue;
  7887. counter2++;
  7888. if( counter2 == 1 )
  7889. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7890. if( counter2 != 1 )
  7891. StringBuf_AppendStr(&buf, ", ");
  7892. StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, card->ename.c_str(), card->nameid);
  7893. }
  7894. if( counter2 > 0 )
  7895. StringBuf_AppendStr(&buf, ")");
  7896. }
  7897. if( StringBuf_Length(&buf) > 0 )
  7898. clif_displaymessage(fd, StringBuf_Value(&buf));
  7899. StringBuf_Clear(&buf);
  7900. }
  7901. if( count == 0 )
  7902. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7903. else
  7904. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7905. clif_displaymessage(fd, StringBuf_Value(&buf));
  7906. StringBuf_Destroy(&buf);
  7907. return 0;
  7908. }
  7909. ACMD_FUNC(stats)
  7910. {
  7911. char job_jobname[100];
  7912. char output[CHAT_SIZE_MAX];
  7913. int i;
  7914. struct {
  7915. const char* format;
  7916. int value;
  7917. } output_table[] = {
  7918. { "Base Level - %d", 0 },
  7919. { NULL, 0 },
  7920. { "Hp - %d", 0 },
  7921. { "MaxHp - %d", 0 },
  7922. { "Sp - %d", 0 },
  7923. { "MaxSp - %d", 0 },
  7924. { "Ap - %d", 0 },
  7925. { "MaxAp - %d", 0 },
  7926. { "Str - %3d", 0 },
  7927. { "Agi - %3d", 0 },
  7928. { "Vit - %3d", 0 },
  7929. { "Int - %3d", 0 },
  7930. { "Dex - %3d", 0 },
  7931. { "Luk - %3d", 0 },
  7932. { "Pow - %3d", 0 },
  7933. { "Sta - %3d", 0 },
  7934. { "Wis - %3d", 0 },
  7935. { "Spl - %3d", 0 },
  7936. { "Con - %3d", 0 },
  7937. { "Crt - %3d", 0 },
  7938. { "Zeny - %d", 0 },
  7939. { "Free Status Points - %d", 0 },
  7940. { "Free Trait Points - %d", 0 },
  7941. { "Free Skill Points - %d", 0 },
  7942. { "JobChangeLvl (2nd) - %d", 0 },
  7943. { "JobChangeLvl (3rd) - %d", 0 },
  7944. { "JobChangeLvl (4th) - %d", 0 },
  7945. { NULL, 0 }
  7946. };
  7947. memset(job_jobname, '\0', sizeof(job_jobname));
  7948. memset(output, '\0', sizeof(output));
  7949. //direct array initialization with variables is not standard C compliant.
  7950. output_table[0].value = sd->status.base_level;
  7951. output_table[1].format = job_jobname;
  7952. output_table[1].value = sd->status.job_level;
  7953. output_table[2].value = sd->status.hp;
  7954. output_table[3].value = sd->status.max_hp;
  7955. output_table[4].value = sd->status.sp;
  7956. output_table[5].value = sd->status.max_sp;
  7957. output_table[6].value = sd->status.ap;
  7958. output_table[7].value = sd->status.max_ap;
  7959. output_table[8].value = sd->status.str;
  7960. output_table[9].value = sd->status.agi;
  7961. output_table[10].value = sd->status.vit;
  7962. output_table[11].value = sd->status.int_;
  7963. output_table[12].value = sd->status.dex;
  7964. output_table[13].value = sd->status.luk;
  7965. output_table[14].value = sd->status.pow;
  7966. output_table[15].value = sd->status.sta;
  7967. output_table[16].value = sd->status.wis;
  7968. output_table[17].value = sd->status.spl;
  7969. output_table[18].value = sd->status.con;
  7970. output_table[19].value = sd->status.crt;
  7971. output_table[20].value = sd->status.zeny;
  7972. output_table[21].value = sd->status.status_point;
  7973. output_table[22].value = sd->status.trait_point;
  7974. output_table[23].value = sd->status.skill_point;
  7975. output_table[24].value = sd->change_level_2nd;
  7976. output_table[25].value = sd->change_level_3rd;
  7977. output_table[26].value = sd->change_level_4th;
  7978. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7979. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7980. clif_displaymessage(fd, output);
  7981. for (i = 0; output_table[i].format != NULL; i++) {
  7982. sprintf(output, output_table[i].format, output_table[i].value);
  7983. clif_displaymessage(fd, output);
  7984. }
  7985. return 0;
  7986. }
  7987. ACMD_FUNC(delitem)
  7988. {
  7989. char item_name[100];
  7990. int amount = 0, idx;
  7991. nullpo_retr(-1, sd);
  7992. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7993. {
  7994. 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>).
  7995. return -1;
  7996. }
  7997. std::shared_ptr<item_data> id = item_db.searchname( item_name );
  7998. if( id == nullptr ){
  7999. id = item_db.find( strtoul( item_name, nullptr, 10 ) );
  8000. }
  8001. if( id == nullptr ){
  8002. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  8003. return -1;
  8004. }
  8005. t_itemid nameid = id->nameid;
  8006. int total = amount;
  8007. // delete items
  8008. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  8009. {
  8010. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  8011. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  8012. {// delete pet
  8013. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  8014. }
  8015. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  8016. amount-= delamount;
  8017. }
  8018. // notify target
  8019. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  8020. clif_displaymessage(sd->fd, atcmd_output);
  8021. // notify source
  8022. if( amount == total )
  8023. {
  8024. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  8025. }
  8026. else if( amount )
  8027. {
  8028. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  8029. clif_displaymessage(fd, atcmd_output);
  8030. }
  8031. else
  8032. {
  8033. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  8034. clif_displaymessage(fd, atcmd_output);
  8035. }
  8036. return 0;
  8037. }
  8038. /*==========================================
  8039. * Custom Fonts
  8040. *------------------------------------------*/
  8041. ACMD_FUNC(font)
  8042. {
  8043. int font_id;
  8044. nullpo_retr(-1,sd);
  8045. font_id = atoi(message);
  8046. if( font_id == 0 ) {
  8047. if( sd->status.font ) {
  8048. sd->status.font = 0;
  8049. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  8050. clif_font(sd);
  8051. } else {
  8052. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  8053. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  8054. }
  8055. } else if( font_id < 0 || font_id > 9 )
  8056. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  8057. else if( font_id != sd->status.font ) {
  8058. sd->status.font = font_id;
  8059. clif_font(sd);
  8060. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  8061. } else
  8062. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  8063. return 0;
  8064. }
  8065. /*==========================================
  8066. * type: 1 = commands (@), 2 = charcommands (#)
  8067. *------------------------------------------*/
  8068. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  8069. {
  8070. char line_buff[CHATBOX_SIZE];
  8071. char* cur = line_buff;
  8072. AtCommandInfo* cmd;
  8073. DBIterator *iter = db_iterator(atcommand_db);
  8074. int count = 0;
  8075. memset(line_buff,' ',CHATBOX_SIZE);
  8076. line_buff[CHATBOX_SIZE-1] = 0;
  8077. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  8078. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  8079. unsigned int slen = 0;
  8080. switch( type ) {
  8081. case COMMAND_CHARCOMMAND:
  8082. if( cmd->char_groups[sd->group_pos] == 0 )
  8083. continue;
  8084. break;
  8085. case COMMAND_ATCOMMAND:
  8086. if( cmd->at_groups[sd->group_pos] == 0 )
  8087. continue;
  8088. break;
  8089. default:
  8090. continue;
  8091. }
  8092. slen = strlen(cmd->command);
  8093. // flush the text buffer if this command won't fit into it
  8094. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8095. clif_displaymessage(fd,line_buff);
  8096. cur = line_buff;
  8097. memset(line_buff,' ',CHATBOX_SIZE);
  8098. line_buff[CHATBOX_SIZE-1] = 0;
  8099. }
  8100. memcpy(cur,cmd->command,slen);
  8101. cur += slen+(10-slen%10);
  8102. count++;
  8103. }
  8104. dbi_destroy(iter);
  8105. clif_displaymessage(fd,line_buff);
  8106. if ( atcmd_binding_count ) {
  8107. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  8108. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  8109. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  8110. unsigned int slen = strlen(atcmd_binding[i]->command);
  8111. if ( count_bind == 0 ) {
  8112. cur = line_buff;
  8113. memset(line_buff,' ',CHATBOX_SIZE);
  8114. line_buff[CHATBOX_SIZE-1] = 0;
  8115. clif_displaymessage(fd, "-----------------");
  8116. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  8117. }
  8118. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8119. clif_displaymessage(fd,line_buff);
  8120. cur = line_buff;
  8121. memset(line_buff,' ',CHATBOX_SIZE);
  8122. line_buff[CHATBOX_SIZE-1] = 0;
  8123. }
  8124. memcpy(cur,atcmd_binding[i]->command,slen);
  8125. cur += slen+(10-slen%10);
  8126. count_bind++;
  8127. }
  8128. }
  8129. if ( count_bind )
  8130. clif_displaymessage(fd,line_buff);// last one
  8131. count += count_bind;
  8132. }
  8133. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  8134. clif_displaymessage(fd, atcmd_output);
  8135. return;
  8136. }
  8137. /*==========================================
  8138. * @commands Lists available @ commands to you
  8139. *------------------------------------------*/
  8140. ACMD_FUNC(commands)
  8141. {
  8142. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  8143. return 0;
  8144. }
  8145. /*==========================================
  8146. * @charcommands Lists available # commands to you
  8147. *------------------------------------------*/
  8148. ACMD_FUNC(charcommands) {
  8149. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  8150. return 0;
  8151. }
  8152. /* for new mounts */
  8153. ACMD_FUNC(mount2) {
  8154. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  8155. if (!sd->sc.data[SC_ALL_RIDING]) {
  8156. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  8157. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  8158. } else {
  8159. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  8160. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  8161. }
  8162. return 0;
  8163. }
  8164. ACMD_FUNC(accinfo) {
  8165. char query[NAME_LENGTH];
  8166. char type = 0; // type = 1, get only account name
  8167. if (!message || !*message || strlen(message) > NAME_LENGTH
  8168. || ( sscanf(message, "%23s %c", query, &type) < 1))
  8169. {
  8170. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  8171. 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".
  8172. return -1;
  8173. } else if (type != 0) {
  8174. type = type-'0'; //make it int
  8175. if (type != 1) {
  8176. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  8177. return -1;
  8178. }
  8179. }
  8180. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  8181. return 0;
  8182. }
  8183. /**
  8184. * @set <variable name{[index]}>{ <value>}
  8185. *
  8186. * Gets or sets a value of a non server variable.
  8187. * If a value is specified it is used to set the variable's value,
  8188. * if not the variable's value is read.
  8189. * In any case it reads and displays the variable's value.
  8190. *
  8191. * Original implementation by Ind
  8192. */
  8193. ACMD_FUNC(set) {
  8194. char reg[46], val[128], name[32];
  8195. int toset = 0, len;
  8196. uint32 index;
  8197. bool is_str = false;
  8198. int64 uid;
  8199. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  8200. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  8201. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  8202. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  8203. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  8204. return -1;
  8205. }
  8206. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  8207. if( reg[0] == '.' ) {
  8208. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  8209. return -1;
  8210. } else if( reg[0] == '\'' ) {
  8211. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  8212. return -1;
  8213. }
  8214. // Check if the user wanted to set an array
  8215. if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
  8216. // The user did not specify array brackets, so we set the index to zero
  8217. index = 0;
  8218. }
  8219. is_str = is_string_variable(name);
  8220. if( ( len = strlen(val) ) > 1 ) {
  8221. if( val[0] == '"' && val[len-1] == '"') {
  8222. val[len-1] = '\0'; //Strip quotes.
  8223. memmove(val, val+1, len-1);
  8224. }
  8225. }
  8226. // Only set the variable if there is a value for it
  8227. if( toset >= 2 ){
  8228. if( is_str ){
  8229. setd_sub_str( NULL, sd, name, index, val, NULL );
  8230. }else{
  8231. setd_sub_num( NULL, sd, name, index, strtoll( val, NULL, 10 ), NULL );
  8232. }
  8233. }
  8234. uid = reference_uid( add_str( name ), index );
  8235. if( is_str ) {// string variable
  8236. char* value;
  8237. switch( reg[0] ) {
  8238. case '@':
  8239. value = pc_readregstr(sd, uid);
  8240. break;
  8241. case '$':
  8242. value = mapreg_readregstr(uid);
  8243. break;
  8244. case '#':
  8245. if( reg[1] == '#' )
  8246. value = pc_readaccountreg2str(sd, uid);// global
  8247. else
  8248. value = pc_readaccountregstr(sd, uid);// local
  8249. break;
  8250. default:
  8251. value = pc_readglobalreg_str(sd, uid);
  8252. break;
  8253. }
  8254. if( value == NULL || *value == '\0' ){// empty string
  8255. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  8256. }else{
  8257. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
  8258. }
  8259. } else {// integer variable
  8260. int64 value;
  8261. switch( reg[0] ) {
  8262. case '@':
  8263. value = pc_readreg(sd, uid);
  8264. break;
  8265. case '$':
  8266. value = mapreg_readreg(uid);
  8267. break;
  8268. case '#':
  8269. if( reg[1] == '#' )
  8270. value = pc_readaccountreg2(sd, uid);// global
  8271. else
  8272. value = pc_readaccountreg(sd, uid);// local
  8273. break;
  8274. default:
  8275. value = pc_readglobalreg(sd, uid);
  8276. break;
  8277. }
  8278. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
  8279. }
  8280. clif_displaymessage(fd, atcmd_output);
  8281. return 0;
  8282. }
  8283. ACMD_FUNC(addperm) {
  8284. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  8285. bool add;
  8286. int i;
  8287. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  8288. add = (strcmpi(parent_cmd, "addperm") == 0);
  8289. if( !message || !*message ) {
  8290. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8291. clif_displaymessage(fd, atcmd_output);
  8292. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8293. for( i = 0; i < perm_size; i++ ) {
  8294. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8295. clif_displaymessage(fd, atcmd_output);
  8296. }
  8297. return -1;
  8298. }
  8299. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8300. if( i == perm_size ) {
  8301. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8302. clif_displaymessage(fd, atcmd_output);
  8303. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8304. for( i = 0; i < perm_size; i++ ) {
  8305. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8306. clif_displaymessage(fd, atcmd_output);
  8307. }
  8308. return -1;
  8309. }
  8310. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  8311. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8312. clif_displaymessage(fd, atcmd_output);
  8313. return -1;
  8314. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  8315. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8316. clif_displaymessage(fd, atcmd_output);
  8317. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8318. clif_displaymessage(fd, atcmd_output);
  8319. for( i = 0; i < perm_size; i++ ) {
  8320. if( sd->permissions&pc_g_permission_name[i].permission ) {
  8321. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8322. clif_displaymessage(fd, atcmd_output);
  8323. }
  8324. }
  8325. return -1;
  8326. }
  8327. if( add )
  8328. sd->permissions |= pc_g_permission_name[i].permission;
  8329. else
  8330. sd->permissions &=~ pc_g_permission_name[i].permission;
  8331. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8332. clif_displaymessage(fd, atcmd_output);
  8333. return 0;
  8334. }
  8335. ACMD_FUNC(unloadnpcfile) {
  8336. if( !message || !*message ) {
  8337. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8338. return -1;
  8339. }
  8340. if( npc_unloadfile(message) )
  8341. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8342. else {
  8343. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8344. return -1;
  8345. }
  8346. return 0;
  8347. }
  8348. ACMD_FUNC(cart) {
  8349. #define MC_CART_MDFY(idx, x) \
  8350. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8351. sd->status.skill[(idx)].lv = (x)?1:0; \
  8352. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8353. int val = atoi(message);
  8354. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8355. uint16 sk_idx = 0;
  8356. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8357. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8358. clif_displaymessage(fd, atcmd_output);
  8359. return -1;
  8360. }
  8361. if( val == 0 && !pc_iscarton(sd) ) {
  8362. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8363. return -1;
  8364. }
  8365. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8366. return -1;
  8367. if( need_skill ) {
  8368. MC_CART_MDFY(sk_idx,1);
  8369. }
  8370. if( !pc_setcart(sd, val) ) {
  8371. if( need_skill ) {
  8372. MC_CART_MDFY(sk_idx,0);
  8373. }
  8374. return -1;/* @cart failed */
  8375. }
  8376. if( need_skill ) {
  8377. MC_CART_MDFY(sk_idx,0);
  8378. }
  8379. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8380. return 0;
  8381. #undef MC_CART_MDFY
  8382. }
  8383. /* Channel System [Ind] */
  8384. ACMD_FUNC(join){
  8385. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8386. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8387. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8388. clif_displaymessage(fd, atcmd_output);
  8389. return -1;
  8390. }
  8391. return channel_pcjoin(sd, chname, pass);
  8392. }
  8393. /*
  8394. * Display available option for @channel command
  8395. * @command : the name of used command (for alias case)
  8396. */
  8397. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8398. {
  8399. int fd = sd->fd;
  8400. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8401. bool can_create = (can_delete || channel_config.private_channel.allow);
  8402. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8403. //option create
  8404. if( can_create ) {
  8405. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8406. clif_displaymessage(fd, atcmd_output);
  8407. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8408. }
  8409. //option delete
  8410. if(can_delete){
  8411. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8412. clif_displaymessage(fd, atcmd_output);
  8413. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8414. }
  8415. //option list
  8416. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8417. clif_displaymessage(fd, atcmd_output);
  8418. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8419. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8420. clif_displaymessage(fd, atcmd_output);
  8421. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8422. if( can_create ) {
  8423. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8424. clif_displaymessage(fd, atcmd_output);
  8425. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8426. }
  8427. //option setcolor
  8428. if(can_create){
  8429. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8430. clif_displaymessage(fd, atcmd_output);
  8431. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8432. }
  8433. //option join
  8434. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8435. clif_displaymessage(fd, atcmd_output);
  8436. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8437. //option leave
  8438. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8439. clif_displaymessage(fd, atcmd_output);
  8440. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8441. //option bindto
  8442. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8443. clif_displaymessage(fd, atcmd_output);
  8444. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8445. //option unbind
  8446. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8447. clif_displaymessage(fd, atcmd_output);
  8448. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8449. //option ban/unban/banlist
  8450. if( can_create ) {
  8451. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8452. clif_displaymessage(fd, atcmd_output);
  8453. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8454. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8455. clif_displaymessage(fd, atcmd_output);
  8456. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8457. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8458. clif_displaymessage(fd, atcmd_output);
  8459. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8460. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8461. clif_displaymessage(fd, atcmd_output);
  8462. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8463. }
  8464. //option setopt
  8465. if(can_create){
  8466. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8467. clif_displaymessage(fd, atcmd_output);
  8468. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8469. }
  8470. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8471. clif_displaymessage(fd, atcmd_output);
  8472. }
  8473. ACMD_FUNC(channel) {
  8474. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8475. sub1[0] = sub2[0] = '\0';
  8476. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8477. atcmd_channel_help(sd,command);
  8478. return 0;
  8479. }
  8480. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8481. return channel_pcdelete(sd,sub1);
  8482. } else if ( strcmpi(key,"list") == 0 ) {
  8483. return channel_display_list(sd,sub1);
  8484. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8485. return channel_pccolor(sd, sub1, sub2);
  8486. } else if ( strcmpi(key,"join") == 0 ) {
  8487. return channel_pcjoin(sd, sub1, sub2);
  8488. }else if ( strcmpi(key,"leave") == 0 ) {
  8489. return channel_pcleave(sd, sub1);
  8490. } else if ( strcmpi(key,"bindto") == 0 ) {
  8491. return channel_pcbind(sd, sub1);
  8492. } else if ( strcmpi(key,"unbind") == 0 ) {
  8493. return channel_pcunbind(sd);
  8494. } else if ( strcmpi(key,"ban") == 0 ) {
  8495. return channel_pcban(sd,sub1,sub2,0);
  8496. } else if ( strcmpi(key,"kick") == 0 ) {
  8497. return channel_pckick(sd,sub1,sub2);
  8498. } else if ( strcmpi(key,"banlist") == 0 ) {
  8499. return channel_pcban(sd,sub1,NULL,3);
  8500. } else if ( strcmpi(key,"unban") == 0 ) {
  8501. return channel_pcban(sd,sub1,sub2,1);
  8502. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8503. return channel_pcban(sd,sub1,NULL,2);
  8504. } else {
  8505. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8506. sub3[0] = sub4[0] = '\0';
  8507. sscanf(sub2, "%19s %19s", sub3, sub4);
  8508. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8509. if (sub4[0] != '\0') {
  8510. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8511. return -1;
  8512. }
  8513. return channel_pccreate(sd,sub1,sub3);
  8514. } else if ( strcmpi(key,"setopt") == 0 ) {
  8515. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8516. }
  8517. atcmd_channel_help(sd,command);
  8518. }
  8519. return 0;
  8520. }
  8521. ACMD_FUNC(fontcolor)
  8522. {
  8523. if( !message || !*message ) {
  8524. channel_display_list(sd,"colors");
  8525. return -1;
  8526. }
  8527. if( strcmpi(message,"Normal") == 0 ) {
  8528. sd->fontcolor = 0;
  8529. } else {
  8530. unsigned char k;
  8531. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8532. if( k == channel_config.colors_count ) {
  8533. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8534. clif_displaymessage(fd, atcmd_output);
  8535. return -1;
  8536. }
  8537. sd->fontcolor = k;
  8538. }
  8539. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8540. clif_displaymessage(fd, atcmd_output);
  8541. return 0;
  8542. }
  8543. ACMD_FUNC(langtype)
  8544. {
  8545. char langstr[8];
  8546. int i=0, fail=0;
  8547. memset(langstr, '\0', sizeof(langstr));
  8548. if(sscanf(message, "%3s", langstr) >= 1){
  8549. int lang=0;
  8550. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8551. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8552. char output[100];
  8553. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8554. sd->langtype = lang;
  8555. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8556. clif_displaymessage(fd,output);
  8557. return 0;
  8558. } else if (lang != -1) { //defined langage but failed check
  8559. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8560. return -1;
  8561. }
  8562. }
  8563. //wrong or no entry
  8564. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8565. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8566. while(fail != -1){ //out of range
  8567. fail = msg_checklangtype(i,false);
  8568. if(fail == 1)
  8569. clif_displaymessage(fd,msg_langtype2langstr(i));
  8570. i++;
  8571. }
  8572. return -1;
  8573. }
  8574. #ifdef VIP_ENABLE
  8575. ACMD_FUNC(vip) {
  8576. struct map_session_data *pl_sd = NULL;
  8577. char * modif_p;
  8578. int32 vipdifftime = 0;
  8579. time_t now=time(NULL);
  8580. nullpo_retr(-1, sd);
  8581. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8582. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8583. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8584. return -1;
  8585. }
  8586. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8587. modif_p = atcmd_output;
  8588. vipdifftime = (int32)solve_time(modif_p);
  8589. if (vipdifftime == 0) {
  8590. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8591. 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.
  8592. return -1;
  8593. }
  8594. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8595. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8596. return -1;
  8597. }
  8598. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8599. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8600. return -1;
  8601. }
  8602. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8603. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8604. if (pl_sd->vip.time <= now) {
  8605. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8606. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8607. } else {
  8608. int year,month,day,hour,minute,second;
  8609. char timestr[21];
  8610. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8611. 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.
  8612. clif_displaymessage(pl_sd->fd,atcmd_output);
  8613. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8614. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8615. clif_displaymessage(pl_sd->fd,atcmd_output);
  8616. if (pl_sd != sd) {
  8617. 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.
  8618. clif_displaymessage(fd,atcmd_output);
  8619. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8620. clif_displaymessage(fd,atcmd_output);
  8621. }
  8622. }
  8623. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8624. return 0;
  8625. }
  8626. /** Enable/disable rate info */
  8627. ACMD_FUNC(showrate) {
  8628. nullpo_retr(-1,sd);
  8629. if (!sd->vip.disableshowrate) {
  8630. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8631. sd->vip.disableshowrate = 1;
  8632. } else {
  8633. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8634. sd->vip.disableshowrate = 0;
  8635. }
  8636. clif_displaymessage(fd,atcmd_output);
  8637. return 0;
  8638. }
  8639. #endif
  8640. ACMD_FUNC(fullstrip) {
  8641. int i;
  8642. TBL_PC *tsd;
  8643. nullpo_retr(-1,sd);
  8644. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8645. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8646. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8647. return -1;
  8648. }
  8649. if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
  8650. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8651. return -1;
  8652. }
  8653. for( i = 0; i < EQI_MAX; i++ ) {
  8654. if( tsd->equip_index[ i ] >= 0 )
  8655. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8656. }
  8657. return 0;
  8658. }
  8659. ACMD_FUNC(changedress){
  8660. sc_type name2id[] = {
  8661. SC_WEDDING,
  8662. SC_XMAS,
  8663. SC_SUMMER,
  8664. SC_DRESSUP,
  8665. SC_HANBOK,
  8666. SC_OKTOBERFEST
  8667. };
  8668. for( sc_type type : name2id ) {
  8669. if( sd->sc.data[type] ) {
  8670. status_change_end( &sd->bl, type, INVALID_TIMER );
  8671. // You should only be able to have one - so we cancel here
  8672. break;
  8673. }
  8674. }
  8675. return 0;
  8676. }
  8677. ACMD_FUNC(costume) {
  8678. const char* names[] = {
  8679. "Wedding",
  8680. "Xmas",
  8681. "Summer",
  8682. "Summer2",
  8683. "Hanbok",
  8684. "Oktoberfest"
  8685. };
  8686. const int name2id[] = {
  8687. SC_WEDDING,
  8688. SC_XMAS,
  8689. SC_SUMMER,
  8690. SC_DRESSUP,
  8691. SC_HANBOK,
  8692. SC_OKTOBERFEST
  8693. };
  8694. unsigned short k = 0, len = ARRAYLENGTH(names);
  8695. if( !message || !*message ) {
  8696. for( k = 0; k < len; k++ ) {
  8697. if( sd->sc.data[name2id[k]] ) {
  8698. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8699. clif_displaymessage(sd->fd, atcmd_output);
  8700. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8701. return 0;
  8702. }
  8703. }
  8704. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8705. for( k = 0; k < len; k++ ) {
  8706. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8707. clif_displaymessage(sd->fd, atcmd_output);
  8708. }
  8709. return -1;
  8710. }
  8711. for( k = 0; k < len; k++ ) {
  8712. if( sd->sc.data[name2id[k]] ) {
  8713. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8714. clif_displaymessage(sd->fd, atcmd_output);
  8715. return -1;
  8716. }
  8717. }
  8718. for( k = 0; k < len; k++ )
  8719. if( strcmpi(message, names[k]) == 0 )
  8720. break;
  8721. if( k == len ) {
  8722. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8723. clif_displaymessage(sd->fd, atcmd_output);
  8724. return -1;
  8725. }
  8726. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  8727. return 0;
  8728. }
  8729. /**
  8730. * Clone other player's equipments
  8731. * Usage: @cloneequip <char name/ID>
  8732. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8733. * @author [Cydh], [Antares]
  8734. */
  8735. ACMD_FUNC(cloneequip) {
  8736. struct map_session_data *pl_sd;
  8737. nullpo_retr(-1, sd);
  8738. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8739. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8740. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8741. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8742. clif_displaymessage(fd, atcmd_output);
  8743. return -1;
  8744. }
  8745. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8746. clif_displaymessage(fd, msg_txt(sd, 3));
  8747. return -1;
  8748. }
  8749. if (sd == pl_sd) {
  8750. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8751. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8752. clif_displaymessage(fd, atcmd_output);
  8753. return -1;
  8754. }
  8755. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8756. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8757. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8758. clif_displaymessage(fd, atcmd_output);
  8759. return -1;
  8760. }
  8761. else {
  8762. int8 i;
  8763. for (i = 0; i < EQI_MAX; i++) {
  8764. short idx;
  8765. char flag = 0;
  8766. struct item tmp_item;
  8767. if ((idx = pl_sd->equip_index[i]) < 0)
  8768. continue;
  8769. if (i == EQI_AMMO)
  8770. continue;
  8771. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8772. continue;
  8773. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8774. if (itemdb_isspecial(tmp_item.card[0]))
  8775. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8776. tmp_item.bound = 0;
  8777. tmp_item.expire_time = 0;
  8778. tmp_item.unique_id = 0;
  8779. tmp_item.favorite = 0;
  8780. tmp_item.amount = 1;
  8781. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8782. clif_additem(sd, 0, 0, flag);
  8783. else
  8784. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8785. }
  8786. }
  8787. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8788. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8789. clif_displaymessage(fd, atcmd_output);
  8790. return 0;
  8791. }
  8792. /**
  8793. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8794. * Usage: @clonestat <char name/ID>
  8795. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8796. * @author [Cydh], [Antares]
  8797. */
  8798. ACMD_FUNC(clonestat) {
  8799. struct map_session_data *pl_sd;
  8800. nullpo_retr(-1, sd);
  8801. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8802. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8803. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8804. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8805. clif_displaymessage(fd, atcmd_output);
  8806. return -1;
  8807. }
  8808. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8809. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8810. return -1;
  8811. }
  8812. if (sd == pl_sd) {
  8813. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8814. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8815. clif_displaymessage(fd, atcmd_output);
  8816. return -1;
  8817. }
  8818. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8819. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8820. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8821. clif_displaymessage(fd, atcmd_output);
  8822. return -1;
  8823. }
  8824. else {
  8825. uint8 i;
  8826. short max_status[PARAM_MAX] = {};
  8827. pc_resetstate(sd);
  8828. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE)) {
  8829. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  8830. if (i >= PARAM_POW && !(sd->class_ & JOBL_FOURTH))
  8831. continue;
  8832. max_status[i] = SHRT_MAX;
  8833. }
  8834. } else {
  8835. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  8836. if (i >= PARAM_POW && sd->class_ & JOBL_FOURTH)
  8837. continue;
  8838. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  8839. }
  8840. }
  8841. #define clonestat_check(cmd,stat)\
  8842. {\
  8843. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8844. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8845. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8846. clif_displaymessage(fd, atcmd_output);\
  8847. sd->status.cmd = max_status[(stat)];\
  8848. }\
  8849. else\
  8850. sd->status.cmd = pl_sd->status.cmd;\
  8851. }
  8852. clonestat_check(str, PARAM_STR);
  8853. clonestat_check(agi, PARAM_AGI);
  8854. clonestat_check(vit, PARAM_VIT);
  8855. clonestat_check(int_, PARAM_INT);
  8856. clonestat_check(dex, PARAM_DEX);
  8857. clonestat_check(luk, PARAM_LUK);
  8858. for (i = PARAM_STR; i < PARAM_POW; i++) {
  8859. clif_updatestatus(sd, SP_STR + i);
  8860. clif_updatestatus(sd, SP_USTR + i);
  8861. }
  8862. if (sd->class_ & JOBL_FOURTH) {
  8863. clonestat_check(pow, PARAM_POW);
  8864. clonestat_check(sta, PARAM_STA);
  8865. clonestat_check(wis, PARAM_WIS);
  8866. clonestat_check(spl, PARAM_SPL);
  8867. clonestat_check(con, PARAM_CON);
  8868. clonestat_check(crt, PARAM_CRT);
  8869. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  8870. clif_updatestatus(sd, SP_POW + i - PARAM_POW);
  8871. clif_updatestatus(sd, SP_UPOW + i - PARAM_POW);
  8872. }
  8873. }
  8874. status_calc_pc(sd, SCO_FORCE);
  8875. }
  8876. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8877. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  8878. clif_displaymessage(fd, atcmd_output);
  8879. #undef clonestat_check
  8880. return 0;
  8881. }
  8882. /**
  8883. * Adopt a character.
  8884. * Usage: @adopt <char name>
  8885. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8886. */
  8887. ACMD_FUNC(adopt)
  8888. {
  8889. TBL_PC *b_sd;
  8890. enum adopt_responses response;
  8891. nullpo_retr(-1, sd);
  8892. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8893. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8894. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8895. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8896. clif_displaymessage(fd, atcmd_output);
  8897. return -1;
  8898. }
  8899. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8900. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8901. return -1;
  8902. }
  8903. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8904. if (response == ADOPT_ALLOWED) {
  8905. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8906. b_sd->adopt_invite = sd->status.account_id;
  8907. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8908. return 0;
  8909. }
  8910. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8911. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8912. return -1;
  8913. }
  8914. /**
  8915. * Opens the limited sale window.
  8916. * Usage: @limitedsale or client command /limitedsale on supported clients
  8917. */
  8918. ACMD_FUNC(limitedsale){
  8919. nullpo_retr(-1, sd);
  8920. clif_sale_open(sd);
  8921. return 0;
  8922. }
  8923. /**
  8924. * Displays camera information from the client.
  8925. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  8926. */
  8927. ACMD_FUNC(camerainfo){
  8928. nullpo_retr(-1, sd);
  8929. if( message == nullptr || message[0] == '\0' ){
  8930. clif_camerainfo( sd, true );
  8931. return 0;
  8932. }
  8933. float range = 0;
  8934. float rotation = 0;
  8935. float latitude = 0;
  8936. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  8937. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  8938. return -1;
  8939. }
  8940. clif_camerainfo( sd, false, range, rotation, latitude );
  8941. return 0;
  8942. }
  8943. ACMD_FUNC(resurrect) {
  8944. nullpo_retr(-1, sd);
  8945. if (!pc_revive_item(sd))
  8946. return -1;
  8947. return 0;
  8948. }
  8949. ACMD_FUNC(quest) {
  8950. uint8 i;
  8951. int quest_id = 0;
  8952. nullpo_retr(-1, sd);
  8953. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8954. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  8955. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  8956. clif_displaymessage(fd, atcmd_output);
  8957. return -1;
  8958. }
  8959. if (!quest_search(quest_id)) {
  8960. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  8961. clif_displaymessage(fd, atcmd_output);
  8962. return -1;
  8963. }
  8964. const char* type[] = { "setquest", "erasequest", "completequest", "checkquest" };
  8965. ARR_FIND( 0, ARRAYLENGTH(type), i, strcmpi(command+1, type[i]) == 0 );
  8966. switch(i) {
  8967. case 0:
  8968. if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
  8969. sprintf(atcmd_output, msg_txt(sd,1507), quest_id); // Character already has quest %d.
  8970. clif_displaymessage(fd, atcmd_output);
  8971. return -1;
  8972. }
  8973. quest_add(sd, quest_id);
  8974. pc_show_questinfo(sd);
  8975. break;
  8976. case 1:
  8977. if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
  8978. sprintf(atcmd_output, msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
  8979. clif_displaymessage(fd, atcmd_output);
  8980. return -1;
  8981. }
  8982. quest_delete(sd, quest_id);
  8983. pc_show_questinfo(sd);
  8984. break;
  8985. case 2:
  8986. if (quest_check(sd, quest_id, HAVEQUEST) < 0)
  8987. quest_add(sd, quest_id);
  8988. if (quest_check(sd, quest_id, HAVEQUEST) < 2)
  8989. quest_update_status(sd, quest_id, Q_COMPLETE);
  8990. pc_show_questinfo(sd);
  8991. break;
  8992. case 3:
  8993. sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
  8994. clif_displaymessage(fd, atcmd_output);
  8995. sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST)); // HAVEQUEST : %d
  8996. clif_displaymessage(fd, atcmd_output);
  8997. sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING)); // HUNTING : %d
  8998. clif_displaymessage(fd, atcmd_output);
  8999. sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME)); // PLAYTIME : %d
  9000. clif_displaymessage(fd, atcmd_output);
  9001. break;
  9002. }
  9003. return 0;
  9004. }
  9005. /**
  9006. * Opens the refineUI
  9007. * Usage: @refineui
  9008. */
  9009. ACMD_FUNC(refineui)
  9010. {
  9011. nullpo_retr(-1, sd);
  9012. #if PACKETVER < 20161012
  9013. clif_displaymessage(fd, msg_txt(sd, 773)); // This command requires packet version 2016-10-12 or newer.
  9014. return -1;
  9015. #else
  9016. if( !battle_config.feature_refineui ){
  9017. clif_displaymessage(fd, msg_txt(sd, 774)); // This command is disabled via configuration.
  9018. return -1;
  9019. }
  9020. if( sd->state.refineui_open ){
  9021. clif_displaymessage(fd, msg_txt(sd, 775)); // You have already opened the refine UI.
  9022. return -1;
  9023. }
  9024. clif_refineui_open(sd);
  9025. return 0;
  9026. #endif
  9027. }
  9028. ACMD_FUNC( stylist ){
  9029. nullpo_retr(-1, sd);
  9030. #if PACKETVER < 20151104
  9031. clif_displaymessage( fd, msg_txt( sd, 798 ) ); // This command requires packet version 2015-11-04 or newer.
  9032. return -1;
  9033. #else
  9034. if( sd->state.stylist_open ){
  9035. clif_displaymessage( fd, msg_txt( sd, 799 ) ); // You have already opened the stylist UI.
  9036. return -1;
  9037. }
  9038. clif_ui_open( sd, OUT_UI_STYLIST, 0 );
  9039. return 0;
  9040. #endif
  9041. }
  9042. #include "../custom/atcommand.inc"
  9043. /**
  9044. * Fills the reference of available commands in atcommand DBMap
  9045. **/
  9046. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  9047. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  9048. // Define with restriction
  9049. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  9050. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  9051. void atcommand_basecommands(void) {
  9052. /**
  9053. * Command reference list, place the base of your commands here
  9054. * TODO: List all commands that causing crash
  9055. **/
  9056. AtCommandInfo atcommand_base[] = {
  9057. #include "../custom/atcommand_def.inc"
  9058. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  9059. ACMD_DEF(where),
  9060. ACMD_DEF(jumpto),
  9061. ACMD_DEF(jump),
  9062. ACMD_DEF(who),
  9063. ACMD_DEF2("who2", who),
  9064. ACMD_DEF2("who3", who),
  9065. ACMD_DEF2("whomap", who),
  9066. ACMD_DEF2("whomap2", who),
  9067. ACMD_DEF2("whomap3", who),
  9068. ACMD_DEF(whogm),
  9069. ACMD_DEF(save),
  9070. ACMD_DEF(load),
  9071. ACMD_DEF(speed),
  9072. ACMD_DEF(storage),
  9073. ACMD_DEF(guildstorage),
  9074. ACMD_DEF(option),
  9075. ACMD_DEF(hide), // + /hide
  9076. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  9077. ACMD_DEF(kill),
  9078. ACMD_DEF(alive),
  9079. ACMD_DEF(kami),
  9080. ACMD_DEF2("kamib", kami),
  9081. ACMD_DEF2("kamic", kami),
  9082. ACMD_DEF2("lkami", kami),
  9083. ACMD_DEF(heal),
  9084. ACMD_DEF(healap),
  9085. ACMD_DEF(item),
  9086. ACMD_DEF(item2),
  9087. ACMD_DEF2("itembound",item),
  9088. ACMD_DEF2("itembound2",item2),
  9089. ACMD_DEF(itemreset),
  9090. ACMD_DEF(clearstorage),
  9091. ACMD_DEF(cleargstorage),
  9092. ACMD_DEF(clearcart),
  9093. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  9094. ACMD_DEF2("jlvl", joblevelup),
  9095. ACMD_DEF(help),
  9096. ACMD_DEF(pvpoff),
  9097. ACMD_DEF(pvpon),
  9098. ACMD_DEF(gvgoff),
  9099. ACMD_DEF(gvgon),
  9100. ACMD_DEF(model),
  9101. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  9102. ACMD_DEF(monster),
  9103. ACMD_DEF2("monstersmall", monster),
  9104. ACMD_DEF2("monsterbig", monster),
  9105. ACMD_DEF(killmonster),
  9106. ACMD_DEF2("killmonster2", killmonster),
  9107. ACMD_DEF(refine),
  9108. ACMD_DEF(produce),
  9109. ACMD_DEF(memo),
  9110. ACMD_DEF(gat),
  9111. ACMD_DEF(displaystatus),
  9112. ACMD_DEF2("stpoint", statuspoint),
  9113. ACMD_DEF2("trpoint", traitpoint),
  9114. ACMD_DEF2("skpoint", skillpoint),
  9115. ACMD_DEF(zeny),
  9116. ACMD_DEF2("str", param),
  9117. ACMD_DEF2("agi", param),
  9118. ACMD_DEF2("vit", param),
  9119. ACMD_DEF2("int", param),
  9120. ACMD_DEF2("dex", param),
  9121. ACMD_DEF2("luk", param),
  9122. ACMD_DEF2("pow", param),
  9123. ACMD_DEF2("sta", param),
  9124. ACMD_DEF2("wis", param),
  9125. ACMD_DEF2("spl", param),
  9126. ACMD_DEF2("con", param),
  9127. ACMD_DEF2("crt", param),
  9128. ACMD_DEF2("glvl", guildlevelup),
  9129. ACMD_DEF(makeegg),
  9130. ACMD_DEF(hatch),
  9131. ACMD_DEF(petfriendly),
  9132. ACMD_DEF(pethungry),
  9133. ACMD_DEF(petrename),
  9134. ACMD_DEF(recall), // + /recall
  9135. ACMD_DEF(night),
  9136. ACMD_DEF(day),
  9137. ACMD_DEF(doom),
  9138. ACMD_DEF(doommap),
  9139. ACMD_DEF(raise),
  9140. ACMD_DEF(raisemap),
  9141. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  9142. ACMD_DEF(kickall),
  9143. ACMD_DEF(allskill),
  9144. ACMD_DEF(questskill),
  9145. ACMD_DEF(lostskill),
  9146. ACMD_DEF(spiritball),
  9147. ACMD_DEF(soulball),
  9148. ACMD_DEF(party),
  9149. ACMD_DEF(guild),
  9150. ACMD_DEF(breakguild),
  9151. ACMD_DEF(agitstart),
  9152. ACMD_DEF(agitend),
  9153. ACMD_DEF(mapexit),
  9154. ACMD_DEF(idsearch),
  9155. ACMD_DEF(broadcast), // + /b and /nb
  9156. ACMD_DEF(localbroadcast), // + /lb and /nlb
  9157. ACMD_DEF(recallall),
  9158. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  9159. ACMD_DEF2("reloaditemdb", reload),
  9160. ACMD_DEF2("reloadmobdb", reload),
  9161. ACMD_DEF2("reloadskilldb", reload),
  9162. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  9163. ACMD_DEF2("reloadatcommand", reload),
  9164. ACMD_DEF2("reloadbattleconf", reload),
  9165. ACMD_DEF2("reloadstatusdb", reload),
  9166. ACMD_DEF2("reloadpcdb", reload),
  9167. ACMD_DEF2("reloadmotd", reload),
  9168. ACMD_DEF2("reloadquestdb", reload),
  9169. ACMD_DEF2("reloadmsgconf", reload),
  9170. ACMD_DEF2("reloadinstancedb", reload),
  9171. ACMD_DEF2("reloadachievementdb",reload),
  9172. ACMD_DEF2("reloadattendancedb",reload),
  9173. ACMD_DEF(partysharelvl),
  9174. ACMD_DEF(mapinfo),
  9175. ACMD_DEF(dye),
  9176. ACMD_DEF2("hairstyle", hair_style),
  9177. ACMD_DEF2("haircolor", hair_color),
  9178. ACMD_DEF2("allstats", stat_all),
  9179. ACMD_DEF2("alltraits", trait_all),
  9180. ACMD_DEF2("block", char_block),
  9181. ACMD_DEF2("ban", char_ban),
  9182. ACMD_DEF2("unblock", char_unblock),
  9183. ACMD_DEF2("unban", char_unban),
  9184. ACMD_DEF2("charban", char_ban),
  9185. ACMD_DEF2("charunban", char_unban),
  9186. ACMD_DEF2("mount", mount_peco),
  9187. ACMD_DEF(guildspy),
  9188. ACMD_DEF(partyspy),
  9189. ACMD_DEF(clanspy),
  9190. ACMD_DEF(repairall),
  9191. ACMD_DEF(guildrecall),
  9192. ACMD_DEF(partyrecall),
  9193. ACMD_DEF(nuke),
  9194. ACMD_DEF(shownpc),
  9195. ACMD_DEF(hidenpc),
  9196. ACMD_DEF(loadnpc),
  9197. ACMD_DEF(unloadnpc),
  9198. ACMD_DEF(reloadnpcfile),
  9199. ACMD_DEF2("time", servertime),
  9200. ACMD_DEF(jail),
  9201. ACMD_DEF(unjail),
  9202. ACMD_DEF(jailfor),
  9203. ACMD_DEF(jailtime),
  9204. ACMD_DEF(disguise),
  9205. ACMD_DEF(undisguise),
  9206. ACMD_DEF(email),
  9207. ACMD_DEF(effect),
  9208. ACMD_DEF(follow),
  9209. ACMD_DEF(addwarp),
  9210. ACMD_DEF(skillon),
  9211. ACMD_DEF(skilloff),
  9212. ACMD_DEF(killer),
  9213. ACMD_DEF(npcmove),
  9214. ACMD_DEF(killable),
  9215. ACMD_DEF(dropall),
  9216. ACMD_DEF(storeall),
  9217. ACMD_DEF(skillid),
  9218. ACMD_DEF(useskill),
  9219. ACMD_DEF(displayskill),
  9220. ACMD_DEF(displayskillcast),
  9221. ACMD_DEF(displayskillunit),
  9222. ACMD_DEF(snow),
  9223. ACMD_DEF(sakura),
  9224. ACMD_DEF(clouds),
  9225. ACMD_DEF(clouds2),
  9226. ACMD_DEF(fog),
  9227. ACMD_DEF(fireworks),
  9228. ACMD_DEF(leaves),
  9229. ACMD_DEF(summon),
  9230. ACMD_DEF(adjgroup),
  9231. ACMD_DEF(trade),
  9232. ACMD_DEF(send),
  9233. ACMD_DEF(setbattleflag),
  9234. ACMD_DEF(unmute),
  9235. ACMD_DEF(clearweather),
  9236. ACMD_DEF(uptime),
  9237. ACMD_DEF(changesex),
  9238. ACMD_DEF(changecharsex),
  9239. ACMD_DEF(mute),
  9240. ACMD_DEF(refresh),
  9241. ACMD_DEF(refreshall),
  9242. ACMD_DEF(identify),
  9243. ACMD_DEF(identifyall),
  9244. ACMD_DEF(gmotd),
  9245. ACMD_DEF(misceffect),
  9246. ACMD_DEF(mobsearch),
  9247. ACMD_DEF(cleanmap),
  9248. ACMD_DEF(cleanarea),
  9249. ACMD_DEF(npctalk),
  9250. ACMD_DEF(pettalk),
  9251. ACMD_DEF(users),
  9252. ACMD_DEF(reset),
  9253. ACMD_DEF(skilltree),
  9254. ACMD_DEF(marry),
  9255. ACMD_DEF(divorce),
  9256. ACMD_DEF(sound),
  9257. ACMD_DEF(undisguiseall),
  9258. ACMD_DEF(disguiseall),
  9259. ACMD_DEF(changelook),
  9260. ACMD_DEF(autoloot),
  9261. ACMD_DEF2("alootid", autolootitem),
  9262. ACMD_DEF(autoloottype),
  9263. ACMD_DEF(mobinfo),
  9264. ACMD_DEF(exp),
  9265. ACMD_DEF(version),
  9266. ACMD_DEF(mutearea),
  9267. ACMD_DEF(rates),
  9268. ACMD_DEF(iteminfo),
  9269. ACMD_DEF(whodrops),
  9270. ACMD_DEF(whereis),
  9271. ACMD_DEF(mapflag),
  9272. ACMD_DEF(me),
  9273. ACMD_DEF(monsterignore),
  9274. ACMD_DEF(fakename),
  9275. ACMD_DEF(size),
  9276. ACMD_DEF(showexp),
  9277. ACMD_DEF(showzeny),
  9278. ACMD_DEF(showdelay),
  9279. ACMD_DEF(autotrade),
  9280. ACMD_DEF(changegm),
  9281. ACMD_DEF(changeleader),
  9282. ACMD_DEF(partyoption),
  9283. ACMD_DEF(invite),
  9284. ACMD_DEF(duel),
  9285. ACMD_DEF(leave),
  9286. ACMD_DEF(accept),
  9287. ACMD_DEF(reject),
  9288. ACMD_DEF(clone),
  9289. ACMD_DEF2("slaveclone", clone),
  9290. ACMD_DEF2("evilclone", clone),
  9291. ACMD_DEF(tonpc),
  9292. ACMD_DEF(commands),
  9293. ACMD_DEF(noask),
  9294. ACMD_DEF(request),
  9295. ACMD_DEF(homlevel),
  9296. ACMD_DEF(homevolution),
  9297. ACMD_DEF(hommutate),
  9298. ACMD_DEF(makehomun),
  9299. ACMD_DEF(homfriendly),
  9300. ACMD_DEF(homhungry),
  9301. ACMD_DEF(homtalk),
  9302. ACMD_DEF(hominfo),
  9303. ACMD_DEF(homstats),
  9304. ACMD_DEF(homshuffle),
  9305. ACMD_DEF(showmobs),
  9306. ACMD_DEF(feelreset),
  9307. ACMD_DEF(hatereset),
  9308. ACMD_DEF(auction),
  9309. ACMD_DEF(mail),
  9310. ACMD_DEF2("noks", ksprotection),
  9311. ACMD_DEF(allowks),
  9312. ACMD_DEF(cash),
  9313. ACMD_DEF2("points", cash),
  9314. ACMD_DEF(agitstart2),
  9315. ACMD_DEF(agitend2),
  9316. ACMD_DEF(resetskill),
  9317. ACMD_DEF(resetstat),
  9318. ACMD_DEF2("storagelist", itemlist),
  9319. ACMD_DEF2("cartlist", itemlist),
  9320. ACMD_DEF2("itemlist", itemlist),
  9321. ACMD_DEF(stats),
  9322. ACMD_DEF(delitem),
  9323. ACMD_DEF(charcommands),
  9324. ACMD_DEF(font),
  9325. ACMD_DEF(accinfo),
  9326. ACMD_DEF(set),
  9327. ACMD_DEF(undisguiseguild),
  9328. ACMD_DEF(disguiseguild),
  9329. ACMD_DEF(sizeall),
  9330. ACMD_DEF(sizeguild),
  9331. ACMD_DEF(addperm),
  9332. ACMD_DEF2("rmvperm", addperm),
  9333. ACMD_DEF(unloadnpcfile),
  9334. ACMD_DEF(cart),
  9335. ACMD_DEF(mount2),
  9336. ACMD_DEF(join),
  9337. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  9338. ACMD_DEF(fontcolor),
  9339. ACMD_DEF(langtype),
  9340. #ifdef VIP_ENABLE
  9341. ACMD_DEF(vip),
  9342. ACMD_DEF(showrate),
  9343. #endif
  9344. ACMD_DEF(fullstrip),
  9345. ACMD_DEF(costume),
  9346. ACMD_DEF(cloneequip),
  9347. ACMD_DEF(clonestat),
  9348. ACMD_DEF(bodystyle),
  9349. ACMD_DEF(adopt),
  9350. ACMD_DEF(agitstart3),
  9351. ACMD_DEF(agitend3),
  9352. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9353. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9354. ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9355. ACMD_DEFR(resurrect, ATCMD_NOCONSOLE),
  9356. ACMD_DEF2("setquest", quest),
  9357. ACMD_DEF2("erasequest", quest),
  9358. ACMD_DEF2("completequest", quest),
  9359. ACMD_DEF2("checkquest", quest),
  9360. ACMD_DEF(refineui),
  9361. ACMD_DEFR(stylist, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9362. };
  9363. AtCommandInfo* atcommand;
  9364. int i;
  9365. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9366. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9367. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9368. continue;
  9369. }
  9370. CREATE(atcommand, AtCommandInfo, 1);
  9371. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9372. atcommand->func = atcommand_base[i].func;
  9373. atcommand->restriction = atcommand_base[i].restriction;
  9374. strdb_put(atcommand_db, atcommand->command, atcommand);
  9375. }
  9376. return;
  9377. }
  9378. /*==========================================
  9379. * Command lookup functions
  9380. *------------------------------------------*/
  9381. bool atcommand_exists(const char* name)
  9382. {
  9383. return strdb_exists(atcommand_db, name);
  9384. }
  9385. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9386. {
  9387. if (strdb_exists(atcommand_db, name))
  9388. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9389. return NULL;
  9390. }
  9391. /// AtCommand suggestion
  9392. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  9393. DBIterator* atcommand_iter;
  9394. AtCommandInfo* command_info = NULL;
  9395. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9396. char* full_match[MAX_SUGGESTIONS];
  9397. char* suggestions[MAX_SUGGESTIONS];
  9398. char* match;
  9399. int prefix_count = 0, full_count = 0;
  9400. bool can_use;
  9401. if (!battle_config.atcommand_suggestions_enabled)
  9402. return;
  9403. atcommand_iter = db_iterator(atcommand_db);
  9404. // Build the matches
  9405. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  9406. match = strstr(command_info->command, name);
  9407. can_use = pc_can_use_command(sd, command_info->command, type);
  9408. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9409. suggestions[prefix_count] = command_info->command;
  9410. ++prefix_count;
  9411. }
  9412. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  9413. full_match[full_count] = command_info->command;
  9414. ++full_count;
  9415. }
  9416. }
  9417. for( auto& pair : atcommand_alias_db ){
  9418. std::shared_ptr<s_atcommand_alias_info> info = pair.second;
  9419. if( pc_can_use_command( sd, info->command->command, type ) ){
  9420. for( const std::string& alias_str : info->aliases ){
  9421. char* alias = const_cast<char *>(alias_str.c_str());
  9422. match = strstr( alias, name );
  9423. if( prefix_count < MAX_SUGGESTIONS && match == alias ){
  9424. suggestions[prefix_count] = alias;
  9425. ++prefix_count;
  9426. }
  9427. if( full_count < MAX_SUGGESTIONS && match != NULL && match != alias ){
  9428. full_match[full_count] = alias;
  9429. ++full_count;
  9430. }
  9431. }
  9432. }
  9433. }
  9434. if ((full_count+prefix_count) > 0) {
  9435. char buffer[512];
  9436. int i;
  9437. // Merge full match and prefix match results
  9438. if (prefix_count < MAX_SUGGESTIONS) {
  9439. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9440. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9441. }
  9442. // Build the suggestion string
  9443. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  9444. strcat(buffer,"\n");
  9445. for(i=0; i < prefix_count; ++i) {
  9446. strcat(buffer,suggestions[i]);
  9447. strcat(buffer," ");
  9448. }
  9449. clif_displaymessage(sd->fd, buffer);
  9450. }
  9451. dbi_destroy(atcommand_iter);
  9452. }
  9453. /**
  9454. * Executes an at-command
  9455. * @param fd
  9456. * @param sd
  9457. * @param message
  9458. * @param type
  9459. * 0 : script call (atcommand)
  9460. * 1 : normal player @atcommand
  9461. * 2 : console (admin:@atcommand)
  9462. * 3 : script call (useatcmd)
  9463. */
  9464. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  9465. {
  9466. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  9467. char output[CHAT_SIZE_MAX];
  9468. //Reconstructed message
  9469. char atcmd_msg[CHAT_SIZE_MAX * 2];
  9470. TBL_PC * ssd = NULL; //sd for target
  9471. AtCommandInfo * info;
  9472. bool is_atcommand = true; // false if it's a charcommand
  9473. nullpo_retr(false, sd);
  9474. //Shouldn't happen
  9475. if ( !message || !*message )
  9476. return false;
  9477. //If cannot use atcomamnd while talking with NPC [Kichi]
  9478. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  9479. return false;
  9480. //Block NOCHAT but do not display it as a normal message
  9481. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  9482. return true;
  9483. // skip 10/11-langtype's codepage indicator, if detected
  9484. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9485. message += 3;
  9486. //Should display as a normal message
  9487. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9488. return false;
  9489. // type value 0|2 = script|console invoked: bypass restrictions
  9490. if ( type == 1 || type == 3) {
  9491. //Commands are disabled on maps flagged as 'nocommand'
  9492. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  9493. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  9494. return false;
  9495. }
  9496. }
  9497. if (*message == charcommand_symbol)
  9498. is_atcommand = false;
  9499. if (is_atcommand) { // @command
  9500. sprintf(atcmd_msg, "%s", message);
  9501. ssd = sd;
  9502. } else { // #command
  9503. char charname[NAME_LENGTH];
  9504. int n;
  9505. //Checks to see if #command has a name or a name + parameters.
  9506. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  9507. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  9508. ) {
  9509. if (pc_get_group_level(sd) == 0) {
  9510. if (n < 1)
  9511. return false; // No command found. Display as normal message.
  9512. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9513. if (!info || info->char_groups[sd->group_pos] == 0) // If we can't use or doesn't exist: don't even display the command failed message
  9514. return false;
  9515. }
  9516. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9517. clif_displaymessage(fd, output);
  9518. return true;
  9519. }
  9520. ssd = map_nick2sd(charname,true);
  9521. if (ssd == NULL) {
  9522. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9523. clif_displaymessage(fd, output);
  9524. return true;
  9525. }
  9526. if (n > 2)
  9527. sprintf(atcmd_msg, "%s %s", command, params);
  9528. else
  9529. sprintf(atcmd_msg, "%s", command);
  9530. }
  9531. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9532. sd->idletime = last_tick;
  9533. if (battle_config.hom_idle_no_share && sd->hd && battle_config.idletime_hom_option&IDLE_ATCOMMAND)
  9534. sd->idletime_hom = last_tick;
  9535. if (battle_config.mer_idle_no_share && sd->md && battle_config.idletime_mer_option&IDLE_ATCOMMAND)
  9536. sd->idletime_mer = last_tick;
  9537. //Clearing these to be used once more.
  9538. memset(command, '\0', sizeof(command));
  9539. memset(params, '\0', sizeof(params));
  9540. //check to see if any params exist within this command
  9541. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9542. params[0] = '\0';
  9543. if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
  9544. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9545. clif_displaymessage(fd, output);
  9546. return true;
  9547. }
  9548. // @commands (script based)
  9549. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9550. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9551. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  9552. if( binding != NULL && binding->npc_event[0] &&
  9553. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9554. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9555. {
  9556. // Check if self or character invoking; if self == character invoked, then self invoke.
  9557. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9558. return true;
  9559. }
  9560. }
  9561. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9562. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9563. if (info == NULL) {
  9564. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9565. return false;
  9566. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9567. clif_displaymessage(fd, output);
  9568. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9569. return true;
  9570. }
  9571. //check restriction
  9572. if (info->restriction) {
  9573. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9574. return true;
  9575. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9576. return true;
  9577. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9578. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9579. return true;
  9580. }
  9581. // type == 1 : player invoked
  9582. if (type == 1) {
  9583. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9584. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9585. return false;
  9586. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9587. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9588. return true;
  9589. }
  9590. }
  9591. //Attempt to use the command
  9592. if ( (info->func(fd, ssd, command, params) != 0) )
  9593. {
  9594. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9595. clif_displaymessage(fd, output);
  9596. return true;
  9597. }
  9598. //Log only if successful.
  9599. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9600. return true;
  9601. }
  9602. void atcommand_db_load_groups(int* group_ids) {
  9603. DBIterator *iter = db_iterator(atcommand_db);
  9604. AtCommandInfo* cmd;
  9605. int i;
  9606. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9607. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9608. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9609. for(i = 0; i < pc_group_max; i++) {
  9610. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9611. cmd->at_groups[i] = 1;
  9612. else
  9613. cmd->at_groups[i] = 0;
  9614. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9615. cmd->char_groups[i] = 1;
  9616. else
  9617. cmd->char_groups[i] = 0;
  9618. }
  9619. }
  9620. dbi_destroy(iter);
  9621. return;
  9622. }
  9623. void atcommand_db_clear(void) {
  9624. if (atcommand_db != NULL) {
  9625. DBIterator *iter = db_iterator(atcommand_db);
  9626. AtCommandInfo* cmd;
  9627. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9628. aFree(cmd->at_groups);
  9629. aFree(cmd->char_groups);
  9630. }
  9631. dbi_destroy(iter);
  9632. db_destroy(atcommand_db);
  9633. }
  9634. atcommand_alias_db.clear();
  9635. }
  9636. void atcommand_doload(void) {
  9637. atcommand_db_clear();
  9638. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9639. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9640. atcommand_alias_db.load();
  9641. }
  9642. void do_init_atcommand(void) {
  9643. atcommand_doload();
  9644. }
  9645. void do_final_atcommand(void) {
  9646. atcommand_db_clear();
  9647. }